Bluetooth: host: Set conn state before sending HCI command
Handle a possible race condition in the host connection state. Set the conn state of the connection object before command is sent. This is in case the calling function is not scheduled again before the connection complete event arrives. In this case find_pending_conn will not find the connection object. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
cc6b8c3a6f
commit
6c1f52dff7
1 changed files with 2 additions and 2 deletions
|
@ -2248,6 +2248,8 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
|
|||
return conn;
|
||||
}
|
||||
#endif
|
||||
bt_conn_set_state(conn, BT_CONN_CONNECT);
|
||||
|
||||
if (bt_le_direct_conn(conn)) {
|
||||
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
|
||||
bt_conn_unref(conn);
|
||||
|
@ -2256,8 +2258,6 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bt_conn_set_state(conn, BT_CONN_CONNECT);
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue