You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/01/26 02:53:47 UTC

incubator-mynewt-larva git commit: Discard current packet when channel is deleted.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 21e7ec282 -> 6132451df


Discard current packet when channel is deleted.

This doesn't matter in our current code, since the only time a channel
gets deleted is when its connection is destroyed.  However, I am adding
this now so that I don't introduce a bug when we implement credit-based
flow control channels.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/6132451d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/6132451d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/6132451d

Branch: refs/heads/master
Commit: 6132451df02b36b008c9d4d6cd8eec4afe3d67ae
Parents: 21e7ec2
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Jan 25 20:51:23 2016 -0500
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Jan 25 20:51:23 2016 -0500

----------------------------------------------------------------------
 net/nimble/host/src/ble_hs_conn.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/6132451d/net/nimble/host/src/ble_hs_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.c b/net/nimble/host/src/ble_hs_conn.c
index 1825cb8..2a1657f 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -78,6 +78,17 @@ err:
     return NULL;
 }
 
+static void
+ble_hs_conn_delete_chan(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan)
+{
+    if (conn->bhc_rx_chan == chan) {
+        conn->bhc_rx_chan = NULL;
+    }
+
+    SLIST_REMOVE(&conn->bhc_channels, chan, ble_l2cap_chan, blc_next);
+    ble_l2cap_chan_free(chan);
+}
+
 void
 ble_hs_conn_free(struct ble_hs_conn *conn)
 {
@@ -93,8 +104,7 @@ ble_hs_conn_free(struct ble_hs_conn *conn)
     ble_att_svr_prep_clear(&conn->bhc_att_svr);
 
     while ((chan = SLIST_FIRST(&conn->bhc_channels)) != NULL) {
-        SLIST_REMOVE(&conn->bhc_channels, chan, ble_l2cap_chan, blc_next);
-        ble_l2cap_chan_free(chan);
+        ble_hs_conn_delete_chan(conn, chan);
     }
 
     rc = os_memblock_put(&ble_hs_conn_pool, conn);