]> granicus.if.org Git - icinga2/commitdiff
InfluxdbWriter: don't leak sockets 6990/head
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 1 Mar 2019 13:30:49 +0000 (14:30 +0100)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 1 Mar 2019 13:30:49 +0000 (14:30 +0100)
refs #6989

lib/perfdata/influxdbwriter.cpp

index 773f21a2a23d1f49ecfbcdfaca6e385918119ac3..b75cd7a3f428320688d31d67bf1c7ef65e542080 100644 (file)
@@ -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());