diff --git a/src/shared/att.c b/src/shared/att.c
index 2bc7682..bc01827 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
if (!op)
return false;
- io_destroy(att->io);
- att->io = NULL;
-
util_debug(att->debug_callback, att->debug_data,
"Operation timed out: 0x%02x", op->opcode);
op->timeout_id = 0;
destroy_att_send_op(op);
+ /*
+ * Directly terminate the connection as required by the ATT protocol.
+ * This should trigger an io disconnect event which will clean up the
+ * io and notify the upper layer.
+ */
+ io_shutdown(att->io);
+
return false;
}
if (!op) {
util_debug(att->debug_callback, att->debug_data,
"Received unexpected ATT response");
- disconnect_cb(att->io, att);
+ io_shutdown(att->io);
return;
}
if (!op || pdu_len) {
util_debug(att->debug_callback, att->debug_data,
"Received unexpected/invalid ATT confirmation");
- disconnect_cb(att->io, att);
+ io_shutdown(att->io);
return;
}
case ATT_OP_TYPE_REQ:
/*
* If a request is currently pending, then the sequential
- * protocol was violated. Disconnect the bearer and notify the
- * upper-layer.
+ * protocol was violated. Disconnect the bearer, which will
+ * promptly notify the upper layer via disconnect handlers.
*/
if (att->in_req) {
util_debug(att->debug_callback, att->debug_data,
"Received request while another is "
"pending: 0x%02x", opcode);
- disconnect_cb(att->io, att);
+ io_shutdown(att->io);
+
return false;
}