Skip to content

Feed v2 sessions from bounded asynchronous peer dialing - #209

Closed
linroid wants to merge 2 commits into
torrent-v2-08-peer-connectfrom
torrent-v2-08-peer-dialer
Closed

linroid wants to merge 2 commits into
torrent-v2-08-peer-connectfrom
torrent-v2-08-peer-dialer

Conversation

@linroid

@linroid linroid commented Sep 12, 2026

Copy link
Copy Markdown
Owner

V2 sessions can now start before peers are connected and consume negotiated arrivals while processing peer traffic and storage completions. Selection rotates between those event sources, waits for pool capacity, validates each arrival's full torrent identity, and handles a finished connection stream without polling.

The new dialer bounds concurrent handshakes and queued results. Admission pressure retries the same endpoint after a bounded delay; ordinary failures and peer timeouts are recorded without stopping later attempts. Session cancellation joins workers and closes queued or blocked-send connection handles. Endpoint-stream failures follow already queued results.

Stacked on #208; part of #162. Endpoint authorization, deduplication and retry policy, tracker/DHT production, and public engine registration remain upstream integration work.

Validation at 5b1d79b716a919168a25b475fa06e0b2ff885925: 506 JVM and 485 executed iOS simulator tests, zero failures/errors/skips; both pinned v1 conformance scenarios and native dependency guard passed. Tests cover worker bounds, admission retry timing, timeout isolation, undelivered ownership, discovery-stream failure, and actual pure-v2/hybrid TCP downloads arriving into empty sessions, including rejection of a connection for another torrent.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-12T20:28:06.133303Z 5b1d79b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b1d79b716

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

failure.value = Failure(endpoint, error)
break
}
if (connected == null) delay(250)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate discovery failure during admission retries

When a worker has already consumed an endpoint and connect keeps returning null because admission remains exhausted, this retry loop never receives from endpoints again. If the endpoint channel then closes exceptionally—or was already closed exceptionally after that endpoint—the failure is never observed, output never closes with its cause, and a session waiting for connections can hang indefinitely despite the documented fatal-stream behavior. The retry path needs to monitor and propagate an upstream failure while preserving retries for temporary admission pressure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3cf0840. Admission retries now inspect a drained endpoint stream after the bounded retry delay and propagate its exceptional close; normal closure still permits the consumed endpoint to connect. The new regression times out before the fix and passes after it. Existing normal-close retry and queued-connection failure tests also pass. The combined child stack passed 515 JVM and 494 executed iOS tests with zero failures; final annotation-only correction was compiled on both targets.

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  707 files  + 5    707 suites  +5   4m 22s ⏱️ +5s
2 900 tests +21  2 900 ✅ +21  0 💤 ±0  0 ❌ ±0 
3 912 runs  +35  3 912 ✅ +35  0 💤 ±0  0 ❌ ±0 

Results for commit 3cf0840. ± Comparison against base commit cd6bbaf.

♻️ This comment has been updated with latest results.

@linroid

linroid commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #236 (V2 scheduling and download execution) in the consolidated eight-PR stack for #162.

The replacement preserves this PR's code and subsequent fixes; its description links the original head and review discussions. The only additional consolidation fix is the CI-discovered listener cancellation regression, documented on the replacement. All eight replacements have passed their required CI checks.

Closing without merging. This branch and its discussions remain available for reference. Review index: #162 (comment)

@linroid linroid closed this Sep 20, 2026
linroid added a commit that referenced this pull request Sep 20, 2026
Consolidates #195–#209, preserving source 3cf0840.
Includes the foundation listener cancellation regression fix discovered by consolidation CI.
@linroid
linroid deleted the torrent-v2-08-peer-dialer branch September 20, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant