fix(core): make socket teardown deterministic - #15
Merged
Conversation
Preserve idempotent close semantics when garbage collection retires a valid socket between state lookup and internal acquisition. Keep test ownership, readiness registration, and finite-transfer completion deterministic while retaining strict close assertions.
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.
Affected repo & language: CERALIVE/srt — C/C++
What
Make socket teardown deterministic across the required epoll, file-transfer, and IPv6 reuse tests. The public close wrapper now preserves its existing idempotent contract when garbage collection retires a socket between the public state lookup and internal close acquisition. Test socket owners release handles exactly once, finite transfers finish by their known byte count, and readiness is registered before launching a fast peer.
Why
The post-merge master gates exposed three real nondeterministic failures:
TestEPoll.SimpleAsync, C++03Transmission.FileUploadin run 29290208582, and WindowsReuseAddr.SameAddrV6in attempt 1 of run 29290208546. Successful retries did not resolve their ownership, close-acquisition, and readiness-registration races.How to verify
ctest --test-dir <build> --output-on-failure.uvx codespell --config scripts/codespell/codespell.cfgandgit diff --check.Local results: native full suite green; exact C++03 full suite green; every focused stress iteration passed with strict close assertions and no
SRT_EINVSOCK. All workflows remain byte-identical tomaster; Actionlint/YAML, cache assertions, release/runtime invariants, and cold/warm package replacement gates remain green.Risks
The production behavior change is deliberately narrow: only
SRT_ERRORplusSRT_EINVSOCKafter an initially nonterminal socket state is converted to idempotent success. Other close errors propagate unchanged. The test changes preserve existing waits, C++03 expectations, and release gates; no skip, retry, timeout, or assertion was weakened.Checklist
857442d