Tear down a handle stamped mid-escalation and pin the wrap flags literally

This commit is contained in:
J. Nick Koston
2026-08-10 17:53:31 -05:00
parent 63ce235937
commit d3dc97d42d
2 changed files with 13 additions and 3 deletions
@@ -653,6 +653,12 @@ void RP2GattClient::fail_connection_(uint8_t reason) {
if (connect_owner == this) {
connect_owner = nullptr;
}
if (this->state_ == EngineState::CONNECTING && this->con_handle_ != HCI_CON_HANDLE_INVALID) {
// A success completion stamped the handle between the escalation
// decision and this lock: tear the link down before cleanup wipes the
// handle, or it leaks its pool block for the rest of the boot.
gap_disconnect(this->con_handle_);
}
}
this->cleanup_link_state_();
this->release_scan_inhibit_();
@@ -7,13 +7,17 @@ from __future__ import annotations
from collections.abc import Callable
from pathlib import Path
from esphome.components import rp2040_ble
from esphome.core import CORE
from ..helpers import get_define_value
WRAP_FLAGS = tuple(
f"-Wl,--wrap={symbol}" for symbol in rp2040_ble._BTSTACK_POOL_SYMBOLS
# Spelled out rather than derived from rp2040_ble's symbol tuple, so a typo
# in the component's list fails here instead of mirroring into the test.
WRAP_FLAGS = (
"-Wl,--wrap=btstack_memory_gatt_client_get",
"-Wl,--wrap=btstack_memory_gatt_client_free",
"-Wl,--wrap=btstack_memory_hci_connection_get",
"-Wl,--wrap=btstack_memory_hci_connection_free",
)