From fc1eac6774dc62834471ecf62d11cefd34c5ae40 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Tue, 24 Dec 2024 21:07:59 +0530 Subject: [PATCH] fix(nimble): Add ATT Tx queue cleanup during link disconnection --- nimble/host/src/ble_gattc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nimble/host/src/ble_gattc.c b/nimble/host/src/ble_gattc.c index e8ba32fbe..2b30e0044 100644 --- a/nimble/host/src/ble_gattc.c +++ b/nimble/host/src/ble_gattc.c @@ -5315,7 +5315,17 @@ ble_gatts_rx_indicate_rsp(uint16_t conn_handle, uint16_t cid) void ble_gattc_connection_broken(uint16_t conn_handle) { + struct ble_hs_conn *conn; + struct os_mbuf_pkthdr *omp; + ble_gattc_fail_procs(conn_handle, BLE_GATT_OP_NONE, BLE_HS_ENOTCONN); + + conn = ble_hs_conn_find(conn_handle); + + while ((omp = STAILQ_FIRST(&conn->att_tx_q)) != NULL) { + STAILQ_REMOVE_HEAD(&conn->att_tx_q, omp_next); + os_mbuf_free_chain(OS_MBUF_PKTHDR_TO_MBUF(omp)); + } } /**