=== modified file 'src/main.c'
--- src/main.c 2015-03-10 19:16:26 +0000
+++ src/main.c 2015-12-09 13:36:30 +0000
@@ -14,6 +14,8 @@
* along with this program. If not, see .
*/
+#include
+
#include
#include
#include
@@ -22,6 +24,8 @@
#include "config.h"
static IndicatorSoundService * service = NULL;
+static int DBUS_OWN_NAME_RETRIES = 30;
+static GMainLoop * loop = NULL;
static gboolean
sigterm_handler (gpointer data)
@@ -37,7 +41,16 @@
gpointer user_data)
{
g_warning("Name lost or unable to acquire bus: %s", name);
- g_main_loop_quit((GMainLoop *)user_data);
+ if (DBUS_OWN_NAME_RETRIES-- == 0) {
+ g_main_loop_quit((GMainLoop *)user_data);
+ } else {
+ // we wait 10 milliseconds to let the system be completely up.
+ // sometimes the indicator starts while dbus seems to be
+ // still starting and if upstart is fast enough restarting
+ // the indicator it may fail to start in the 30 upstart retries.
+ usleep(10000);
+ try_bus_own_name();
+ }
}
static void
@@ -66,11 +79,22 @@
g_clear_object(&accounts);
}
+void
+try_bus_own_name()
+{
+ g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.canonical.indicator.sound",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ on_bus_acquired,
+ NULL, /* name acquired */
+ on_name_lost,
+ loop,
+ NULL);
+}
+
int
main (int argc, char ** argv)
{
- GMainLoop * loop = NULL;
-
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
@@ -83,14 +107,7 @@
/* Initialize libnotify */
notify_init ("indicator-sound");
- g_bus_own_name(G_BUS_TYPE_SESSION,
- "com.canonical.indicator.sound",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- on_bus_acquired,
- NULL, /* name acquired */
- on_name_lost,
- loop,
- NULL);
+ try_bus_own_name();
g_main_loop_run(loop);