diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2016-09-21 20:35:21 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2016-09-21 20:35:21 -0500 |
commit | b74f5f6a37edaab28156e551462407096cfbfcbd (patch) | |
tree | 26fad492954215637de7d3888357f195bf46803f /src | |
parent | 3b7185fdf0d21897fd874d337d57379f911cc63c (diff) | |
download | ayatana-indicator-display-b74f5f6a37edaab28156e551462407096cfbfcbd.tar.gz ayatana-indicator-display-b74f5f6a37edaab28156e551462407096cfbfcbd.tar.bz2 ayatana-indicator-display-b74f5f6a37edaab28156e551462407096cfbfcbd.zip |
adbd-client's std::condition_variable::wait() call seems to be the system_error culprit, so wrapping in try-catch to be cautious
Diffstat (limited to 'src')
-rw-r--r-- | src/adbd-client.cpp | 17 | ||||
-rw-r--r-- | src/usb-manager.cpp | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/adbd-client.cpp b/src/adbd-client.cpp index 85389f4..83b15ac 100644 --- a/src/adbd-client.cpp +++ b/src/adbd-client.cpp @@ -124,11 +124,11 @@ private: while (!g_cancellable_is_cancelled(m_cancellable)) { - g_debug("%s creating a client socket to '%s'", G_STRLOC, socket_path.c_str()); + g_debug("%s thread %p creating a client socket to '%s'", G_STRLOC, g_thread_self(), socket_path.c_str()); auto socket = create_client_socket(socket_path); bool got_valid_req = false; - g_debug("%s calling read_request", G_STRLOC); + g_debug("%s thread %p calling read_request", g_thread_self(), G_STRLOC); std::string reqstr; if (socket != nullptr) reqstr = read_request(socket); @@ -138,16 +138,21 @@ private: if (reqstr.substr(0,2) == "PK") { PKResponse response = PKResponse::DENY; const auto public_key = reqstr.substr(2); - g_debug("%s got pk [%s]", G_STRLOC, public_key.c_str()); + g_debug("%s thread %p got pk [%s]", G_STRLOC, g_thread_self(), public_key.c_str()); if (!public_key.empty()) { got_valid_req = true; std::unique_lock<std::mutex> lk(m_pkresponse_mutex); m_pkresponse_ready = false; + m_pkresponse = AdbdClient::PKResponse::DENY; 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); - }); + try { + m_pkresponse_cv.wait(lk, [this](){ + return m_pkresponse_ready || g_cancellable_is_cancelled(m_cancellable); + }); + } catch (std::system_error& e) { + g_critical("%s thread %p unable to wait for response because of unexpected error '%s'", G_STRLOC, g_thread_self(), e.what()); + } response = m_pkresponse; g_debug("%s thread %p got response '%d', is-cancelled %d", G_STRLOC, g_thread_self(), diff --git a/src/usb-manager.cpp b/src/usb-manager.cpp index 4d750c0..aac289a 100644 --- a/src/usb-manager.cpp +++ b/src/usb-manager.cpp @@ -102,7 +102,7 @@ private: m_snap = std::make_shared<UsbSnap>(m_req.fingerprint); m_snap_connections.insert((*m_snap).on_user_response().connect( [this](AdbdClient::PKResponse response, bool remember_choice){ - g_debug("%s user responded! response %d, remember %d", G_STRLOC, int(response), int(remember_choice)); + g_debug("%s thread %p user responded! response %d, remember %d", G_STRLOC, g_thread_self(), int(response), int(remember_choice)); m_req.respond(response); if (remember_choice && (response == AdbdClient::PKResponse::ALLOW)) write_public_key(m_req.public_key); |