From: Gunnar Beutner Date: Wed, 27 Jan 2016 07:43:20 +0000 (+0100) Subject: Improve performance for ApiListener::SyncRelayMessage X-Git-Tag: v2.4.2~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d5592a615da762e4c36e2adcd263d7d254296aa;p=icinga2 Improve performance for ApiListener::SyncRelayMessage refs #11014 --- diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 6565c4aef..9235622fc 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -636,13 +636,12 @@ void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin, Zone::Ptr target_zone = endpoint->GetZone(); - allZones.insert(target_zone); /* only relay messages to zones which have access to the object */ - if (!target_zone->CanAccessObject(secobj)) { - finishedLogZones.insert(target_zone); + if (!target_zone->CanAccessObject(secobj)) continue; - } + + allZones.insert(target_zone); /* don't relay messages to disconnected endpoints */ if (!endpoint->GetConnected()) { diff --git a/lib/remote/zone.cpp b/lib/remote/zone.cpp index 12b6b4b1f..311b11cca 100644 --- a/lib/remote/zone.cpp +++ b/lib/remote/zone.cpp @@ -63,7 +63,7 @@ bool Zone::CanAccessObject(const ConfigObject::Ptr& object) { Zone::Ptr object_zone; - if (dynamic_pointer_cast(object)) + if (object->GetReflectionType() == Zone::TypeInstance) object_zone = static_pointer_cast(object); else object_zone = static_pointer_cast(object->GetZone());