From 57149ff89998e0613956387f2730f5d1a2cf0362 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 12 May 2016 14:00:19 +0200 Subject: [PATCH] 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 1cb6e3f3c..560e8a58a 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(); -- 2.40.0