summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto Von Dentz <luiz.dentz-von@nokia.com>2010-01-08 12:17:19 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-01-08 04:23:56 -0800
commitdc1b04588d7f08bda9d6df073fb477f89d60fb2f (patch)
tree89b9ac8d4399be5ce304d759c868e8ef15db33e0
parent2271c9fed743991d83ece8a7650b547d0391d1fc (diff)
downloadconnman-dc1b04588d7f08bda9d6df073fb477f89d60fb2f.tar.gz
connman-dc1b04588d7f08bda9d6df073fb477f89d60fb2f.tar.bz2
connman-dc1b04588d7f08bda9d6df073fb477f89d60fb2f.zip
Fix regression when removing watches
filter_data_find return the first data registered in this case so there is no guarantee that it return the same data as passed to filter_data_remove_callback which is the one that should be removed. The fix is to simple cache the connection removing the correct data before checking if there is any filter left.
-rw-r--r--gdbus/watch.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 42e158fe..75e42103 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -299,6 +299,8 @@ static struct filter_callback *filter_data_add_callback(
static gboolean filter_data_remove_callback(struct filter_data *data,
struct filter_callback *cb)
{
+ DBusConnection *connection;
+
data->callbacks = g_slist_remove(data->callbacks, cb);
data->processed = g_slist_remove(data->processed, cb);
@@ -315,15 +317,17 @@ static gboolean filter_data_remove_callback(struct filter_data *data,
if (data->registered && !remove_match(data))
return FALSE;
+ connection = dbus_connection_ref(data->connection);
+ listeners = g_slist_remove(listeners, data);
+ filter_data_free(data);
+
/* Remove filter if there are no listeners left for the connection */
- data = filter_data_find(data->connection, NULL, NULL, NULL, NULL,
- NULL);
+ data = filter_data_find(connection, NULL, NULL, NULL, NULL, NULL);
if (!data)
- dbus_connection_remove_filter(data->connection, message_filter,
+ dbus_connection_remove_filter(connection, message_filter,
NULL);
- listeners = g_slist_remove(listeners, data);
- filter_data_free(data);
+ dbus_connection_unref(connection);
return TRUE;
}