std.Io.Threaded: fix the cancellation race

Now, before a syscall is entered, beginSyscall is called, which may
return error.Canceled. After syscall returns, whether error or success,
endSyscall is called. If the syscall returns EINTR then checkCancel is
called.

`cancelRequested` is removed from the std.Io VTable for now, with plans
to replace it with a more powerful API that allows protection against
cancellation requests.

closes #25751
This commit is contained in:
Andrew Kelley 2025-11-27 08:42:06 -08:00
parent 95f93a0b28
commit 29e418cbfb
2 changed files with 1956 additions and 1160 deletions

View file

@ -620,11 +620,6 @@ pub const VTable = struct {
result: []u8,
result_alignment: std.mem.Alignment,
) void,
/// Returns whether the current thread of execution is known to have
/// been requested to cancel.
///
/// Thread-safe.
cancelRequested: *const fn (?*anyopaque) bool,
/// When this function returns, implementation guarantees that `start` has
/// either already been called, or a unit of concurrency has been assigned

File diff suppressed because it is too large Load diff