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>
This commit is contained in:
Emil Gydesen 2024-05-14 14:54:04 +02:00 committed by Johan Hedberg
parent fcf089574d
commit 4a97746312

View File

@ -852,7 +852,9 @@ static void conn_destroy(struct bt_conn *conn, void *data)
bt_conn_set_state(conn, BT_CONN_DISCONNECT_COMPLETE);
}
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
if (conn->state != BT_CONN_DISCONNECTED) {
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
}
}
void bt_conn_cleanup_all(void)