service: Add timeout event only the first time
authorYu A Wang <yu.a.wang@intel.com>
Thu, 9 Jun 2011 09:06:15 +0000 (05:06 -0400)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 14 Jun 2011 09:26:27 +0000 (11:26 +0200)
When connect to a 3G service with weak signal, it may connect
several times. When connman suspend to S3 and resume several
times, function remove_timeout only remove the last timeout event.
This will lead connman crash when connect_timeout invoked by other
timeout event to access previous already freed service.

src/service.c

index 1b45f740def165ebd44ef5ae710cf9b51f0e3554..2ba956e33cf2d3f73d96aa2dcd6537643fb64e1f 100644 (file)
@@ -3936,8 +3936,9 @@ int __connman_service_connect(struct connman_service *service)
                return 0;
 
        if (err == -EINPROGRESS) {
-               service->timeout = g_timeout_add_seconds(CONNECT_TIMEOUT,
-                                               connect_timeout, service);
+               if (service->timeout == 0)
+                       service->timeout = g_timeout_add_seconds(
+                               CONNECT_TIMEOUT, connect_timeout, service);
 
                return -EINPROGRESS;
        }