[PHP] fix: preserve orderly TCP close across bridges#755
Merged
brandonpayton merged 3 commits intoJul 11, 2026
Conversation
Phase B-1 matrix build status —
|
| Package | Arch | Status | Sha |
|---|---|---|---|
| kandelo-sdk | wasm32 | built | bbcaea9f |
| rootfs | wasm32 | built | 3e34a9d0 |
| shell | wasm32 | built | 16aa686a |
| lamp | wasm32 | built | 88379fdd |
| node-vfs | wasm32 | built | 7aecb2ac |
| wordpress | wasm32 | built | 5810f4f5 |
Auto-generated; replaced on each push. Raw data in the publish-status workflow artifact.
This was referenced Jul 10, 2026
Tie accepted connection lifetime to pipe ownership, retain inbound data across backpressure, wake blocked pipe I/O, and drain queued output before FIN. Model final TCP receive ownership as a discard sink, reject unsupported enabled SO_LINGER, and record the additive real-reader ABI export.
3da3a8f to
1d697ba
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.
Why
TCP close is an orderly, simplex FIN operation: already-queued bytes must remain readable, each direction closes independently, and FIN must not be fabricated into an exact count of successful later writes. Kandelo's pipe-backed loopback sockets, Node bridge, and virtual network instead mixed orderly close with reset behavior and tied accepted bridges too closely to the process that originally accepted them. That broke ordinary stream shutdown, blocked-I/O wakeups, and forked socket ownership.
This constituent repairs that platform contract across the kernel and both host networking backends. It is stacked into the still-unmerged Batch 2 aggregate because its new host/kernel export must be included in the aggregate ABI 16→17 reconciliation before any main landing.
Source change
The two original commits introduced
allowHalfOpen/orderly Node close handling, separated virtual FIN from abort, and changed pipe-backed TCP close behavior. The original implementation also invented an "exactly one write after FIN" rule and a one-second forced-destroy timer; neither accurately models TCP.Review changes
The appended corrective commit:
kernel_pipe_has_readerskernel export and regeneratesabi/snapshot.json;SHUT_RDWRwrites reportEPIPE/SIGPIPEcorrectly;allowHalfOpen,end(), anddestroySoon()rather than timer-driven truncation;SHUT_WR;fork(), including final-owner cleanup and port reuse;SO_LINGERwithEOPNOTSUPPinstead of silently promising unsupported close behavior;EPIPE); andView
Accept into Batch 2 only. The repaired FIN/reset separation, backpressure, wakeups, and ownership model are sound based on review and focused validation. It is intentionally not independently main-ready:
host/src/kernel-worker.tsnow requireskernel_pipe_has_readers, while this constituent still reports ABI 16. Existing prebuilt ABI-16 kernels do not provide that export. Batch 2 must make this part of its promised ABI 16→17 reconciliation, rebuild generated artifacts, and pass the full aggregate gate before #871 can advance.Validation
Run through
scripts/dev-shell.shon the repaired source tree unless noted:cargo test -p kandelo --target aarch64-apple-darwin --lib: 1,010 passed, 0 failed.cd host && npx vitest run test/virtual-network-e2e.test.ts test/tcp-backend.test.ts test/virtual-network.test.ts: 32 passed, 2 skipped.cd host && npm run typecheck: passed.bash build.sh: passed.scripts/run-sortix-tests.sh --sequential basic sys_socket/tcp-peer-close-eof-epipe sys_socket/tcp-shutdown-half-close sys_socket/tcp-shutdown-matrix: 3/3 passed.bash scripts/check-abi-version.sh: snapshot/header/TypeScript bindings are synchronized; the structural diff is the additivekernel_pipe_has_readersexport. This is not a semantic ABI-clearance claim.git diff --check: clean.The exact full host run and canonical
./run.sh browserstartup were attempted but reached the generated PHP artifact and failed at the known missingenv.__wasm_posix_vm_interrupt_afterimport supplied by #757. They are recorded as failed aggregate attempts, not passes. A final browser network-lab rerun was also blocked by the currently generated GNU netcat artifact, which fails its own Node netcat tests; the real-browser Sortix close/shutdown cases above are the final browser evidence for this constituent. The complete host, libc, ABI, and browser gate remains due on #871's reconciled final head.Stack and provenance
integration/kd-6nz-php-phpt-platform-fixes([PHP] Batch 2: PHPT platform and ABI fixes #871).ec4b05ceefix: close bridged TCP sockets gracefully2c2d967d5fix: model TCP close as orderly FIN1d697bac5fix: preserve orderly TCP close across bridges.--force-with-leasefrom its reviewed old head so the repaired replay, rather than the stale stack ancestry, is what enters Batch 2.Supersedes the old fork-headed #735.