nimble/l2cap: Fix hanlding broken ACL during L2CAP procedure With this patch we make sure that all processing procedures are free and user is notified about broken link
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/01835da6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/01835da6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/01835da6 Branch: refs/heads/1_0_0_dev Commit: 01835da6cd8265ba011ed01cb74fe277acc10fc0 Parents: 45c365c Author: Åukasz Rymanowski <[email protected]> Authored: Wed Mar 1 09:26:17 2017 +0100 Committer: Marko Kiiskila <[email protected]> Committed: Mon Mar 6 15:53:28 2017 -0800 ---------------------------------------------------------------------- net/nimble/host/src/ble_l2cap_sig.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/01835da6/net/nimble/host/src/ble_l2cap_sig.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_l2cap_sig.c b/net/nimble/host/src/ble_l2cap_sig.c index 444a8f6..439acfe 100644 --- a/net/nimble/host/src/ble_l2cap_sig.c +++ b/net/nimble/host/src/ble_l2cap_sig.c @@ -1200,17 +1200,26 @@ ble_l2cap_sig_conn_broken(uint16_t conn_handle, int reason) { struct ble_l2cap_sig_proc *proc; - /* If there was a connection update in progress, indicate to the - * application that it did not complete. - */ - - proc = ble_l2cap_sig_proc_extract(conn_handle, - BLE_L2CAP_SIG_PROC_OP_UPDATE, 0); + /* 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 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; +#endif + } - if (proc != NULL) { - ble_l2cap_sig_update_call_cb(proc, reason); - ble_l2cap_sig_proc_free(proc); + STAILQ_REMOVE_HEAD(&ble_l2cap_sig_procs, next); + ble_l2cap_sig_proc_free(proc); } + } /**
