Skip to content

Commit db82e54

Browse files
PavelVPVrlubos
authored andcommitted
Revert "[nrf noup] bluetooth: conn: Skip buffer ref count check in send_buf"
This reverts commit 687cefa. Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent be772e1 commit db82e54

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -695,17 +695,13 @@ static int send_buf(struct bt_conn *conn, struct net_buf *buf,
695695

696696
uint16_t frag_len = MIN(conn_mtu(conn), len);
697697

698-
/* If ATT sent callback is delayed until data transmission is done by BLE controller, the
699-
* transmitted buffer may have an additional reference. The reference is used to extend
700-
* lifetime of the net buffer until the data transmission is confirmed by ACK of the remote.
701-
*
702-
* send_buf function can be called multiple times, if buffer has to be fragmented over HCI.
703-
* In that case, the callback is provided as an argument only for the last transmitted
704-
* fragment. The `buf->ref == 1` check is skipped because it's impossible to properly
705-
* validate number of references for the sent fragments if buffers may have the additional
706-
* reference.
707-
*/
708-
__ASSERT_NO_MSG(IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX) || (buf->ref == 1));
698+
if (buf->ref > 1 + (cb ? 1 : 0)) {
699+
/* Allow for an additional buffer reference if callback is provided.
700+
* This can be used to extend lifetime of the net buffer until the
701+
* data transmission is confirmed by ACK of the remote.
702+
*/
703+
__ASSERT_NO_MSG(false);
704+
}
709705

710706
if (buf->len > frag_len) {
711707
LOG_DBG("keep %p around", buf);

0 commit comments

Comments
 (0)