Fix non-blocking Socket#connect on Unix - #17436
Open
ysbaddaden wants to merge 3 commits into
Open
ysbaddaden wants to merge 3 commits into
ysbaddaden wants to merge 3 commits into
Conversation
The macOS 26.7 release has a bug where non-blocking socket connections may complete with EISCONN (connected) when it actually failed (sic). Adds a second check for the actual error state (SO_ERROR) of the socket after EISCONN, which apparently catches the issue. Co-Authored-By: nogginly <19142777+nogginly@users.noreply.github.com>
Member
|
I suppose there is no reason to check with |
Collaborator
Author
|
Now io_uring also raises on EISCONN 👍 There's indeed no need to check for |
straight-shoota
approved these changes
Sep 21, 2026
Socket#connect on Unix
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.
The macOS 26.7 release apparently has a bug where non-blocking socket connection may complete withSee https://forum.crystal-lang.org/t/socket-connection-error-after-macos-26-7-update/9145EISCONN(connected) when it actually failed (sic).EDIT: Our non-blocking loop for
Socket#connectis wrong: unlike other operations,connectmusn't be re-tried after waiting, it's actually asynchronous, and we must check the socket error state after waiting for the socket to become writable. See connect(2).Adds a second check for the actual error state (SO_ERROR) of the socket after EISCONN.
This apparently catches the issue.Adapted from https://github.com/nogginly/socket_connect_fix.cr/blob/b22e7df11d3911be9f04f4a9fc5ff8de0c829e2d/src/socket_connect_fix.cr by @nogginly