[Xfce4-commits] [xfce/xfce4-settings] 01/01: Set the G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT flag on name acquired
noreply at xfce.org
noreply at xfce.org
Mon Jun 4 09:03:51 CEST 2018
This is an automated email from the git hooks/post-receive script.
a l i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/xfce4-settings.
commit 6aacb9673b13c7e3f86885010b7fabe955abac4e
Author: Ali Abdallah <ali at xfce.org>
Date: Mon Jun 4 08:50:01 2018 +0200
Set the G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT flag on name acquired
Set the G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT only when we acquire
the bus name, otherwise D-Bus might queue us, ending with multiple
xfsettingsd instances running each one waiting for the other to exit
to acquire its role.
This seems to be the correct way to do it with gdbus, as there is
no DBUS_NAME_FLAG_DO_NOT_QUEUE equivalent in gdbus.
---
xfsettingsd/main.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/xfsettingsd/main.c b/xfsettingsd/main.c
index 4fc5c9b..6d34913 100644
--- a/xfsettingsd/main.c
+++ b/xfsettingsd/main.c
@@ -93,6 +93,18 @@ on_name_lost (GDBusConnection *connection,
}
static void
+on_name_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ GBusNameOwnerFlags dbus_flags;
+
+ /* Update the name flags to allow replacement */
+ dbus_flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT;
+ g_bus_own_name_on_connection (connection, XFSETTINGS_DBUS_NAME, dbus_flags, NULL, NULL, NULL, NULL );
+}
+
+static void
signal_handler (gint signum,
gpointer user_data)
{
@@ -248,9 +260,11 @@ main (gint argc, gchar **argv)
}
/* Allow the settings daemon to be replaced */
- dbus_flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | G_BUS_NAME_OWNER_FLAGS_REPLACE;
+ dbus_flags = G_BUS_NAME_OWNER_FLAGS_NONE;
+ if (opt_replace || name_owned)
+ dbus_flags = G_BUS_NAME_OWNER_FLAGS_REPLACE ;
- owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, XFSETTINGS_DBUS_NAME, dbus_flags, NULL, NULL, on_name_lost, NULL, NULL );
+ owner_id = g_bus_own_name_on_connection (dbus_connection, XFSETTINGS_DBUS_NAME, dbus_flags, on_name_acquired, on_name_lost, NULL, NULL );
}
else
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list