nimble/host: reset resource counts in ble_gatts_reset() - #2294
Open
gmarull wants to merge 1 commit into
Open
Conversation
ble_gatts_count_cfg() only ever adds to ble_hs_max_services, ble_hs_max_attrs and ble_hs_max_client_configs, and nothing ever resets them. ble_gatts_start() drops the added service definitions, so an application that resets the GATT server and registers its services again (host stop/start cycles, MicroPython soft reboots) has to count them again, and every cycle grows the pools allocated by ble_att_svr_start() and ble_gatts_start(). The only way to avoid the leak today is to poke the ble_hs_priv.h counters from application code. Clear the counters in ble_gatts_reset(), together with any service definitions added but not yet started (they would otherwise fail to register against zero-sized pools), so the server really returns to its initial state and the next count/add/start sequence sizes the pools from scratch. Adjust the test helper, which relied on the counts preset by ble_hs_test_util_init() surviving the reset. Fixes apache#896 Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ble_gatts_count_cfg()only ever adds toble_hs_max_services,ble_hs_max_attrsandble_hs_max_client_configs, and nothing ever resets them.ble_gatts_start()drops the added service definitions, so an application that resets the GATT server and registers its services again (host stop/start cycles, MicroPython soft reboots) has to count them again, and every cycle grows the pools allocated byble_att_svr_start()andble_gatts_start(). The only way to avoid the leak today is to poke theble_hs_priv.hcounters from application code.Clear the counters in
ble_gatts_reset(), together with any service definitions added but not yet started (they would otherwise fail to register against zero-sized pools), so the server really returns to its initial state and the next count/add/start sequence sizes the pools from scratch. The test helper is adjusted, as it relied on the counts preset byble_hs_test_util_init()surviving the reset.Fixes #896