[icinga-checkins] icinga.org: icinga2/master: Fix memory/ thread leak in the HttpServerConnection class
git at icinga.org
git at icinga.org
Wed Feb 3 10:02:51 CET 2016
Module: icinga2
Branch: master
Commit: 2dc385e31ba7f3dd217d3c36c7926017697bd079
URL: https://git.icinga.org/?p=icinga2.git;a=commit;h=2dc385e31ba7f3dd217d3c36c7926017697bd079
Author: Gunnar Beutner <gunnar at beutner.name>
Date: Wed Feb 3 09:54:31 2016 +0100
Fix memory/thread leak in the HttpServerConnection class
fixes #10655
---
lib/base/tlsstream.cpp | 23 ++++++++++++++---------
lib/remote/httpserverconnection.cpp | 3 +--
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/lib/base/tlsstream.cpp b/lib/base/tlsstream.cpp
index 2f24a11..f1248ee 100644
--- a/lib/base/tlsstream.cpp
+++ b/lib/base/tlsstream.cpp
@@ -189,7 +189,7 @@ void TlsStream::OnEvent(int revents)
VERIFY(!"Invalid TlsAction");
}
- if (rc < 0) {
+ if (rc <= 0) {
int err = SSL_get_error(m_SSL.get(), rc);
switch (err) {
@@ -208,7 +208,7 @@ void TlsStream::OnEvent(int revents)
Close();
- break;
+ return;
default:
m_ErrorCode = ERR_peek_error();
m_ErrorOccurred = true;
@@ -224,7 +224,7 @@ void TlsStream::OnEvent(int revents)
Close();
- break;
+ return;
}
}
@@ -242,11 +242,12 @@ void TlsStream::OnEvent(int revents)
while (m_RecvQ->IsDataAvailable() && IsHandlingEvents())
SignalDataAvailable();
-
- if (m_Shutdown && !m_SendQ->IsDataAvailable())
- Close();
}
+ if (m_Shutdown && !m_SendQ->IsDataAvailable()) {
+ lock.unlock();
+ Close();
+ }
}
void TlsStream::HandleError(void) const
@@ -312,6 +313,7 @@ void TlsStream::Write(const void *buffer, size_t count)
void TlsStream::Shutdown(void)
{
m_Shutdown = true;
+ ChangeEvents(POLLOUT);
}
/**
@@ -324,10 +326,13 @@ void TlsStream::Close(void)
void TlsStream::CloseInternal(bool inDestructor)
{
- if (!m_Eof && !inDestructor) {
- m_Eof = true;
+ if (m_Eof)
+ return;
+
+ m_Eof = true;
+
+ if (!inDestructor)
SignalDataAvailable();
- }
SocketEvents::Unregister();
diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp
index 409b6f2..d78ced4 100644
--- a/lib/remote/httpserverconnection.cpp
+++ b/lib/remote/httpserverconnection.cpp
@@ -78,8 +78,7 @@ void HttpServerConnection::Disconnect(void)
ApiListener::Ptr listener = ApiListener::GetInstance();
listener->RemoveHttpClient(this);
- if (!m_Stream->IsEof())
- m_Stream->Shutdown();
+ m_Stream->Shutdown();
}
bool HttpServerConnection::ProcessMessage(void)
More information about the icinga-checkins
mailing list