authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-28 18:19:12-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-30 12:10:02-08:00
loga635d62a6b01e9b5b50f5256bef445f5f438a399
tree5c77fbd2dd8be220d0e648bed954a033a1fa6909
parent7ea1d02f9ea767e0d94dbea0437c4216bf69a2c9

std.Io.Threaded.batchWaitWindows: eager result sets any_done true

Thanks jacobly for finding the bug

1 files changed, 4 insertions(+), 1 deletions(-)

lib/std/Io/Threaded.zig+4-1
...@@ -2677,6 +2677,8 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa...@@ -2677,6 +2677,8 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
2677 b.user.complete_tail = complete_tail;2677 b.user.complete_tail = complete_tail;
2678 }2678 }
26792679
2680 var any_done = false;
2681
2680 while (submit_head != submit_tail) : (submit_head = submit_head.next(len)) {2682 while (submit_head != submit_tail) : (submit_head = submit_head.next(len)) {
2681 const op = ring[submit_head.index(len)];2683 const op = ring[submit_head.index(len)];
2682 const operation = &operations[op];2684 const operation = &operations[op];
...@@ -2686,6 +2688,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa...@@ -2686,6 +2688,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
2686 .noop => |*o| {2688 .noop => |*o| {
2687 _ = o.status.unstarted;2689 _ = o.status.unstarted;
2688 o.status = .{ .result = {} };2690 o.status = .{ .result = {} };
2691 any_done = true;
2689 submitComplete(ring, &complete_tail, op);2692 submitComplete(ring, &complete_tail, op);
2690 },2693 },
2691 .file_read_streaming => |*o| {2694 .file_read_streaming => |*o| {
...@@ -2693,6 +2696,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa...@@ -2693,6 +2696,7 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
2693 switch (try ntReadFile(o.file.handle, o.data, &metadata.iosb)) {2696 switch (try ntReadFile(o.file.handle, o.data, &metadata.iosb)) {
2694 .status => {2697 .status => {
2695 o.status = .{ .result = ntReadFileResult(&metadata.iosb) };2698 o.status = .{ .result = ntReadFileResult(&metadata.iosb) };
2699 any_done = true;
2696 submitComplete(ring, &complete_tail, op);2700 submitComplete(ring, &complete_tail, op);
2697 },2701 },
2698 .pending => {2702 .pending => {
...@@ -2707,7 +2711,6 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa...@@ -2707,7 +2711,6 @@ fn batchWaitWindows(t: *Threaded, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.Wa
2707 var delay_interval: windows.LARGE_INTEGER = timeoutToWindowsInterval(timeout);2711 var delay_interval: windows.LARGE_INTEGER = timeoutToWindowsInterval(timeout);
27082712
2709 while (true) {2713 while (true) {
2710 var any_done = false;
2711 var any_pending = false;2714 var any_pending = false;
2712 for (metadatas, 0..) |*metadata, op_usize| {2715 for (metadatas, 0..) |*metadata, op_usize| {
2713 if (!metadata.pending) continue;2716 if (!metadata.pending) continue;