Skip to content

Commit 617178c

Browse files
committed
esp32: return from receive_events once drained
Fix ESP32 event poller re-blocking after running a listener, which could delay a process readied by a driver (e.g. an active-mode socket message) until the next event or timer tick Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 2903b59 commit 617178c

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7070
- Fixed several underallocation issues that could trigger data corruption on `binary:replace`, `zlib:compress` and bsd socket recv code.
7171
- Fixed a bug where `catch` would raise on regular atom results
7272
- Fixed ESP32 socket driver holding the global socket-list lock across blocking TCP connects, leaking the port on connect failure, losing concurrent `accept` waiters, leaking `netbuf` on receive error paths, and a recycled-`netconn` race between socket close and the event handler
73+
- Fixed the ESP32 event poller re-blocking after running a listener, which could delay a process
74+
readied by a driver (e.g. an active-mode socket message) until the next event or timer tick
7375

7476
## [0.7.0-alpha.1] - 2026-04-06
7577

src/platforms/esp32/components/avm_sys/sys.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ static void receive_events(GlobalContext *glb, TickType_t wait_ticks)
132132
void *sender = NULL;
133133
QueueSetMemberHandle_t event_source;
134134
while ((event_source = xQueueSelectFromSet(event_set, wait_ticks))) {
135+
// Drain without re-blocking after the first event, then return so the
136+
// scheduler loop can run any process a listener just made ready
137+
wait_ticks = 0;
135138
// Listener used shared event_queue.
136139
if (event_source == event_queue) {
137140
if (UNLIKELY(xQueueReceive(event_queue, &sender, 0) == pdFALSE)) {

0 commit comments

Comments
 (0)