]> granicus.if.org Git - icinga2/commitdiff
Fix deadlock in ServiceDbConnect::Add{Comments,Downtimes}.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 9 Dec 2013 12:22:50 +0000 (13:22 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 9 Dec 2013 12:22:50 +0000 (13:22 +0100)
Fixes #5286

lib/db_ido/servicedbobject.cpp

index b9a5cd7d51ed7474ef330c0dbee9083aa9416d61..4b32938b854d80a914998d4e9d690b34e5db8903 100644 (file)
@@ -325,11 +325,11 @@ void ServiceDbObject::AddComments(const Service::Ptr& service)
        /* dump all comments */
        Dictionary::Ptr comments = service->GetComments();
 
-       ObjectLock olock(comments);
-
        if (comments->GetLength() > 0)
                RemoveComments(service);
 
+       ObjectLock olock(comments);
+
        BOOST_FOREACH(const Dictionary::Pair& kv, comments) {
                AddComment(service, kv.second);
        }
@@ -490,11 +490,11 @@ void ServiceDbObject::AddDowntimes(const Service::Ptr& service)
        /* dump all downtimes */
        Dictionary::Ptr downtimes = service->GetDowntimes();
 
-       ObjectLock olock(downtimes);
-
        if (downtimes->GetLength() > 0)
                RemoveDowntimes(service);
 
+       ObjectLock olock(downtimes);
+
        BOOST_FOREACH(const Dictionary::Pair& kv, downtimes) {
                AddDowntime(service, kv.second);
        }