This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 53f81096b nimble/l2cap: Fix cleaning up pending procedures on
disconnect
53f81096b is described below
commit 53f81096b6462f18e044c0188e1f934d89270f9e
Author: Szymon Janc <[email protected]>
AuthorDate: Wed Aug 6 15:54:26 2025 +0200
nimble/l2cap: Fix cleaning up pending procedures on disconnect
Procedures needs to be removed based on diconnected connection handle
and not all of them. Otherwsie this could lead to droping pending
procedure for other connection. Also ble_l2cap_sig_procs list could
be corrupted since it is being modified without host lock held.
---
nimble/host/src/ble_l2cap_sig.c | 48 +++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/nimble/host/src/ble_l2cap_sig.c b/nimble/host/src/ble_l2cap_sig.c
index 6e8960e92..0a3591cd4 100644
--- a/nimble/host/src/ble_l2cap_sig.c
+++ b/nimble/host/src/ble_l2cap_sig.c
@@ -1983,31 +1983,37 @@ ble_l2cap_sig_conn_broken(uint16_t conn_handle, int
reason)
{
struct ble_l2cap_sig_proc *proc;
- /* Report a failure for each timed out procedure. */
- while ((proc = STAILQ_FIRST(&ble_l2cap_sig_procs)) != NULL) {
- switch(proc->op) {
- case BLE_L2CAP_SIG_PROC_OP_UPDATE:
- ble_l2cap_sig_update_call_cb(proc, reason);
- break;
+ /* If there were any pending procedure, indicate to the application that it
+ * did not complete.
+ */
+ proc = ble_l2cap_sig_proc_extract(conn_handle,
BLE_L2CAP_SIG_PROC_OP_UPDATE, 0);
+ if (proc != NULL) {
+ ble_l2cap_sig_update_call_cb(proc, reason);
+ ble_l2cap_sig_proc_free(proc);
+ }
+
#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) != 0
- case BLE_L2CAP_SIG_PROC_OP_CONNECT:
- ble_l2cap_sig_coc_connect_cb(proc, reason);
- break;
- case BLE_L2CAP_SIG_PROC_OP_DISCONNECT:
- ble_l2cap_sig_coc_disconnect_cb(proc, reason);
- break;
-#if MYNEWT_VAL(BLE_L2CAP_ENHANCED_COC)
- case BLE_L2CAP_SIG_PROC_OP_RECONFIG:
- ble_l2cap_sig_coc_reconfig_cb(proc, reason);
- break;
-#endif
-#endif
- }
+ proc = ble_l2cap_sig_proc_extract(conn_handle,
BLE_L2CAP_SIG_PROC_OP_CONNECT, 0);
+ if (proc != NULL) {
+ ble_l2cap_sig_coc_connect_cb(proc, reason);
+ ble_l2cap_sig_proc_free(proc);
+ }
- STAILQ_REMOVE_HEAD(&ble_l2cap_sig_procs, next);
- ble_l2cap_sig_proc_free(proc);
+ proc = ble_l2cap_sig_proc_extract(conn_handle,
+ BLE_L2CAP_SIG_PROC_OP_DISCONNECT, 0);
+ if (proc != NULL) {
+ ble_l2cap_sig_coc_disconnect_cb(proc, reason);
+ ble_l2cap_sig_proc_free(proc);
}
+#if MYNEWT_VAL(BLE_L2CAP_ENHANCED_COC)
+ proc = ble_l2cap_sig_proc_extract(conn_handle,
BLE_L2CAP_SIG_PROC_OP_RECONFIG, 0);
+ if (proc != NULL) {
+ ble_l2cap_sig_coc_reconfig_cb(proc, reason);
+ ble_l2cap_sig_proc_free(proc);
+ }
+#endif
+#endif
}
/**