[PATCH ipv6 v1 06/14] service: Only disconnect the service if both IPv4 and IPv6 states agree.

Jukka Rissanen jukka.rissanen at nokia.com
Mon Jan 24 04:12:07 PST 2011


---
 src/service.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/service.c b/src/service.c
index 98f824b..09c6913 100644
--- a/src/service.c
+++ b/src/service.c
@@ -107,6 +107,7 @@ struct connman_service {
 	char **proxies;
 	char **excludes;
 	char *pac;
+	int connect_count;
 };
 
 static void append_path(gpointer value, gpointer user_data)
@@ -2886,6 +2887,7 @@ static void service_initialize(struct connman_service *service)
 	stats_init(service);
 
 	service->provider = NULL;
+	service->connect_count = 0;
 }
 
 /**
@@ -3298,6 +3300,8 @@ int __connman_service_indicate_state(struct connman_service *service,
 	if (state == CONNMAN_SERVICE_STATE_READY) {
 		enum connman_service_proxy_method proxy_config;
 
+		g_atomic_int_inc(&service->connect_count);
+
 		set_reconnect_state(service, TRUE);
 
 		__connman_service_set_favorite(service, TRUE);
@@ -3336,11 +3340,15 @@ int __connman_service_indicate_state(struct connman_service *service,
 
 		default_changed();
 	} else if (state == CONNMAN_SERVICE_STATE_DISCONNECT) {
-		__connman_location_finish(service);
 
-		default_changed();
+		if (g_atomic_int_dec_and_test(&service->connect_count) ==
+									TRUE) {
+			__connman_location_finish(service);
+
+			default_changed();
 
-		__connman_wpad_stop(service);
+			__connman_wpad_stop(service);
+		}
 
 		update_nameservers(service);
 		dns_changed(service);
@@ -3363,7 +3371,8 @@ int __connman_service_indicate_state(struct connman_service *service,
 	if (iter != NULL)
 		g_sequence_sort_changed(iter, service_compare, NULL);
 
-	__connman_profile_changed(FALSE);
+	if (service->connect_count == 0)
+		__connman_profile_changed(FALSE);
 
 	service_state = combine_state(service->state_ipv4,
 							service->state_ipv6);
-- 
1.7.0.4




More information about the connman mailing list