[PATCH 1/4] service: Fix VPN and service list head ordering

Patrik Flykt patrik.flykt at linux.intel.com
Tue Sep 24 05:48:55 PDT 2013


A VPN service will always get an order value of 10 independent of its
position in the sorted list of services. An order of 1 for the first
item in the service list is not stored in the service struct as it will
conflict with service sorting.
---
 src/service.c |   28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/service.c b/src/service.c
index 370e3fd..7c8c2c3 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4755,7 +4755,7 @@ int __connman_service_set_favorite_delayed(struct connman_service *service,
 	service->favorite = favorite;
 
 	if (!delay_ordering)
-		service->order = __connman_service_get_order(service);
+		__connman_service_get_order(service);
 
 	favorite_changed(service);
 
@@ -6406,27 +6406,29 @@ const char *__connman_service_get_name(struct connman_service *service)
 
 unsigned int __connman_service_get_order(struct connman_service *service)
 {
+	unsigned int order = 0;
+
 	if (!service)
 		return 0;
 
-	if (!service->favorite) {
-		service->order = 0;
-		goto done;
-	}
+	service->order = 0;
+
+	if (!service->favorite)
+		return 0;
 
 	if (service == service_list->data)
-		service->order = 1;
-	else if (service->type == CONNMAN_SERVICE_TYPE_VPN &&
-			!service->do_split_routing)
+		order = 1;
+
+	if (service->type == CONNMAN_SERVICE_TYPE_VPN &&
+			!service->do_split_routing) {
 		service->order = 10;
-	else
-		service->order = 0;
+		order = 10;
+	}
 
 	DBG("service %p name %s order %d split %d", service, service->name,
-		service->order, service->do_split_routing);
+		order, service->do_split_routing);
 
-done:
-	return service->order;
+	return order;
 }
 
 void __connman_service_update_ordering(void)
-- 
1.7.10.4




More information about the connman mailing list