aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2012-12-16 01:16:28 +0100
committerMarcel Holtmann <marcel@holtmann.org>2012-12-19 03:47:54 +0100
commitea17665e75a2c308b0c53f45f60eb26aa6b76951 (patch)
tree4d96c9fc68d3336fac7466afce7af0295b85e2a3
parenta60a65eeeb5033d3de4e4803b2ef5ed6c6919b51 (diff)
downloadpacrunner-ea17665e75a2c308b0c53f45f60eb26aa6b76951.tar.gz
gdbus: Fix race condition with creating duplicate client proxies
-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;