authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-16 21:21:56-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-30 12:10:01-08:00
logf4140f6e8b0aae1dc2e449852a739a14908b2c60
tree199e38677813e9a41e6152f16fa0712a19c4e059
parentafd91234a1214e58cd07ea99ba7fe51675a08b89

std.Io.Threaded: fix batchWait impl


1 files changed, 7 insertions(+), 10 deletions(-)

lib/std/Io/Threaded.zig+7-10
...@@ -2524,6 +2524,7 @@ fn batchWait(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout) Io.Batch....@@ -2524,6 +2524,7 @@ fn batchWait(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.
2524 try operate(t, &operations[op]);2524 try operate(t, &operations[op]);
2525 ring[complete_tail.index(len)] = op;2525 ring[complete_tail.index(len)] = op;
2526 complete_tail = complete_tail.next(len);2526 complete_tail = complete_tail.next(len);
2527 poll_i = 0;
2527 return;2528 return;
2528 },2529 },
2529 else => {},2530 else => {},
...@@ -2548,24 +2549,20 @@ fn batchWait(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout) Io.Batch....@@ -2548,24 +2549,20 @@ fn batchWait(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout) Io.Batch.
2548 if (deadline == null) continue;2549 if (deadline == null) continue;
2549 return error.Timeout;2550 return error.Timeout;
2550 }2551 }
2551 var canceled = false;2552 while (poll_i != 0) {
2552 for (poll_buffer[0..poll_i], map_buffer[0..poll_i]) |*poll_fd, op| {2553 poll_i -= 1;
2554 const poll_fd = &poll_buffer[poll_i];
2555 const op = map_buffer[poll_i];
2553 if (poll_fd.revents == 0) {2556 if (poll_fd.revents == 0) {
2554 submit_head = submit_head.prev(len);2557 submit_head = submit_head.prev(len);
2555 ring[submit_head.index(len)] = op;2558 ring[submit_head.index(len)] = op;
2556 } else {2559 } else {
2557 operate(t, &operations[op]) catch |err| switch (err) {2560 try operate(t, &operations[op]);
2558 error.Canceled => {
2559 canceled = true;
2560 continue;
2561 },
2562 };
2563 ring[complete_tail.index(len)] = op;2561 ring[complete_tail.index(len)] = op;
2564 complete_tail = complete_tail.next(len);2562 complete_tail = complete_tail.next(len);
2565 }2563 }
2566 }2564 }
2567 poll_i = 0;2565 return;
2568 return if (canceled) error.Canceled;
2569 },2566 },
2570 .INTR => continue,2567 .INTR => continue,
2571 else => return error.ConcurrencyUnavailable,2568 else => return error.ConcurrencyUnavailable,