]> granicus.if.org Git - icinga2/commitdiff
Fix incorrect locks
authorGunnar Beutner <gunnar@beutner.name>
Tue, 28 Oct 2014 17:57:30 +0000 (18:57 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 28 Oct 2014 17:57:30 +0000 (18:57 +0100)
lib/config/configitem.cpp

index 1cb27246b51fdbfbd85db487aab9c196e508ba0a..06a14cf276c14f5decf8fded487cc5edfbd9e516 100644 (file)
@@ -120,7 +120,9 @@ Expression::Ptr ConfigItem::GetExpressionList(void) const
 
 Dictionary::Ptr ConfigItem::GetProperties(void)
 {
-       ASSERT(OwnsLock());
+       ASSERT(!OwnsLock());
+
+       ObjectLock olock(this);
 
        if (!m_Properties) {
                DebugHint dhint;
@@ -186,15 +188,7 @@ DynamicObject::Ptr ConfigItem::Commit(void)
        if (IsAbstract())
                return DynamicObject::Ptr();
 
-       Dictionary::Ptr properties;
-
-       {
-               ObjectLock olock(this);
-
-               properties = GetProperties();
-       }
-
-       DynamicObject::Ptr dobj = dtype->CreateObject(properties);
+       DynamicObject::Ptr dobj = dtype->CreateObject(GetProperties());
        dobj->SetDebugInfo(m_DebugInfo);
        dobj->Register();
 
@@ -307,10 +301,7 @@ void ConfigItem::WriteObjectsFile(const String& filename)
                persistentItem->Set("type", item->GetType());
                persistentItem->Set("name", item->GetName());
                persistentItem->Set("abstract", item->IsAbstract());
-               {
-                       ObjectLock olock(item);
-                       persistentItem->Set("properties", item->GetProperties());
-               }
+               persistentItem->Set("properties", item->GetProperties());
                persistentItem->Set("debug_hints", item->GetDebugHints());
 
                String json = JsonEncode(persistentItem);