From: Gunnar Beutner Date: Tue, 3 Sep 2013 09:00:57 +0000 (+0200) Subject: cluster: Fix crash bug. X-Git-Tag: v0.0.3~612 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b31ced475080a1a4e1651b8a8c1739271b245d0;p=icinga2 cluster: Fix crash bug. --- diff --git a/components/cluster/clustercomponent.cpp b/components/cluster/clustercomponent.cpp index 7edc099b8..31efc8d17 100644 --- a/components/cluster/clustercomponent.cpp +++ b/components/cluster/clustercomponent.cpp @@ -215,14 +215,16 @@ void ClusterComponent::RelayMessage(const Endpoint::Ptr& except, const Dictionar pmessage->Set("message", message); ObjectLock olock(this); - String json = Value(pmessage).Serialize(); - NetString::WriteStringToStream(m_LogFile, json); - m_LogMessageCount++; - m_LogMessageTimestamp = ts; - - if (m_LogMessageCount > 250000) { - CloseLogFile(); - OpenLogFile(); + if (m_LogFile) { + String json = Value(pmessage).Serialize(); + NetString::WriteStringToStream(m_LogFile, json); + m_LogMessageCount++; + m_LogMessageTimestamp = ts; + + if (m_LogMessageCount > 250000) { + CloseLogFile(); + OpenLogFile(); + } } }