diff options
-rw-r--r-- | src/mm-base-bearer.c | 33 |
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); } |