From c818d94d93ac04c18926add94a5dccbc44676681 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 5 Feb 2014 09:24:26 +0100 Subject: [PATCH] Fix race condition in the config validator. Fixes #5602 --- lib/config/configcompilercontext.cpp | 8 ++++++++ lib/config/configcompilercontext.h | 2 ++ 2 files changed, 10 insertions(+) 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; }; } -- 2.40.0