]> granicus.if.org Git - icinga2/commitdiff
Fix crash while reading livestatus query.
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 12 Dec 2013 11:07:47 +0000 (12:07 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 12 Dec 2013 11:07:47 +0000 (12:07 +0100)
Refs #5316

components/livestatus/listener.cpp
components/livestatus/listener.h

index c23af4ecf296e8fc4e8b26f2f7d23048f9d497f8..518fdb81c5ebb9048a78f53db28b9faf9daad556 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "livestatus/listener.h"
 #include "config/configcompilercontext.h"
+#include "base/utility.h"
 #include "base/objectlock.h"
 #include "base/dynamictype.h"
 #include "base/logger_fwd.h"
@@ -103,12 +104,11 @@ void LivestatusListener::ServerThreadProc(const Socket::Ptr& server)
 
                Log(LogInformation, "livestatus", "Client connected");
 
-               boost::thread thread(boost::bind(&LivestatusListener::ClientThreadProc, this, client));
-               thread.detach();
+               Utility::QueueAsyncCallback(boost::bind(&LivestatusListener::ClientHandler, this, client));
        }
 }
 
-void LivestatusListener::ClientThreadProc(const Socket::Ptr& client)
+void LivestatusListener::ClientHandler(const Socket::Ptr& client)
 {
        {
                boost::mutex::scoped_lock lock(l_ComponentMutex);
@@ -131,17 +131,9 @@ void LivestatusListener::ClientThreadProc(const Socket::Ptr& client)
                                break;
                }
 
-               try {
-                       Query::Ptr query = make_shared<Query>(lines, GetCompatLogPath());
-                       if (!query->Execute(stream))
-                               break;
-               } catch (const std::exception& ex) {
-                       std::ostringstream info;
-                       info << "Exception thrown while running livestatus query: " << std::endl
-                            << DiagnosticInformation(ex);
-                       Log(LogCritical, "livestatus", info.str());
-                       return;
-               }
+               Query::Ptr query = make_shared<Query>(lines, GetCompatLogPath());
+               if (!query->Execute(stream))
+                       break;
        }
 
        {
index 2a6ff36d597abf2fae88b9654db55fc4a240c9df..7ea5c968cc3d294d1a73b3e04beddf3fc73e7fec 100644 (file)
@@ -48,7 +48,7 @@ protected:
 
 private:
        void ServerThreadProc(const Socket::Ptr& server);
-       void ClientThreadProc(const Socket::Ptr& client);
+       void ClientHandler(const Socket::Ptr& client);
 };
 
 }