XAsync: a failing Begin fails the call, and E_PENDING does not complete #56

Manually merged
github merged 1 commit from gh-pr/56/head into gh-pr/56/base 2026-11-26 04:06:55 +00:00
Owner

@⁠gefydev on GitHub · 2026-11-22 23:03 UTC · original
gefydev:xasync-begin-complete-contract → main · +45 −3 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC

Two differences from libHttpClient's AsyncLib.cpp in how xasync.rs reports results:

  • XAsyncBegin: when the provider's Begin fails, the call is completed with that error, and XCL also returned it from XAsyncBegin. libHttpClient returns S_OK there: the caller gets the error once, through the block. A title that treats a failed XAsyncBegin as "nothing was started" and frees the block, or retries, does so on a block that was already completed (and whose completion callback may already be queued). XAsyncRun likewise when its schedule fails.
  • XAsyncComplete(b, E_PENDING, ...): libHttpClient returns without completing ("E_PENDING is special -- if you still have work to do don't complete"). XCL turned it into E_FAIL and completed the call, ending an operation the provider meant to keep running.

Both now follow libHttpClient.

This is independent of #53 (which changes XAsyncCancel in the same file); the two merge without conflicts.

Validation

  • New tests a_failing_begin_fails_the_call_not_xasyncbegin and completing_with_e_pending_does_not_complete. On main both fail (XAsyncBegin returns E_FAIL; the status after XAsyncComplete(E_PENDING) is E_FAIL instead of E_PENDING).
  • cargo test -p xcl --lib: 345 passed, 0 failed, on Windows GNU under Wine.
**@⁠gefydev** on GitHub · 2026-11-22 23:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/56) `gefydev:xasync-begin-complete-contract` → `main` · +45 −3 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC Two differences from libHttpClient's `AsyncLib.cpp` in how `xasync.rs` reports results: - `XAsyncBegin`: when the provider's Begin fails, the call is completed with that error, and XCL also returned it from `XAsyncBegin`. libHttpClient returns `S_OK` there: the caller gets the error once, through the block. A title that treats a failed `XAsyncBegin` as "nothing was started" and frees the block, or retries, does so on a block that was already completed (and whose completion callback may already be queued). `XAsyncRun` likewise when its schedule fails. - `XAsyncComplete(b, E_PENDING, ...)`: libHttpClient returns without completing ("E_PENDING is special -- if you still have work to do don't complete"). XCL turned it into `E_FAIL` and completed the call, ending an operation the provider meant to keep running. Both now follow libHttpClient. This is independent of #53 (which changes `XAsyncCancel` in the same file); the two merge without conflicts. ## Validation - New tests `a_failing_begin_fails_the_call_not_xasyncbegin` and `completing_with_e_pending_does_not_complete`. On `main` both fail (`XAsyncBegin` returns `E_FAIL`; the status after `XAsyncComplete(E_PENDING)` is `E_FAIL` instead of `E_PENDING`). - `cargo test -p xcl --lib`: 345 passed, 0 failed, on Windows GNU under Wine.
As in libHttpClient's AsyncLib.cpp:

- XAsyncBegin returns S_OK when the provider's Begin fails: the call is
  completed with that error, and the caller gets it once, through the
  block. XCL returned the error as well, so a caller saw it both as the
  return value and in its completion. XAsyncRun likewise when its
  schedule fails.
- XAsyncComplete with E_PENDING does nothing (the provider still has
  work to do). XCL completed the call with E_FAIL.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:06:55 +00:00
github manually merged commit 2ca2b73ba7 into gh-pr/56/base 2026-11-26 04:06:55 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 09:45 UTC · original

Merged (daa27b0). Follow-up in e38cb65: XAsyncSchedule on a terminated queue returns E_ABORT like XTaskQueueSubmitDelayedCallback after #57, so with this PR such an XAsyncRun / XCL operation fails through the block and its work never runs (test async_work_on_a_terminated_queue_is_aborted).

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!

**@⁠ivall** on GitHub · 2026-11-23 09:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/56#issuecomment-7097052801) Merged (daa27b0). Follow-up in e38cb65: `XAsyncSchedule` on a terminated queue returns `E_ABORT` like `XTaskQueueSubmitDelayedCallback` after #57, so with this PR such an `XAsyncRun` / XCL operation fails through the block and its work never runs (test `async_work_on_a_terminated_queue_is_aborted`). 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.