Skip to content

Commit d44a97f

Browse files
tyethclaude
andcommitted
espressif: treat a select() that returns 0 as a spurious wakeup
socket_select_task asserted that select() with no timeout returns at least one ready socket. lwIP checks the sockets again after it wakes, so it returns 0 when the main task has already read the datagram that woke it. The shared mDNS browser does exactly that with its system socket, and DEBUG=1 builds stopped at the assert (Socket.c:111). Release builds compile the assert out and loop, so wait again explicitly instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 742fcab commit d44a97f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • ports/espressif/common-hal/socketpool

‎ports/espressif/common-hal/socketpool/Socket.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ static void socket_select_task(void *arg) {
108108
continue;
109109
}
110110

111-
assert(num_triggered > 0);
111+
// lwIP's select() checks the sockets again after it wakes, so it can
112+
// return 0 even with no timeout: the main task has already read the
113+
// datagram that woke it (the shared mDNS browser reads its own system
114+
// socket, for one). Nothing is ready, so just wait again.
115+
if (num_triggered == 0) {
116+
continue;
117+
}
112118

113119
// Notice event trigger
114120
if (FD_ISSET(socket_change_fd, &readfds)) {

0 commit comments

Comments
 (0)