From 29e8961cda0ac8279189fc4d2379ba0033d57895 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 15 Mar 2019 13:15:24 +0100 Subject: [PATCH] ElasticsearchWriter: don't leak sockets refs #7018 (cherry picked from commit b2e2b587da530a5b79f746ed0db5b3804b502e07) --- lib/perfdata/elasticsearchwriter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index 029857094..2287365ef 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -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. */ -- 2.40.0