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/38ae5704 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/38ae5704 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/38ae5704 Branch: refs/heads/master Commit: 38ae570452466f55cd15f7b03b78b25babcd1c66 Parents: 34e6486 Author: Åukasz Rymanowski <lukasz.rymanow...@codecoup.pl> Authored: Wed Mar 1 09:26:17 2017 +0100 Committer: Åukasz Rymanowski <lukasz.rymanow...@codecoup.pl> Committed: Fri Mar 3 12:40:42 2017 +0100 ---------------------------------------------------------------------- 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/38ae5704/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); } + } /**