std.Io.Threaded: handle TIMEOUT from NtDelayExceution

This commit is contained in:
Andrew Kelley 2026-01-29 15:03:33 -08:00
parent f8828e543a
commit 866ee4f1c5
2 changed files with 8 additions and 1 deletions

View file

@ -2761,7 +2761,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
const delay_rc = windows.ntdll.NtDelayExecution(windows.TRUE, &delay_interval);
alertable_syscall.finish();
switch (delay_rc) {
.SUCCESS => {
.SUCCESS, .TIMEOUT => {
// The thread woke due to the timeout. Although spurious
// timeouts are OK, when no deadline is passed we must not
// return `error.Timeout`.

View file

@ -594,6 +594,13 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile(
IoStatusBlock: *IO_STATUS_BLOCK,
) callconv(.winapi) NTSTATUS;
/// This function has been observed to return SUCCESS on timeout on Windows 10
/// and TIMEOUT on Wine 10.0.
///
/// This function has been observed on Windows 11 such that positive interval
/// is real time, which can cause waits to be interrupted by changing system
/// time, however negative intervals are not affected by changes to system
/// time.
pub extern "ntdll" fn NtDelayExecution(
Alertable: BOOLEAN,
DelayInterval: *const LARGE_INTEGER,