From: Gunnar Beutner Date: Wed, 5 Feb 2014 08:24:26 +0000 (+0100) Subject: Fix race condition in the config validator. X-Git-Tag: v0.0.7~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c818d94d93ac04c18926add94a5dccbc44676681;p=icinga2 Fix race condition in the config validator. Fixes #5602 --- diff --git a/lib/config/configcompilercontext.cpp b/lib/config/configcompilercontext.cpp index 1ebded614..380fc242d 100644 --- a/lib/config/configcompilercontext.cpp +++ b/lib/config/configcompilercontext.cpp @@ -27,16 +27,22 @@ using namespace icinga; void ConfigCompilerContext::AddMessage(bool error, const String& message) { + boost::mutex::scoped_lock lock(m_Mutex); + m_Messages.push_back(ConfigCompilerMessage(error, message)); } std::vector ConfigCompilerContext::GetMessages(void) const { + boost::mutex::scoped_lock lock(m_Mutex); + return m_Messages; } bool ConfigCompilerContext::HasErrors(void) const { + boost::mutex::scoped_lock lock(m_Mutex); + BOOST_FOREACH(const ConfigCompilerMessage& message, m_Messages) { if (message.Error) return true; @@ -47,6 +53,8 @@ bool ConfigCompilerContext::HasErrors(void) const void ConfigCompilerContext::Reset(void) { + boost::mutex::scoped_lock lock(m_Mutex); + m_Messages.clear(); } diff --git a/lib/config/configcompilercontext.h b/lib/config/configcompilercontext.h index 0194f7a79..a9f43b60f 100644 --- a/lib/config/configcompilercontext.h +++ b/lib/config/configcompilercontext.h @@ -53,6 +53,8 @@ public: private: std::vector m_Messages; + + mutable boost::mutex m_Mutex; }; }