From 1db349df189d5e467eb27ead637aeb136d089516 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 4 Jul 2013 09:45:44 +0200 Subject: [PATCH] livestatus: stop reading data if stream was closed fixes #4371 --- components/livestatus/component.cpp | 3 ++- components/livestatus/query.cpp | 8 ++++++-- components/livestatus/query.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) 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; -- 2.40.0