feat(libkernel): cancel blocked POSIX writes safely #11969
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11969"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-27T14:07:34Z.
What
Implement milestone 2: a blocked POSIX write can be cancelled while retaining descriptor ownership until native operations drain. Completed positive counts, including partial counts, win; zero/error returns check pending cancellation after guards release. Disabled cancellation stays pending, and cleanup/TSD run exactly once after operation ownership ends.
APIs: write, _write, writev, _writev, pwrite, pwritev, send, sendto, sendmsg, _sendto, _sendmsg. Paths include ordinary files, shared-memory objects, pipes, stream and datagram sockets. Positioned pipe/socket writes retain their existing errors. SCE and libSceNet gain no cancellation points. Accept/connect and multiplexed waits remain later milestones.
The write layer reuses #11872's descriptor admission, signals and cancellation/close machinery. Native transports preserve known partial progress; Windows pipe vector transfers preserve small-write atomicity. Linux preflight metadata and synchronous flushes now participate in native interruption. An interrupted two-phase O_FSYNC write can leave buffered bytes visible without durable completion; it reports success only after flushing succeeds and never replays those bytes after interrupted flushing. Direct SCE flush behavior is preserved. Restricted-right Windows pipe handles fall back to their existing native write capability when attribute queries are denied.
Stack: read
8c68efe407; transport3c360d54ee; writedc7772e6e1. Includes pinned main228cd64b53and declared read prerequisites #10817/#10755 with original commits/authorship preserved. The transport branch preserves all six exact #10943 candidate commits through6adaa5acdf. The standalone owning-TLS repaireebaac5b24and descriptor export repair4527224683belong to the read prerequisite.Transport-only comparison; write-only comparison (17 files, seven commits after transport).
Publication constraint: CONTRIBUTING allows 20 open PRs while an author has 1-19 merged; this author has 20 open/17 merged. The separate transport branch is published but cannot have an upstream PR yet. This account lacks upstream push access and upstream has no read/transport base branch. This PR still targets main, so its Files changed includes prerequisites; the linked incremental comparison is write-only. A maintainer-provided upstream base or merged prerequisites is needed for a write-only upstream Files changed view.
Overlap coordination: #11872 tracker explicitly covers #11896, #10645, #10552 and #11625. #11896 confirms reads first; external #10645/#10552 replies remain pending. #11625 source head is preserved. Write/carrier seam requests remain linked for #8463, #9019, #10645 and #10943. No agreement or combined runtime validation of those external PRs is claimed. The overlap report includes inconclusive comparisons for older base-conflicting PRs. Its live base
d13b3d7c55has no libkernel changes after the pinned main; its libc drift is an unrelated 15-line vector-algorithm addition. recvfrom/sendto are moved existing wrappers, not new duplicate exports (the public-header audit verifies ownership). The report's #11969 row compares this PR's previous head before publication, not another implementation.Tested
Current-main refresh (2026-10-28)
Merged upstream main
957a22d51f02ccacff218cdf9a27c36af7cc9aebwithout rewriting published commits; resulting head560f498196e7db59ef8b4f41463105dadb96e15a. The refreshed #11872 head21d5a977f9is an ancestor. Code merged automatically; the manual debt resolution retains main's #8916 sleep-cancellation behavior and this stack's read/write/flush/signal limitations. Original transport commits and authorship remain intact.Linux x86-64 Ubuntu 24.04 container translated on Apple Silicon, GCC 13.3, Release, bundled dependencies built from source: production libc/libkernel and focused test targets build; 536/536 tests pass, zero skips. Selection consists of all registrations using
guest_io_write_cancel_tests,guest_io_write_sync_cancel_tests,guest_io_read_cancel_tests,guest_io_descriptor_access_testsandguest_pthread_cancel_tests, run withctest --test-dir /tmp/anyps5-build -R <exact selected names> --output-on-failure -j 4. This is translated-container evidence, not native Linux/Windows or console evidence; no full-suite or fresh title run. Signal/context tests are outside this selection.Public-header audit: 368 libraries / 12,990 exports, unique declarations and umbrella coverage verified. Whitespace and conventions against actual upstream main pass (one inherited SSL debt-length warning). The required
--base origin/maincheck also ran, but the fork's origin/main is still0c6a5bd5938f; it reports upstream main's pre-existing non-Conventional revert subject97f1d41a2c, rather than an error introduced by this refresh. The livetools/pr_overlap.py --branch refresh/posix-io-cancellation-writes --repo boykopovar/AnyPS5 --jobs 4scan completed; existing unresolved overlaps/order and transport-publication constraints remain, with no new agreement claimed. Earlier evidence below remains attributed to its original revisions.Windows 11 / WinLibs GCC 15.2 Release; Linux/WSL2 imav-tao / GCC 13.3 Release. Full production libs, relinker and focused-target builds pass on both systems.
e87a337fee(zero bytes, no FUSE interrupt); the final head issues FUSE_INTERRUPT, cancels promptly and leaves zero bytes. Holding post-write synchronous classification also cancels promptly without external release and retains two buffered bytes. The private probe calls built production libraries; host libstdc++ preloading avoids unpatched libc guest-unwinder interposition in this host fixture.Fresh independent read-only MICRO/MACRO pairs reviewed the read repairs, transport composition and successive write candidates. Confirmed synchronous flush, restricted pipe and preflight metadata findings were fixed with regressions. The final pair reviewed
dc7772e6e1and found no remaining confirmed defect; both independently ran the 40 preflight cases. Earlier Windows address-waking fixture flakiness reproduces on the prerequisite baseline; this final serial suite passes.Git diff --check and python3 tools/check_conventions.py --base origin/main pass with zero errors and one inherited SSL debt-length warning. tools/pr_overlap.py completes at the exact final head. No tracked notes/logs, new third-party dependency or source comments were added.
Limits remain in library debt: deferred cancellation only; non-interruptible drivers can delay cancellation/close, descriptor replacement and stdio closure can wait, Windows pipe quota readiness retries use 1 ms, and Windows blocking PEEK|WAITALL remains unsupported. macOS runtime and console behavior are unverified.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Pull request closed