Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report OOM errors in NimBLE callbacks. #2687

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/resources/ble_esp32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,9 @@ ServiceContainer<T>::get_or_create_service(const BleCallbackScope* scope,
// try to recover on OOM.
scope->gc();
service = _new BleServiceResource(group(), type(), uuid, start,end);
if (!service) {
ESP_LOGE("BLE", "OOM while creating service in NimBLE callback");
}
}
if (!service) return null;
group()->register_resource(service);
Expand Down Expand Up @@ -1668,6 +1671,9 @@ BleCharacteristicResource* BleServiceResource::get_or_create_characteristic(
// try to recover on OOM.
scope->gc();
characteristic = _new BleCharacteristicResource(group(), this, uuid, properties, value_handle, def_handle);
if (!characteristic) {
ESP_LOGE("BLE", "OOM while creating characteristic in NimBLE callback");
}
}
if (!characteristic) return null;
group()->register_resource(characteristic);
Expand Down Expand Up @@ -1870,6 +1876,9 @@ BleDescriptorResource* BleCharacteristicResource::get_or_create_descriptor(const
// try to recover on OOM.
scope->gc();
descriptor = _new BleDescriptorResource(group(), this, uuid, handle, properties);
if (!descriptor) {
ESP_LOGE("BLE", "OOM while creating descriptor in NimBLE callback");
}
}
if (!descriptor) return null;
group()->register_resource(descriptor);
Expand Down Expand Up @@ -2179,7 +2188,10 @@ bool BleCharacteristicResource::update_subscription_status(const BleCallbackScop
// try to recover on OOM.
scope.gc();
subscription = _new Subscription(indicate, notify, conn_handle);
if (!subscription) return false;
if (!subscription) {
ESP_LOGE("BLE", "OOM while creating subscription in NimBLE callback");
return false;
}
}

subscriptions_.append(subscription);
Expand Down
Loading