rymanluk commented on a change in pull request #279: BLE Host - Policy for SM key overflow URL: https://github.com/apache/incubator-mynewt-core/pull/279#discussion_r119288035
########## File path: net/nimble/host/src/ble_store.c ########## @@ -28,49 +28,98 @@ ble_store_read(int obj_type, const union ble_store_key *key, { int rc; + ble_hs_lock(); + if (ble_hs_cfg.store_read_cb == NULL) { rc = BLE_HS_ENOTSUP; } else { rc = ble_hs_cfg.store_read_cb(obj_type, key, val); } + ble_hs_unlock(); + return rc; } int ble_store_write(int obj_type, const union ble_store_value *val) { + struct ble_store_status_event event; int rc; if (ble_hs_cfg.store_write_cb == NULL) { - rc = BLE_HS_ENOTSUP; - } else { - rc = ble_hs_cfg.store_write_cb(obj_type, val); + return BLE_HS_ENOTSUP; } - return rc; + while (1) { + ble_hs_lock(); + rc = ble_hs_cfg.store_write_cb(obj_type, val); + ble_hs_unlock(); + + switch (rc) { + case 0: + return 0; + case BLE_HS_ESTORE_CAP: + /* Record didn't fit. Give the application the opportunity to free + * up some space. + */ + event.obj_type = obj_type; + event.event_code = BLE_STORE_EVENT_OVERFLOW; + event.value = val; + rc = ble_store_status(&event); + if (rc != 0) { + return rc; + } + + /* Application made room for the record; try again. */ + break; + + default: + return rc; + } + } } int ble_store_delete(int obj_type, const union ble_store_key *key) { int rc; + ble_hs_lock(); Review comment: same as above ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services