]> granicus.if.org Git - icinga2/commitdiff
Remove deadlock in db_ido
authorGunnar Beutner <gunnar@beutner.name>
Tue, 14 Apr 2015 13:09:50 +0000 (15:09 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 14 Apr 2015 13:11:20 +0000 (15:11 +0200)
refs #9017

lib/db_ido/dbevents.cpp
lib/db_ido/dbevents.hpp

index fe04c8a4349ae5d60a88419999d07f6188370276..4248d0bbffdadc54c8625b536ca3dcc452234938 100644 (file)
@@ -45,7 +45,7 @@ void DbEvents::StaticInitialize(void)
        /* Status */
        Checkable::OnCommentAdded.connect(boost::bind(&DbEvents::AddComment, _1, _2));
        Checkable::OnCommentRemoved.connect(boost::bind(&DbEvents::RemoveComment, _1, _2));
-       Checkable::OnDowntimeAdded.connect(boost::bind(&DbEvents::AddDowntime, _1, _2));
+       Checkable::OnDowntimeAdded.connect(boost::bind(&DbEvents::AddDowntime, _1, _2, true));
        Checkable::OnDowntimeRemoved.connect(boost::bind(&DbEvents::RemoveDowntime, _1, _2));
        Checkable::OnDowntimeTriggered.connect(boost::bind(&DbEvents::TriggerDowntime, _1, _2));
        Checkable::OnAcknowledgementSet.connect(boost::bind(&DbEvents::AddAcknowledgement, _1, _4));
@@ -469,17 +469,18 @@ void DbEvents::AddDowntimes(const Checkable::Ptr& checkable)
        ObjectLock olock(downtimes);
 
        BOOST_FOREACH(const Dictionary::Pair& kv, downtimes) {
-               AddDowntime(checkable, kv.second);
+               AddDowntime(checkable, kv.second, false);
        }
 }
 
-void DbEvents::AddDowntime(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime)
+void DbEvents::AddDowntime(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool remove_existing)
 {
        /*
         * make sure to delete any old downtime to avoid multiple inserts from
         * configured ScheduledDowntime dumps and CreateNextDowntime() calls
         */
-       RemoveDowntime(checkable, downtime);
+       if (remove_existing)
+               RemoveDowntime(checkable, downtime);
        AddDowntimeInternal(checkable, downtime, false);
 }
 
index 7db25c595a5a5731836716e399bcc1ed309103d1..b3da7d78fa9d7b02c1d8f3e39c682dde7bf552d0 100644 (file)
@@ -94,7 +94,7 @@ public:
        static void AddComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
        static void RemoveComment(const Checkable::Ptr& checkable, const Comment::Ptr& comment);
 
-       static void AddDowntime(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);
+       static void AddDowntime(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, bool remove_existing);
        static void RemoveDowntime(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);
        static void TriggerDowntime(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime);