From d11deb8ad35d76e8531968e0eda749bab765cd59 Mon Sep 17 00:00:00 2001 From: Patrik Flykt Date: Thu, 5 Apr 2012 22:38:45 +0300 Subject: [PATCH] service: Update ordering regarding connected preferred service When a new service goes online, run the service ordering check. If the return value is -EAGAIN, neither service was preferred and a new autoconnection attempt is done to find a preferred service. When a new service goes to ready state, run the service ordering check similarly as with the online state. Since online check will be run next, only re-attempt autoconnection when the online check is known to have failed and the service will stay at ready state. --- src/service.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/service.c b/src/service.c index 911b6bb..5b5dac6 100644 --- a/src/service.c +++ b/src/service.c @@ -4330,6 +4330,7 @@ static int service_indicate_state(struct connman_service *service) { enum connman_service_state old_state, new_state; struct connman_service *def_service; + int result; GSequenceIter *iter; if (service == NULL) @@ -4351,9 +4352,12 @@ static int service_indicate_state(struct connman_service *service) def_service = __connman_service_get_default(); if (new_state == CONNMAN_SERVICE_STATE_ONLINE) { - if (def_service != NULL && def_service != service && - def_service->state == CONNMAN_SERVICE_STATE_ONLINE) - return -EALREADY; + result = service_update_preferred_order(def_service, + service, new_state); + if (result == -EALREADY) + return result; + if (result == -EAGAIN) + __connman_service_auto_connect(); } service->state = new_state; @@ -4388,6 +4392,8 @@ static int service_indicate_state(struct connman_service *service) if (new_state == CONNMAN_SERVICE_STATE_READY) { enum connman_ipconfig_method method; + service_update_preferred_order(def_service, service, new_state); + set_reconnect_state(service, TRUE); __connman_service_set_favorite(service, TRUE); @@ -4662,12 +4668,12 @@ int __connman_service_online_check_failed(struct connman_service *service, DBG("service %p type %d count %d", service, type, service->online_check_count); - if (type == CONNMAN_IPCONFIG_TYPE_IPV4) - /* currently we only retry IPv6 stuff */ - return 0; - - if (service->online_check_count != 1) + /* currently we only retry IPv6 stuff */ + if (type == CONNMAN_IPCONFIG_TYPE_IPV4 || + service->online_check_count != 1) { + __connman_service_auto_connect(); return 0; + } service->online_check_count = 0; -- 2.7.4