]> granicus.if.org Git - icinga2/commitdiff
Optimize two ObjectLocks into one in Notification::BeginExecuteNotification method
authorConrad Clement <cclement@printeron.com>
Wed, 20 Jul 2016 18:30:05 +0000 (14:30 -0400)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 2 Aug 2016 16:36:29 +0000 (18:36 +0200)
object is locked twice to update values of
NotificationNumber, LastNotification and LastProblemNotification.
LastNotificaiton is updated inside each ObjectLock
merge two ObjectLocks into one and remove duplicate update

fixes #12188

Signed-off-by: Michael Friedrich <michael.friedrich@netways.de>
lib/icinga/notification.cpp

index 06413a4c5003897452877e6ad2c3b4bd6db61cb5..804eb235c915c9c868c8f4271f218bfa65095f11 100644 (file)
@@ -348,9 +348,9 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
        {
                ObjectLock olock(this);
 
+               UpdateNotificationNumber();
                double now = Utility::GetTime();
                SetLastNotification(now);
-
                if (type == NotificationProblem)
                        SetLastProblemNotification(now);
        }
@@ -365,12 +365,6 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
                std::copy(members.begin(), members.end(), std::inserter(allUsers, allUsers.begin()));
        }
 
-       {
-               ObjectLock olock(this);
-               UpdateNotificationNumber();
-               SetLastNotification(Utility::GetTime());
-       }
-
        std::set<User::Ptr> allNotifiedUsers;
        Array::Ptr notifiedUsers = GetNotifiedUsers();