Fix race condition in the config validator.

Fixes #5602
This commit is contained in:
Gunnar Beutner 2014-02-05 09:24:26 +01:00
parent 1728095c53
commit c818d94d93
2 changed files with 10 additions and 0 deletions

View File

@ -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<ConfigCompilerMessage> 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();
}

View File

@ -53,6 +53,8 @@ public:
private:
std::vector<ConfigCompilerMessage> m_Messages;
mutable boost::mutex m_Mutex;
};
}