[icinga-checkins] icinga.org: icinga2/master: Fix crash in HttpServerConnection:: ProcessMessageAsync

git at icinga.org git at icinga.org
Fri Aug 19 20:36:43 CEST 2016


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

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Aug 19 20:35:20 2016 +0200

Fix crash in HttpServerConnection::ProcessMessageAsync

fixes #12493

---

 lib/remote/httpserverconnection.cpp |   12 +++++++++++-
 lib/remote/jsonrpcconnection.cpp    |    9 ++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp
index 6498dd5..acf5ccd 100644
--- a/lib/remote/httpserverconnection.cpp
+++ b/lib/remote/httpserverconnection.cpp
@@ -80,7 +80,14 @@ void HttpServerConnection::Disconnect(void)
 	ApiListener::Ptr listener = ApiListener::GetInstance();
 	listener->RemoveHttpClient(this);
 
-	m_Stream->Shutdown();
+	m_CurrentRequest.~HttpRequest();
+	new (&m_CurrentRequest) HttpRequest(Stream::Ptr());
+
+	{
+		Stream::Ptr stream = m_Stream;
+		m_Stream.reset();
+		stream->Close();
+	}
 }
 
 bool HttpServerConnection::ProcessMessage(void)
@@ -204,6 +211,9 @@ void HttpServerConnection::DataAvailableHandler(void)
 {
 	bool close = false;
 
+	if (!m_Stream)
+		return;
+
 	if (!m_Stream->IsEof()) {
 		boost::mutex::scoped_lock lock(m_DataHandlerMutex);
 
diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp
index 651ff0e..54c3935 100644
--- a/lib/remote/jsonrpcconnection.cpp
+++ b/lib/remote/jsonrpcconnection.cpp
@@ -129,7 +129,11 @@ void JsonRpcConnection::Disconnect(void)
 	Log(LogWarning, "JsonRpcConnection")
 	    << "API client disconnected for identity '" << m_Identity << "'";
 
-	m_Stream->Close();
+	{
+		Stream::Ptr stream = m_Stream;
+		m_Stream.reset();
+		stream->Close();
+	}
 
 	if (m_Endpoint)
 		m_Endpoint->RemoveClient(this);
@@ -234,6 +238,9 @@ void JsonRpcConnection::DataAvailableHandler(void)
 {
 	bool close = false;
 
+	if (!m_Stream)
+		return;
+
 	if (!m_Stream->IsEof()) {
 		boost::mutex::scoped_lock lock(m_DataHandlerMutex);
 



More information about the icinga-checkins mailing list