]> granicus.if.org Git - icinga2/commitdiff
StreamLogger#BindStream(): set #m_FlushLogTimer only if needed 7130/head
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Thu, 18 Apr 2019 10:23:50 +0000 (12:23 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Wed, 24 Apr 2019 09:47:02 +0000 (11:47 +0200)
refs #6737

lib/base/streamlogger.cpp

index 0c3d797f28f56fcbee892f291ee9064f67e593ae..146fe3c91b20bec78e6f17b405259a3aaa130821 100644 (file)
@@ -55,10 +55,12 @@ void StreamLogger::BindStream(std::ostream *stream, bool ownsStream)
        m_Stream = stream;
        m_OwnsStream = ownsStream;
 
-       m_FlushLogTimer = new Timer();
-       m_FlushLogTimer->SetInterval(1);
-       m_FlushLogTimer->OnTimerExpired.connect(std::bind(&StreamLogger::FlushLogTimerHandler, this));
-       m_FlushLogTimer->Start();
+       if (!m_FlushLogTimer) {
+               m_FlushLogTimer = new Timer();
+               m_FlushLogTimer->SetInterval(1);
+               m_FlushLogTimer->OnTimerExpired.connect(std::bind(&StreamLogger::FlushLogTimerHandler, this));
+               m_FlushLogTimer->Start();
+       }
 }
 
 /**