Skip to content

Fix a bad race condition that causes intermittent socket receive failures#171

Closed
aggieNick02 wants to merge 1 commit intoadafruit:mainfrom
PCPartPicker:main
Closed

Fix a bad race condition that causes intermittent socket receive failures#171
aggieNick02 wants to merge 1 commit intoadafruit:mainfrom
PCPartPicker:main

Conversation

@aggieNick02
Copy link
Contributor

The issue is caused by the code checking socket status after checking if bytes are available. Bytes may have become available between the last byte available check and the socket status check. This causes us to incorrectly ignore the newly available bytes and return 0 to the caller, which in any blocking/timeout scenario tells the caller no more bytes will ever be available.

This was introduced in commit 89b9f10
See also
#151
as a fix for
#135

failures.

The issue is caused by the code checking socket status *after* checking
if bytes are available. Bytes may have become available between the
last byte available check and the socket status check. This causes us to
incorrectly ignore the newly available bytes and return 0 to the caller,
which in any blocking/timeout scenario tells the caller no more bytes
will ever be available.

This was introduced in commit 89b9f10
See also
adafruit#151
as a fix for
adafruit#135
@FoamyGuy FoamyGuy mentioned this pull request Jan 23, 2026
@FoamyGuy
Copy link
Contributor

This change makes sense and looks good to me. I tested it successfully with the simpletest, httpserver, and aio_post examples from this repo with an Ethernet FeatherWing + Feather RP2350.

Unfortunately there were changes in main in the interim that caused conflicts with this branch. I tried merging and resolving, but library maintainers do not have permission to push to this branch so I am unable to update the PR.

I have opened #188 with the same change and will merge that one.

@FoamyGuy FoamyGuy closed this Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants