Skip to content

Add receive shutdown that preserves stream writes - #122

Closed
proggeramlug wants to merge 2 commits into
codex/wasi-tcp-controlsfrom
codex/wasi-receive-shutdown
Closed

proggeramlug wants to merge 2 commits into
codex/wasi-tcp-controlsfrom
codex/wasi-receive-shutdown

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

WASI receive shutdown must stop and discard input while the socket remains writable. Cancelling the caller's read future alone leaves its native read slot owned by AsyncIo.

Add Driver::shutdown_receive and AsyncIo::shutdown_receive. Unix and Windows perform receive-only native shutdown; WASI 0.2 forwards the corresponding socket operation. After native success the adapter cancels and discards its read slot, retains its buffer until terminal acknowledgement, and returns EOF on subsequent reads. Repeated calls succeed and sends remain independent. Unsupported transports fail without changing adapter state. WASI 0.3/web explicitly return Unsupported for this synchronous control; their receive streams need asynchronous cancellation before endpoint disposal.

Validation: Linux passes 194 core/contract tests plus three doctests, and all three new executor contracts in release. macOS passes the three executor contracts and the independent native probe. Both pass all-target core/contract Clippy with warnings and undocumented unsafe blocks denied. WASI 0.2 passes all 53 contracts in debug and release under checksum-pinned Wasmtime 46.0.0, plus all-target Clippy. Tests cover a pending read beside live writes, discarding a partially consumed completion, UDP rejection preserving a read, and repeated shutdown. An independent probe detaches the native socket and verifies shutdown through the OS, then sends exact bytes through its surviving write direction. The full required CI matrix is green on 605ee21: native Linux x86-64/ARM64, macOS and Windows; WASI 0.2/0.3 builds and protocols; web, Miri, Loom, dependencies, and protocol gates. CI run.

Stacked on #121. No dependency, feature, release or policy changes. Remains draft pending dependent Perry WASI integration.

@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
proggeramlug force-pushed the codex/wasi-tcp-controls branch from 9c64952 to c8ef920 Compare October 23, 2026 18:50
@proggeramlug
proggeramlug force-pushed the codex/wasi-receive-shutdown branch from 605ee21 to 8a584f7 Compare October 23, 2026 18:50
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