Skip to content

Commit 4a97746

Browse files
Thalleyjhedberg
authored andcommitted
Bluetooth: Host: Guard set state in conn_destroy
If bt_conn_set_state(conn, BT_CONN_DISCONNECTED) is called while the connection is already disconnected, this triggers a warning. This is likely to happen when bt_conn_cleanup_all is called as part of bt_disable. Added the state check to avoid unnecessary warnings in the log. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent fcf0895 commit 4a97746

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
@@ -852,7 +852,9 @@ static void conn_destroy(struct bt_conn *conn, void *data)
852852
bt_conn_set_state(conn, BT_CONN_DISCONNECT_COMPLETE);
853853
}
854854

855-
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
855+
if (conn->state != BT_CONN_DISCONNECTED) {
856+
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
857+
}
856858
}
857859

858860
void bt_conn_cleanup_all(void)

0 commit comments

Comments
 (0)