]> granicus.if.org Git - icinga2/commitdiff
Implement support for downtime comments.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 19 Jun 2013 08:42:28 +0000 (10:42 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 19 Jun 2013 08:42:28 +0000 (10:42 +0200)
Fixes #3894

lib/icinga/service-comment.cpp
lib/icinga/service-downtime.cpp

index 23c80af6c9caced201522dd8be2290cbba1c86b4..0a02be8bd53dec9cd657301f5e1771a144fdaa83 100644 (file)
@@ -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");
        }
 }
index 654e3f46fe2b3bf29bdb653c5ae317f6129344dd..5720e35c6472cd4016d82fb3f4265ba3cb0fe160 100644 (file)
@@ -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)