Create service ipconfig only when it's NULL
authorSamuel Ortiz <sameo@linux.intel.com>
Fri, 25 Jun 2010 12:56:05 +0000 (14:56 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 25 Jun 2010 12:56:05 +0000 (14:56 +0200)
If a service already has an allocated ipconfig layer but the corresponding
network index is negative, the only thing left to do is to set the ipconfig
index properly.
The oFono plugin toggles the network index between connection while the
service ipconfig layer stays alive.

src/network.c

index a241d15..c36298e 100644 (file)
@@ -447,12 +447,15 @@ const char *connman_network_get_path(struct connman_network *network)
 void connman_network_set_index(struct connman_network *network, int index)
 {
        struct connman_service *service;
+       struct connman_ipconfig *ipconfig;
 
        service = __connman_service_lookup_from_network(network);
        if (service == NULL)
                goto done;
 
-       if (network->element.index < 0)
+       ipconfig = __connman_service_get_ipconfig(service);
+
+       if (network->element.index < 0 && ipconfig == NULL)
                /*
                 * This is needed for plugins that havent set their ipconfig
                 * layer yet, due to not being able to get a network index
@@ -460,10 +463,7 @@ void connman_network_set_index(struct connman_network *network, int index)
                 */
                __connman_service_create_ipconfig(service, index);
        else {
-               struct connman_ipconfig *ipconfig;
-
                /* If index changed, the index of ipconfig must be reset. */
-               ipconfig = __connman_service_get_ipconfig(service);
                if (ipconfig == NULL)
                        goto done;