From 3b7185fdf0d21897fd874d337d57379f911cc63c Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 21 Sep 2016 19:05:02 -0500 Subject: in adbd-client's dtor, check the worker thread's joinable() state before calling join() on it --- src/adbd-client.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/adbd-client.cpp b/src/adbd-client.cpp index e436a43..85389f4 100644 --- a/src/adbd-client.cpp +++ b/src/adbd-client.cpp @@ -48,7 +48,8 @@ public: g_cancellable_cancel(m_cancellable); m_pkresponse_cv.notify_one(); m_sleep_cv.notify_one(); - m_worker_thread.join(); + if (m_worker_thread.joinable()) + m_worker_thread.join(); g_clear_object(&m_cancellable); } @@ -104,6 +105,8 @@ private: void on_public_key_response(PKResponse response) { + g_debug("%s got response %d", G_STRLOC, int(response)); + // set m_pkresponse and wake up the waiting worker thread std::unique_lock lk(m_pkresponse_mutex); m_pkresponse = response; @@ -141,11 +144,13 @@ private: std::unique_lock lk(m_pkresponse_mutex); m_pkresponse_ready = false; pass_public_key_to_main_thread(public_key); + g_debug("%s thread %p waiting", G_STRLOC, g_thread_self()); m_pkresponse_cv.wait(lk, [this](){ return m_pkresponse_ready || g_cancellable_is_cancelled(m_cancellable); }); response = m_pkresponse; - g_debug("%s got response '%d', is-cancelled %d", G_STRLOC, + g_debug("%s thread %p got response '%d', is-cancelled %d", G_STRLOC, + g_thread_self(), int(response), int(g_cancellable_is_cancelled(m_cancellable))); } -- cgit v1.2.3