Skip to content

Propagate read errors in IO backend#7994

Merged
headius merged 2 commits intojruby:jruby-9.3from
headius:socket_rst_fixes_9.3
Oct 31, 2023
Merged

Propagate read errors in IO backend#7994
headius merged 2 commits intojruby:jruby-9.3from
headius:socket_rst_fixes_9.3

Conversation

@headius
Copy link
Member

@headius headius commented Oct 31, 2023

JRuby 9.3 version of #7967.

The case of SocketException("Connection reset") was not handled,
and IOException only checked for one message. This combines the
logic for errnoFromException with the logic for errnorFromMessage.

The exception handling stack was also cleaned up here.
@headius headius added this to the JRuby 9.3.12.0 milestone Oct 31, 2023
@headius headius changed the base branch from master to jruby-9.3 October 31, 2023 18:29
This code previously assumed that all -1 return values from read
meant EAGAIN and that we should proceed to selection. If the read
result was actually equivalent to EAGAIN, this was correct. If the
read result was some other error, we still would proceed to the
selection, and in most cases the same or similar error would be
raised at that point. However at least one particular case: a
"Connection reset" event caused by the other end sending RST (due
in this case to SO_LINGER=0), the selection operation did *not*
raise any error, and appeared to be readable. As a result we went
back to the read, another "Connection reset" was triggered, we
assumed it was EAGAIN, and so on.

This commit checks the errno for exactly matching EAGAIN or
EWOULDBLOCK before performing the selection, otherwise raising an
error for the failed read.

Fixes jruby#7961
@headius headius force-pushed the socket_rst_fixes_9.3 branch from cd25166 to 18a606d Compare October 31, 2023 18:30
@headius headius changed the title https://github.com/jruby/jruby/pull/7967 Propagate read errors in IO backend Oct 31, 2023
@headius headius merged commit df7274e into jruby:jruby-9.3 Oct 31, 2023
@headius headius modified the milestones: JRuby 9.3.12.0, JRuby 9.3.13.0 Feb 6, 2024
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.

1 participant