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/11/23 22:49:29 UTC

[3/4] incubator-mynewt-core git commit: BLE Host - On rx indicate, allocate rsp first.

BLE Host - On rx indicate, allocate rsp first.

Don't process the indicate command until after we have successfully
allocated a response.  If response allocation fails, then reply with an
"insufficient resources" ATT error and throw away the indication.
Indicates are a bit different from other ATT commands because the
request is forwarded to the application as a GAP event, so we can't
reuse the request mbuf in the response.


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

Branch: refs/heads/develop
Commit: be0d6430de7762d226413a2efe9a0124f86b3a8f
Parents: fc4c950
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Nov 23 14:46:33 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Nov 23 14:46:33 2016 -0800

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_svr.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be0d6430/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index 5f31f4a..5cbd2a7 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -2670,16 +2670,18 @@ ble_att_svr_rx_indicate(uint16_t conn_handle, struct os_mbuf **rxom)
         goto done;
     }
 
+    /* Ensure we can allocate a response before processing the indication. */
+    rc = ble_att_svr_build_indicate_rsp(rxom, &txom, &att_err);
+    if (rc != 0) {
+        goto done;
+    }
+
     /* Strip the request base from the front of the mbuf. */
     os_mbuf_adj(*rxom, BLE_ATT_INDICATE_REQ_BASE_SZ);
 
     ble_gap_notify_rx_event(conn_handle, req.baiq_handle, *rxom, 1);
     *rxom = NULL;
 
-    rc = ble_att_svr_build_indicate_rsp(rxom, &txom, &att_err);
-    if (rc != 0) {
-        goto done;
-    }
     BLE_ATT_LOG_EMPTY_CMD(1, "indicate rsp", conn_handle);
 
     rc = 0;