host_time: bound the Windows timer wait

Even with per-thread timers, an INFINITE wait turns any missed signal
into an indefinitely parked thread. Wait at most the requested sleep
plus 2 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shokunin
2026-10-22 11:01:16 -07:00
parent 7d06facf18
commit 33dfa2d134
+4 -2
View File
@@ -86,8 +86,10 @@ void psx_host_sleep_micros(unsigned usec)
if (hundred_ns >= 0)
hundred_ns = -1LL;
due.QuadPart = hundred_ns;
if (SetWaitableTimer(timer, &due, 0, NULL, NULL, FALSE) &&
WaitForSingleObject(timer, INFINITE) == WAIT_OBJECT_0) {
/* Bounded: a missed signal costs at most the sleep plus 2 ms, never
* an indefinitely parked thread. */
if (SetWaitableTimer(timer, &due, 0, NULL, NULL, FALSE)) {
(void)WaitForSingleObject(timer, (DWORD)(usec / 1000u) + 2u);
return;
}
}