Fix crash while reading livestatus query.

Refs #5316
This commit is contained in:
Michael Friedrich 2013-12-12 12:07:47 +01:00
parent e6c6a7dc52
commit 1119c2f17b
2 changed files with 7 additions and 15 deletions

View 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;
}
{

View 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);
};
}