From: Daniel Wagner <[email protected]>
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.
---
src/session.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/session.c b/src/session.c
index aa70208..5a4b61b 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 (explicit_disconnect(session) == TRUE) {
+ 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,
--
1.7.6
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman