Conversation
…being created URLConnectionState::cancel cancels whatever task the token holds, and start assigns the token only after creating and resuming the task, which for the first task in a process also constructs the shared NSURLSession. A cancel arriving in that interval cancelled an empty token, and start then waited out the whole connection timeout. The connection state now records the cancel under the same mutex as the token, and start honours it right after the assignment, before anything waits.
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 #1747.
URLConnectionState::cancelcancels whatever task the token holds, andstartassigns the token only after creating and resuming the task, which for the first task in a process also constructs the sharedNSURLSession. A cancel arriving in that interval cancelled an empty token, andstartthen waited out the whole connection timeout.The connection state now records the cancel under the same mutex as the token, and
starthonours it right after the assignment, before anything waits. The Windows implementation already re-checks its cancel flag under the lock at each handle assignment; this brings macOS in line.Reproduced on 9.0.2 with a stream toward a blackhole address cancelled from another thread 50 ms after
connect()began: the first run after a macOS 26 guest booted took 10.19 s; with this change, two boots with that run first and nine more runs each stayed under 0.35 s. The interval is timing-dependent, so the test that shows it is the first request after boot rather than a unit test in this PR.