authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-29 15:03:33-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-30 22:03:14-08:00
log866ee4f1c52ae3e5a8ac95c9c5e61b019aa5eadb
tree8e9d736fe53529aeb48aa7ef11319c0f6bdfae47
parentf8828e543ab6331395ef4d9f9a2b53770028b6b2

std.Io.Threaded: handle TIMEOUT from NtDelayExceution


2 files changed, 8 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+1-1
......@@ -2761,7 +2761,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
27612761 const delay_rc = windows.ntdll.NtDelayExecution(windows.TRUE, &delay_interval);
27622762 alertable_syscall.finish();
27632763 switch (delay_rc) {
2764 .SUCCESS => {
2764 .SUCCESS, .TIMEOUT => {
27652765 // The thread woke due to the timeout. Although spurious
27662766 // timeouts are OK, when no deadline is passed we must not
27672767 // return `error.Timeout`.
lib/std/os/windows/ntdll.zig+7
......@@ -594,6 +594,13 @@ pub extern "ntdll" fn NtCancelSynchronousIoFile(
594594 IoStatusBlock: *IO_STATUS_BLOCK,
595595) callconv(.winapi) NTSTATUS;
596596
597/// This function has been observed to return SUCCESS on timeout on Windows 10
598/// and TIMEOUT on Wine 10.0.
599///
600/// This function has been observed on Windows 11 such that positive interval
601/// is real time, which can cause waits to be interrupted by changing system
602/// time, however negative intervals are not affected by changes to system
603/// time.
597604pub extern "ntdll" fn NtDelayExecution(
598605 Alertable: BOOLEAN,
599606 DelayInterval: *const LARGE_INTEGER,