From d0b936a26c09065a9568e4593965a3ea6ce476d9 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 30 Jun 2014 15:53:17 +0300 Subject: [PATCH] core: Fix attio notification for server connections We need to ensure that all attio instances get properly notified also for ATT connections received through the server socket. This patch moves the dev->attios dispatching from a client-specifie att_succcess_cb to the device_attach_attrib function that's shared for both client and server roles. --- src/device.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/device.c b/src/device.c index 2c9ff9296..9de5e2f7e 100644 --- a/src/device.c +++ b/src/device.c @@ -3344,6 +3344,8 @@ static void attio_connected(gpointer data, gpointer user_data) struct attio_data *attio = data; GAttrib *attrib = user_data; + DBG(""); + if (attio->cfunc) attio->cfunc(attrib, attio->user_data); } @@ -3352,6 +3354,8 @@ static void attio_disconnected(gpointer data, gpointer user_data) { struct attio_data *attio = data; + DBG(""); + if (attio->dcfunc) attio->dcfunc(attio->user_data); } @@ -3363,6 +3367,8 @@ static gboolean attrib_disconnected_cb(GIOChannel *io, GIOCondition cond, int sock, err = 0; socklen_t len; + DBG(""); + if (device->browse) goto done; @@ -3597,6 +3603,15 @@ bool device_attach_attrib(struct btd_device *dev, GIOChannel *io) dev->cleanup_id = g_io_add_watch(io, G_IO_HUP, attrib_disconnected_cb, dev); + /* + * Remove the device from the connect_list and give the passive + * scanning another chance to be restarted in case there are + * other devices in the connect_list. + */ + adapter_connect_list_remove(dev->adapter, dev); + + g_slist_foreach(dev->attios, attio_connected, dev->attrib); + return true; } @@ -3677,24 +3692,6 @@ static void att_error_cb(const GError *gerr, gpointer user_data) } } -static void att_success_cb(gpointer user_data) -{ - struct att_callbacks *attcb = user_data; - struct btd_device *device = attcb->user_data; - - if (device->attios == NULL) - return; - - /* - * Remove the device from the connect_list and give the passive - * scanning another chance to be restarted in case there are - * other devices in the connect_list. - */ - adapter_connect_list_remove(device->adapter, device); - - g_slist_foreach(device->attios, attio_connected, device->attrib); -} - int device_connect_le(struct btd_device *dev) { struct btd_adapter *adapter = dev->adapter; @@ -3714,7 +3711,6 @@ int device_connect_le(struct btd_device *dev) attcb = g_new0(struct att_callbacks, 1); attcb->err = att_error_cb; - attcb->success = att_success_cb; attcb->user_data = dev; if (dev->le_state.paired) @@ -4835,6 +4831,8 @@ static gboolean notify_attios(gpointer user_data) { struct btd_device *device = user_data; + DBG(""); + if (device->attrib == NULL) return FALSE; -- 2.47.3