From: Gunnar Beutner Date: Fri, 20 Apr 2012 14:10:38 +0000 (+0200) Subject: Fixed crash while unloading auth/sub components. X-Git-Tag: v0.0.1~608 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ae2c4aa5b9438b899f00391e701ec8366ddfa21;p=icinga2 Fixed crash while unloading auth/sub components. --- diff --git a/icinga/authenticationcomponent.cpp b/icinga/authenticationcomponent.cpp index 833f2e6cd..85f3d0ae0 100644 --- a/icinga/authenticationcomponent.cpp +++ b/icinga/authenticationcomponent.cpp @@ -25,12 +25,17 @@ void AuthenticationComponent::Start(void) void AuthenticationComponent::Stop(void) { + IcingaApplication::Ptr app = GetIcingaApplication(); + if (app) { + EndpointManager::Ptr mgr = app->GetEndpointManager(); + mgr->UnregisterEndpoint(m_AuthenticationEndpoint); + } } int AuthenticationComponent::NewEndpointHandler(const NewEndpointEventArgs& neea) { - if (neea.Endpoint->IsLocal()) + if (neea.Endpoint->IsLocal() || neea.Endpoint->HasIdentity()) return 0; JsonRpcRequest request; @@ -42,6 +47,8 @@ int AuthenticationComponent::NewEndpointHandler(const NewEndpointEventArgs& neea request.SetParams(params); neea.Endpoint->ProcessRequest(m_AuthenticationEndpoint, request); + + return 0; } int AuthenticationComponent::IdentityMessageHandler(const NewRequestEventArgs& nrea) diff --git a/icinga/subscriptioncomponent.cpp b/icinga/subscriptioncomponent.cpp index 437fcce5f..b1f3b45c3 100644 --- a/icinga/subscriptioncomponent.cpp +++ b/icinga/subscriptioncomponent.cpp @@ -29,8 +29,12 @@ void SubscriptionComponent::Start(void) void SubscriptionComponent::Stop(void) { - EndpointManager::Ptr mgr = GetIcingaApplication()->GetEndpointManager(); - mgr->UnregisterEndpoint(m_SubscriptionEndpoint); + IcingaApplication::Ptr app = GetIcingaApplication(); + + if (app) { + EndpointManager::Ptr mgr = app->GetEndpointManager(); + mgr->UnregisterEndpoint(m_SubscriptionEndpoint); + } } int SubscriptionComponent::SyncSubscription(Endpoint::Ptr target, string type, const NewMethodEventArgs& nmea)