You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2019/03/25 13:01:04 UTC

[mynewt-nimble] branch master updated: host: Free txq on connection free, not atomic del

This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new e1b77b4  host: Free txq on connection free, not atomic del
e1b77b4 is described below

commit e1b77b4ac170c0daa3af8148bc40edbca04fccb1
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Fri Mar 22 15:06:50 2019 -0700

    host: Free txq on connection free, not atomic del
    
    This commit just moves a bit of code from one function to another.
    Previously, a connection's transmit queue was freed in
    `ble_hs_atomic_conn_delete()`.  This operation is more logically placed
    in the more "leaf" function `ble_hs_conn_free()`.
---
 nimble/host/src/ble_hs_atomic.c | 7 -------
 nimble/host/src/ble_hs_conn.c   | 6 ++++++
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/nimble/host/src/ble_hs_atomic.c b/nimble/host/src/ble_hs_atomic.c
index f32ba8a..5d51fbe 100644
--- a/nimble/host/src/ble_hs_atomic.c
+++ b/nimble/host/src/ble_hs_atomic.c
@@ -23,17 +23,10 @@ int
 ble_hs_atomic_conn_delete(uint16_t conn_handle)
 {
     struct ble_hs_conn *conn;
-    struct os_mbuf_pkthdr *omp;
 
     ble_hs_lock();
     conn = ble_hs_conn_find(conn_handle);
     if (conn != NULL) {
-
-        while ((omp = STAILQ_FIRST(&conn->bhc_tx_q)) != NULL) {
-            STAILQ_REMOVE_HEAD(&conn->bhc_tx_q, omp_next);
-            os_mbuf_free_chain(OS_MBUF_PKTHDR_TO_MBUF(omp));
-        }
-
         ble_hs_conn_remove(conn);
         ble_hs_conn_free(conn);
 
diff --git a/nimble/host/src/ble_hs_conn.c b/nimble/host/src/ble_hs_conn.c
index 2e23da3..e1e5e7e 100644
--- a/nimble/host/src/ble_hs_conn.c
+++ b/nimble/host/src/ble_hs_conn.c
@@ -207,6 +207,7 @@ ble_hs_conn_free(struct ble_hs_conn *conn)
 #endif
 
     struct ble_l2cap_chan *chan;
+    struct os_mbuf_pkthdr *omp;
     int rc;
 
     if (conn == NULL) {
@@ -219,6 +220,11 @@ ble_hs_conn_free(struct ble_hs_conn *conn)
         ble_hs_conn_delete_chan(conn, chan);
     }
 
+    while ((omp = STAILQ_FIRST(&conn->bhc_tx_q)) != NULL) {
+        STAILQ_REMOVE_HEAD(&conn->bhc_tx_q, omp_next);
+        os_mbuf_free_chain(OS_MBUF_PKTHDR_TO_MBUF(omp));
+    }
+
 #if MYNEWT_VAL(BLE_HS_DEBUG)
     memset(conn, 0xff, sizeof *conn);
 #endif