Skip to content

Commit 2ef96e2

Browse files
LingaoMcarlescufi
authored andcommitted
Bluetooth: Host: Fix unable cleanup conn
The peripheral is configured to update the connection parameters for 5 seconds by default. There is an abnormal situation with a very low probability. The central actively disconnects or abnormally disconnects the Bluetooth connection at the same time. At this time, the connection disconnection event will be handled by BT RX. At this time, sysworkq has sent a parameter update request and will receive a reply with status = 0x02, because the handle is invalid at this time. We can not just cancel work, because work->flag may be in K_WORK_RUNNING, so work->flag is set to K_WORK_CANCELING and subsequent conn_cleanup will unable call k_work_rescheduler successfully. According submit_to_queue_locked will return ret = -EBUSY. if (flag_test(&work->flags, K_WORK_CANCELING_BIT)) { /* Disallowed */ ret = -EBUSY; As a result, the connection cannot be cleanup correctly. Signed-off-by: Lingao Meng <[email protected]>
1 parent bc47f66 commit 2ef96e2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,9 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state)
892892
tx_notify(conn);
893893

894894
/* Cancel Connection Update if it is pending */
895-
if (conn->type == BT_CONN_TYPE_LE) {
895+
if ((conn->type == BT_CONN_TYPE_LE) &&
896+
(k_work_delayable_busy_get(&conn->deferred_work) &
897+
(K_WORK_QUEUED | K_WORK_DELAYED))) {
896898
k_work_cancel_delayable(&conn->deferred_work);
897899
}
898900

0 commit comments

Comments
 (0)