std.Io.Threaded: fix bad use of AlertableSyscall

The defer would cause two problems:
1. keeping the state active during call to NtCancelIoFile
2. invalid state transition. after canceled is returned from
   checkCancel, new status is already canceled. calling finish after
   that is illegal.
This commit is contained in:
Andrew Kelley
2026-01-27 11:33:07 -08:00
parent efa502a1cd
commit 2fb224cb84
+1 -1
View File
@@ -8689,7 +8689,6 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
return e;
},
};
defer alertable_syscall.finish();
waitForApcOrAlert();
while (@atomicLoad(windows.NTSTATUS, &io_status_block.u.Status, .acquire) == .PENDING) {
alertable_syscall.checkCancel() catch |err| switch (err) {
@@ -8700,6 +8699,7 @@ fn fileReadStreamingWindows(file: File, data: []const []u8) File.Reader.Error!us
};
waitForApcOrAlert();
}
alertable_syscall.finish();
},
} else |err| return err;
return ntReadFileResult(&io_status_block);