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:28 UTC
[2/4] incubator-mynewt-core git commit: BLE Host - Differentiate
prep-q-full / insuf. res.
BLE Host - Differentiate prep-q-full / insuf. res.
There are still some decisions to be made here. If we receive a
subsequent prep write command, and we have no mbufs, is it a prepare
queue full or insufficient resources error?
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/fc4c950f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fc4c950f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fc4c950f
Branch: refs/heads/develop
Commit: fc4c950f6285af66df5b9ad10969d27c2fe8fb97
Parents: ed2ff11
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Nov 23 14:45:08 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Nov 23 14:45:08 2016 -0800
----------------------------------------------------------------------
net/nimble/host/src/ble_att_svr.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fc4c950f/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 a5fd0eb..5f31f4a 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -2154,12 +2154,13 @@ ble_att_svr_prep_free(struct ble_att_prep_entry *entry)
}
static struct ble_att_prep_entry *
-ble_att_svr_prep_alloc(void)
+ble_att_svr_prep_alloc(uint8_t *att_err)
{
struct ble_att_prep_entry *entry;
entry = os_memblock_get(&ble_att_svr_prep_entry_pool);
if (entry == NULL) {
+ *att_err = BLE_ATT_ERR_PREPARE_QUEUE_FULL;
return NULL;
}
@@ -2167,6 +2168,7 @@ ble_att_svr_prep_alloc(void)
entry->bape_value = ble_hs_mbuf_l2cap_pkt();
if (entry->bape_value == NULL) {
ble_att_svr_prep_free(entry);
+ *att_err = BLE_ATT_ERR_INSUFFICIENT_RES;
return NULL;
}
@@ -2340,9 +2342,8 @@ ble_att_svr_insert_prep_entry(uint16_t conn_handle,
conn = ble_hs_conn_find_assert(conn_handle);
- prep_entry = ble_att_svr_prep_alloc();
+ prep_entry = ble_att_svr_prep_alloc(out_att_err);
if (prep_entry == NULL) {
- *out_att_err = BLE_ATT_ERR_PREPARE_QUEUE_FULL;
return BLE_HS_ENOMEM;
}
prep_entry->bape_handle = req->bapc_handle;
@@ -2355,7 +2356,13 @@ ble_att_svr_insert_prep_entry(uint16_t conn_handle,
BLE_ATT_PREP_WRITE_CMD_BASE_SZ,
OS_MBUF_PKTLEN(rxom) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ);
if (rc != 0) {
+ /* Failed to allocate an mbuf to hold the additional data. */
ble_att_svr_prep_free(prep_entry);
+
+ /* XXX: We need to differentiate between "prepare queue full" and
+ * "insufficient resources." Currently, we always indicate prepare
+ * queue full.
+ */
*out_att_err = BLE_ATT_ERR_PREPARE_QUEUE_FULL;
return rc;
}