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 2017/04/11 00:55:16 UTC

[10/11] incubator-mynewt-core git commit: nimble/l2cap: Fix hs locking issue when sending le_credit_update

nimble/l2cap: Fix hs locking issue when sending le_credit_update


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

Branch: refs/heads/master
Commit: 0b3ea953da71eca84fdcbcfd7affbea2e615ce8e
Parents: 8a64a49
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Fri Mar 17 15:32:12 2017 +0100
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Thu Apr 6 10:04:03 2017 +0200

----------------------------------------------------------------------
 net/nimble/host/src/ble_l2cap_coc.c      | 7 +++++--
 net/nimble/host/src/ble_l2cap_sig.c      | 6 +++---
 net/nimble/host/src/ble_l2cap_sig_priv.h | 3 ++-
 3 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0b3ea953/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 87d830a..5c4b9af 100644
--- a/net/nimble/host/src/ble_l2cap_coc.c
+++ b/net/nimble/host/src/ble_l2cap_coc.c
@@ -222,7 +222,7 @@ ble_l2cap_coc_rx_fn(struct ble_l2cap_chan *chan)
          * so since we have still buffer to handle it
          */
         rx->credits = 1;
-        ble_l2cap_sig_le_credits(chan, rx->credits);
+        ble_l2cap_sig_le_credits(chan->conn_handle, chan->scid, rx->credits);
     }
 
     BLE_HS_LOG(DEBUG, "Received partial sdu_len=%d, credits left=%d\n",
@@ -468,7 +468,10 @@ ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_rx)
      * to be able to send complete SDU.
      */
     if (chan->coc_rx.credits < c->initial_credits) {
-        ble_l2cap_sig_le_credits(chan, c->initial_credits - chan->coc_rx.credits);
+        ble_hs_unlock();
+        ble_l2cap_sig_le_credits(chan->conn_handle, chan->scid,
+                                 c->initial_credits - chan->coc_rx.credits);
+        ble_hs_lock();
         chan->coc_rx.credits = c->initial_credits;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0b3ea953/net/nimble/host/src/ble_l2cap_sig.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig.c b/net/nimble/host/src/ble_l2cap_sig.c
index d9e7c52..1acfbad 100644
--- a/net/nimble/host/src/ble_l2cap_sig.c
+++ b/net/nimble/host/src/ble_l2cap_sig.c
@@ -1047,7 +1047,7 @@ ble_l2cap_sig_le_credits_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr,
 }
 
 int
-ble_l2cap_sig_le_credits(struct ble_l2cap_chan *chan, uint16_t credits)
+ble_l2cap_sig_le_credits(uint16_t conn_handle, uint16_t scid, uint16_t credits)
 {
     struct ble_l2cap_sig_le_credits *cmd;
     struct os_mbuf *txom;
@@ -1059,10 +1059,10 @@ ble_l2cap_sig_le_credits(struct ble_l2cap_chan *chan, uint16_t credits)
         return BLE_HS_ENOMEM;
     }
 
-    cmd->scid = htole16(chan->scid);
+    cmd->scid = htole16(scid);
     cmd->credits = htole16(credits);
 
-    return ble_l2cap_sig_tx(chan->conn_handle, txom);
+    return ble_l2cap_sig_tx(conn_handle, txom);
 }
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0b3ea953/net/nimble/host/src/ble_l2cap_sig_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig_priv.h b/net/nimble/host/src/ble_l2cap_sig_priv.h
index 49d096c..3af6f75 100644
--- a/net/nimble/host/src/ble_l2cap_sig_priv.h
+++ b/net/nimble/host/src/ble_l2cap_sig_priv.h
@@ -108,7 +108,8 @@ int ble_l2cap_sig_coc_connect(uint16_t conn_handle, uint16_t psm, uint16_t mtu,
                               struct os_mbuf *sdu_rx,
                               ble_l2cap_event_fn *cb, void *cb_arg);
 int ble_l2cap_sig_disconnect(struct ble_l2cap_chan *chan);
-int ble_l2cap_sig_le_credits(struct ble_l2cap_chan *chan, uint16_t credits);
+int ble_l2cap_sig_le_credits(uint16_t conn_handle, uint16_t scid,
+                             uint16_t credits);
 #else
 #define ble_l2cap_sig_coc_connect(conn_handle, psm, mtu, sdu_rx, cb, cb_arg) \
                                                                 BLE_HS_ENOTSUP