Respect unread buffered data when checking EOF - #68
Open
OskarEichler wants to merge 1 commit into
Open
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.
Summary
Return false from BufferedIO#eof? while unread bytes remain in its own buffer. Only ask the underlying IO after that buffer is exhausted.
Reproduction
A bounded local Socket.pair reproduction also shows the old eof? blocking while a complete second line is already buffered and the peer remains open. The patched call returns false without waiting. The remaining buffered line is preserved when the peer closes.
Verification
6cba9756b72eaa5a939b4cb6e032ec1da88b07bd.bundle exec rake test: 30 tests, 66 assertions, zero failures/errors on the baseline and this branch.git diff --checkpass. Supplemental RuboCop Lint has the same 11 pre-existing offenses; no lint-clean claim.Compatibility and limitations
No signature changes. eof? intentionally stops reporting EOF, or waiting on the underlying socket, while this wrapper still has unread data.
The patch also applies to installed release 0.3.0, whose runtime file matches the reviewed master. Gem version, dependencies and Ruby >= 2.6 requirement stay unchanged. Only macOS/Ruby 4.0.6 was run locally; other Ruby/OS combinations require upstream CI. No production traffic or external service was used.