From 2a6b122413dfc8762a7839bbe41c125455a17b5c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 1 Mar 2019 14:30:49 +0100 Subject: [PATCH] InfluxdbWriter: don't leak sockets refs #6989 --- lib/perfdata/influxdbwriter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/perfdata/influxdbwriter.cpp b/lib/perfdata/influxdbwriter.cpp index 773f21a2a..b75cd7a3f 100644 --- a/lib/perfdata/influxdbwriter.cpp +++ b/lib/perfdata/influxdbwriter.cpp @@ -9,6 +9,7 @@ #include "icinga/macroprocessor.hpp" #include "icinga/icingaapplication.hpp" #include "icinga/checkcommand.hpp" +#include "base/defer.hpp" #include "base/tcpsocket.hpp" #include "base/configtype.hpp" #include "base/objectlock.hpp" @@ -447,6 +448,8 @@ void InfluxdbWriter::Flush() if (!stream) return; + Defer close ([&stream]() { stream->Close(); }); + Url::Ptr url = new Url(); url->SetScheme(GetSslEnable() ? "https" : "http"); url->SetHost(GetHost()); -- 2.40.0