From 34ac81071b90e4e15c209b2540d62cc8ca55f9da Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Fri, 2 Jun 2017 12:16:21 +0200 Subject: 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 --- src/mm-base-bearer.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3-70-g09d2