From 62c97b745d508a5ed7011bf3b8400fde4677b839 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 30 Jan 2026 12:27:27 -0800 Subject: [PATCH] std.Io.Threaded: stop checking bytes read with END_OF_FILE --- lib/std/Io/Threaded.zig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 18f24eb40c..45184e6d59 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -8816,9 +8816,10 @@ fn fileReadStreamingPosix(file: File, data: []const []u8) File.ReadStreamingErro fn fileReadStreamingWindows(file: File, data: []const []u8) File.ReadStreamingError!usize { var io_status_block: windows.IO_STATUS_BLOCK = .{ .u = .{ .Status = .PENDING }, - .Information = 0, + .Information = undefined, }; try ntReadFile(file.handle, data, &noopApc, null, &io_status_block); + while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) { // Once we get here we must not return from the function until the // operation completes, thereby releasing reference to io_status_block. @@ -8842,10 +8843,7 @@ fn ntReadFileResult(io_status_block: *const windows.IO_STATUS_BLOCK) !usize { .PENDING => unreachable, .CANCELLED => unreachable, .SUCCESS => return io_status_block.Information, - .END_OF_FILE, .PIPE_BROKEN => { - if (io_status_block.Information == 0) return error.EndOfStream; - return io_status_block.Information; - }, + .END_OF_FILE, .PIPE_BROKEN => return error.EndOfStream, .INVALID_DEVICE_REQUEST => return error.IsDir, .LOCK_NOT_GRANTED => return error.LockViolation, .ACCESS_DENIED => return error.AccessDenied,