ElasticsearchWriter: don't leak sockets

refs #7018

(cherry picked from commit b2e2b587da530a5b79f746ed0db5b3804b502e07)
This commit is contained in:
Alexander A. Klimov 2019-03-15 13:15:24 +01:00 committed by Michael Friedrich
parent 1fc3a77c4a
commit 29e8961cda

View 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. */