]> granicus.if.org Git - icinga2/commitdiff
Optimize signal calls.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 10 Nov 2013 15:53:57 +0000 (16:53 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 10 Nov 2013 15:53:57 +0000 (16:53 +0100)
Refs #5049

components/checker/checkercomponent.h
lib/icinga/notification.cpp
lib/icinga/service-check.cpp
lib/icinga/service-comment.cpp
lib/icinga/service-downtime.cpp
lib/icinga/service-flapping.cpp
lib/icinga/service-notification.cpp
lib/icinga/service.cpp

index a393328a0cd907d52fb2d3c94f18629d6d4358b1..b0e9a2f23479e6e6f386d6d78be2ed4f8dcb8539 100644 (file)
@@ -50,14 +50,7 @@ struct ServiceNextCheckExtractor
                if (!service->HasAuthority("checker"))
                        return Utility::GetTime() + 60;
 
-               double next = service->GetNextCheck();
-
-               while (next == 0) {
-                       service->UpdateNextCheck();
-                       next = service->GetNextCheck();
-               }
-
-               return next;
+               return service->GetNextCheck();
        }
 };
 
index 36a734982e1aaf115fdf21370f1ae4981591fc14..f6204ca188d1920f6ac81976a14cf4c533ac55e9 100644 (file)
@@ -130,7 +130,7 @@ void Notification::SetNextNotification(double time, const String& authority)
 {
        SetNextNotificationRaw(time);
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnNextNotificationChanged), GetSelf(), time, authority));
+       OnNextNotificationChanged(GetSelf(), time, authority);
 }
 
 void Notification::UpdateNotificationNumber(void)
index 3a1152a351547db341e5d723f5f3adf477911e2a..45e98fc8a00d19ed35f012ca4044ca0ca0d27d75 100644 (file)
@@ -94,7 +94,7 @@ void Service::SetNextCheck(double nextCheck, const String& authority)
 {
        SetNextCheckRaw(nextCheck);
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(Service::OnNextCheckChanged), GetSelf(), nextCheck, authority));
+       OnNextCheckChanged(GetSelf(), nextCheck, authority);
 }
 
 double Service::GetNextCheck(void)
@@ -150,7 +150,7 @@ void Service::SetEnableActiveChecks(bool enabled, const String& authority)
 {
        SetOverrideEnableActiveChecks(enabled);
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableActiveChecksChanged), GetSelf(), enabled, authority));
+       OnEnableActiveChecksChanged(GetSelf(), enabled, authority);
 }
 
 bool Service::GetEnablePassiveChecks(void) const
@@ -165,7 +165,7 @@ void Service::SetEnablePassiveChecks(bool enabled, const String& authority)
 {
        SetOverrideEnablePassiveChecks(enabled);
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnablePassiveChecksChanged), GetSelf(), enabled, authority));
+       OnEnablePassiveChecksChanged(GetSelf(), enabled, authority);
 }
 
 bool Service::GetForceNextCheck(void) const
@@ -177,7 +177,7 @@ void Service::SetForceNextCheck(bool forced, const String& authority)
 {
        SetForceNextCheckRaw(forced);
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnForceNextCheckChanged), GetSelf(), forced, authority));
+       OnForceNextCheckChanged(GetSelf(), forced, authority);
 }
 
 void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& authority)
@@ -367,15 +367,13 @@ void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& autho
 //                     " threshold: " + Convert::ToString(GetFlappingThreshold()) +
 //                     "% current: " + Convert::ToString(GetFlappingCurrent()) + "%.");
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnNewCheckResult), GetSelf(), cr, authority));
+       OnNewCheckResult(GetSelf(), cr, authority);
        OnStateChanged(GetSelf());
 
-       if (hardChange) {
-               Utility::QueueAsyncCallback(boost::bind(boost::ref(OnStateChange), GetSelf(), cr, StateTypeHard, authority));
-       }
-       else if (stateChange) {
-               Utility::QueueAsyncCallback(boost::bind(boost::ref(OnStateChange), GetSelf(), cr, StateTypeSoft, authority));
-       }
+       if (hardChange)
+               OnStateChange(GetSelf(), cr, StateTypeHard, authority);
+       else if (stateChange)
+               OnStateChange(GetSelf(), cr, StateTypeSoft, authority);
 
        if (call_eventhandler)
                ExecuteEventHandler();
index e07f2a08e6b96989a5e413e465a2f670ca482396..b06f4c25dcc2abc89e2f41269f450ebf4ea34d17 100644 (file)
@@ -79,7 +79,7 @@ String Service::AddComment(CommentType entryType, const String& author,
                l_CommentsCache[uid] = GetSelf();
        }
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnCommentAdded), GetSelf(), comment, authority));
+       OnCommentAdded(GetSelf(), comment, authority);
 
        return uid;
 }
@@ -126,7 +126,7 @@ void Service::RemoveComment(const String& id, const String& authority)
                l_CommentsCache.erase(id);
        }
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnCommentRemoved), owner, comment, authority));
+       OnCommentRemoved(owner, comment, authority);
 }
 
 String Service::GetCommentIDFromLegacyID(int id)
index 31a06f5e9260db45b3636c65e3c597330fc8ad21..d1442239b24a51f594049a656aba8e0532bedf8c 100644 (file)
@@ -99,7 +99,7 @@ String Service::AddDowntime(const String& author, const String& comment,
 
        Log(LogWarning, "icinga", "added downtime with ID '" + Convert::ToString(downtime->GetLegacyId()) + "'.");
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnDowntimeAdded), GetSelf(), downtime, authority));
+       OnDowntimeAdded(GetSelf(), downtime, authority);
 
        return uid;
 }
@@ -132,7 +132,7 @@ void Service::RemoveDowntime(const String& id, bool cancelled, const String& aut
 
        Log(LogWarning, "icinga", "removed downtime with ID '" + Convert::ToString(downtime->GetLegacyId()) + "' from service '" + owner->GetName() + "'.");
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnDowntimeRemoved), owner, downtime, authority));
+       OnDowntimeRemoved(owner, downtime, authority);
 }
 
 void Service::TriggerDowntimes(void)
@@ -185,7 +185,7 @@ void Service::TriggerDowntime(const String& id)
                TriggerDowntime(tid);
        }
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnDowntimeTriggered), owner, downtime));
+       OnDowntimeTriggered(owner, downtime);
 }
 
 String Service::GetDowntimeIDFromLegacyID(int id)
index ac9a01b48099958a1b6e8b442603b8cc0427ac5f..144b165a5813137639689c62ba2ca0d57789246d 100644 (file)
@@ -50,7 +50,7 @@ void Service::SetEnableFlapping(bool enabled, const String& authority)
        SetEnableFlappingRaw(enabled);
 
        OnFlappingChanged(GetSelf(), enabled ? FlappingEnabled : FlappingDisabled);
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableFlappingChanged), GetSelf(), enabled, authority));
+       OnEnableFlappingChanged(GetSelf(), enabled, authority);
 }
 
 void Service::UpdateFlappingStatus(bool stateChange)
index 49134594030c0b9c3601f1c4ea97139e0ec3b71f..77158fad1f05445a493f4b0b2081f3b300875974 100644 (file)
@@ -171,7 +171,7 @@ void Service::SetEnableNotifications(bool enabled, const String& authority)
 {
        SetEnableNotificationsRaw(enabled);
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableNotificationsChanged), GetSelf(), enabled, authority));
+       OnEnableNotificationsChanged(GetSelf(), enabled, authority);
 }
 
 bool Service::GetForceNextNotification(void) const
@@ -183,5 +183,5 @@ void Service::SetForceNextNotification(bool forced, const String& authority)
 {
        SetForceNextNotificationRaw(forced);
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnForceNextNotificationChanged), GetSelf(), forced, authority));
+       OnForceNextNotificationChanged(GetSelf(), forced, authority);
 }
index 9d526dc688a08d8574ca9026dd03ef6447e6dea6..dbec5f49cf2dd746762b54043c2fd89e7aa35129 100644 (file)
@@ -199,8 +199,7 @@ void Service::AcknowledgeProblem(const String& author, const String& comment, Ac
 
        OnNotificationsRequested(GetSelf(), NotificationAcknowledgement, GetLastCheckResult(), author, comment);
 
-       boost::function<void (void)> f = boost::bind(boost::ref(Service::OnAcknowledgementSet), GetSelf(), author, comment, type, expiry, authority);
-       Utility::QueueAsyncCallback(f);
+       OnAcknowledgementSet(GetSelf(), author, comment, type, expiry, authority);
 }
 
 void Service::ClearAcknowledgement(const String& authority)
@@ -210,7 +209,7 @@ void Service::ClearAcknowledgement(const String& authority)
        SetAcknowledgementRaw(AcknowledgementNone);
        SetAcknowledgementExpiry(0);
 
-       Utility::QueueAsyncCallback(boost::bind(boost::ref(OnAcknowledgementCleared), GetSelf(), authority));
+       OnAcknowledgementCleared(GetSelf(), authority);
 }
 
 std::set<Host::Ptr> Service::GetParentHosts(void) const