]> granicus.if.org Git - icinga2/commitdiff
ElasticsearchWriter: don't leak sockets
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 15 Mar 2019 12:15:24 +0000 (13:15 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Tue, 19 Mar 2019 10:31:20 +0000 (11:31 +0100)
refs #7018

(cherry picked from commit b2e2b587da530a5b79f746ed0db5b3804b502e07)

lib/perfdata/elasticsearchwriter.cpp

index 029857094cbabedb7adf88bff80e0bef2d42bef5..2287365ef8b0855a89c1decafab67861df40aa64 100644 (file)
@@ -25,6 +25,7 @@
 #include "icinga/compatutility.hpp"
 #include "icinga/service.hpp"
 #include "icinga/checkcommand.hpp"
+#include "base/defer.hpp"
 #include "base/tcpsocket.hpp"
 #include "base/stream.hpp"
 #include "base/base64.hpp"
@@ -441,6 +442,8 @@ void ElasticsearchWriter::SendRequest(const String& body)
        if (!stream)
                return;
 
+       Defer close ([&stream]() { stream->Close(); });
+
        HttpRequest req(stream);
 
        /* Specify required headers by Elasticsearch. */