Skip to content

XAsync: publish the final status before removing a completed call - #23

Open
Jineggegg wants to merge 1 commit into
readmet3xt-lab:mainfrom
Jineggegg:xasync-publish-before-remove
Open

Jineggegg wants to merge 1 commit into
readmet3xt-lab:mainfrom
Jineggegg:xasync-publish-before-remove

Conversation

@Jineggegg

Copy link
Copy Markdown

What this fixes

An error or zero-size completion removed its call before provider cleanup ran. A blocking status query (XAsyncGetStatus with wait) could miss the call during cleanup and read E_PENDING instead of the work result.

This change:

  • Keeps the claimed call registered and visible to waiters throughout the unlocked provider cleanup, and excludes it from new work while it completes.
  • Publishes the status first, then removes the entry under the registry lock.
  • Records the call result in the call itself, so existing waiters get the real result even if the block is reused for another call.
  • Adds a regression test that pauses cleanup mid-way and checks a waiting status query still returns the completion result (E_ABORT), not E_PENDING.

Testing

  • cargo check -p victory-hle --lib: clean (only pre-existing warnings elsewhere).
  • cargo test -p victory-hle --lib xasync: 13 passed, 0 failed, including the new status_waits_for_cleanup_to_publish_the_result test.
  • The same fix was verified on an RTX 5090 in Jineggegg/VIctory round 1 (deterministic race test plus the full XAsync suite).

Origin

Adapted from Jineggegg/VIctory e071177 (round-1 item #3). Foxhound had no claimed flag — its first-completion guard was the done lock — so this port brings the claimed flag in, and completing, cancelling and scheduled work now agree on which calls are still live.

An error or zero-size completion removed its call before provider cleanup. A blocking status query could miss the call during cleanup and read E_PENDING instead of the work result.

Keep the claimed call available to waiters during unlocked cleanup, exclude it from new work, then publish the status and remove the entry under the registry lock. Return the captured call result to existing waiters even if the block is reused. Exercise the race deterministically with a paused cleanup.

Adapted from Jineggegg/VIctory e071177. Foxhound had no claimed flag: its first-completion guard was the done lock. This port brings the claimed flag in, so completing, cancelling and scheduled work all agree on which calls are still live.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant