[PATCH] base-bearer: use an initial longer timeout for connectivity check

Aleksander Morgado aleksander at aleksander.es
Fri Jun 2 10:21:49 UTC 2017


If we ask too quick for the PDP context status after a successful
connection attempt reported by the modem, we may find it still flagged
as inactive if the modem is still busy setting up the PPP session.

Do an explicit longer initial timeout before we run the first check,
and after that one setup the additional checks at a higher rate.

Reported-by: Colin Helliwell <colin.helliwell at ln-systems.com>
---

Hey Colin,

What do you think of this patch? Could you see if it helps with the issue you had?

Cheers!

---
 src/mm-base-bearer.c | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/mm-base-bearer.c b/src/mm-base-bearer.c
index 02084dff..5285e4f2 100644
--- a/src/mm-base-bearer.c
+++ b/src/mm-base-bearer.c
@@ -46,7 +46,9 @@

 #define BEARER_STATS_UPDATE_TIMEOUT 30

-#define BEARER_CONNECTION_MONITOR_TIMEOUT 5
+/* Initial connectivity check after 30s, then each 5s */
+#define BEARER_CONNECTION_MONITOR_INITIAL_TIMEOUT 30
+#define BEARER_CONNECTION_MONITOR_TIMEOUT          5

 G_DEFINE_TYPE (MMBaseBearer, mm_base_bearer, MM_GDBUS_TYPE_BEARER_SKELETON)

@@ -191,12 +193,29 @@ connection_monitor_cb (MMBaseBearer *self)
 {
     /* If the implementation knows how to load connection status, run it */
     MM_BASE_BEARER_GET_CLASS (self)->load_connection_status (
-            self,
-            (GAsyncReadyCallback)load_connection_status_ready,
-            NULL);
+        self,
+        (GAsyncReadyCallback)load_connection_status_ready,
+        NULL);
     return G_SOURCE_CONTINUE;
 }

+static gboolean
+initial_connection_monitor_cb (MMBaseBearer *self)
+{
+    MM_BASE_BEARER_GET_CLASS (self)->load_connection_status (
+        self,
+        (GAsyncReadyCallback)load_connection_status_ready,
+        NULL);
+
+    /* Add new monitor timeout at a higher rate */
+    self->priv->connection_monitor_id = g_timeout_add_seconds (BEARER_CONNECTION_MONITOR_TIMEOUT,
+                                                               (GSourceFunc) connection_monitor_cb,
+                                                               self);
+
+    /* Remove the initial connection monitor timeout as we added a new one */
+    return G_SOURCE_REMOVE;
+}
+
 static void
 connection_monitor_start (MMBaseBearer *self)
 {
@@ -208,10 +227,10 @@ connection_monitor_start (MMBaseBearer *self)
     if (self->priv->load_connection_status_unsupported)
         return;

-    /* Schedule */
+    /* Schedule initial check */
     g_assert (!self->priv->connection_monitor_id);
-    self->priv->connection_monitor_id = g_timeout_add_seconds (BEARER_CONNECTION_MONITOR_TIMEOUT,
-                                                               (GSourceFunc) connection_monitor_cb,
+    self->priv->connection_monitor_id = g_timeout_add_seconds (BEARER_CONNECTION_MONITOR_INITIAL_TIMEOUT,
+                                                               (GSourceFunc) initial_connection_monitor_cb,
                                                                self);
 }

--
2.13.0


More information about the ModemManager-devel mailing list