From ffb9bb1f79e97f151aa8cb0352db3e81b4be9caf Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 23 Oct 2013 15:07:46 +0100 Subject: [PATCH] gdbus: Work around a D-Bus bug with path_namespace='/' match rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit D-Bus versions < 1.6.18 (i.e. all current versions) have a bug with the path_namespace='/' match rule key. It should conceptually match everything, but actually matches nothing. This results in no property change (or other) signals being forwarded to the D-Bus client. The work-around implemented in GDBusObjectManagerClient is to remove the path_namespace match key if its value is ‘/’. For the upstream D-Bus bug, see: https://bugs.freedesktop.org/show_bug.cgi?id=70799 https://bugzilla.gnome.org/show_bug.cgi?id=710726 --- gio/gdbusobjectmanagerclient.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/gio/gdbusobjectmanagerclient.c b/gio/gdbusobjectmanagerclient.c index ed0adc00b..d9ccf7160 100644 --- a/gio/gdbusobjectmanagerclient.c +++ b/gio/gdbusobjectmanagerclient.c @@ -1105,12 +1105,24 @@ subscribe_signals (GDBusObjectManagerClient *manager, if (name_owner != NULL) { - /* the bus daemon may not implement path_prefix so gracefully - * handle this by using a fallback - */ - manager->priv->match_rule = g_strdup_printf ("type='signal',sender='%s',path_namespace='%s'", - name_owner, manager->priv->object_path); + /* Only add path_namespace if it's non-'/'. This removes a no-op key from + * the match rule, and also works around a D-Bus bug where + * path_namespace='/' matches nothing in D-Bus versions < 1.6.18. + * + * See: https://bugs.freedesktop.org/show_bug.cgi?id=70799 */ + if (g_str_equal (manager->priv->object_path, "/")) + { + manager->priv->match_rule = g_strdup_printf ("type='signal',sender='%s'", + name_owner); + } + else + { + manager->priv->match_rule = g_strdup_printf ("type='signal',sender='%s',path_namespace='%s'", + name_owner, manager->priv->object_path); + } + /* The bus daemon may not implement path_namespace so gracefully + * handle this by using a fallback triggered if @error is set. */ ret = g_dbus_connection_call_sync (manager->priv->connection, "org.freedesktop.DBus", "/org/freedesktop/DBus",