]> granicus.if.org Git - icinga2/commitdiff
Fix race condition in ConfigObject::SetAuthority
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 12 May 2016 12:00:19 +0000 (14:00 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 12 May 2016 12:06:28 +0000 (14:06 +0200)
fixes #11784

lib/base/configobject.cpp

index 1cb6e3f3c5403ee72aef3ab4aec56b9a7268945c..560e8a58a0715b8755c1ff6a22ed5f5174c9b895 100644 (file)
@@ -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();