From 20387d262ff104f9de3defc264c5c2010d272857 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 15 Aug 2011 15:57:59 +0100 Subject: [PATCH] GDBusProxy: if a well-known name is not owned, don't GetAll from the dbus-daemon If you run: ( cd gio/tests && G_DBUS_DEBUG=all ./gdbus-proxy-well-known-name ) you can see that in the case where the name com.example.TestService isn't owned yet, the GDBusProxy calls GetAll() with no destination, resulting in an error reply from the peer (the dbus-daemon itself). That's clearly not right! However, if priv->name is NULL, that indicates the special case where we really do want to talk directly to a peer, instead of via the bus daemon (most likely to be used on peer-to-peer connections); in that special case, do call GetAll(). Signed-off-by: Simon McVittie Signed-off-by: David Zeuthen --- gio/gdbusproxy.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c index a0e0180..f776662 100644 --- a/gio/gdbusproxy.c +++ b/gio/gdbusproxy.c @@ -1316,6 +1316,7 @@ async_init_get_name_owner_cb (GDBusConnection *connection, gpointer user_data) { AsyncInitData *data = user_data; + gboolean get_all; if (res != NULL) { @@ -1350,7 +1351,25 @@ async_init_get_name_owner_cb (GDBusConnection *connection, } } - if (!(data->proxy->priv->flags & G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES)) + get_all = TRUE; + + if (data->proxy->priv->flags & G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES) + { + /* Don't load properties if the API user doesn't want them */ + get_all = FALSE; + } + else if (data->proxy->priv->name_owner == NULL && + data->proxy->priv->name != NULL) + { + /* Don't attempt to load properties if the name_owner is NULL (which + * usually means the name isn't owned), unless name is also NULL (which + * means we actually wanted to talk to the directly-connected process - + * either dbus-daemon or a peer - instead of going via dbus-daemon) + */ + get_all = FALSE; + } + + if (get_all) { /* load all properties asynchronously */ g_dbus_connection_call (data->proxy->priv->connection, -- 2.7.4