fix(windows-host): claim the vdisplay single-instance guard eagerly at serve startup

On-glass the lazy (first-session) claim let a second host started while the
freshly-restarted service sat idle win the mutex and ADD a monitor on the
real driver — priority backwards. The claim is now a process-global,
retryable slot (a failed claim is not memoized, so it heals once the other
instance exits), and `serve` claims it before any client can connect;
ensure_device keeps the lazy claim for standalone punktfunk1-host runs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 18:57:47 +00:00
parent 7e31020c1c
commit 3f33ed30ae
2 changed files with 31 additions and 6 deletions
+5
View File
@@ -156,6 +156,11 @@ fn real_main() -> Result<()> {
// --gamestream — the GameStream/Moonlight-compat planes too (opt-in; #5/#9 trusted-LAN caveat).
Some("serve") => {
let (mgmt_opts, native, gamestream) = parse_serve(&args[1..])?;
// Claim the pf-vdisplay single-instance guard EAGERLY, before any client connects: the
// claim is first-comer-wins, and a lazily-claiming service could lose its own machine's
// driver to a stray second host started while the service sat idle.
#[cfg(target_os = "windows")]
vdisplay::manager::claim_instance_eagerly();
gamestream::serve(mgmt_opts, native, gamestream)
}
// Print the management API's OpenAPI document (for client codegen).