[icinga-checkins] icinga.org: icinga2/master: Fix race condition in ConfigObject:: SetAuthority

git at icinga.org git at icinga.org
Thu May 12 14:00:39 CEST 2016


Module: icinga2
Branch: master
Commit: 5559733bc6579ec895c1d6b5bf11d391683cd37a
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=5559733bc6579ec895c1d6b5bf11d391683cd37a

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Thu May 12 14:00:19 2016 +0200

Fix race condition in ConfigObject::SetAuthority

fixes #11784

---

 lib/base/configobject.cpp |   22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp
index 1cb6e3f..560e8a5 100644
--- a/lib/base/configobject.cpp
+++ b/lib/base/configobject.cpp
@@ -386,18 +386,18 @@ void ConfigObject::Activate(bool runtimeCreated)
 {
 	CONTEXT("Activating object '" + GetName() + "' of type '" + GetType()->GetName() + "'");
 
-	Start(runtimeCreated);
-
-	ASSERT(GetStartCalled());
-
 	{
 		ObjectLock olock(this);
+
+		Start(runtimeCreated);
+
+		ASSERT(GetStartCalled());
 		ASSERT(!IsActive());
 		SetActive(true, true);
-	}
 
-	if (GetHAMode() == HARunEverywhere)
-		SetAuthority(true);
+		if (GetHAMode() == HARunEverywhere)
+			SetAuthority(true);
+	}
 
 	NotifyActive();
 }
@@ -422,11 +422,11 @@ void ConfigObject::Deactivate(bool runtimeRemoved)
 			return;
 
 		SetActive(false, true);
-	}
 
-	SetAuthority(false);
+		SetAuthority(false);
 
-	Stop(runtimeRemoved);
+		Stop(runtimeRemoved);
+	}
 
 	ASSERT(GetStopCalled());
 
@@ -465,6 +465,8 @@ void ConfigObject::Resume(void)
 
 void ConfigObject::SetAuthority(bool authority)
 {
+	ObjectLock olock(this);
+
 	if (authority && GetPaused()) {
 		SetResumeCalled(false);
 		Resume();



More information about the icinga-checkins mailing list