Optimize two ObjectLocks into one in Notification::BeginExecuteNotification method

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>
This commit is contained in:
Conrad Clement 2016-07-20 14:30:05 -04:00 committed by Michael Friedrich
parent 1ff6939f90
commit 3f0b6ec003

View File

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