fix(esp_event): Handler unregistration by itself issue

when esp_event_handler_unregister_with_internal cannot take
the loop mutex (e.g., when the handler unregisters itself),
create an event with a special base identifier and add it to
the queue of the corresponding loop to postpone the removal
of the handler from the list at a time when the loop mutex can be
successfully taken.
This commit is contained in:
Guillaume Souchere
2024-12-31 12:11:37 +01:00
parent d8d3c50b3f
commit 15f6775f5d
4 changed files with 307 additions and 99 deletions

View File

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@@ -41,3 +41,16 @@ def test_esp_event_profiling(dut: Dut) -> None:
matches = dut.expect(r'HANDLER .+ inv:[1-9][0-9]{0,} time:[1-9][0-9]{0,} us', timeout=2)
matches_arr = matches.group().split(b'\r\n')
assert (len(matches_arr) == 3)
dut.expect('1 Tests 0 Failures 0 Ignored', timeout=120)
dut.expect_exact("Enter next test, or 'enter' to see menu")
dut.write('"esp_event_dump does not show self unregistered handler"')
# look for 1 handlers never invoked
matches = dut.expect(r'HANDLER .+ inv:0 time:0 us', timeout=2)
matches_arr = matches.group().split(b'\r\n')
assert (len(matches_arr) == 1)
dut.expect('1 Tests 0 Failures 0 Ignored', timeout=120)
dut.expect_exact("Enter next test, or 'enter' to see menu")
dut.write('"self unregistered handlers are never called again after they return"')
dut.expect('1 Tests 0 Failures 0 Ignored', timeout=120)