mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-09 10:40:04 +00:00
l2cap: Fix double disconnect issue
It might happen that we get into situation that host will try to disconnect same channel couple times e.g when receiveing many corrupted packets. This patch make sure that host will send l2cap disconnect command only once.
This commit is contained in:
committed by
Szymon Janc
parent
75c745dbc8
commit
089f0d849a
@@ -105,6 +105,7 @@ typedef int ble_l2cap_tx_fn(struct ble_hs_conn *conn,
|
||||
struct ble_l2cap_chan *chan);
|
||||
|
||||
#define BLE_L2CAP_CHAN_F_TXED_MTU 0x01 /* We have sent our MTU. */
|
||||
#define BLE_L2CAP_CHAN_F_DISCONNECTING 0x02 /* We have sent L2CAP Disconnect. */
|
||||
|
||||
SLIST_HEAD(ble_l2cap_chan_list, ble_l2cap_chan);
|
||||
|
||||
|
||||
@@ -1640,6 +1640,10 @@ ble_l2cap_sig_disconnect(struct ble_l2cap_chan *chan)
|
||||
struct ble_l2cap_sig_proc *proc;
|
||||
int rc;
|
||||
|
||||
if (chan->flags & BLE_L2CAP_CHAN_F_DISCONNECTING) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
proc = ble_l2cap_sig_proc_alloc();
|
||||
if (proc == NULL) {
|
||||
return BLE_HS_ENOMEM;
|
||||
@@ -1661,6 +1665,10 @@ ble_l2cap_sig_disconnect(struct ble_l2cap_chan *chan)
|
||||
req->scid = htole16(chan->scid);
|
||||
|
||||
rc = ble_l2cap_sig_tx(proc->conn_handle, txom);
|
||||
/* Mark channel as disconnecting */
|
||||
if (rc == 0) {
|
||||
chan->flags |= BLE_L2CAP_CHAN_F_DISCONNECTING;
|
||||
}
|
||||
|
||||
done:
|
||||
ble_l2cap_sig_process_status(proc, rc);
|
||||
|
||||
Reference in New Issue
Block a user