[icinga-checkins] icinga.org: icinga2/master: livestatus: stop reading data if stream was closed

git at icinga.org git at icinga.org
Thu Jul 4 09:48:50 CEST 2013


Module: icinga2
Branch: master
Commit: 1db349df189d5e467eb27ead637aeb136d089516
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=1db349df189d5e467eb27ead637aeb136d089516

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Thu Jul  4 09:45:44 2013 +0200

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 7ef3138..bc10ca5 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<Query>(lines);
-		query->Execute(stream);
+		if (!query->Execute(stream))
+			break;
 	}
 }
diff --git a/components/livestatus/query.cpp b/components/livestatus/query.cpp
index f43a5f1..9e17b70 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 8f9a81f..2d8362d 100644
--- a/components/livestatus/query.h
+++ b/components/livestatus/query.h
@@ -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;





More information about the icinga-checkins mailing list