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/07 00:05:32 UTC

[37/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/25e85d3d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/25e85d3d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/25e85d3d

Branch: refs/heads/1_0_0_dev
Commit: 25e85d3d96ee2dbb8015d9e65a018514616ef9b3
Parents: 7870412
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Sun Feb 12 15:23:09 2017 +0100
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Mar 6 15:52:43 2017 -0800

----------------------------------------------------------------------
 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/25e85d3d/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/25e85d3d/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/25e85d3d/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