network: don't add into profile while unregistered
authorPekka Pessi <Pekka.Pessi@nokia.com>
Mon, 30 Aug 2010 15:21:11 +0000 (18:21 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 8 Sep 2010 18:06:23 +0000 (20:06 +0200)
The connman_network_set_group() created an extra ref to service if it
was called before network was probed and registered.

src/network.c

index a74043c..68769e4 100644 (file)
@@ -534,21 +534,24 @@ void connman_network_set_group(struct connman_network *network,
        }
 
        if (g_strcmp0(network->group, group) == 0) {
-               if (group != NULL)
+               if (group != NULL && network->registered)
                        __connman_profile_update_network(network);
                return;
        }
 
        if (network->group != NULL) {
-               __connman_profile_remove_network(network);
+               if (network->registered)
+                       __connman_profile_remove_network(network);
 
                g_free(network->group);
        }
 
        network->group = g_strdup(group);
 
-       if (network->group != NULL)
-               __connman_profile_add_network(network);
+       if (network->group != NULL) {
+               if (network->registered)
+                       __connman_profile_add_network(network);
+       }
 }
 
 /**
@@ -1745,7 +1748,8 @@ static void network_remove(struct connman_element *element)
        case CONNMAN_NETWORK_TYPE_WIFI:
        case CONNMAN_NETWORK_TYPE_WIMAX:
                if (network->group != NULL) {
-                       __connman_profile_remove_network(network);
+                       if (network->registered)
+                               __connman_profile_remove_network(network);
 
                        g_free(network->group);
                        network->group = NULL;