* [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch
@ 2012-04-03 16:14 Anderson Lizardo
2012-04-03 16:14 ` [PATCH BlueZ 2/3] thermometer: Fix D-Bus service disconnect watch removal Anderson Lizardo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Anderson Lizardo @ 2012-04-03 16:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Even though service watches accepted a "destroy" callback, they were
being ignored. This fix properly pass them along so they are called when
the watch is removed.
---
gdbus/watch.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gdbus/watch.c b/gdbus/watch.c
index fba58c3..9a716b0 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -666,7 +666,7 @@ guint g_dbus_add_service_watch(DBusConnection *connection, const char *name,
if (data == NULL)
return 0;
- cb = filter_data_add_callback(data, connect, disconnect, NULL, NULL,
+ cb = filter_data_add_callback(data, connect, disconnect, NULL, destroy,
user_data);
if (cb == NULL)
return 0;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ 2/3] thermometer: Fix D-Bus service disconnect watch removal
2012-04-03 16:14 [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch Anderson Lizardo
@ 2012-04-03 16:14 ` Anderson Lizardo
2012-04-03 16:15 ` [PATCH BlueZ 3/3] attrib: " Anderson Lizardo
2012-04-04 10:01 ` [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2012-04-03 16:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
destroy_watcher() will be automatically called when removing the D-Bus
watch (it was set as the destroy callback when adding the watch),
therefore it is only necessary to remove the watch.
---
thermometer/thermometer.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index a64ed54..9d23275 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -136,14 +136,18 @@ static void destroy_watcher(gpointer user_data)
{
struct watcher *watcher = user_data;
- if (watcher->id > 0)
- g_dbus_remove_watch(watcher->t->conn, watcher->id);
-
g_free(watcher->path);
g_free(watcher->srv);
g_free(watcher);
}
+static void remove_watcher(gpointer user_data)
+{
+ struct watcher *watcher = user_data;
+
+ g_dbus_remove_watch(watcher->t->conn, watcher->id);
+}
+
static void destroy_char(gpointer user_data)
{
struct characteristic *c = user_data;
@@ -172,7 +176,7 @@ static void destroy_thermometer(gpointer user_data)
g_slist_free_full(t->chars, destroy_char);
if (t->fwatchers != NULL)
- g_slist_free_full(t->fwatchers, destroy_watcher);
+ g_slist_free_full(t->fwatchers, remove_watcher);
dbus_connection_unref(t->conn);
btd_device_unref(t->dev);
@@ -814,7 +818,7 @@ static void watcher_exit(DBusConnection *conn, void *user_data)
remove_int_watcher(t, watcher);
t->fwatchers = g_slist_remove(t->fwatchers, watcher);
- watcher->id = 0;
+ g_dbus_remove_watch(watcher->t->conn, watcher->id);
if (g_slist_length(t->fwatchers) == 0)
disable_final_measurement(t);
@@ -893,7 +897,7 @@ static DBusMessage *unregister_watcher(DBusConnection *conn, DBusMessage *msg,
remove_int_watcher(t, watcher);
t->fwatchers = g_slist_remove(t->fwatchers, watcher);
- destroy_watcher(watcher);
+ g_dbus_remove_watch(watcher->t->conn, watcher->id);
if (g_slist_length(t->fwatchers) == 0)
disable_final_measurement(t);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ 3/3] attrib: Fix D-Bus service disconnect watch removal
2012-04-03 16:14 [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch Anderson Lizardo
2012-04-03 16:14 ` [PATCH BlueZ 2/3] thermometer: Fix D-Bus service disconnect watch removal Anderson Lizardo
@ 2012-04-03 16:15 ` Anderson Lizardo
2012-04-04 10:01 ` [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2012-04-03 16:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
watcher_free() will be automatically called when removing the D-Bus
watch (it was set as the destroy callback when adding the watch),
therefore it is only necessary to remove the watch.
---
attrib/client.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/attrib/client.c b/attrib/client.c
index f1c26c4..b5282c2 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -227,6 +227,7 @@ static void watcher_exit(DBusConnection *conn, void *user_data)
DBG("%s watcher %s exited", gatt->path, watcher->name);
gatt->watchers = g_slist_remove(gatt->watchers, watcher);
+ g_dbus_remove_watch(gatt->conn, watcher->id);
remove_attio(gatt);
}
@@ -429,10 +430,8 @@ static DBusMessage *unregister_watcher(DBusConnection *conn,
return btd_error_not_authorized(msg);
watcher = l->data;
- g_dbus_remove_watch(conn, watcher->id);
gatt->watchers = g_slist_remove(gatt->watchers, watcher);
- watcher_free(watcher);
-
+ g_dbus_remove_watch(conn, watcher->id);
remove_attio(gatt);
return dbus_message_new_method_return(msg);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch
2012-04-03 16:14 [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch Anderson Lizardo
2012-04-03 16:14 ` [PATCH BlueZ 2/3] thermometer: Fix D-Bus service disconnect watch removal Anderson Lizardo
2012-04-03 16:15 ` [PATCH BlueZ 3/3] attrib: " Anderson Lizardo
@ 2012-04-04 10:01 ` Johan Hedberg
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2012-04-04 10:01 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi Lizardo,
On Tue, Apr 03, 2012, Anderson Lizardo wrote:
> Even though service watches accepted a "destroy" callback, they were
> being ignored. This fix properly pass them along so they are called when
> the watch is removed.
> ---
> gdbus/watch.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
All three patches have been applied. I also applied this gdbus one to
the obexd tree. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-04 10:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-03 16:14 [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch Anderson Lizardo
2012-04-03 16:14 ` [PATCH BlueZ 2/3] thermometer: Fix D-Bus service disconnect watch removal Anderson Lizardo
2012-04-03 16:15 ` [PATCH BlueZ 3/3] attrib: " Anderson Lizardo
2012-04-04 10:01 ` [PATCH BlueZ 1/3] gdbus: Use destroy callback for service watch Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).