diff --git a/lib/icinga/service-comment.cpp b/lib/icinga/service-comment.cpp index 23c80af6c..0a02be8bd 100644 --- a/lib/icinga/service-comment.cpp +++ b/lib/icinga/service-comment.cpp @@ -82,9 +82,13 @@ String Service::AddComment(CommentType entryType, const String& author, } String id = Utility::NewUniqueID(); - comments->Set(id, comment); - Touch("comments"); + { + ObjectLock olock(this); + + comments->Set(id, comment); + Touch("comments"); + } return id; } @@ -105,6 +109,8 @@ void Service::RemoveComment(const String& id) Dictionary::Ptr comments = owner->GetComments(); if (comments) { + ObjectLock olock(owner); + comments->Remove(id); owner->Touch("comments"); } @@ -208,7 +214,11 @@ void Service::RefreshCommentsCache(void) legacy_id = l_NextCommentID++; comment->Set("legacy_id", legacy_id); - service->Touch("comments"); + + { + ObjectLock olock(service); + service->Touch("comments"); + } } newLegacyCommentsCache[legacy_id] = id; @@ -254,6 +264,7 @@ void Service::RemoveExpiredComments(void) comments->Remove(id); } + ObjectLock olock(this); Touch("comments"); } } diff --git a/lib/icinga/service-downtime.cpp b/lib/icinga/service-downtime.cpp index 654e3f46f..5720e35c6 100644 --- a/lib/icinga/service-downtime.cpp +++ b/lib/icinga/service-downtime.cpp @@ -79,8 +79,12 @@ String Service::AddDowntime(const String& author, const String& comment, Dictionary::Ptr otherDowntimes = otherOwner->Get("downtimes"); Dictionary::Ptr otherDowntime = otherDowntimes->Get(triggeredBy); Dictionary::Ptr triggers = otherDowntime->Get("triggers"); - triggers->Set(triggeredBy, triggeredBy); - otherOwner->Touch("downtimes"); + + { + ObjectLock olock(otherOwner); + triggers->Set(triggeredBy, triggeredBy); + otherOwner->Touch("downtimes"); + } } Dictionary::Ptr downtimes; @@ -99,7 +103,12 @@ String Service::AddDowntime(const String& author, const String& comment, String id = Utility::NewUniqueID(); downtimes->Set(id, downtime); - Touch("downtimes"); + { + ObjectLock olock(this); + Touch("downtimes"); + } + + (void) AddComment(CommentDowntime, author, comment, endTime); return id; } @@ -116,8 +125,11 @@ void Service::RemoveDowntime(const String& id) if (!downtimes) return; - downtimes->Remove(id); - owner->Touch("downtimes"); + { + ObjectLock olock(owner); + downtimes->Remove(id); + owner->Touch("downtimes"); + } } void Service::TriggerDowntimes(void)