Skip to content

Commit ed0dfb9

Browse files
hermabecarlescufi
authored andcommitted
Bluetooth: Host: Fix ATT PDU alloc being non-blocking.
The API is documented as being blocking. Making it nonblocking was an unintentional API change. Signed-off-by: Herman Berget <[email protected]>
1 parent e494d9c commit ed0dfb9

File tree

1 file changed

+7
-5
lines changed
  • subsys/bluetooth/host

1 file changed

+7
-5
lines changed

subsys/bluetooth/host/att.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ struct bt_att_tx_meta {
152152
static struct bt_att_tx_meta_data tx_meta_data[CONFIG_BT_CONN_TX_MAX];
153153
K_FIFO_DEFINE(free_att_tx_meta_data);
154154

155-
static struct bt_att_tx_meta_data *tx_meta_data_alloc(void)
155+
static struct bt_att_tx_meta_data *tx_meta_data_alloc(k_timeout_t timeout)
156156
{
157-
return k_fifo_get(&free_att_tx_meta_data, K_NO_WAIT);
157+
return k_fifo_get(&free_att_tx_meta_data, timeout);
158158
}
159159

160160
static inline void tx_meta_data_free(struct bt_att_tx_meta_data *data)
@@ -531,6 +531,7 @@ struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t op,
531531
struct bt_att_hdr *hdr;
532532
struct net_buf *buf;
533533
struct bt_att_tx_meta_data *data;
534+
k_timeout_t timeout;
534535

535536
if (len + sizeof(op) > chan->chan.tx.mtu) {
536537
BT_WARN("ATT MTU exceeded, max %u, wanted %zu",
@@ -542,18 +543,19 @@ struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t op,
542543
case ATT_RESPONSE:
543544
case ATT_CONFIRMATION:
544545
/* Use a timeout only when responding/confirming */
545-
buf = bt_l2cap_create_pdu_timeout(NULL, 0, BT_ATT_TIMEOUT);
546+
timeout = BT_ATT_TIMEOUT;
546547
break;
547548
default:
548-
buf = bt_l2cap_create_pdu(NULL, 0);
549+
timeout = K_FOREVER;
549550
}
550551

552+
buf = bt_l2cap_create_pdu_timeout(NULL, 0, timeout);
551553
if (!buf) {
552554
BT_ERR("Unable to allocate buffer for op 0x%02x", op);
553555
return NULL;
554556
}
555557

556-
data = tx_meta_data_alloc();
558+
data = tx_meta_data_alloc(timeout);
557559
if (!data) {
558560
BT_WARN("Unable to allocate ATT TX meta");
559561
net_buf_unref(buf);

0 commit comments

Comments
 (0)