Don't create interim update entries if RADIUS accounting is disabled
authorMartin Willi <martin@revosec.ch>
Thu, 14 Mar 2013 15:44:09 +0000 (16:44 +0100)
committerMartin Willi <martin@revosec.ch>
Thu, 14 Mar 2013 15:44:09 +0000 (16:44 +0100)
src/libcharon/plugins/eap_radius/eap_radius_accounting.c
src/libcharon/plugins/eap_radius/eap_radius_plugin.c

index dfec0bd..3620a40 100644 (file)
@@ -648,6 +648,7 @@ METHOD(listener_t, child_updown, bool,
 METHOD(eap_radius_accounting_t, destroy, void,
        private_eap_radius_accounting_t *this)
 {
+       charon->bus->remove_listener(charon->bus, &this->public.listener);
        singleton = NULL;
        this->mutex->destroy(this->mutex);
        this->sessions->destroy(this->sessions);
@@ -680,7 +681,12 @@ eap_radius_accounting_t *eap_radius_accounting_create()
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
        );
 
-       singleton = this;
+       if (lib->settings->get_bool(lib->settings,
+                                       "%s.plugins.eap-radius.accounting", FALSE, charon->name))
+       {
+               singleton = this;
+               charon->bus->add_listener(charon->bus, &this->public.listener);
+       }
        return &this->public;
 }
 
index c32f521..3baf467 100644 (file)
@@ -227,7 +227,6 @@ METHOD(plugin_t, destroy, void,
        this->configs->destroy_offset(this->configs,
                                                                  offsetof(radius_config_t, destroy));
        this->lock->destroy(this->lock);
-       charon->bus->remove_listener(charon->bus, &this->accounting->listener);
        this->accounting->destroy(this->accounting);
        free(this);
        instance = NULL;
@@ -260,11 +259,6 @@ plugin_t *eap_radius_plugin_create()
        instance = this;
 
        if (lib->settings->get_bool(lib->settings,
-                                       "%s.plugins.eap-radius.accounting", FALSE, charon->name))
-       {
-               charon->bus->add_listener(charon->bus, &this->accounting->listener);
-       }
-       if (lib->settings->get_bool(lib->settings,
                                        "%s.plugins.eap-radius.dae.enable", FALSE, charon->name))
        {
                this->dae = eap_radius_dae_create(this->accounting);