]> granicus.if.org Git - icinga2/commitdiff
ElasticsearchWriter: don't leak sockets 7020/head
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 15 Mar 2019 12:15:24 +0000 (13:15 +0100)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Mon, 18 Mar 2019 14:09:07 +0000 (15:09 +0100)
refs #7018

lib/perfdata/elasticsearchwriter.cpp

index 53ed48f9769ddaf3fd17e645a6176f2c83e0e358..e66a790769d79fce7301419ba624d24f7f999c07 100644 (file)
@@ -8,6 +8,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"
@@ -445,6 +446,8 @@ void ElasticsearchWriter::SendRequest(const String& body)
        if (!stream)
                return;
 
+       Defer close ([&stream]() { stream->Close(); });
+
        HttpRequest req(stream);
 
        /* Specify required headers by Elasticsearch. */