Skip to content
Permalink
Browse files

Bluetooth: conn: Warn when blocking with K_FOREVER

If debug is enabled print warnings when a call with K_FOREVER would have
blocked.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information...
Vudentz authored and carlescufi committed Aug 1, 2019
1 parent 47250b5 commit 4244b320e7355af2e5db06fdee1bba3444951aad
Showing with 20 additions and 2 deletions.
  1. +20 −2 subsys/bluetooth/host/conn.c
@@ -1220,7 +1220,16 @@ static struct bt_conn_tx *add_pending_tx(struct bt_conn *conn,

BT_DBG("conn %p cb %p user_data %p", conn, cb, user_data);

tx = k_fifo_get(&free_tx, K_FOREVER);
if (IS_ENABLED(CONFIG_BT_DEBUG_CONN)) {
tx = k_fifo_get(&free_tx, K_NO_WAIT);
if (!tx) {
BT_WARN("Unable to get a free conn_tx, yielding...");
tx = k_fifo_get(&free_tx, K_FOREVER);
}
} else {
tx = k_fifo_get(&free_tx, K_FOREVER);
}

tx->conn = bt_conn_ref(conn);
k_work_init(&tx->work, tx_notify_cb);
tx->data.cb = cb;
@@ -2281,7 +2290,16 @@ struct net_buf *bt_conn_create_pdu(struct net_buf_pool *pool, size_t reserve)
pool = &acl_tx_pool;
}

buf = net_buf_alloc(pool, K_FOREVER);
if (IS_ENABLED(CONFIG_BT_DEBUG_CONN)) {
buf = net_buf_alloc(pool, K_NO_WAIT);
if (!buf) {
BT_WARN("Unable to allocate buffer");
buf = net_buf_alloc(pool, K_FOREVER);
}
} else {
buf = net_buf_alloc(pool, K_FOREVER);
}

__ASSERT_NO_MSG(buf);

reserve += sizeof(struct bt_hci_acl_hdr) + CONFIG_BT_HCI_RESERVE;

0 comments on commit 4244b32

Please sign in to comment.
You can’t perform that action at this time.