Repository navigation
[RT-SW-421] test: the loopback probe's closed endpoint is a port no parallel test can be handed - #422
Merged
Conversation
Blind-Striker
force-pushed
the
fix/421-loopback-closed-endpoint
branch
2 times, most recently
from
October 17, 2026 05:58
9a811ad to
4b4b69c
Compare
… can be handed (#421) ClosedEndpointAsync disposed a server and returned its released ephemeral port, which a parallel test binding port 0 could be handed before the probe connected, so a refusal turned into a connect. The closed endpoint is now a free port below every platform's ephemeral range (Windows/macOS 49152+, Linux 32768+).
Blind-Striker
force-pushed
the
fix/421-loopback-closed-endpoint
branch
from
October 17, 2026 06:01
4b4b69c to
45f1620
Compare
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.
What
The loopback probe tests' "closed" endpoint can no longer be a port that a parallel test is handed. Test-only.
Closes #421.
Cause
LoopbackTransportTests.ClosedEndpointAsync()started aLoopbackHttpServer, disposed it, and returned the port it had just released. That port belongs to the platform's ephemeral range. A parallel test binding port 0 could be handed it before the probe connected, and then the "refused" verdict became a connect. This happened on net472 on master380fd540, on an unchanged tree.The change
ClosedEndpoint()finds a free loopback port below every platform's ephemeral range with a bind, starting at 20000, and releases it. No port-0 bind is ever handed such a port, so nothing in the suite can take it. Every call takes its own candidates from a process-wideInterlockedcounter. The class's four callers run in parallel, and on macOS a port that another caller is momentarily binding would time out instead of refusing; with the counter, two callers never try the same port. All four callers are unchanged except for that one arrange line. No retry, no widened bound, no new type.Why not a socket held bound but not listening
That was the first idea. Measured on three OSes, it fails twice:
TcpListenercan rebind the held port, so the hold reserves nothing.Proof (probes run on all three OSes, not committed; scratchpad scripts)
LoopbackTransportTestspasses on net10.0 (10/10) and net472 (17/17).