From 204c3482b4866dede672c48619915a360998b0f7 Mon Sep 17 00:00:00 2001 From: Will San Filippo Date: Tue, 29 Oct 2019 17:49:57 -0700 Subject: [PATCH] nimble/host: Use os_mbuf_pack_chains if BLE_L2CAP_JOIN_RX_FRAGS is set to 1, use the new API to pack mbuf chains instead of previous method. This new API will do more copying (possibly) but will better utilize memory in that it will use the entire data buffer of each mbuf in the chain. --- nimble/host/src/ble_l2cap.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/nimble/host/src/ble_l2cap.c b/nimble/host/src/ble_l2cap.c index a9252b8e0..d88eb1830 100644 --- a/nimble/host/src/ble_l2cap.c +++ b/nimble/host/src/ble_l2cap.c @@ -188,17 +188,13 @@ ble_l2cap_remove_rx(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan) static void ble_l2cap_append_rx(struct ble_l2cap_chan *chan, struct os_mbuf *frag) { - int rc; - - (void)rc; - #if MYNEWT_VAL(BLE_L2CAP_JOIN_RX_FRAGS) + struct os_mbuf *m; + /* Copy the data from the incoming fragment into the packet in progress. */ - rc = os_mbuf_appendfrom(chan->rx_buf, frag, 0, OS_MBUF_PKTLEN(frag)); - if (rc == 0) { - os_mbuf_free_chain(frag); - return; - } + m = os_mbuf_pack_chains(chan->rx_buf, frag); + assert(m); + return; #endif /* Join disabled or append failed due to mbuf shortage. Just attach the