mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-22 13:10:55 +01: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:
parent
b807321d1b
commit
28573f5abe
1 changed files with 7 additions and 0 deletions
|
@ -165,6 +165,9 @@ void NimBLEDevice::stopAdvertising() {
|
||||||
return false;
|
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;
|
int rc =0;
|
||||||
|
|
||||||
if(pClient->isConnected()) {
|
if(pClient->isConnected()) {
|
||||||
|
@ -176,6 +179,10 @@ void NimBLEDevice::stopAdvertising() {
|
||||||
while(pClient->isConnected()) {
|
while(pClient->isConnected()) {
|
||||||
taskYIELD();
|
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) {
|
} else if(pClient->m_pTaskData != nullptr) {
|
||||||
rc = ble_gap_conn_cancel();
|
rc = ble_gap_conn_cancel();
|
||||||
if (rc != 0 && rc != BLE_HS_EALREADY) {
|
if (rc != 0 && rc != BLE_HS_EALREADY) {
|
||||||
|
|
Loading…
Reference in a new issue