fix: check recvsize before nonblocking mode in TCP recv() (AUD-004) - #183
Open
occamsshavingkit wants to merge 1 commit into
Open
fix: check recvsize before nonblocking mode in TCP recv() (AUD-004)#183occamsshavingkit wants to merge 1 commit into
occamsshavingkit wants to merge 1 commit into
Conversation
In the non-IPv6 W5500 path, socket.c:687-692 checked nonblocking mode before checking recvsize != 0. A nonblocking TCP socket returned SOCK_BUSY even when RX data was available, so the RX pointer never advanced and retries could not drain the socket. Fix: swap the two checks so recvsize != 0 is evaluated first, matching the ordering already used by the IPv6 branch at lines 679-685.
niansa
added a commit
to niansa/ioLibrary_Driver
that referenced
this pull request
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes nonblocking TCP socket returning
SOCK_BUSYeven when RX data is available.Problem
In the non-IPv6 W5500 path at
Ethernet/socket.c:687-692, the#elsebranch checked nonblocking mode before checkingrecvsize != 0:A nonblocking TCP socket returned
SOCK_BUSYeven when RX data was available. The RX pointer never advanced, so retries could not drain the socket and the receive buffer eventually stalled.Fix
Swap the two checks so
recvsize != 0is evaluated first, matching the ordering already used by the IPv6 branch at lines 679-685:Verification
_WIZCHIP_valuesSOCK_BUSY(the check is still present, just reordered)