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>
This commit is contained in:
Aleksander Morgado
2017-06-05 15:18:00 +02:00
parent db5619b3eb
commit 34ac81071b
+26 -7
View File
@@ -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);
}