You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/03/06 21:19:05 UTC
[29/50] incubator-mynewt-core git commit: nimble/l2cap: Add helper to
clean L2CAP LE CoC channel
nimble/l2cap: Add helper to clean L2CAP LE CoC channel
With this patch we make sure that when CoC is used, outstanding
os_mbufs are freed when channel is closing
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fbceba58
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fbceba58
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fbceba58
Branch: refs/heads/master
Commit: fbceba584c5cd31f2b1253527023469b0a262162
Parents: 98e2cb9
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Sun Feb 12 15:23:09 2017 +0100
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Fri Mar 3 12:40:42 2017 +0100
----------------------------------------------------------------------
net/nimble/host/src/ble_l2cap.c | 1 +
net/nimble/host/src/ble_l2cap_coc.c | 12 ++++++++++++
net/nimble/host/src/ble_l2cap_coc_priv.h | 2 ++
3 files changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fbceba58/net/nimble/host/src/ble_l2cap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.c b/net/nimble/host/src/ble_l2cap.c
index b0ab23d..046a136 100644
--- a/net/nimble/host/src/ble_l2cap.c
+++ b/net/nimble/host/src/ble_l2cap.c
@@ -79,6 +79,7 @@ ble_l2cap_chan_free(struct ble_l2cap_chan *chan)
}
os_mbuf_free_chain(chan->rx_buf);
+ ble_l2cap_coc_cleanup_chan(chan);
rc = os_memblock_put(&ble_l2cap_chan_pool, chan);
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fbceba58/net/nimble/host/src/ble_l2cap_coc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_coc.c b/net/nimble/host/src/ble_l2cap_coc.c
index b549ba7..9794a00 100644
--- a/net/nimble/host/src/ble_l2cap_coc.c
+++ b/net/nimble/host/src/ble_l2cap_coc.c
@@ -277,6 +277,18 @@ ble_l2cap_coc_create_srv_chan(uint16_t conn_handle, uint16_t psm,
}
void
+ble_l2cap_coc_cleanup_chan(struct ble_l2cap_chan *chan)
+{
+ /* PSM 0 is used for fixed channels. */
+ if (chan->psm == 0) {
+ return;
+ }
+
+ os_mbuf_free_chain(chan->coc_rx.sdu);
+ os_mbuf_free_chain(chan->coc_tx.sdu);
+}
+
+void
ble_l2cap_coc_le_credits_update(uint16_t conn_handle, uint16_t dcid,
uint16_t credits)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fbceba58/net/nimble/host/src/ble_l2cap_coc_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_coc_priv.h b/net/nimble/host/src/ble_l2cap_coc_priv.h
index 88380ea..36ab4dc 100644
--- a/net/nimble/host/src/ble_l2cap_coc_priv.h
+++ b/net/nimble/host/src/ble_l2cap_coc_priv.h
@@ -62,6 +62,7 @@ struct ble_l2cap_chan * ble_l2cap_coc_chan_alloc(uint16_t conn_handle,
struct os_mbuf *sdu_rx,
ble_l2cap_event_fn *cb,
void *cb_arg);
+void ble_l2cap_coc_cleanup_chan(struct ble_l2cap_chan *chan);
void ble_l2cap_coc_le_credits_update(uint16_t conn_handle, uint16_t dcid,
uint16_t credits);
void ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan,
@@ -70,6 +71,7 @@ void ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan,
#define ble_l2cap_coc_init() 0
#define ble_l2cap_coc_create_server(psm, mtu, cb, cb_arg) BLE_HS_ENOTSUP
#define ble_l2cap_coc_recv_ready(chan, sdu_rx)
+#define ble_l2cap_coc_cleanup_chan(chan)
#endif
#ifdef __cplusplus