From: Daniel Wagner Date: Thu, 11 Aug 2011 14:56:18 +0000 (+0200) Subject: session: Track reason on a session level X-Git-Tag: 2.0_alpha~1249 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4250ca086f6550db46b85dffe081f9f19b4ab04c;p=framework%2Fconnectivity%2Fconnman.git session: Track reason on a session level We need to track the Connect()/Disconnect() on a global session level and not only in the info. This is needed when we were not able to select and connect to a matching service in the first place. It might happen that a valid service is added in time and then we want to use it. --- diff --git a/src/session.c b/src/session.c index da9162c..7d9fc8b 100644 --- a/src/session.c +++ b/src/session.c @@ -84,6 +84,7 @@ struct session_info { unsigned int marker; struct service_entry *entry; + enum connman_session_reason reason; }; struct connman_session { @@ -760,6 +761,7 @@ static void test_and_disconnect(struct connman_session *session) entry = info->entry; info->online = FALSE; + info->reason = CONNMAN_SESSION_REASON_UNKNOWN; info->entry = NULL; if (disconnect == TRUE) { @@ -784,6 +786,8 @@ static void select_and_connect(struct connman_session *session, DBG("session %p reason %s", session, reason2string(reason)); + info->reason = reason; + iter = g_sequence_get_begin_iter(session->service_list); while (g_sequence_iter_is_end(iter) == FALSE) { @@ -902,6 +906,20 @@ static void session_changed(struct connman_session *session, break; } + if (info->reason == CONNMAN_SESSION_REASON_CONNECT) { + DBG("Retry to find a matching session"); + /* + * The user called Connect() but there was no + * matching session available at this point. + * Now there might be a new one. Let's retry + * to select and connect + */ + select_and_connect(session, + CONNMAN_SESSION_REASON_CONNECT); + + break; + } + if (info->stay_connected == TRUE) { DBG("StayConnected"); select_and_connect(session,