From 5ae2c4aa5b9438b899f00391e701ec8366ddfa21 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 20 Apr 2012 16:10:38 +0200 Subject: [PATCH] Fixed crash while unloading auth/sub components. --- icinga/authenticationcomponent.cpp | 9 ++++++++- icinga/subscriptioncomponent.cpp | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) 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) -- 2.40.0