]> granicus.if.org Git - icinga2/commitdiff
StreamLogger#BindStream(): set #m_FlushLogTimer only if needed
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Thu, 18 Apr 2019 10:23:50 +0000 (12:23 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Thu, 16 May 2019 13:27:29 +0000 (15:27 +0200)
refs #6737

(cherry picked from commit 622f68412440d4fa3ac1b347a929087073bc24f9)

lib/base/streamlogger.cpp

index aa1d62cd3ae9267ef3f07f01219115858895538d..9ce1a292923d0572292359b5d9454ecf92eb5877 100644 (file)
@@ -72,10 +72,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();
+       }
 }
 
 /**