aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-01-21 10:30:52 -0600
committerTed Gould <ted@gould.cx>2010-01-21 10:30:52 -0600
commit0219e0e7d51086cc691367e8deda356ac2b6aabc (patch)
tree67d9919a3dd3d14bead1d308de8cb00b15a84f5f
parent4a7af569bd96c25cbf028fd7144fd2f5d6262a3c (diff)
downloadlibayatana-indicator-0219e0e7d51086cc691367e8deda356ac2b6aabc.tar.gz
libayatana-indicator-0219e0e7d51086cc691367e8deda356ac2b6aabc.tar.bz2
libayatana-indicator-0219e0e7d51086cc691367e8deda356ac2b6aabc.zip
Adding in tracking of the restart idle function and making sure we don't do it twice.
-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;