Hi Marcel,

2010/8/30 Pekka Pessi <[email protected]>:
> It seems to me that most service methods assume there is valid network
> pointer, so my patch is not probably a very good idea.
>
> It might be better to remove and free the service once the network (or
> underlying device) is removed.

It seems to me that the problem is in network.c:network_probe() which
re-adds the network and creates an extra ref to service. Probably the
original idea was to delay the addition until the network was probed
and registered, something like this:

diff --git a/src/network.c b/src/network.c
index 551d737..42fe0b8 100644
--- a/src/network.c
+++ b/src/network.c
@@ -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;

-- 
Pekka.Pessi mail at nokia.com
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to