From d5c33d84f76cd704ff8e1c82342310588c7799f7 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 17 Feb 2015 14:31:10 +0100 Subject: [PATCH] Fix a deadlock in ApiClient::~ApiClient fixes #8462 --- lib/remote/apiclient.cpp | 14 ++------------ lib/remote/apiclient.hpp | 1 - 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/remote/apiclient.cpp b/lib/remote/apiclient.cpp index dfef74c4f..dd0a4dfe8 100644 --- a/lib/remote/apiclient.cpp +++ b/lib/remote/apiclient.cpp @@ -74,13 +74,6 @@ ConnectionRole ApiClient::GetRole(void) const void ApiClient::SendMessage(const Dictionary::Ptr& message) { - if (m_WriteQueue.GetLength() > 20000) { - Log(LogWarning, "remote") - << "Closing connection for API identity '" << m_Identity << "': Too many queued messages."; - Disconnect(); - return; - } - m_WriteQueue.Enqueue(boost::bind(&ApiClient::SendMessageSync, ApiClient::Ptr(this), message)); } @@ -106,11 +99,6 @@ void ApiClient::SendMessageSync(const Dictionary::Ptr& message) } void ApiClient::Disconnect(void) -{ - Utility::QueueAsyncCallback(boost::bind(&ApiClient::DisconnectSync, ApiClient::Ptr(this))); -} - -void ApiClient::DisconnectSync(void) { Log(LogWarning, "ApiClient") << "API client disconnected for identity '" << m_Identity << "'"; @@ -127,6 +115,8 @@ void ApiClient::DisconnectSync(void) } catch (const std::exception&) { /* Ignore the exception. */ } + + m_WriteQueue.Join(); } bool ApiClient::ProcessMessage(void) diff --git a/lib/remote/apiclient.hpp b/lib/remote/apiclient.hpp index b0de343ae..de0b3eee5 100644 --- a/lib/remote/apiclient.hpp +++ b/lib/remote/apiclient.hpp @@ -58,7 +58,6 @@ public: ConnectionRole GetRole(void) const; void Disconnect(void); - void DisconnectSync(void); void SendMessage(const Dictionary::Ptr& request); -- 2.40.0