From d3fc07500088860aed39a9b22549ba38a9201d99 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 14 Apr 2015 15:09:50 +0200 Subject: [PATCH] Remove deadlock in db_ido refs #9017 --- lib/db_ido/dbevents.cpp | 9 +++++---- lib/db_ido/dbevents.hpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index fe04c8a43..4248d0bbf 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -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); } diff --git a/lib/db_ido/dbevents.hpp b/lib/db_ido/dbevents.hpp index 7db25c595..b3da7d78f 100644 --- a/lib/db_ido/dbevents.hpp +++ b/lib/db_ido/dbevents.hpp @@ -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);