]> granicus.if.org Git - icinga2/commitdiff
Fixed crash while unloading auth/sub components.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 20 Apr 2012 14:10:38 +0000 (16:10 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 20 Apr 2012 14:10:38 +0000 (16:10 +0200)
icinga/authenticationcomponent.cpp
icinga/subscriptioncomponent.cpp

index 833f2e6cd67cf13c595c1c59e1dc7080f5239f89..85f3d0ae06703a64376b26d6a572aa0df4964e67 100644 (file)
@@ -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)
index 437fcce5f48bb7a2f2310bcb308c5796ab80a51b..b1f3b45c3b8d8d34a98e61e63395b525d53a7d81 100644 (file)
@@ -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)