From: Gunnar Beutner Date: Tue, 17 Feb 2015 13:31:10 +0000 (+0100) Subject: Fix a deadlock in ApiClient::~ApiClient X-Git-Tag: v2.3.0~188 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5c33d84f76cd704ff8e1c82342310588c7799f7;p=icinga2 Fix a deadlock in ApiClient::~ApiClient fixes #8462 --- 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);