connection: Service was not ref counted properly
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Wed, 24 Aug 2011 14:02:05 +0000 (17:02 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 12 Sep 2011 09:40:47 +0000 (11:40 +0200)
The reference counting problems were clearly seen with VPN service.

src/connection.c

index d8d95f3..477cf84 100644 (file)
@@ -229,6 +229,7 @@ static struct gateway_data *add_gateway(struct connman_service *service,
                }
        }
 
+       connman_service_ref(service);
        g_hash_table_replace(gateway_hash, service, data);
 
        return data;
@@ -720,9 +721,10 @@ void __connman_connection_gateway_remove(struct connman_service *service,
                        && do_ipv4 == TRUE) ||
                (data->ipv6_gateway != NULL && data->ipv4_gateway == NULL
                        && do_ipv6 == TRUE)
-               )
+               ) {
+               connman_service_unref(service);
                g_hash_table_remove(gateway_hash, service);
-       else
+       else
                DBG("Not yet removing gw ipv4 %p/%d ipv6 %p/%d",
                        data->ipv4_gateway, do_ipv4,
                        data->ipv6_gateway, do_ipv6);