Skip to content

Commit 178b807

Browse files
MarekPietaanangl
authored andcommitted
[nrf noup] bluetooth: conn: Allow for an extra ref in bt_conn_send_cb
Allow for an additional buffer reference if callback is provided. This can be used to extend lifetime of the net buffer until the data transmission is confirmed by ACK of the remote. Jira: NCSDK-27422 Signed-off-by: Marek Pieta <[email protected]> (cherry picked from commit c735ea2)
1 parent a902788 commit 178b807

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subsys/bluetooth/host/conn.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,11 @@ int bt_conn_send_cb(struct bt_conn *conn, struct net_buf *buf,
478478
LOG_DBG("conn handle %u buf len %u cb %p user_data %p", conn->handle, buf->len, cb,
479479
user_data);
480480

481-
if (buf->ref != 1) {
481+
/* Allow for an additional buffer reference if callback is provided. This can be used to
482+
* extend lifetime of the net buffer until the data transmission is confirmed by ACK of the
483+
* remote.
484+
*/
485+
if (buf->ref > 1 + (cb ? 1 : 0)) {
482486
/* The host may alter the buf contents when fragmenting. Higher
483487
* layers cannot expect the buf contents to stay intact. Extra
484488
* refs suggests a silent data corruption would occur if not for

0 commit comments

Comments
 (0)