From: Michael Friedrich Date: Thu, 12 Dec 2013 11:07:47 +0000 (+0100) Subject: Fix crash while reading livestatus query. X-Git-Tag: v0.0.6~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1119c2f17bc2c8696e285ec82517f783dfaa2520;p=icinga2 Fix crash while reading livestatus query. Refs #5316 --- diff --git a/components/livestatus/listener.cpp b/components/livestatus/listener.cpp index c23af4ecf..518fdb81c 100644 --- a/components/livestatus/listener.cpp +++ b/components/livestatus/listener.cpp @@ -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(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(lines, GetCompatLogPath()); + if (!query->Execute(stream)) + break; } { diff --git a/components/livestatus/listener.h b/components/livestatus/listener.h index 2a6ff36d5..7ea5c968c 100644 --- a/components/livestatus/listener.h +++ b/components/livestatus/listener.h @@ -48,7 +48,7 @@ protected: private: void ServerThreadProc(const Socket::Ptr& server); - void ClientThreadProc(const Socket::Ptr& client); + void ClientHandler(const Socket::Ptr& client); }; }