Skip to content

Preserve bound native TCP sockets through asynchronous connection - #120

Closed
proggeramlug wants to merge 2 commits into
codex/shared-stdio-ownershipfrom
codex/wasi-bound-tcp
Closed

proggeramlug wants to merge 2 commits into
codex/shared-stdio-ownershipfrom
codex/wasi-bound-tcp

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

WASI TCP hosts must reserve a local endpoint and set handshake-sensitive options before choosing a peer. The existing connect API creates a fresh socket, so it cannot preserve that state.

Add Driver::tcp_connect_bound and ExecutorHandle::connect_bound for exclusively owned, bound but unconnected native transports. Unix and Windows retain the socket identity, local endpoint and existing options while using the existing asynchronous connect, timeout and cancellation machinery. Setup failure releases native ownership and core reservations; dropping an unpolled or pending future releases its transport. Backends without native transport adoption return Unsupported.

Validation:

  • Six macOS regressions pass: IPv4/IPv6 identities, reserved ports and options; exact bidirectional bytes; invalid/connected/listening transports; admission rollback; cancellation completion ordering; executor delivery and unpolled/pending future cleanup.
  • Linux: 187 core/contract tests and three doctests pass with all features. Native tests execute unprivileged in a private devpts namespace.
  • The deadline regression now exercises ordinary TCP, adopted TCP and pipe connections, including cancellation errors and delayed native acknowledgement.
  • On a3f7a0074c080ae47bef8bdfb92c42472902f328, all 18 native CI arms pass (Linux x86_64/arm64, macOS and Windows), including the six new bound-TCP contracts on Windows. Native Clippy passes on all four platforms; WASI 0.2/0.3, browser, loom, Miri and workflow/dependency checks pass. The full required matrix, including protocol, instruction review and ci-gate, passes in CI 39857872029.

Stacked on #119 while that dependency repair awaits integration. No release/version or dependency-policy change. Draft until platform qualification and the dependent Perry WASI integration are complete.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

proggeramlug added a commit that referenced this pull request Nov 8, 2026
…d shared stdio

Upstreams the provider repairs Perry has been carrying as a patched copy of
alpha.10, so its WASI provider, native async and concurrent HTTP paths can
run on a published turnloop.

- ExecutorHandle::connect_bound and Backend::open_bound_tcp: connect an
  explicitly bound, not-yet-connected native TCP socket through the driver
  (Unix and IOCP), keeping its local address.
- AsyncIo::shutdown_receive: shut down the receive side of a stream without
  disturbing writes in flight; refused while a read is pending.
- AsyncDatagram and ExecutorHandle::datagram: an executor adapter that keeps
  UDP packet boundaries and source addresses.
- backend::stdio: overlapping handles on one Unix stdio descriptor share its
  ownership, so closing one does not reset the settings another relies on.
- Keepalive parameter setters on Unix, IOCP and WASI use the shared
  validation helpers without changing whether keepalive is enabled.

The IOCP unit tests move to backend/iocp/tests.rs; no test is dropped.
Supersedes #119, #120, #121, #122 and #123.
proggeramlug added a commit that referenced this pull request Nov 8, 2026
…d shared stdio

Upstreams the provider repairs Perry has been carrying as a patched copy of
alpha.10, so its WASI provider, native async and concurrent HTTP paths can
run on a published turnloop.

- ExecutorHandle::connect_bound and Backend::open_bound_tcp: connect an
  explicitly bound, not-yet-connected native TCP socket through the driver
  (Unix and IOCP), keeping its local address.
- AsyncIo::shutdown_receive: shut down the receive side of a stream without
  disturbing writes in flight; refused while a read is pending.
- AsyncDatagram and ExecutorHandle::datagram: an executor adapter that keeps
  UDP packet boundaries and source addresses.
- backend::stdio: overlapping handles on one Unix stdio descriptor share its
  ownership, so closing one does not reset the settings another relies on.
- Keepalive parameter setters on Unix, IOCP and WASI use the shared
  validation helpers without changing whether keepalive is enabled.

The IOCP unit tests move to backend/iocp/tests.rs; no test is dropped.
Supersedes #119, #120, #121, #122 and #123.
@proggeramlug

Copy link
Copy Markdown
Contributor Author

Superseded by #131, which upstreams all of Perry's provider repairs (merged).

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