Skip to content

Commit 3da1acd

Browse files
authored
Fix esp32 tcpip message starvation (SmingHub#2976)
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. See SmingHub#2971 (comment)
1 parent 98e9f4d commit 3da1acd

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)