From 33bebd726e11a46a26ec7f24d0e07455532923e3 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Thu, 9 Feb 2012 12:56:04 -0300 Subject: [PATCH] device: Fix notifying ATTIO drivers when browsing If disconnection happens during the primary service discovery ATTIO drivers should not be notified. --- src/device.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/device.c b/src/device.c index 33e35ab8c..3b59d7fd1 100644 --- a/src/device.c +++ b/src/device.c @@ -1753,6 +1753,9 @@ static void attrib_disconnected(gpointer user_data) int sock, err = 0; socklen_t len; + if (device->browse) + goto done; + io = g_attrib_get_channel(device->attrib); sock = g_io_channel_unix_get_fd(io); len = sizeof(err); @@ -1760,21 +1763,19 @@ static void attrib_disconnected(gpointer user_data) g_slist_foreach(device->attios, attio_disconnected, NULL); - attrib_channel_detach(device->attrib, device->attachid); - g_attrib_unref(device->attrib); - device->attrib = NULL; - device->attachid = 0; - - if (device->auto_connect == FALSE) - return; - - if (err != ETIMEDOUT) - return; + if (device->auto_connect == FALSE || err != ETIMEDOUT) + goto done; device->auto_id = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT_IDLE, AUTO_CONNECTION_INTERVAL, att_connect, device, att_connect_dispatched); + +done: + attrib_channel_detach(device->attrib, device->attachid); + device->attachid = 0; + g_attrib_unref(device->attrib); + device->attrib = NULL; } static void primary_cb(GSList *services, guint8 status, gpointer user_data) @@ -1805,9 +1806,7 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data) device->attachid = 0; g_attrib_unref(device->attrib); device->attrib = NULL; - } else - g_attrib_set_disconnect_function(device->attrib, - attrib_disconnected, device); + } g_slist_free(uuids); -- 2.11.0