Always poll_connect on Apple platforms in connect_timeout - #669
Draft
rootkiller6788 wants to merge 1 commit into
Draft
Always poll_connect on Apple platforms in connect_timeout#669rootkiller6788 wants to merge 1 commit into
rootkiller6788 wants to merge 1 commit into
Conversation
On Apple platforms (macOS, iOS, tvOS, watchOS, visionOS) a non-blocking connect(2) can return success even though the connection is not yet established. Treating that as immediate success causes connect_timeout to return Ok(()) while the socket is still unconnected. Skip the fast-path early return on Apple platforms so the function always falls through to poll_connect, which waits for the connection to actually complete. Fixes rust-lang#652.
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.
Fixes #652.
On Apple platforms (macOS, iOS, tvOS, watchOS, visionOS) a non-blocking
connect(2)can return success even though the connection is not yet established.Socket::connect_timeoutcurrently treatsOk(())fromconnectas an immediate success and returns early, skippingpoll_connect. In that case the function returnsOk(())whilepeer_addr()/getpeernamestill reportsENOTCONN.This change skips the fast-path early return on Apple platforms so the function always falls through to
poll_connect, which waits for the connection to actually complete (and surfaces the real error on failure).Behaviour on non-Apple platforms is unchanged.
Reported by @BiagioFesta in #652 and confirmed by @Thomasdezeeuw.