[icinga-checkins] icinga.org: icinga2/master: Fix memory leak in Stream::Close

git at icinga.org git at icinga.org
Wed Feb 3 13:02:53 CET 2016


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

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Wed Feb  3 12:56:54 2016 +0100

Fix memory leak in Stream::Close

refs #10655

---

 lib/base/stream.cpp |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/base/stream.cpp b/lib/base/stream.cpp
index 796a2c8..240f9cb 100644
--- a/lib/base/stream.cpp
+++ b/lib/base/stream.cpp
@@ -76,9 +76,16 @@ bool Stream::WaitForData(int timeout)
 	return IsDataAvailable() || IsEof();
 }
 
+static void StreamDummyCallback(void)
+{ }
+
 void Stream::Close(void)
 {
 	OnDataAvailable.disconnect_all_slots();
+
+	/* Force signals2 to remove the slots, see https://stackoverflow.com/questions/2049291/force-deletion-of-slot-in-boostsignals2
+	 * for details. */
+	OnDataAvailable.connect(boost::bind(&StreamDummyCallback));
 }
 
 StreamReadStatus Stream::ReadLine(String *line, StreamReadContext& context, bool may_wait)



More information about the icinga-checkins mailing list