[icinga-checkins] icinga.org: icinga2/feature/doc-review-11599: Fix crash in ConfigItem:: Commit

git at icinga.org git at icinga.org
Mon May 23 11:51:54 CEST 2016


Module: icinga2
Branch: feature/doc-review-11599
Commit: 9687e27c389c6a6455159a12c76e7f23700f5ada
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=9687e27c389c6a6455159a12c76e7f23700f5ada

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed May 18 12:53:41 2016 +0200

Fix crash in ConfigItem::Commit

fixes #11804

---

 lib/config/configitem.cpp |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp
index 580bb97..e26263a 100644
--- a/lib/config/configitem.cpp
+++ b/lib/config/configitem.cpp
@@ -194,7 +194,10 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
 			Log(LogNotice, "ConfigObject")
 			    << "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
 
-			m_IgnoredItems.push_back(m_DebugInfo.Path);
+			{
+				boost::mutex::scoped_lock lock(m_Mutex);
+				m_IgnoredItems.push_back(m_DebugInfo.Path);
+			}
 
 			return ConfigObject::Ptr();
 		}
@@ -243,7 +246,10 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
 			Log(LogNotice, "ConfigObject")
 			    << "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
 
-			m_IgnoredItems.push_back(m_DebugInfo.Path);
+			{
+				boost::mutex::scoped_lock lock(m_Mutex);
+				m_IgnoredItems.push_back(m_DebugInfo.Path);
+			}
 
 			return ConfigObject::Ptr();
 		}
@@ -259,7 +265,10 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
 			Log(LogNotice, "ConfigObject")
 			    << "Ignoring config object '" << m_Name << "' of type '" << m_Type << "' due to errors: " << DiagnosticInformation(ex);
 
-			m_IgnoredItems.push_back(m_DebugInfo.Path);
+			{
+				boost::mutex::scoped_lock lock(m_Mutex);
+				m_IgnoredItems.push_back(m_DebugInfo.Path);
+			}
 
 			return ConfigObject::Ptr();
 		}
@@ -374,7 +383,10 @@ void ConfigItem::OnAllConfigLoadedHelper(void)
 
 			Unregister();
 
-			m_IgnoredItems.push_back(m_DebugInfo.Path);
+			{
+				boost::mutex::scoped_lock lock(m_Mutex);
+				m_IgnoredItems.push_back(m_DebugInfo.Path);
+			}
 
 			return;
 		}
@@ -645,6 +657,8 @@ std::vector<ConfigItem::Ptr> ConfigItem::GetItems(const String& type)
 
 void ConfigItem::RemoveIgnoredItems(const String& allowedConfigPath)
 {
+	boost::mutex::scoped_lock lock(m_Mutex);
+
 	BOOST_FOREACH(const String& path, m_IgnoredItems) {
 		if (path.Find(allowedConfigPath) == String::NPos)
 			continue;



More information about the icinga-checkins mailing list