Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket error fixes #5760

merged 4 commits into from
Jun 7, 2019

Socket error fixes #5760

merged 4 commits into from
Jun 7, 2019


Copy link

@headius headius commented Jun 4, 2019

This fixes issues from #5709 and #5754.

  • Unify logic for turning Java exceptions into Errno based on their messages. This allows the proper errors to be raised for ETIMEDOUT and EHOSTUNREACH within socket logic.
  • Check for closed channel when doing the final flush logic in IO. This allows channels closed elsewhere or sockets not completely established to be closed again without error.
  • Remove custom Socket#close since it should now work with the modified IO#close finalization logic.

This allows failed connections from sockets (jruby#5709, jruby#5754) to
raise the actual socket error even though the logic in socket.rb
tries to close the failed socket.

This approach differs from jruby#5713 in that it modifies the final
flush logic to skip closed channels rather than modifying the
IO#closed? logic to do that same check.
@headius headius added this to the JRuby milestone Jun 4, 2019
Copy link
Member Author

headius commented Jun 7, 2019

I have reverted the general change to IO since it appears to break too many things and doesn't match MRI semantics. The unusual case here is that using JDK sockets, several connection failures leave the channel in a closed state, unusable for further connecting but not nulled out as is needed for close to silently move on. I am making a narrower change now that cleans up the socket after any of these fatal connection failures, so it looks to the Ruby close logic like it has already been closed cleanly elsewhere.

Because the case of a socket that fails to connect has special
behavior for us (the socket is closed or never opened by JDK) we
force it to clean up after a connect fails due to a
ConnectException. This may be valid for other failures but I am
limiting scope of this special case for now.

See jruby#5754.
@headius headius merged commit ea6b95f into jruby:master Jun 7, 2019
@headius headius deleted the socket_error_fixes branch June 7, 2019 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

1 participant