esp-lwip
esp-lwip copied to clipboard
Fix leak/deadlock in netif_loop_output if tcpip_try_callback fails
There is currently a leak/deadlock in the processing of loopback traffic in netif_loop_output
.
When a packet is received for loopback processing and there are no packets waiting, a netif_poll
call is scheduled via tcpip_try_callback
. If there are already packets waiting, the new packet is added to the queue and no call is scheduled. As the “try” suggests, tcpip_try_callback
can fail if the tcpip-task mbox is full. In that case, the netif_poll
call is not scheduled and further loopback packets will not attempt to schedule it again, causing all loopback packets to be stuck forever.
This issue was fixed upstream four years ago and this PR is the original upstream patch, rebased to apply cleanly and match the current state of upstream.
Edit: I just noticed that this has already been fixed in the 2.1.3-esp branch 2.5 years ago, but the current Arduino ESP32 still suffering from this years later. :(