InfluxdbWriter: don't leak sockets

refs #6989
This commit is contained in:
Alexander A. Klimov 2019-03-01 14:30:49 +01:00
parent a9841a9197
commit 2a6b122413

View File

@ -9,6 +9,7 @@
#include "icinga/macroprocessor.hpp" #include "icinga/macroprocessor.hpp"
#include "icinga/icingaapplication.hpp" #include "icinga/icingaapplication.hpp"
#include "icinga/checkcommand.hpp" #include "icinga/checkcommand.hpp"
#include "base/defer.hpp"
#include "base/tcpsocket.hpp" #include "base/tcpsocket.hpp"
#include "base/configtype.hpp" #include "base/configtype.hpp"
#include "base/objectlock.hpp" #include "base/objectlock.hpp"
@ -447,6 +448,8 @@ void InfluxdbWriter::Flush()
if (!stream) if (!stream)
return; return;
Defer close ([&stream]() { stream->Close(); });
Url::Ptr url = new Url(); Url::Ptr url = new Url();
url->SetScheme(GetSslEnable() ? "https" : "http"); url->SetScheme(GetSslEnable() ? "https" : "http");
url->SetHost(GetHost()); url->SetHost(GetHost());