Diff between 983b84124e4d36a5a2214a9b1e6bffc0cd425a30 and 33bebd726e11a46a26ec7f24d0e07455532923e3

Changed Files

File Additions Deletions Status
src/device.c +12 -13 modified

Full Patch

diff --git a/src/device.c b/src/device.c
index 33e35ab..3b59d7f 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);