aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-01-15 20:38:04 -0600
committerTed Gould <ted@gould.cx>2010-01-15 20:38:04 -0600
commitb9344c35f45a52ab15462746998d1b11b63e5928 (patch)
tree1bde730a7f3b7c2bb71d2077898e0788a3919a71 /libindicator
parent41559b3cc70cffacc023a6a21cca41b5b1070447 (diff)
downloadlibayatana-indicator-b9344c35f45a52ab15462746998d1b11b63e5928.tar.gz
libayatana-indicator-b9344c35f45a52ab15462746998d1b11b63e5928.tar.bz2
libayatana-indicator-b9344c35f45a52ab15462746998d1b11b63e5928.zip
Reset the restart_count when we start, and start to bring in 'start_service_again' to begin to throttle the restarts.
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-service-manager.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libindicator/indicator-service-manager.c b/libindicator/indicator-service-manager.c
index ee29767..6c6dca9 100644
--- a/libindicator/indicator-service-manager.c
+++ b/libindicator/indicator-service-manager.c
@@ -43,6 +43,7 @@ License along with this library. If not, see
@connected: Whether we're connected to the service or not.
@this_service_version: The version of the service that we're looking for.
@bus: A reference to the bus so we don't have to keep getting it.
+ @restart_count: The number of times we've restarted this service.
*/
typedef struct _IndicatorServiceManagerPrivate IndicatorServiceManagerPrivate;
struct _IndicatorServiceManagerPrivate {
@@ -52,6 +53,7 @@ struct _IndicatorServiceManagerPrivate {
gboolean connected;
guint this_service_version;
DBusGConnection * bus;
+ guint restart_count;
};
/* Signals Stuff */
@@ -93,6 +95,7 @@ static void indicator_service_manager_finalize (GObject *object);
static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);
static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);
static void start_service (IndicatorServiceManager * service);
+static void start_service_again (IndicatorServiceManager * manager);
G_DEFINE_TYPE (IndicatorServiceManager, indicator_service_manager, G_TYPE_OBJECT);
@@ -169,6 +172,7 @@ indicator_service_manager_init (IndicatorServiceManager *self)
priv->connected = FALSE;
priv->this_service_version = 0;
priv->bus = NULL;
+ priv->restart_count = 0;
/* Start talkin' dbus */
GError * error = NULL;
@@ -327,6 +331,12 @@ watch_cb (DBusGProxy * proxy, guint service_api_version, guint this_service_vers
return;
}
+ /* We've done it, now let's stop counting. */
+ /* Note: we're not checking versions. Because, the hope is that
+ the guy holding the name we want with the wrong version will
+ drop and we can start another service quickly. */
+ priv->restart_count = 0;
+
if (service_api_version != INDICATOR_SERVICE_VERSION) {
g_warning("Service is using a different version of the service interface. Expecting %d and got %d.", INDICATOR_SERVICE_VERSION, service_api_version);
dbus_g_proxy_call_no_reply(priv->service_proxy, "UnWatch", G_TYPE_INVALID);
@@ -358,11 +368,13 @@ start_service_cb (DBusGProxy * proxy, guint status, GError * error, gpointer use
if (error != NULL) {
g_warning("Unable to start service '%s': %s", priv->name, error->message);
+ start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
return;
}
if (status != DBUS_START_REPLY_SUCCESS && status != DBUS_START_REPLY_ALREADY_RUNNING) {
g_warning("Status of starting the process '%s' was an error: %d", priv->name, status);
+ start_service_again(INDICATOR_SERVICE_MANAGER(user_data));
return;
}
@@ -423,6 +435,18 @@ start_service (IndicatorServiceManager * service)
return;
}
+/* 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
+ being successful. */
+static void
+start_service_again (IndicatorServiceManager * manager)
+{
+
+
+ return;
+}
+
/* API */
/**