From e07e2d14a387959e5c13e9cf5a74bc6de228b99e Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 22 Aug 2011 14:24:18 +0200 Subject: [PATCH] session: Fix selection of services In case we didn't select a service (entry) reset the one in the info (deselection). And then we have also take a refence if the reason was CONNECT. --- src/session.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/session.c b/src/session.c index f0b6a20..19771b2 100644 --- a/src/session.c +++ b/src/session.c @@ -823,18 +823,23 @@ static void select_and_connect(struct connman_session *session, if (info->entry != NULL && info->entry != entry) test_and_disconnect(session); - if (entry != NULL) { - info->entry = entry; - info->entry->reason = reason; + if (entry == NULL) { + info->entry = NULL; + return; + } - if (explicit_connect(reason) == TRUE) - __connman_service_session_inc(info->entry->service); + info->entry = entry; + info->entry->reason = reason; - if (do_connect == TRUE) - __connman_service_connect(info->entry->service); - else - info->online = is_online(entry->state); + if (do_connect == TRUE) { + __connman_service_session_inc(info->entry->service); + __connman_service_connect(info->entry->service); + } else if (reason == CONNMAN_SESSION_REASON_CONNECT) { + /* session is already online take ref */ + __connman_service_session_inc(info->entry->service); } + + info->online = is_online(entry->state); } static void session_changed(struct connman_session *session, -- 2.7.4