XAsync: cancellation is the provider's to do #52

Merged
gefydev merged 1 commit from upstream-pr/53 into main 2026-11-23 09:44:41 +00:00
gefydev commented 2026-11-22 22:41:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-22T22:41:17Z.


XAsyncCancel (xasync.rs) calls the provider with XAsyncOp::Cancel and then completes the block with E_ABORT itself. libHttpClient's XAsyncCancel (Source/Task/AsyncLib.cpp) only calls the provider. A provider that supports cancelling completes with E_ABORT, now or later. One that doesn't, like the provider behind XAsyncRun, which ignores Cancel, runs to its normal end.

Forcing the completion has two effects in XCL's fallback (no Gaming Services):

  • An XAsyncRun or a provider that ignores Cancel ends with E_ABORT, and work that hasn't started yet never runs.
  • E_ABORT has no payload, so XAsyncComplete runs the provider's Cleanup right away, even if its DoWork is still running on the queue. For XCL's own operations (begin_with), that Cleanup frees the Payload. The running work then writes its result into it when it returns (*p.result.lock() = Some(r) in payload_provider).

XAsyncCancel now only calls the provider. XCL's payload_provider already ignores Cancel, so XCL's own operations finish normally, as XAsyncRun does in libHttpClient.

Validation

  • cancel_is_the_providers_to_do: a provider that ignores Cancel stays pending and completes normally; one that completes in Cancel ends with E_ABORT. The first half fails on main.
  • cancel_lets_running_work_finish: cancels a begin_with operation while its work is running, then reads the work's result. On main, the status is E_ABORT right after the cancel.
  • cargo test -p xcl --lib: 341 passed, 0 failed, on Windows GNU under Wine.
<!-- greyfinch-sync:ivall/xcl:issue:6548756113 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/53). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-22T22:41:17Z. --- `XAsyncCancel` (`xasync.rs`) calls the provider with `XAsyncOp::Cancel` and then completes the block with `E_ABORT` itself. libHttpClient's `XAsyncCancel` (`Source/Task/AsyncLib.cpp`) only calls the provider. A provider that supports cancelling completes with `E_ABORT`, now or later. One that doesn't, like the provider behind `XAsyncRun`, which ignores `Cancel`, runs to its normal end. Forcing the completion has two effects in XCL's fallback (no Gaming Services): - An `XAsyncRun` or a provider that ignores `Cancel` ends with `E_ABORT`, and work that hasn't started yet never runs. - `E_ABORT` has no payload, so `XAsyncComplete` runs the provider's `Cleanup` right away, even if its `DoWork` is still running on the queue. For XCL's own operations (`begin_with`), that `Cleanup` frees the `Payload`. The running work then writes its result into it when it returns (`*p.result.lock() = Some(r)` in `payload_provider`). `XAsyncCancel` now only calls the provider. XCL's `payload_provider` already ignores `Cancel`, so XCL's own operations finish normally, as `XAsyncRun` does in libHttpClient. ## Validation - `cancel_is_the_providers_to_do`: a provider that ignores `Cancel` stays pending and completes normally; one that completes in `Cancel` ends with `E_ABORT`. The first half fails on `main`. - `cancel_lets_running_work_finish`: cancels a `begin_with` operation while its work is running, then reads the work's result. On `main`, the status is `E_ABORT` right after the cancel. - `cargo test -p xcl --lib`: 341 passed, 0 failed, on Windows GNU under Wine.
upstream-sync closed this pull request 2026-11-24 06:56:56 +00:00
ivall commented 2026-11-24 07:00:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T09:45:13Z.


Merged in 848e740 (merge a963568). Matches libHttpClient's XAsyncCancel; the payload freed under a running DoWork was a real hazard in the fallback path.

Tested on Windows 11 (RX 9070): cargo test --workspace green (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7097052019 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/53#issuecomment-7097052019). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T09:45:13Z. --- Merged in 848e740 (merge a963568). Matches libHttpClient's `XAsyncCancel`; the payload freed under a running DoWork was a real hazard in the fallback path. Tested on Windows 11 (RX 9070): `cargo test --workspace` green (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!52
No description provided.