mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-16 14:09:54 +00:00
MYNEWT-397: Nimble controller assert if advertising started/stopped frequently
There was an assert in the advertising code in the nimble controller that would assert if the advertising state machine was not enabled and an advertising event finished. The code contained a race condition where it was possible that the advertising state machine was stopped but an advertising end event was processed by the Link Layer. The code will now ignore advertising packets that are processed after advertising has been stopped as these events are asynchronous to the controller. X-Original-Commit: 317f82c61cbf22cfe11305809b3765ae64d46515
This commit is contained in:
@@ -651,16 +651,18 @@ ble_ll_adv_sm_stop(struct ble_ll_adv_sm *advsm)
|
||||
if (advsm->enabled) {
|
||||
/* Remove any scheduled advertising items */
|
||||
ble_ll_sched_rmv_elem(&advsm->adv_sch);
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
|
||||
/* Set to standby if we are no longer advertising */
|
||||
OS_ENTER_CRITICAL(sr);
|
||||
if (ble_ll_state_get() == BLE_LL_STATE_ADV) {
|
||||
ble_phy_disable();
|
||||
ble_ll_wfr_disable();
|
||||
ble_ll_state_set(BLE_LL_STATE_STANDBY);
|
||||
}
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
|
||||
os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
|
||||
|
||||
/* If there is an event buf we need to free it */
|
||||
if (advsm->conn_comp_ev) {
|
||||
ble_hci_trans_buf_free(advsm->conn_comp_ev);
|
||||
@@ -1161,6 +1163,15 @@ ble_ll_adv_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
|
||||
{
|
||||
int adv_event_over;
|
||||
|
||||
/*
|
||||
* It is possible that advertising was stopped and a packet plcaed on the
|
||||
* LL receive packet queue. In this case, just ignore the received packet
|
||||
* as the advertising state machine is no longer "valid"
|
||||
*/
|
||||
if (!g_ble_ll_adv_sm.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have received a scan request and we are transmitting a response
|
||||
* or we have received a valid connect request, dont "end" the advertising
|
||||
|
||||
Reference in New Issue
Block a user