Thread (37 messages) flat view 37 messages, 3 authors, 2011-07-27
STALE5496d

[PATCH BlueZ 12/12] Address remote initiated disconnection

From: Claudio Takahasi <hidden>
Date: 2011-07-06 21:24:24
Subsystem: the rest · Maintainer: Linus Torvalds

Local initiated disconnection will be triggered when the last GAttrib
reference is dropped. For remote initiated disconnection it is necessary
to track the socket HUP registering disconnection GAttrib callback.
---
 src/device.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/src/device.c b/src/device.c
index 52462be..90761d4 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1615,7 +1615,7 @@ static void attio_disconnected(gpointer data, gpointer user_data)
 
 static gboolean att_auto_connect(gpointer user_data);
 
-static void attrib_destroyed(gpointer user_data)
+static void attrib_disconnected(gpointer user_data)
 {
 	struct btd_device *device = user_data;
 
@@ -1627,6 +1627,13 @@ static void attrib_destroyed(gpointer user_data)
 							att_auto_connect,
 							device);
 
+	g_attrib_unref(device->attrib);
+}
+
+static void attrib_destroyed(gpointer user_data)
+{
+	struct btd_device *device = user_data;
+
 	device->attrib = NULL;
 }
 
@@ -1697,6 +1704,8 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 	}
 
 	device->attrib = g_attrib_new(io);
+	g_attrib_set_disconnect_function(device->attrib, attrib_disconnected,
+								device);
 	g_attrib_set_destroy_function(device->attrib, attrib_destroyed, device);
 
 	if (req)
-- 
1.7.6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help