livestatus: stop reading data if stream was closed

fixes #4371
This commit is contained in:
Michael Friedrich 2013-07-04 09:45:44 +02:00
parent 8c3663ab0e
commit 1db349df18
3 changed files with 9 additions and 4 deletions

View File

@ -96,6 +96,7 @@ void LivestatusComponent::ClientThreadProc(const Socket::Ptr& client)
}
Query::Ptr query = boost::make_shared<Query>(lines);
query->Execute(stream);
if (!query->Execute(stream))
break;
}
}

View File

@ -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;
}

View File

@ -42,7 +42,7 @@ public:
Query(const std::vector<String>& lines);
void Execute(const Stream::Ptr& stream);
bool Execute(const Stream::Ptr& stream);
private:
String m_Verb;