From: Alexander A. Klimov Date: Thu, 18 Apr 2019 10:23:50 +0000 (+0200) Subject: StreamLogger#BindStream(): set #m_FlushLogTimer only if needed X-Git-Tag: v2.11.0-rc1~135^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=622f68412440d4fa3ac1b347a929087073bc24f9;p=icinga2 StreamLogger#BindStream(): set #m_FlushLogTimer only if needed refs #6737 --- diff --git a/lib/base/streamlogger.cpp b/lib/base/streamlogger.cpp index 0c3d797f2..146fe3c91 100644 --- a/lib/base/streamlogger.cpp +++ b/lib/base/streamlogger.cpp @@ -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(); + } } /**