connection: Fix service refcount
authorYu A Wang <arron.wang@intel.com>
Mon, 19 Dec 2011 08:00:17 +0000 (03:00 -0500)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 13 Jan 2012 15:15:06 +0000 (16:15 +0100)
Service may be refcount two times when add_gateway for both ipv4 and
ipv6, we need to unref the service twice according when we have both
ipv6 and ipv4 gateway

src/connection.c

index 54f2b74..58adfeb 100644 (file)
@@ -713,6 +713,14 @@ void __connman_connection_gateway_remove(struct connman_service *service,
        err = disable_gateway(data, type);
 
        /*
+        * We may refcount service twice seperately for ipv4 and ipv6
+        * then we need to unref accordingly.
+        */
+       if (do_ipv4 == do_ipv6 && data->ipv4_gateway != NULL &&
+                                       data->ipv6_gateway != NULL)
+               connman_service_unref(service);
+
+       /*
         * We remove the service from the hash only if all the gateway
         * settings are to be removed.
         */