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