summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-12-16 00:16:28 (GMT)
committerMarcel Holtmann <marcel@holtmann.org>2012-12-19 02:49:11 (GMT)
commit02b2ca520d2a707901c65de056a2fde0117b07c6 (patch)
tree79a15f84feec5661bf3bee5458e4a37b06100e4f /gdbus
parent5b0e16952d4ab058b55d00197f53e296042be31e (diff)
downloadconnman-02b2ca520d2a707901c65de056a2fde0117b07c6.zip
connman-02b2ca520d2a707901c65de056a2fde0117b07c6.tar.gz
connman-02b2ca520d2a707901c65de056a2fde0117b07c6.tar.bz2
gdbus: Fix race condition with creating duplicate client proxies
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/client.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gdbus/client.c b/gdbus/client.c
index 76e4cc1..d7d9e36 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;