From: Daniel Wagner <[email protected]>

---
 src/session.c |   71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/session.c b/src/session.c
index d681d72..6cfd40a 100644
--- a/src/session.c
+++ b/src/session.c
@@ -28,6 +28,77 @@
 
 #include "connman.h"
 
+/*
+ * How the session connection management works
+ * -------------------------------------------
+ *
+ * When a session is created, a sorted list of services (service_list)
+ * is added to the session. The services are filtered and stable
+ * sorted according following rules:
+ *
+ *  - AllowedBearer (filter and sort)
+ *  - RoamingPolicy (filter and sort)
+ *
+ * A stable sorting algorithms maintains the relative order of records
+ * with equal keys. If a service is removed or added all sessions
+ * service list is updated and refiltered and sorted according the
+ * above rules.
+ *
+ * There are three triggers which lead to evalute the connect
+ * algorithm:
+ *
+ *  - Session.Connect()
+ *  - PeriodicTimer
+ *  - Offline
+ *
+ * Connect algorithm:
+ *
+ *               Session.Connect()     Offline
+ *               PeriodicConnect        |
+ *                        | Yes  +------+-------+  No
+ *                        +------+StayConnected?+------ Do nothing
+ *                        |      +--------------+
+ *                        |
+ *                        |
+ *                 +------+-------+
+ *           +-----+EmergencyCall?+-----+
+ *        Yes|     +--------------+     |No
+ *           |                          |
+ *         Connect to            +--------------+
+ *         first available   +---+AvoidHandover?+---+
+ *         Service           |   +--------------+   |
+ *                        Yes|                      |No
+ *                  +----------------+              |
+ *              +---+In service_list +---+          |
+ *           Yes|   |and online?     |   |No        |
+ *              |   +----------------+   |          |
+ *              |                        |          |
+ *          Take that one                Take first in
+ *                                       service_list
+ *
+ * There are two triggers which lead to evalut the disconnect
+ * algorithm
+ *
+ *  - Session.Disconnect()
+ *  - IdleTimeout()
+ *
+ * Disconnect algorithm:
+ *
+ *   IdleTimeout()
+ *   Session.Disconnect()
+ *        |
+ *        |
+ *        |
+ * +-----------------+    Yes
+ * |service not used +-------------+
+ * |by other session?|             |
+ * +------.----------+             |
+ *        |No                      |
+ *        |                        |
+ *     Service.disconnect()   Do nothing
+ *
+ */
+
 static DBusConnection *connection;
 static GHashTable *session_hash;
 static connman_bool_t sessionmode;
-- 
1.7.4.2

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to