summaryrefslogtreecommitdiff
path: root/src/mm-base-bearer.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-06-02 12:16:21 +0200
committerAleksander Morgado <aleksander@aleksander.es>2017-06-05 15:18:00 +0200
commit34ac81071b90e4e15c209b2540d62cc8ca55f9da (patch)
tree58072a2ab3337bdd2de878fdf49f5a410c29b6fa /src/mm-base-bearer.c
parentdb5619b3eb9bac980f8f1f67c1589b5d73761917 (diff)
base-bearer: use an initial longer timeout for connectivity check
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@ln-systems.com>
Diffstat (limited to 'src/mm-base-bearer.c')
-rw-r--r--src/mm-base-bearer.c33
1 files 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);
}