Skip to content

Commit

Permalink
InfluxdbWriter: don't leak sockets
Browse files Browse the repository at this point in the history
refs #6989

(cherry picked from commit 2a6b122)
  • Loading branch information
Al2Klimov authored and Michael Friedrich committed Mar 19, 2019
1 parent c9d27e7 commit 1fc3a77
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/perfdata/influxdbwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "icinga/macroprocessor.hpp"
#include "icinga/icingaapplication.hpp"
#include "icinga/checkcommand.hpp"
#include "base/defer.hpp"
#include "base/tcpsocket.hpp"
#include "base/configtype.hpp"
#include "base/objectlock.hpp"
Expand Down Expand Up @@ -432,6 +433,8 @@ void InfluxdbWriter::Flush()
if (!stream)
return;

Defer close ([&stream]() { stream->Close(); });

Url::Ptr url = new Url();
url->SetScheme(GetSslEnable() ? "https" : "http");
url->SetHost(GetHost());
Expand Down

0 comments on commit 1fc3a77

Please sign in to comment.