From: Gunnar Beutner Date: Wed, 27 Jan 2016 07:43:20 +0000 (+0100) Subject: Improve performance for ApiListener::SyncRelayMessage X-Git-Tag: v2.5.0~584 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ae1f1abee28486d4c1c3e778fd90b5630a82036;p=icinga2 Improve performance for ApiListener::SyncRelayMessage refs #11014 --- diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 5f5961d12..92d42ac24 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -642,13 +642,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());