Skip to content

Commit dc76fa2

Browse files
committed
Fix esp32 tcpip message starvation
Limit sming task processing to only those messages waiting in the queue. When heavily stressed, loop never exits and tcpip messages don't get serviced.
1 parent 10cf967 commit dc76fa2

File tree

1 file changed

+3
-1
lines changed
  • Sming/Arch/Esp32/Components/esp32/src

1 file changed

+3
-1
lines changed

Sming/Arch/Esp32/Components/esp32/src/tasks.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ volatile bool eventQueueFlag;
3333
void tcpip_message_handler(void*)
3434
{
3535
eventQueueFlag = false;
36+
// Process only waiting messages (not newly posted ones) so tcpip doesn't starve
37+
auto messageCount = uxQueueMessagesWaiting(eventQueue);
3638
os_event_t evt;
37-
while(xQueueReceive(eventQueue, &evt, 0) == pdTRUE) {
39+
while(messageCount-- && xQueueReceive(eventQueue, &evt, 0) == pdTRUE) {
3840
taskCallback(&evt);
3941
}
4042
}

0 commit comments

Comments
 (0)