Repository navigation
Conversation
BaggyALPHA
left a comment
There was a problem hiding this comment.
The three new shared-port tests passed independently on Windows. A synthetic reentrant-dispatch test found one remaining cancellation case. Two manual queues share their ports. Queue B has a work callback and a completion callback pending, and queue A has a completion callback pending. While B is terminating, its canceled work callback dispatches the shared completion port through A. B's completion then receives canceled=false, and A's completion correctly receives canceled=false.
The termination flag is already set on B when this happens. Port::take drops the submitting queue identity, and XTaskQueueDispatch always supplies false. The dispatcher needs to read the submitting queue's cancellation state when it invokes the callback, including on the serialized worker path. Microsoft's libHttpClient reference implementation does this in DrainOneItem using the entry's port context. Keeping shared cancellation state with the queued entry would let dispatch distinguish the two callbacks.
AI-assisted (Codex). Tested with synthetic callbacks.
catminou4
left a comment
There was a problem hiding this comment.
Static review only: Windows-only code (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff.
XTaskQueueTerminate now cancels only the terminating queue's own tasks on shared ports: submit() takes an owner id + terminated flag, take_owned() collects only that owner's tasks, and two tests cover manual and serialized shared ports (record/hold extern callbacks log cancellation). Previously terminating one queue could cancel another queue's tasks on the same port — a real correctness fix for shared-port titles.
|
I independently tested exact head A follow-up that carries the submitting queue's cancellation state into both dispatch paths passed all 13 isolated Linux tests, including the three API cases, which also passed 25 repeats. The exact PR plus follow-up passed Windows-target checks for AI-assisted using Codex. |
dda166c to
0ef707e
Compare
Fixes #1637.
Ports the verified fix from @AndyLatimer's fork (commit 47e61a2 by Manuel Pérez), applied unchanged onto
ffe310e; the commit keeps its original author.Summary
XTaskQueueTerminatedrained every port unconditionally, so terminating one queue cancelled the queued callbacks and pendingXAsyncwork of every other queue sharing that port (manual, serialized, or composite queues mapping both ports to one shared port).Queuegets a monotonic id, shared acrossXTaskQueueDuplicateHandleand distinct for composite queues.Port::take_ownedremoves only the terminating queue's tasks, keeping other queues' order.Port::submitre-checksqueue.terminatedunder the port lock, so a task racing with termination is cancelled instead of enqueued after the drain.Tests
Three new synthetic tests (also in the commit): shared manual port with duplicate handles and a composite queue on one port, shared serialized port, and pending
XAsyncRuncalls across composite queues. All pass with the fix and fail before it.Validation
cargo test -p victory-hle --locked -- --test-threads=1— passed (97 unit tests and 1 integration test).cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings— passed.cargo xtask policy— passed (154 files).rustfmt --edition 2024 --checkon the file reports only pre-existing hunks in untouched code.