Skip to content

Improve --server fallback robustness - #2205

Merged
oferchen merged 2 commits into
masterfrom
ensure-server-matches-upstream-sender-receiver
Nov 21, 2025
Merged

oferchen merged 2 commits into
masterfrom
ensure-server-matches-upstream-sender-receiver

Conversation

@oferchen

@oferchen oferchen commented Nov 21, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • handle channel interruptions and propagate signal-based exits when delegating --server to the fallback binary
  • add coverage for signal exit code mapping in the server-mode tests

Testing

  • cargo test --package cli server_mode

[Codex Task](

@oferchen
oferchen merged commit 80a33e3 into master Nov 21, 2025
@oferchen
oferchen deleted the ensure-server-matches-upstream-sender-receiver branch November 21, 2025 23:53
oferchen added a commit that referenced this pull request May 17, 2026
) (#4227)

Document the current io_uring abort path, ASYNC_CANCEL semantics, a wiring
sketch, the completion-vs-cancel race, verification strategy, and the
recommendation to defer until either async io_uring lands or an abort-leak
bug is reported. Every helper today follows submit + wait + drain inside a
single function, so no in-flight SQE outlives the caller's stack frame and
there is nothing to cancel under the present architecture.
oferchen added a commit that referenced this pull request May 17, 2026
Scaffold the `IORING_OP_ASYNC_CANCEL` primitive now that the async daemon
listener (#4278), session ring pool (#4275), and per-thread rings (#4288)
have landed code paths that keep SQEs in-flight across abort decision
points. Until now, every io_uring helper followed `submit + wait + drain`
and never needed cancellation; the deferred design at
`docs/design/iouring-async-cancel.md` documented the trigger condition
this commit fulfils.

- New module `crates/fast_io/src/io_uring/cancel.rs` (Linux + `io_uring`
  feature gated):
  - `cancel_by_user_data(&mut IoUring, u64) -> io::Result<CancelOutcome>`
    submits a single `IORING_OP_ASYNC_CANCEL` SQE matched against the
    target SQE's `user_data` tag and reports the kernel's terminal
    outcome.
  - `cancel_all_by_fd(&mut IoUring, RawFd) -> io::Result<usize>` uses
    `IORING_ASYNC_CANCEL_FD | IORING_ASYNC_CANCEL_ALL` (kernel 5.19+) to
    cancel every in-flight SQE that touches the given fd.
  - `enum CancelOutcome { Cancelled, NotFound, AlreadyComplete }` maps
    the three race outcomes (`0`, `-ENOENT`, `-EALREADY`) to typed
    variants so callers route into the correct buffer reclaim path.
- Added `OpTag::Cancel` so cancel CQEs are demuxable from target CQEs
  sharing the same CQ; updated `SharedRing::reap` to flag a Cancel CQE
  as an InvalidData misuse rather than silently drop it.
- Added cross-platform UAPI constants `IORING_OP_ASYNC_CANCEL`,
  `ASYNC_CANCEL_MIN_KERNEL`, `ASYNC_CANCEL_FD_MIN_KERNEL` in
  `io_uring_common`, mirrored in the non-Linux stub.
- Stub module in `io_uring_stub.rs` returns `Unsupported` so
  cross-platform callers compile without `cfg` branching.
- Re-exported the primitive from the `io_uring` module and `CancelOutcome`
  from the crate root.
- Unit coverage:
  - `cancel_by_user_data_cancels_inflight_poll` submits a PollAdd on an
    empty pipe, cancels it, asserts `CancelOutcome::Cancelled`.
  - `cancel_by_user_data_reports_not_found_for_unknown_tag` asserts
    `-ENOENT` is folded into `NotFound`, not surfaced as an error.
  - `cancel_all_by_fd_cancels_inflight_polls` cancels two PollAdds
    bulk-by-fd (skips cleanly on kernels < 5.19).
  - `CancelOutcome::from_cqe_result` decode parity for each variant
    plus error surface for other errnos.
  - Stub mirrors assert `Unsupported` and constant parity.
oferchen added a commit that referenced this pull request May 18, 2026
) (#4227)

Document the current io_uring abort path, ASYNC_CANCEL semantics, a wiring
sketch, the completion-vs-cancel race, verification strategy, and the
recommendation to defer until either async io_uring lands or an abort-leak
bug is reported. Every helper today follows submit + wait + drain inside a
single function, so no in-flight SQE outlives the caller's stack frame and
there is nothing to cancel under the present architecture.
oferchen added a commit that referenced this pull request May 18, 2026
Scaffold the `IORING_OP_ASYNC_CANCEL` primitive now that the async daemon
listener (#4278), session ring pool (#4275), and per-thread rings (#4288)
have landed code paths that keep SQEs in-flight across abort decision
points. Until now, every io_uring helper followed `submit + wait + drain`
and never needed cancellation; the deferred design at
`docs/design/iouring-async-cancel.md` documented the trigger condition
this commit fulfils.

- New module `crates/fast_io/src/io_uring/cancel.rs` (Linux + `io_uring`
  feature gated):
  - `cancel_by_user_data(&mut IoUring, u64) -> io::Result<CancelOutcome>`
    submits a single `IORING_OP_ASYNC_CANCEL` SQE matched against the
    target SQE's `user_data` tag and reports the kernel's terminal
    outcome.
  - `cancel_all_by_fd(&mut IoUring, RawFd) -> io::Result<usize>` uses
    `IORING_ASYNC_CANCEL_FD | IORING_ASYNC_CANCEL_ALL` (kernel 5.19+) to
    cancel every in-flight SQE that touches the given fd.
  - `enum CancelOutcome { Cancelled, NotFound, AlreadyComplete }` maps
    the three race outcomes (`0`, `-ENOENT`, `-EALREADY`) to typed
    variants so callers route into the correct buffer reclaim path.
- Added `OpTag::Cancel` so cancel CQEs are demuxable from target CQEs
  sharing the same CQ; updated `SharedRing::reap` to flag a Cancel CQE
  as an InvalidData misuse rather than silently drop it.
- Added cross-platform UAPI constants `IORING_OP_ASYNC_CANCEL`,
  `ASYNC_CANCEL_MIN_KERNEL`, `ASYNC_CANCEL_FD_MIN_KERNEL` in
  `io_uring_common`, mirrored in the non-Linux stub.
- Stub module in `io_uring_stub.rs` returns `Unsupported` so
  cross-platform callers compile without `cfg` branching.
- Re-exported the primitive from the `io_uring` module and `CancelOutcome`
  from the crate root.
- Unit coverage:
  - `cancel_by_user_data_cancels_inflight_poll` submits a PollAdd on an
    empty pipe, cancels it, asserts `CancelOutcome::Cancelled`.
  - `cancel_by_user_data_reports_not_found_for_unknown_tag` asserts
    `-ENOENT` is folded into `NotFound`, not surfaced as an error.
  - `cancel_all_by_fd_cancels_inflight_polls` cancels two PollAdds
    bulk-by-fd (skips cleanly on kernels < 5.19).
  - `CancelOutcome::from_cqe_result` decode parity for each variant
    plus error surface for other errnos.
  - Stub mirrors assert `Unsupported` and constant parity.
oferchen added a commit that referenced this pull request May 18, 2026
) (#4227)

Document the current io_uring abort path, ASYNC_CANCEL semantics, a wiring
sketch, the completion-vs-cancel race, verification strategy, and the
recommendation to defer until either async io_uring lands or an abort-leak
bug is reported. Every helper today follows submit + wait + drain inside a
single function, so no in-flight SQE outlives the caller's stack frame and
there is nothing to cancel under the present architecture.
oferchen added a commit that referenced this pull request May 18, 2026
Scaffold the `IORING_OP_ASYNC_CANCEL` primitive now that the async daemon
listener (#4278), session ring pool (#4275), and per-thread rings (#4288)
have landed code paths that keep SQEs in-flight across abort decision
points. Until now, every io_uring helper followed `submit + wait + drain`
and never needed cancellation; the deferred design at
`docs/design/iouring-async-cancel.md` documented the trigger condition
this commit fulfils.

- New module `crates/fast_io/src/io_uring/cancel.rs` (Linux + `io_uring`
  feature gated):
  - `cancel_by_user_data(&mut IoUring, u64) -> io::Result<CancelOutcome>`
    submits a single `IORING_OP_ASYNC_CANCEL` SQE matched against the
    target SQE's `user_data` tag and reports the kernel's terminal
    outcome.
  - `cancel_all_by_fd(&mut IoUring, RawFd) -> io::Result<usize>` uses
    `IORING_ASYNC_CANCEL_FD | IORING_ASYNC_CANCEL_ALL` (kernel 5.19+) to
    cancel every in-flight SQE that touches the given fd.
  - `enum CancelOutcome { Cancelled, NotFound, AlreadyComplete }` maps
    the three race outcomes (`0`, `-ENOENT`, `-EALREADY`) to typed
    variants so callers route into the correct buffer reclaim path.
- Added `OpTag::Cancel` so cancel CQEs are demuxable from target CQEs
  sharing the same CQ; updated `SharedRing::reap` to flag a Cancel CQE
  as an InvalidData misuse rather than silently drop it.
- Added cross-platform UAPI constants `IORING_OP_ASYNC_CANCEL`,
  `ASYNC_CANCEL_MIN_KERNEL`, `ASYNC_CANCEL_FD_MIN_KERNEL` in
  `io_uring_common`, mirrored in the non-Linux stub.
- Stub module in `io_uring_stub.rs` returns `Unsupported` so
  cross-platform callers compile without `cfg` branching.
- Re-exported the primitive from the `io_uring` module and `CancelOutcome`
  from the crate root.
- Unit coverage:
  - `cancel_by_user_data_cancels_inflight_poll` submits a PollAdd on an
    empty pipe, cancels it, asserts `CancelOutcome::Cancelled`.
  - `cancel_by_user_data_reports_not_found_for_unknown_tag` asserts
    `-ENOENT` is folded into `NotFound`, not surfaced as an error.
  - `cancel_all_by_fd_cancels_inflight_polls` cancels two PollAdds
    bulk-by-fd (skips cleanly on kernels < 5.19).
  - `CancelOutcome::from_cqe_result` decode parity for each variant
    plus error surface for other errnos.
  - Stub mirrors assert `Unsupported` and constant parity.
oferchen added a commit that referenced this pull request Aug 24, 2026
) (#4227)

Document the current io_uring abort path, ASYNC_CANCEL semantics, a wiring
sketch, the completion-vs-cancel race, verification strategy, and the
recommendation to defer until either async io_uring lands or an abort-leak
bug is reported. Every helper today follows submit + wait + drain inside a
single function, so no in-flight SQE outlives the caller's stack frame and
there is nothing to cancel under the present architecture.
oferchen added a commit that referenced this pull request Aug 24, 2026
Scaffold the `IORING_OP_ASYNC_CANCEL` primitive now that the async daemon
listener (#4278), session ring pool (#4275), and per-thread rings (#4288)
have landed code paths that keep SQEs in-flight across abort decision
points. Until now, every io_uring helper followed `submit + wait + drain`
and never needed cancellation; the deferred design at
`docs/design/iouring-async-cancel.md` documented the trigger condition
this commit fulfils.

- New module `crates/fast_io/src/io_uring/cancel.rs` (Linux + `io_uring`
  feature gated):
  - `cancel_by_user_data(&mut IoUring, u64) -> io::Result<CancelOutcome>`
    submits a single `IORING_OP_ASYNC_CANCEL` SQE matched against the
    target SQE's `user_data` tag and reports the kernel's terminal
    outcome.
  - `cancel_all_by_fd(&mut IoUring, RawFd) -> io::Result<usize>` uses
    `IORING_ASYNC_CANCEL_FD | IORING_ASYNC_CANCEL_ALL` (kernel 5.19+) to
    cancel every in-flight SQE that touches the given fd.
  - `enum CancelOutcome { Cancelled, NotFound, AlreadyComplete }` maps
    the three race outcomes (`0`, `-ENOENT`, `-EALREADY`) to typed
    variants so callers route into the correct buffer reclaim path.
- Added `OpTag::Cancel` so cancel CQEs are demuxable from target CQEs
  sharing the same CQ; updated `SharedRing::reap` to flag a Cancel CQE
  as an InvalidData misuse rather than silently drop it.
- Added cross-platform UAPI constants `IORING_OP_ASYNC_CANCEL`,
  `ASYNC_CANCEL_MIN_KERNEL`, `ASYNC_CANCEL_FD_MIN_KERNEL` in
  `io_uring_common`, mirrored in the non-Linux stub.
- Stub module in `io_uring_stub.rs` returns `Unsupported` so
  cross-platform callers compile without `cfg` branching.
- Re-exported the primitive from the `io_uring` module and `CancelOutcome`
  from the crate root.
- Unit coverage:
  - `cancel_by_user_data_cancels_inflight_poll` submits a PollAdd on an
    empty pipe, cancels it, asserts `CancelOutcome::Cancelled`.
  - `cancel_by_user_data_reports_not_found_for_unknown_tag` asserts
    `-ENOENT` is folded into `NotFound`, not surfaced as an error.
  - `cancel_all_by_fd_cancels_inflight_polls` cancels two PollAdds
    bulk-by-fd (skips cleanly on kernels < 5.19).
  - `CancelOutcome::from_cqe_result` decode parity for each variant
    plus error surface for other errnos.
  - Stub mirrors assert `Unsupported` and constant parity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant