diff --git a/components/livestatus/component.cpp b/components/livestatus/component.cpp index 7ef313851..bc10ca534 100644 --- a/components/livestatus/component.cpp +++ b/components/livestatus/component.cpp @@ -96,6 +96,7 @@ void LivestatusComponent::ClientThreadProc(const Socket::Ptr& client) } Query::Ptr query = boost::make_shared(lines); - query->Execute(stream); + if (!query->Execute(stream)) + break; } } diff --git a/components/livestatus/query.cpp b/components/livestatus/query.cpp index f43a5f1f8..9e17b70ac 100644 --- a/components/livestatus/query.cpp +++ b/components/livestatus/query.cpp @@ -302,7 +302,7 @@ void Query::PrintFixed16(const Stream::Ptr& stream, int code, const String& data stream->Write(header.CStr(), header.GetLength()); } -void Query::Execute(const Stream::Ptr& stream) +bool Query::Execute(const Stream::Ptr& stream) { try { Log(LogInformation, "livestatus", "Executing livestatus query: " + m_Verb); @@ -319,6 +319,10 @@ void Query::Execute(const Stream::Ptr& stream) SendResponse(stream, 452, boost::diagnostic_information(ex)); } - if (!m_KeepAlive) + if (!m_KeepAlive) { stream->Close(); + return false; + } + + return true; } diff --git a/components/livestatus/query.h b/components/livestatus/query.h index 8f9a81f50..2d8362d9b 100644 --- a/components/livestatus/query.h +++ b/components/livestatus/query.h @@ -42,7 +42,7 @@ public: Query(const std::vector& lines); - void Execute(const Stream::Ptr& stream); + bool Execute(const Stream::Ptr& stream); private: String m_Verb;