From 3b876e47d50b416f9f609186e3e8882576724ef5 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Wed, 20 Jul 2011 17:25:13 -0300 Subject: [PATCH] Address remote initiated disconnection 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/device.c b/src/device.c index 91f8e5d20..9dd657cb3 100644 --- a/src/device.c +++ b/src/device.c @@ -1610,7 +1610,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; @@ -1621,6 +1621,7 @@ static void attrib_destroyed(gpointer user_data) att_auto_connect, device); + g_attrib_unref(device->attrib); device->attrib = NULL; } @@ -1705,8 +1706,8 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data) gatt_discover_primary(req->attrib, NULL, primary_cb, req); } else if (device->attios) { device->attrib = g_attrib_new(io); - g_attrib_set_destroy_function(device->attrib, attrib_destroyed, - device); + g_attrib_set_disconnect_function(device->attrib, + attrib_disconnected, device); g_slist_foreach(device->attios, attio_connected, device->attrib); }