mirror of https://github.com/Icinga/icinga2.git
Merge pull request #6990 from Icinga/bugfix/influxdbwriter-oom-6989
InfluxdbWriter: don't leak sockets
This commit is contained in:
commit
2de8bac588
|
@ -30,7 +30,11 @@ public:
|
|||
inline
|
||||
~Defer()
|
||||
{
|
||||
m_Func();
|
||||
try {
|
||||
m_Func();
|
||||
} catch (...) {
|
||||
// https://stackoverflow.com/questions/130117/throwing-exceptions-out-of-a-destructor
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -9,6 +9,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"
|
||||
|
@ -447,6 +448,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());
|
||||
|
|
Loading…
Reference in New Issue