From 8a6ea50b2aaeb1b317196b16886e874ff98485c0 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 17 Jul 2009 09:54:59 +0200 Subject: [PATCH] Fix issues with current auto-connect logic --- src/profile.c | 2 -- src/service.c | 62 +++++++++++++++++++++++------------------------------------ 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/profile.c b/src/profile.c index 5ce355e..f6ab24b 100644 --- a/src/profile.c +++ b/src/profile.c @@ -93,8 +93,6 @@ static gboolean services_changed(gpointer user_data) append_services(&entry); g_dbus_send_message(connection, signal); - __connman_service_auto_connect(); - return FALSE; } diff --git a/src/service.c b/src/service.c index 2cfbdb8..2753d90 100644 --- a/src/service.c +++ b/src/service.c @@ -440,24 +440,6 @@ static connman_bool_t is_connecting(struct connman_service *service) return FALSE; } -static struct connman_service *find_pending_service(void) -{ - struct connman_service *service; - GSequenceIter *iter; - - iter = g_sequence_get_begin_iter(service_list); - - while (g_sequence_iter_is_end(iter) == FALSE) { - service = g_sequence_get(iter); - if (service->pending != NULL) - return service; - - iter = g_sequence_iter_next(iter); - } - - return NULL; -} - static connman_bool_t is_ignore(struct connman_service *service) { if (service->ignore == TRUE) @@ -471,38 +453,38 @@ static connman_bool_t is_ignore(struct connman_service *service) void __connman_service_auto_connect(void) { - struct connman_service *service; + struct connman_service *service = NULL; GSequenceIter *iter; DBG(""); - service = find_pending_service(); - if (service != NULL) - return; - iter = g_sequence_get_begin_iter(service_list); - if (g_sequence_iter_is_end(iter) == TRUE) - return; - service = g_sequence_get(iter); + while (g_sequence_iter_is_end(iter) == FALSE) { + service = g_sequence_get(iter); + + if (service->pending != NULL) + return; - while (is_ignore(service) == TRUE) { - iter = g_sequence_iter_next(iter); - if (g_sequence_iter_is_end(iter)) + if (is_connecting(service) == TRUE) return; - service = g_sequence_get(iter); - } - if (service->favorite == FALSE) - return; + if (service->favorite == FALSE) + return; - if (service->state == CONNMAN_SERVICE_STATE_READY) - return; + if (service->state == CONNMAN_SERVICE_STATE_READY) + return; - if (is_connecting(service) == TRUE) - return; + if (is_ignore(service) == FALSE && + service->state == CONNMAN_SERVICE_STATE_IDLE) + break; - if (service->state == CONNMAN_SERVICE_STATE_IDLE) + service = NULL; + + iter = g_sequence_iter_next(iter); + } + + if (service != NULL) __connman_service_connect(service); } @@ -1038,6 +1020,10 @@ int __connman_service_indicate_state(struct connman_service *service, __connman_profile_changed(FALSE); + if (service->favorite == TRUE && + service->state == CONNMAN_SERVICE_STATE_IDLE) + __connman_service_auto_connect(); + return 0; } -- 2.7.4