diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2012-12-16 01:16:28 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-12-19 03:50:42 +0100 |
commit | 5de077a604c4d4a6a8b042b87ea51fa0e4b21485 (patch) | |
tree | eaf03a2f21843e74ad07d910d29f57e2f4ece1d6 | |
parent | 4a0cab2f852a8f10089969b2464f7d7f0d095651 (diff) | |
download | ofono-5de077a604c4d4a6a8b042b87ea51fa0e4b21485.tar.bz2 |
gdbus: Fix race condition with creating duplicate client proxies
-rw-r--r-- | gdbus/client.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gdbus/client.c b/gdbus/client.c index 76e4cc17..d7d9e361 100644 --- a/gdbus/client.c +++ b/gdbus/client.c @@ -196,6 +196,23 @@ static void prop_entry_free(gpointer data) g_free(prop); } +static GDBusProxy *proxy_lookup(GDBusClient *client, const char *path, + const char *interface) +{ + GList *list; + + for (list = g_list_first(client->proxy_list); list; + list = g_list_next(list)) { + GDBusProxy *proxy = list->data; + + if (g_str_equal(proxy->interface, interface) == TRUE && + g_str_equal(proxy->obj_path, path) == TRUE) + return proxy; + } + + return NULL; +} + static GDBusProxy *proxy_new(GDBusClient *client, const char *path, const char *interface) { @@ -621,6 +638,12 @@ static void parse_properties(GDBusClient *client, const char *path, if (g_str_equal(interface, DBUS_INTERFACE_PROPERTIES) == TRUE) return; + proxy = proxy_lookup(client, path, interface); + if (proxy) { + update_properties(proxy, iter); + return; + } + proxy = proxy_new(client, path, interface); if (proxy == NULL) return; |