aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-01-15 21:15:30 -0600
committerTed Gould <ted@gould.cx>2010-01-15 21:15:30 -0600
commit2ce95b0279e75123beef7cdc1b440b03ffb56c55 (patch)
tree5e0df84b70b2f070fbe53a5042ebcd69686e8dfc /libindicator
parentb9344c35f45a52ab15462746998d1b11b63e5928 (diff)
downloadlibayatana-indicator-2ce95b0279e75123beef7cdc1b440b03ffb56c55.tar.gz
libayatana-indicator-2ce95b0279e75123beef7cdc1b440b03ffb56c55.tar.bz2
libayatana-indicator-2ce95b0279e75123beef7cdc1b440b03ffb56c55.zip
Filling out the function to start it again, and adding in the function to respond to the timeout.
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-service-manager.c22
1 files changed, 22 insertions, 0 deletions
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;
}