STM32 - fix bug where sockets stop receiving data #4536
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The function _eth_arch_low_level_input() is meant to pass data into LWIP and to prepare the ethernet buffers to receive more data. If the LWIP heap is empty and the call to pbuf_alloc() in _eth_arch_low_level_input returns null, the ethernet receive buffers are not updated to receive data. Because of this the ethernet RX interrupt will not fire. Since the RX interrupt is the only thing that triggers a call to _eth_arch_low_level_input(), the receive buffers will never get cleared, and the device stops receiving data.
To prevent this from happening, this patch ensures that the function _eth_arch_low_level_input() clears the receive buffers even if a new pbuf for the data couldn't be allocated.
This issue can be reproduce by running the test
"features-feature_lwip-tests-mbedmicro-net-udp_echo_parallel"
and on the same machine running the below python script to flood the
device with UDP broadcast packets: