Repository navigation
Stop socket reads at EOF or the requested byte count - #649
Merged
Merged
Conversation
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.
Socket::readBytes()can keep retrying after a clean peer shutdown when the previous socket error is still would-block. It also polls for readability after receiving every requested byte, adding a wait or even turning a completed read into a poll error.Treat a zero-byte receive as EOF regardless of the previous error, and only poll while bytes remain. The change is in the shared socket helper and applies to plain and TLS sockets without an API change.
Add in-memory tests for completed buffered/streamed reads, EOF with a stale would-block error, empty reads, and immediate cancellation. The fixture deliberately has no native descriptor so unnecessary readiness polling is detected. These tests have no network dependencies, sleeps, or timeout waits; every generated case measures under 1 ms locally.
Validation: three failing assertions on master before the fix; all 25 assertions pass afterward. Full plain-socket suite: 29/29 passed. Targeted ThreadSanitizer run passed. Strict C++11 production build with warnings as errors, formatting and diff checks passed. MinGW production/test syntax checks passed with pre-existing unrelated signedness/unused-parameter warnings suppressed.