listen for CHILD_SA state changes only until it has been installed
authorMartin Willi <martin@strongswan.org>
Fri, 3 Jul 2009 08:46:30 +0000 (10:46 +0200)
committerMartin Willi <martin@strongswan.org>
Fri, 3 Jul 2009 14:16:00 +0000 (16:16 +0200)
src/charon/plugins/nm/nm_service.c

index 5d036d4..574c5bd 100644 (file)
@@ -173,6 +173,7 @@ static bool child_state_change(listener_t *listener, ike_sa_t *ike_sa,
                {
                        case CHILD_INSTALLED:
                                signal_ipv4_config(private->plugin, ike_sa, child_sa);
+                               listener->child_state_change = NULL;
                                break;
                        case CHILD_DESTROYING:
                                signal_failure(private->plugin,
@@ -208,6 +209,7 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
 {
        nm_creds_t *creds;
        NMSettingVPN *settings;
+       listener_t *listener;
        identification_t *user = NULL, *gateway;
        const char *address, *str;
        bool virtual, encap, ipcomp;
@@ -459,8 +461,9 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
         * Register listener
         */
        NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->ike_sa = ike_sa;
-       charon->bus->add_listener(charon->bus, 
-                                                       &NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->listener);
+       listener = &NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->listener;
+       listener->child_state_change = child_state_change;
+       charon->bus->add_listener(charon->bus, listener);
        charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
        return TRUE;
 }
@@ -556,7 +559,6 @@ static void nm_strongswan_plugin_init(NMStrongswanPlugin *plugin)
        private->plugin = NM_VPN_PLUGIN(plugin);
        memset(&private->listener.log, 0, sizeof(listener_t));
        private->listener.ike_state_change = ike_state_change;
-       private->listener.child_state_change = child_state_change;
        private->listener.ike_keys = ike_keys;
 }