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 22:03:14-08:00
log9134430387bb99504c5813abc8b566a97ba5b1f0
tree5562e690cf8a10ba1e40e74368d135271cae0916
parent68a34df0257b4baec32617bf8c70c223849b59e2

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,