gdk: stop serialized workers after the last port user #28
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!28
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/28/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@zerkend on GitHub · 2026-11-21 18:07 UTC · original
zerkend:codex/xasync-worker-cleanup→main· +89 −1 · 1 files · 63 commits · closed without mergingLibrary / area: compat-common / XTaskQueue
A serialized port worker waited forever after its final queue user released the port. It kept both the thread and an Arc alive even with an empty queue and the port marked terminated.
Exit when the queue is empty and its user count reaches zero. Reset
serial_startedwhile holding the queue lock so a completion marker queued later can restart the worker. Termination while another user still owns the port keeps the worker available for its completion marker.Four tests cover final release, shared ownership, restarting for a late completion marker, and cancellation/marker ordering during a running callback.
Source of behaviour: the existing queue user-count and termination-marker contracts; Microsoft's MIT-licensed TaskQueue reference also tears down port execution resources: https://github.com/microsoft/libHttpClient/blob/main/Source/Task/TaskQueue.cpp . No reference code was copied.
Validation (Windows, Rust 1.100):
cargo test --locked -p compat-common --lib: 36 passed.cargo test --locked -p compat-common --test gdk_rt --test gdk_rt_terminate: 2 passed.git diff --checkpasses.Build prerequisite: validation temporarily used only the public-checkout build guards from PR #12 at
03ab331(compat-common/build.rsandsrc/online/mod.rs). Those changes are not included here. Unmodified main cannot compile compat-common because backend_data is absent.Exports changed: none. No game/console files or binaries included.
Additional Windows smoke check on PR #12 plus this fix and #26: built xhost and all eight default runtime DLLs; xhost --load-only loaded the exact staged DLLs successfully (8 pass, 0 fail, 0 skip). No game was run.
@QuentinDanblon on GitHub · 2026-11-21 21:44 UTC · original
Overlap note: #48 (mine) rewrites the queue part of
gdk/rt.rsto match libHttpClient's TaskQueue. Serialized ports there use the system thread pool with the reference single-drainer counter, so no per-port worker thread exists, and the leak this PR fixes disappears with it. #48 also runs 55 scenarios against both the emulator and the real PC xgameruntime.dll. If #48 is not taken, this PR is the minimal fix for the same leak. I can port your 4 regression scenarios into #48's suite so they keep running either way.@omonkeyz on GitHub · 2026-11-22 13:13 UTC · original
Main's history was rewritten, which auto-closed this PR (sorry for the noise). Superseded: ensure_serial already resets and exits when the last user leaves. The tests are also carried in #48.
Pull request closed