Bluetooth: Fix sending dummy buffer to kill invalid tx fiber

This fix prevents from sending dummy buffer to kill tx fiber
if this fiber didn't started.

Tx fiber is started during transition from BT_CONN_CONNECT state
(for outgoing connections) or BT_CONN_DISCONNECTED (incoming)
to BT_CONN_CONNECTED state.
So the only states that have tx fiber running are BT_CONN_CONNECTED
and BT_CONN_DISCONNECT and only transitions from these states
should be taken into account.

Change-Id: I558c937812368b0bd305f6c9935cced565c70606
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
Mariusz Skamra 2015-07-03 12:05:23 +02:00 committed by Anas Nashif
commit 3fcf60a6e6

View file

@ -323,8 +323,13 @@ void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state)
break; break;
case BT_CONN_DISCONNECTED: case BT_CONN_DISCONNECTED:
/* Send dummy buffer to wake up and kill the tx fiber */ /* Send dummy buffer to wake up and stop the tx fiber
nano_fifo_put(&conn->tx_queue, bt_buf_get(BT_DUMMY, 0)); * for states where it was running
*/
if (old_state == BT_CONN_CONNECTED ||
old_state == BT_CONN_DISCONNECT) {
nano_fifo_put(&conn->tx_queue, bt_buf_get(BT_DUMMY, 0));
}
bt_conn_put(conn); bt_conn_put(conn);