espressif / esp-nimble

A fork of NimBLE stack, for use with ESP32 and ESP-IDF
Apache License 2.0
76 stars 50 forks source link

ble_hs_lock during bonding #3

Closed BrianPugh closed 4 years ago

BrianPugh commented 4 years ago

During bonding, the writing portion ( ble_store_write() ) is surrounded by a ble_hs_lock() which explicitly doesn't allow nested locks.

https://github.com/espressif/esp-nimble/blob/nimble-1.2.0-idf/nimble/host/src/ble_store.c#L54

However, when it's called during bonding here:

https://github.com/espressif/esp-nimble/blob/nimble-1.2.0-idf/nimble/host/src/ble_gatts.c#L1706

It's also surrounded by ble_hs_lock() , so this call will always fail. Should ble_store_write() invoke ble_hs_lock_nested() instead? Or is something else wrong?

prasad-alatkar commented 4 years ago

Hi @BrianPugh , if you look at ble_hs_lock() carefully it calls ble_hs_lock_nested() internally if BLE host debug (BLE_HS_DEBUG) flag is not 1, so there should not be any problem, I have verified from my end.

However I do agree that ble_hs_lock API's description ' Locks the BLE host mutex. Nested locks not allowed' is little misleading.

prasad-alatkar commented 4 years ago

@BrianPugh, thank you for reporting the issue, there is upstream PR which addresses your concerns,link to PR: PR!567 . I will get this merged as soon as the upstream PR is merged.

BrianPugh commented 4 years ago

upstream was merged!

dhrishi commented 4 years ago

Closing as this is now merged in esp-nimble as well.