]> granicus.if.org Git - icinga2/commitdiff
Fix a deadlock in ApiClient::~ApiClient
authorGunnar Beutner <gunnar@beutner.name>
Tue, 17 Feb 2015 13:31:10 +0000 (14:31 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 17 Feb 2015 13:31:10 +0000 (14:31 +0100)
fixes #8462

lib/remote/apiclient.cpp
lib/remote/apiclient.hpp

index dfef74c4f94ca0f974096a0b5235198267a2458c..dd0a4dfe8adedf0954297184fc7787bb1a3b76b2 100644 (file)
@@ -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)
index b0de343ae62f22919bd30aeb664658d77206d305..de0b3eee59945d9686044d96af04f38c3064b2f3 100644 (file)
@@ -58,7 +58,6 @@ public:
        ConnectionRole GetRole(void) const;
 
        void Disconnect(void);
-       void DisconnectSync(void);
 
        void SendMessage(const Dictionary::Ptr& request);