diff --git a/src/device.c b/src/device.c
index bd25a27..9f0bfa3 100644
--- a/src/device.c
+++ b/src/device.c
g_dbus_remove_watch(req->conn, req->listener_id);
if (req->attrib)
g_attrib_unref(req->attrib);
- if (req->io) {
- if (shutdown)
- g_io_channel_shutdown(req->io, FALSE, NULL);
- g_io_channel_unref(req->io);
- }
if (req->msg)
dbus_message_unref(req->msg);
if (req->conn)
bt_cancel_discovery(&src, &device->bdaddr);
+ if (device->att_io != NULL) {
+ g_io_channel_shutdown(device->att_io, FALSE, NULL);
+ g_io_channel_unref(device->att_io);
+ device->att_io = NULL;
+ }
+
device->browse = NULL;
browse_request_free(req, TRUE);
}
struct browse_req *req = device->browse;
GAttrib *attrib;
+ g_io_channel_unref(device->att_io);
+ device->att_io = NULL;
+
if (gerr) {
DBusMessage *reply;
sec_level = secure ? BT_IO_SEC_HIGH : BT_IO_SEC_LOW;
- req->io = bt_io_connect(BT_IO_L2CAP, browse_primary_connect_cb,
+ device->att_io = bt_io_connect(BT_IO_L2CAP, browse_primary_connect_cb,
device, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR, &src,
BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
- if (req->io == NULL) {
+ if (device->att_io == NULL) {
browse_request_free(req, FALSE);
return -EIO;
}