mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2025-07-29 18:07:14 +02:00
Fix crash in NimBLEDevice::deleteClient when notification arrives.
While deleting the client attribute database, if a notification occurs there is a possibility of concurrency causing an exception. This fixes that by setting a flag before calling disconnect in the deleteClient function to prevent processing further notifications.
This commit is contained in:
@ -165,6 +165,9 @@ void NimBLEDevice::stopAdvertising() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the connection established flag to false to stop notifications
|
||||
// from accessing the attribute vectors while they are being deleted.
|
||||
pClient->m_connEstablished = false;
|
||||
int rc =0;
|
||||
|
||||
if(pClient->isConnected()) {
|
||||
@ -176,6 +179,10 @@ void NimBLEDevice::stopAdvertising() {
|
||||
while(pClient->isConnected()) {
|
||||
taskYIELD();
|
||||
}
|
||||
// Since we set the flag to false the app will not get a callback
|
||||
// in the disconnect event so we call it here for good measure.
|
||||
pClient->m_pClientCallbacks->onDisconnect(pClient);
|
||||
|
||||
} else if(pClient->m_pTaskData != nullptr) {
|
||||
rc = ble_gap_conn_cancel();
|
||||
if (rc != 0 && rc != BLE_HS_EALREADY) {
|
||||
|
Reference in New Issue
Block a user