summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-12-29 12:27:33 -0800
committerMarcel Holtmann <marcel@holtmann.org>2012-12-29 14:49:47 -0800
commitfcb88e484e8100c168eaa3aeff37de5eb35ded55 (patch)
treebde95942e0dc418dc32107527a41d552f29ee1d8 /gdbus
parent087d227daff0f62009bdd81c6d56bfd7af5f6f1f (diff)
downloadconnman-fcb88e484e8100c168eaa3aeff37de5eb35ded55.tar.gz
connman-fcb88e484e8100c168eaa3aeff37de5eb35ded55.tar.bz2
connman-fcb88e484e8100c168eaa3aeff37de5eb35ded55.zip
gdbus: Fix handling of client connect/disconnect signals
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/client.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/gdbus/client.c b/gdbus/client.c
index 8d2a7513..b46d5e41 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -877,6 +877,9 @@ static void get_managed_objects(GDBusClient *client)
DBusMessage *msg;
DBusPendingCall *call;
+ if (!client->proxy_added && !client->proxy_removed)
+ return;
+
msg = dbus_message_new_method_call(client->service_name, "/",
DBUS_INTERFACE_DBUS ".ObjectManager",
"GetManagedObjects");
@@ -918,21 +921,19 @@ static void get_name_owner_reply(DBusPendingCall *call, void *user_data)
DBUS_TYPE_INVALID) == FALSE)
goto done;
- g_free(client->unique_name);
- client->unique_name = g_strdup(name);
-
- g_dbus_client_ref(client);
+ if (client->unique_name == NULL) {
+ client->unique_name = g_strdup(name);
- if (client->connect_func)
- client->connect_func(client->dbus_conn, client->connect_data);
+ if (client->connect_func)
+ client->connect_func(client->dbus_conn,
+ client->connect_data);
+ }
done:
dbus_message_unref(reply);
dbus_pending_call_unref(client->pending_call);
client->pending_call = NULL;
-
- g_dbus_client_unref(client);
}
static void get_name_owner(GDBusClient *client, const char *name)
@@ -994,15 +995,15 @@ static DBusHandlerResult message_filter(DBusConnection *connection,
if (g_str_equal(name, client->service_name) == FALSE)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- if (*new == '\0') {
+ if (*new == '\0' && client->unique_name != NULL &&
+ g_str_equal(old, client->unique_name) == TRUE) {
if (client->disconn_func)
client->disconn_func(client->dbus_conn,
client->disconn_data);
g_free(client->unique_name);
client->unique_name = NULL;
- } else if (*old == '\0') {
- g_free(client->unique_name);
+ } else if (*old == '\0' && client->unique_name == NULL) {
client->unique_name = g_strdup(new);
if (client->connect_func)