Repository navigation
Conversation
kares
reviewed
Dec 6, 2026
BasicSocket#recv_nonblock treated "no data yet" and EOF the same, so once
the peer had shut down it raised EAGAIN forever instead of returning nil
as CRuby does. The nonblocking read now keeps the raw count, and EOF is
reported apart from "would block".
exception: false hid every error, not only "would block", so a connected
but unbound socket returned nil instead of raising Errno::ENOTCONN. Now
it only silences "would block". For a DatagramChannel, a zero-length
datagram is data ("") rather than EAGAIN, read_nonblock reads it as EOF
as CRuby does, and the channel's blocking mode is put back afterwards.
Untags the recv_nonblock specs for EOF on a closed stream socket and for
ENOTCONN on a connected but unbound socket.
CufeHaco
force-pushed
the
recv-nonblock-eof
branch
from
December 6, 2026 17:54
9f1a871 to
7af3192
Compare
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.
Split out of #9874, as Sampo asked.
BasicSocket#recv_nonblockraisedEAGAINforever once the peer had shut down, instead of returningnilthe way CRuby does, because "no data yet" and EOF looked the same. The nonblocking read now keeps the raw count, so EOF is reported separately from "would block".exception: falsealso hid every error, not just "would block". That meant a connected but unbound socket returnednilinstead of raisingErrno::ENOTCONN. Now it only silences "would block". On aDatagramChannel, a zero-length datagram is now data ("") rather thanEAGAIN, and the channel's blocking mode is restored afterwards.This untags 3 specs in
recv_nonblock_tags.txt: EOF on a closed stream socket, and ENOTCONN ×2.Testing: the EOF spec hangs on master, passes with this change, and passes on CRuby 4.0. The rest of
spec/ruby/library/socketshows no new failures.