From 2ce95b0279e75123beef7cdc1b440b03ffb56c55 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 Jan 2010 21:15:30 -0600 Subject: Filling out the function to start it again, and adding in the function to respond to the timeout. --- libindicator/indicator-service-manager.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c index 6c6dca9..0c552d4 100644 --- a/libindicator/indicator-service-manager.c +++ b/libindicator/indicator-service-manager.c @@ -435,6 +435,18 @@ start_service (IndicatorServiceManager * service) return; } +/* The callback that starts the service for real after + the timeout as determined in 'start_service_again'. + This could be in the idle or a timer. */ +static gboolean +start_service_again_cb (gpointer data) +{ + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(data); + priv->restart_count++; + start_service(INDICATOR_SERVICE_MANAGER(data)); + return FALSE; +} + /* This function tries to start a new service, perhaps after a timeout that it determines. The real issue here is that it throttles restarting if we're not @@ -442,7 +454,17 @@ start_service (IndicatorServiceManager * service) static void start_service_again (IndicatorServiceManager * manager) { + IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(manager); + if (priv->restart_count == 0) { + /* First time, do it in idle */ + g_idle_add(start_service_again_cb, manager); + } else { + /* Not our first time 'round the block. Let's slow this down. */ + if (priv->restart_count > 16) + priv->restart_count = 16; /* Not more than 1024x */ + g_timeout_add((1 << priv->restart_count) * timeout_multiplier, start_service_again_cb, manager); + } return; } -- cgit v1.2.3