aboutsummaryrefslogtreecommitdiff
path: root/libindicator/indicator-service-manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'libindicator/indicator-service-manager.c')
-rw-r--r--libindicator/indicator-service-manager.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c
index 5d1bd91..7bb9a9b 100644
--- a/libindicator/indicator-service-manager.c
+++ b/libindicator/indicator-service-manager.c
@@ -54,6 +54,7 @@ struct _IndicatorServiceManagerPrivate {
guint this_service_version;
DBusGConnection * bus;
guint restart_count;
+ gint restart_source;
};
/* Signals Stuff */
@@ -168,6 +169,7 @@ indicator_service_manager_init (IndicatorServiceManager *self)
priv->this_service_version = 0;
priv->bus = NULL;
priv->restart_count = 0;
+ priv->restart_source = 0;
/* Start talkin' dbus */
GError * error = NULL;
@@ -201,6 +203,13 @@ indicator_service_manager_dispose (GObject *object)
{
IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(object);
+ /* Removing the idle task to restart if it exists. */
+ if (priv->restart_source != 0) {
+ g_source_remove(priv->restart_source);
+ }
+ /* Block any restart calls */
+ priv->restart_source = -1;
+
/* If we were connected we need to make sure to
tell people that it's no longer the case. */
if (priv->connected) {
@@ -468,6 +477,7 @@ start_service_again_cb (gpointer data)
IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(data);
priv->restart_count++;
start_service(INDICATOR_SERVICE_MANAGER(data));
+ priv->restart_source = 0;
return FALSE;
}
@@ -480,6 +490,12 @@ start_service_again (IndicatorServiceManager * manager)
{
IndicatorServiceManagerPrivate * priv = INDICATOR_SERVICE_MANAGER_GET_PRIVATE(manager);
+ /* If we've already got a restart source running then
+ let's not do this again. */
+ if (priv->restart_source != 0) {
+ return;
+ }
+
/* Allow the restarting to be disabled */
if (g_getenv(TIMEOUT_ENV_NAME)) {
return;
@@ -492,7 +508,7 @@ start_service_again (IndicatorServiceManager * manager)
/* 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);
+ priv->restart_source = g_timeout_add((1 << priv->restart_count) * TIMEOUT_MULTIPLIER, start_service_again_cb, manager);
}
return;