Bluetooth: Fix giving back pkts semaphore when disconnecting
The TX fiber might be blocked waiting for the num_pkts semaphore when a disconnection occurs. If we only give back the semaphore once exiting the while-loop we may end up in a deadlock. Giving back the semaphore in the connection disconnect handler solves this. An additional fix this patch does is to ensure that we don't perform integer underflow because of the last iteration. Change-Id: Ia67dc506885d0c2bad25c598ea349f1fd251218b Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
c31fcf4e5a
commit
37d204e03d
1 changed files with 7 additions and 6 deletions
|
@ -1004,12 +1004,7 @@ static void conn_tx_fiber(int arg1, int arg2)
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return any unacknowledged packets */
|
BT_ASSERT(!conn->pending_pkts);
|
||||||
if (conn->pending_pkts) {
|
|
||||||
while (conn->pending_pkts--) {
|
|
||||||
nano_fiber_sem_give(bt_conn_get_pkts(conn));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bt_conn_reset_rx_state(conn);
|
bt_conn_reset_rx_state(conn);
|
||||||
|
|
||||||
|
@ -1115,6 +1110,12 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state)
|
||||||
notify_connected(conn);
|
notify_connected(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return any unacknowledged packets */
|
||||||
|
while (conn->pending_pkts) {
|
||||||
|
nano_fiber_sem_give(bt_conn_get_pkts(conn));
|
||||||
|
conn->pending_pkts--;
|
||||||
|
}
|
||||||
|
|
||||||
/* Cancel Connection Update if it is pending */
|
/* Cancel Connection Update if it is pending */
|
||||||
if (conn->type == BT_CONN_TYPE_LE)
|
if (conn->type == BT_CONN_TYPE_LE)
|
||||||
nano_delayed_work_cancel(&conn->le.update_work);
|
nano_delayed_work_cancel(&conn->le.update_work);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue