authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-19 16:48:35-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:11-08:00
log64de4a7371e3851dddf39c608d08d480395bb0ab
tree2d323d592f66dbe273199190ccd7894500e03e90
parenta8088306f6223b07ad9b7ae37486bcc9e0ac08c9

std.Io.Threaded: remove handling of ECANCELED

The only known situation in which this occurs is when using musl with the undocumented extension PTHREAD_CANCEL_MASKED, causing the next syscall to return ECANCELED. However zig std lib does not use this mechanism, even when targeting musl libc because it would require each async task to be on a fresh pthread. For the same reason, if third party code were to cause ECANCELED to be returned from any of these syscalls, it would cause subsequent tasks to be incorrectly canceled since they cannot be rearmed. Thus, this Io implementation cannot handle this error code correctly, expecting never to receive it.

1 files changed, 1 insertions(+), 112 deletions(-)

lib/std/Io/Threaded.zig+1-112
......@@ -216,13 +216,6 @@ const Thread = struct {
216216 ) orelse return;
217217 }
218218
219 fn endSyscallCanceled(thread: *Thread) Io.Cancelable {
220 if (thread.current_closure) |closure| {
221 @atomicStore(CancelStatus, &closure.cancel_status, .acknowledged, .release);
222 }
223 return error.Canceled;
224 }
225
226219 fn currentSignalId() SignaleeId {
227220 return if (std.Thread.use_pthreads) std.c.pthread_self() else std.Thread.getCurrentId();
228221 }
......@@ -1531,7 +1524,6 @@ fn dirCreateDirPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, perm
15311524 try current_thread.checkCancel();
15321525 continue;
15331526 },
1534 .CANCELED => return current_thread.endSyscallCanceled(),
15351527 else => |e| {
15361528 current_thread.endSyscall();
15371529 switch (e) {
......@@ -1574,7 +1566,6 @@ fn dirCreateDirWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permi
15741566 try current_thread.checkCancel();
15751567 continue;
15761568 },
1577 .CANCELED => return current_thread.endSyscallCanceled(),
15781569 else => |e| {
15791570 current_thread.endSyscall();
15801571 switch (e) {
......@@ -1875,7 +1866,6 @@ fn dirStatFileLinux(
18751866 try current_thread.checkCancel();
18761867 continue;
18771868 },
1878 .CANCELED => return current_thread.endSyscallCanceled(),
18791869 else => |e| {
18801870 current_thread.endSyscall();
18811871 switch (e) {
......@@ -1925,7 +1915,6 @@ fn posixStatFile(current_thread: *Thread, dir_fd: posix.fd_t, sub_path: [:0]cons
19251915 try current_thread.checkCancel();
19261916 continue;
19271917 },
1928 .CANCELED => return current_thread.endSyscallCanceled(),
19291918 else => |e| {
19301919 current_thread.endSyscall();
19311920 switch (e) {
......@@ -1986,7 +1975,6 @@ fn dirStatFileWasi(
19861975 try current_thread.checkCancel();
19871976 continue;
19881977 },
1989 .CANCELED => return current_thread.endSyscallCanceled(),
19901978 else => |e| {
19911979 current_thread.endSyscall();
19921980 switch (e) {
......@@ -2026,7 +2014,6 @@ fn fileLength(userdata: ?*anyopaque, file: File) File.LengthError!u64 {
20262014 try current_thread.checkCancel();
20272015 continue;
20282016 },
2029 .CANCELED => return current_thread.endSyscallCanceled(),
20302017 else => |e| {
20312018 current_thread.endSyscall();
20322019 switch (e) {
......@@ -2077,7 +2064,6 @@ fn fileStatPosix(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
20772064 try current_thread.checkCancel();
20782065 continue;
20792066 },
2080 .CANCELED => return current_thread.endSyscallCanceled(),
20812067 else => |e| {
20822068 current_thread.endSyscall();
20832069 switch (e) {
......@@ -2130,7 +2116,6 @@ fn fileStatLinux(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
21302116 try current_thread.checkCancel();
21312117 continue;
21322118 },
2133 .CANCELED => return current_thread.endSyscallCanceled(),
21342119 else => |e| {
21352120 current_thread.endSyscall();
21362121 switch (e) {
......@@ -2215,7 +2200,6 @@ fn fileStatWasi(userdata: ?*anyopaque, file: File) File.StatError!File.Stat {
22152200 try current_thread.checkCancel();
22162201 continue;
22172202 },
2218 .CANCELED => return current_thread.endSyscallCanceled(),
22192203 else => |e| {
22202204 current_thread.endSyscall();
22212205 switch (e) {
......@@ -2267,7 +2251,6 @@ fn dirAccessPosix(
22672251 try current_thread.checkCancel();
22682252 continue;
22692253 },
2270 .CANCELED => return current_thread.endSyscallCanceled(),
22712254 else => |e| {
22722255 current_thread.endSyscall();
22732256 switch (e) {
......@@ -2317,7 +2300,6 @@ fn dirAccessWasi(
23172300 try current_thread.checkCancel();
23182301 continue;
23192302 },
2320 .CANCELED => return current_thread.endSyscallCanceled(),
23212303 else => |e| {
23222304 current_thread.endSyscall();
23232305 switch (e) {
......@@ -2464,7 +2446,6 @@ fn dirCreateFilePosix(
24642446 try current_thread.checkCancel();
24652447 continue;
24662448 },
2467 .CANCELED => return current_thread.endSyscallCanceled(),
24682449 else => |e| {
24692450 current_thread.endSyscall();
24702451 switch (e) {
......@@ -2519,7 +2500,6 @@ fn dirCreateFilePosix(
25192500 try current_thread.checkCancel();
25202501 continue;
25212502 },
2522 .CANCELED => return current_thread.endSyscallCanceled(),
25232503 else => |e| {
25242504 current_thread.endSyscall();
25252505 switch (e) {
......@@ -2686,7 +2666,6 @@ fn dirCreateFileWasi(
26862666 try current_thread.checkCancel();
26872667 continue;
26882668 },
2689 .CANCELED => return current_thread.endSyscallCanceled(),
26902669 else => |e| {
26912670 current_thread.endSyscall();
26922671 switch (e) {
......@@ -2783,7 +2762,6 @@ fn dirOpenFilePosix(
27832762 try current_thread.checkCancel();
27842763 continue;
27852764 },
2786 .CANCELED => return current_thread.endSyscallCanceled(),
27872765 else => |e| {
27882766 current_thread.endSyscall();
27892767 switch (e) {
......@@ -2849,7 +2827,6 @@ fn dirOpenFilePosix(
28492827 try current_thread.checkCancel();
28502828 continue;
28512829 },
2852 .CANCELED => return current_thread.endSyscallCanceled(),
28532830 else => |e| {
28542831 current_thread.endSyscall();
28552832 switch (e) {
......@@ -2878,7 +2855,6 @@ fn dirOpenFilePosix(
28782855 try current_thread.checkCancel();
28792856 continue;
28802857 },
2881 .CANCELED => return current_thread.endSyscallCanceled(),
28822858 else => |err| {
28832859 current_thread.endSyscall();
28842860 return posix.unexpectedErrno(err);
......@@ -2899,7 +2875,6 @@ fn dirOpenFilePosix(
28992875 try current_thread.checkCancel();
29002876 continue;
29012877 },
2902 .CANCELED => return current_thread.endSyscallCanceled(),
29032878 else => |err| {
29042879 current_thread.endSyscall();
29052880 return posix.unexpectedErrno(err);
......@@ -3104,7 +3079,6 @@ fn dirOpenFileWasi(
31043079 try current_thread.checkCancel();
31053080 continue;
31063081 },
3107 .CANCELED => return current_thread.endSyscallCanceled(),
31083082 else => |e| {
31093083 current_thread.endSyscall();
31103084 switch (e) {
......@@ -3203,7 +3177,6 @@ fn dirOpenDirPosix(
32033177 try current_thread.checkCancel();
32043178 continue;
32053179 },
3206 .CANCELED => return current_thread.endSyscallCanceled(),
32073180 else => |e| {
32083181 current_thread.endSyscall();
32093182 switch (e) {
......@@ -3256,7 +3229,6 @@ fn dirOpenDirHaiku(
32563229 try current_thread.checkCancel();
32573230 continue;
32583231 },
3259 .CANCELED => return current_thread.endSyscallCanceled(),
32603232 else => |e| {
32613233 current_thread.endSyscall();
32623234 switch (e) {
......@@ -3398,7 +3370,6 @@ fn dirReadLinux(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir
33983370 try current_thread.checkCancel();
33993371 continue;
34003372 },
3401 .CANCELED => return current_thread.endSyscallCanceled(),
34023373 else => |e| {
34033374 current_thread.endSyscall();
34043375 switch (e) {
......@@ -3508,7 +3479,6 @@ fn dirReadDarwin(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Di
35083479 try current_thread.checkCancel();
35093480 continue;
35103481 },
3511 .CANCELED => return current_thread.endSyscallCanceled(),
35123482 else => |e| {
35133483 current_thread.endSyscall();
35143484 switch (e) {
......@@ -3585,7 +3555,6 @@ fn dirReadBsd(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.R
35853555 try current_thread.checkCancel();
35863556 continue;
35873557 },
3588 .CANCELED => return current_thread.endSyscallCanceled(),
35893558 else => |e| {
35903559 current_thread.endSyscall();
35913560 switch (e) {
......@@ -3680,7 +3649,6 @@ fn dirReadIllumos(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) D
36803649 try current_thread.checkCancel();
36813650 continue;
36823651 },
3683 .CANCELED => return current_thread.endSyscallCanceled(),
36843652 else => |e| {
36853653 current_thread.endSyscall();
36863654 switch (e) {
......@@ -3957,7 +3925,6 @@ fn dirRealPathFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, o
39573925 try current_thread.checkCancel();
39583926 continue;
39593927 },
3960 .CANCELED => return current_thread.endSyscallCanceled(),
39613928 else => |e| {
39623929 current_thread.endSyscall();
39633930 switch (e) {
......@@ -4045,7 +4012,6 @@ fn realPathPosix(current_thread: *Thread, fd: posix.fd_t, out_buffer: []u8) File
40454012 try current_thread.checkCancel();
40464013 continue;
40474014 },
4048 .CANCELED => return current_thread.endSyscallCanceled(),
40494015 else => |e| {
40504016 current_thread.endSyscall();
40514017 switch (e) {
......@@ -4082,7 +4048,6 @@ fn realPathPosix(current_thread: *Thread, fd: posix.fd_t, out_buffer: []u8) File
40824048 try current_thread.checkCancel();
40834049 continue;
40844050 },
4085 .CANCELED => return current_thread.endSyscallCanceled(),
40864051 else => |e| {
40874052 current_thread.endSyscall();
40884053 switch (e) {
......@@ -4115,7 +4080,6 @@ fn realPathPosix(current_thread: *Thread, fd: posix.fd_t, out_buffer: []u8) File
41154080 try current_thread.checkCancel();
41164081 continue;
41174082 },
4118 .CANCELED => return current_thread.endSyscallCanceled(),
41194083 else => |e| {
41204084 current_thread.endSyscall();
41214085 switch (e) {
......@@ -4163,7 +4127,6 @@ fn dirDeleteFileWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.
41634127 try current_thread.checkCancel();
41644128 continue;
41654129 },
4166 .CANCELED => return current_thread.endSyscallCanceled(),
41674130 else => |e| {
41684131 current_thread.endSyscall();
41694132 switch (e) {
......@@ -4208,7 +4171,6 @@ fn dirDeleteFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir
42084171 try current_thread.checkCancel();
42094172 continue;
42104173 },
4211 .CANCELED => return current_thread.endSyscallCanceled(),
42124174 // Some systems return permission errors when trying to delete a
42134175 // directory, so we need to handle that case specifically and
42144176 // translate the error.
......@@ -4225,7 +4187,6 @@ fn dirDeleteFilePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir
42254187 break;
42264188 },
42274189 .INTR => continue,
4228 .CANCELED => return current_thread.endSyscallCanceled(),
42294190 else => {
42304191 current_thread.endSyscall();
42314192 return error.PermissionDenied;
......@@ -4443,7 +4404,6 @@ fn dirDeleteDirWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.D
44434404 try current_thread.checkCancel();
44444405 continue;
44454406 },
4446 .CANCELED => return current_thread.endSyscallCanceled(),
44474407 else => |e| {
44484408 current_thread.endSyscall();
44494409 switch (e) {
......@@ -4488,7 +4448,6 @@ fn dirDeleteDirPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8) Dir.
44884448 try current_thread.checkCancel();
44894449 continue;
44904450 },
4491 .CANCELED => return current_thread.endSyscallCanceled(),
44924451 else => |e| {
44934452 current_thread.endSyscall();
44944453 switch (e) {
......@@ -4654,7 +4613,6 @@ fn dirRenameWasi(
46544613 while (true) {
46554614 switch (std.os.wasi.path_rename(old_dir.handle, old_sub_path.ptr, old_sub_path.len, new_dir.handle, new_sub_path.ptr, new_sub_path.len)) {
46564615 .SUCCESS => return current_thread.endSyscall(),
4657 .CANCELED => return current_thread.endSyscallCanceled(),
46584616 .INTR => {
46594617 try current_thread.checkCancel();
46604618 continue;
......@@ -4709,7 +4667,6 @@ fn dirRenamePosix(
47094667 while (true) {
47104668 switch (posix.errno(posix.system.renameat(old_dir.handle, old_sub_path_posix, new_dir.handle, new_sub_path_posix))) {
47114669 .SUCCESS => return current_thread.endSyscall(),
4712 .CANCELED => return current_thread.endSyscallCanceled(),
47134670 .INTR => {
47144671 try current_thread.checkCancel();
47154672 continue;
......@@ -4890,7 +4847,6 @@ fn dirSymLinkWasi(
48904847 while (true) {
48914848 switch (std.os.wasi.path_symlink(target_path.ptr, target_path.len, dir.handle, sym_link_path.ptr, sym_link_path.len)) {
48924849 .SUCCESS => return current_thread.endSyscall(),
4893 .CANCELED => return current_thread.endSyscallCanceled(),
48944850 .INTR => {
48954851 try current_thread.checkCancel();
48964852 continue;
......@@ -4943,7 +4899,6 @@ fn dirSymLinkPosix(
49434899 while (true) {
49444900 switch (posix.errno(posix.system.symlinkat(target_path_posix, dir.handle, sym_link_path_posix))) {
49454901 .SUCCESS => return current_thread.endSyscall(),
4946 .CANCELED => return current_thread.endSyscallCanceled(),
49474902 .INTR => {
49484903 try current_thread.checkCancel();
49494904 continue;
......@@ -5010,7 +4965,6 @@ fn dirReadLinkWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffer
50104965 current_thread.endSyscall();
50114966 return n;
50124967 },
5013 .CANCELED => return current_thread.endSyscallCanceled(),
50144968 .INTR => {
50154969 try current_thread.checkCancel();
50164970 continue;
......@@ -5052,7 +5006,6 @@ fn dirReadLinkPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, buffe
50525006 const len: usize = @bitCast(rc);
50535007 return len;
50545008 },
5055 .CANCELED => return current_thread.endSyscallCanceled(),
50565009 .INTR => {
50575010 try current_thread.checkCancel();
50585011 continue;
......@@ -5137,7 +5090,6 @@ fn posixFchmodat(
51375090 posix.system.fchmodat(dir_fd, path, mode);
51385091 switch (posix.errno(rc)) {
51395092 .SUCCESS => return current_thread.endSyscall(),
5140 .CANCELED => return current_thread.endSyscallCanceled(),
51415093 .INTR => {
51425094 try current_thread.checkCancel();
51435095 continue;
......@@ -5176,7 +5128,6 @@ fn posixFchmodat(
51765128 while (true) {
51775129 switch (std.os.linux.errno(std.os.linux.fchmodat2(dir_fd, path, mode, flags))) {
51785130 .SUCCESS => return current_thread.endSyscall(),
5179 .CANCELED => return current_thread.endSyscallCanceled(),
51805131 .INTR => {
51815132 try current_thread.checkCancel();
51825133 continue;
......@@ -5252,7 +5203,6 @@ fn posixFchown(current_thread: *Thread, fd: posix.fd_t, uid: posix.uid_t, gid: p
52525203 while (true) {
52535204 switch (posix.errno(posix.system.fchown(fd, uid, gid))) {
52545205 .SUCCESS => return current_thread.endSyscall(),
5255 .CANCELED => return current_thread.endSyscallCanceled(),
52565206 .INTR => {
52575207 try current_thread.checkCancel();
52585208 continue;
......@@ -5333,7 +5283,6 @@ fn fileSyncPosix(userdata: ?*anyopaque, file: File) File.SyncError!void {
53335283 while (true) {
53345284 switch (posix.errno(posix.system.fsync(file.handle))) {
53355285 .SUCCESS => return current_thread.endSyscall(),
5336 .CANCELED => return current_thread.endSyscallCanceled(),
53375286 .INTR => {
53385287 try current_thread.checkCancel();
53395288 continue;
......@@ -5361,7 +5310,6 @@ fn fileSyncWasi(userdata: ?*anyopaque, file: File) File.SyncError!void {
53615310 while (true) {
53625311 switch (std.os.wasi.fd_sync(file.handle)) {
53635312 .SUCCESS => return current_thread.endSyscall(),
5364 .CANCELED => return current_thread.endSyscallCanceled(),
53655313 .INTR => {
53665314 try current_thread.checkCancel();
53675315 continue;
......@@ -5405,7 +5353,6 @@ fn isTty(current_thread: *Thread, file: File) Io.Cancelable!bool {
54055353 current_thread.endSyscall();
54065354 return true;
54075355 },
5408 .CANCELED => return current_thread.endSyscallCanceled(),
54095356 .INTR => {
54105357 try current_thread.checkCancel();
54115358 continue;
......@@ -5445,7 +5392,6 @@ fn isTty(current_thread: *Thread, file: File) Io.Cancelable!bool {
54455392 current_thread.endSyscall();
54465393 return true;
54475394 },
5448 .CANCELED => return current_thread.endSyscallCanceled(),
54495395 .INTR => {
54505396 try current_thread.checkCancel();
54515397 continue;
......@@ -5627,7 +5573,6 @@ fn fileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthE
56275573 while (true) {
56285574 switch (std.os.wasi.fd_filestat_set_size(file.handle, length)) {
56295575 .SUCCESS => return current_thread.endSyscall(),
5630 .CANCELED => return current_thread.endSyscallCanceled(),
56315576 .INTR => {
56325577 try current_thread.checkCancel();
56335578 continue;
......@@ -5653,7 +5598,6 @@ fn fileSetLength(userdata: ?*anyopaque, file: File, length: u64) File.SetLengthE
56535598 while (true) {
56545599 switch (posix.errno(ftruncate_sym(file.handle, signed_len))) {
56555600 .SUCCESS => return current_thread.endSyscall(),
5656 .CANCELED => return current_thread.endSyscallCanceled(),
56575601 .INTR => {
56585602 try current_thread.checkCancel();
56595603 continue;
......@@ -5723,7 +5667,6 @@ fn setPermissionsPosix(current_thread: *Thread, fd: posix.fd_t, mode: posix.mode
57235667 while (true) {
57245668 switch (posix.errno(posix.system.fchmod(fd, mode))) {
57255669 .SUCCESS => return current_thread.endSyscall(),
5726 .CANCELED => return current_thread.endSyscallCanceled(),
57275670 .INTR => {
57285671 try current_thread.checkCancel();
57295672 continue;
......@@ -5782,7 +5725,6 @@ fn dirSetTimestamps(
57825725 while (true) {
57835726 switch (posix.errno(posix.system.utimensat(dir.handle, sub_path_posix, &times, flags))) {
57845727 .SUCCESS => return current_thread.endSyscall(),
5785 .CANCELED => return current_thread.endSyscallCanceled(),
57865728 .INTR => {
57875729 try current_thread.checkCancel();
57885730 continue;
......@@ -5829,7 +5771,6 @@ fn dirSetTimestampsNow(
58295771 while (true) {
58305772 switch (posix.errno(posix.system.utimensat(dir.handle, sub_path_posix, null, flags))) {
58315773 .SUCCESS => return current_thread.endSyscall(),
5832 .CANCELED => return current_thread.endSyscallCanceled(),
58335774 .INTR => {
58345775 try current_thread.checkCancel();
58355776 continue;
......@@ -5890,7 +5831,6 @@ fn fileSetTimestamps(
58905831 .MTIM = true,
58915832 })) {
58925833 .SUCCESS => return current_thread.endSyscall(),
5893 .CANCELED => return current_thread.endSyscallCanceled(),
58945834 .INTR => {
58955835 try current_thread.checkCancel();
58965836 continue;
......@@ -5915,7 +5855,6 @@ fn fileSetTimestamps(
59155855 while (true) {
59165856 switch (posix.errno(posix.system.futimens(file.handle, &times))) {
59175857 .SUCCESS => return current_thread.endSyscall(),
5918 .CANCELED => return current_thread.endSyscallCanceled(),
59195858 .INTR => {
59205859 try current_thread.checkCancel();
59215860 continue;
......@@ -5952,7 +5891,6 @@ fn fileSetTimestampsNow(userdata: ?*anyopaque, file: File) File.SetTimestampsErr
59525891 .MTIM_NOW = true,
59535892 })) {
59545893 .SUCCESS => return current_thread.endSyscall(),
5955 .CANCELED => return current_thread.endSyscallCanceled(),
59565894 .INTR => {
59575895 try current_thread.checkCancel();
59585896 continue;
......@@ -5977,7 +5915,6 @@ fn fileSetTimestampsNow(userdata: ?*anyopaque, file: File) File.SetTimestampsErr
59775915 while (true) {
59785916 switch (posix.errno(posix.system.futimens(file.handle, null))) {
59795917 .SUCCESS => return current_thread.endSyscall(),
5980 .CANCELED => return current_thread.endSyscallCanceled(),
59815918 .INTR => {
59825919 try current_thread.checkCancel();
59835920 continue;
......@@ -6061,7 +5998,6 @@ fn fileLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!v
60615998 while (true) {
60625999 switch (posix.errno(posix.system.flock(file.handle, operation))) {
60636000 .SUCCESS => return current_thread.endSyscall(),
6064 .CANCELED => return current_thread.endSyscallCanceled(),
60656001 .INTR => {
60666002 try current_thread.checkCancel();
60676003 continue;
......@@ -6143,7 +6079,6 @@ fn fileTryLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockErro
61436079 current_thread.endSyscall();
61446080 return true;
61456081 },
6146 .CANCELED => return current_thread.endSyscallCanceled(),
61476082 .INTR => {
61486083 try current_thread.checkCancel();
61496084 continue;
......@@ -6259,7 +6194,6 @@ fn fileDowngradeLock(userdata: ?*anyopaque, file: File) File.DowngradeLockError!
62596194 current_thread.endSyscall();
62606195 return;
62616196 },
6262 .CANCELED => return current_thread.endSyscallCanceled(),
62636197 .INTR => {
62646198 try current_thread.checkCancel();
62656199 continue;
......@@ -6328,7 +6262,6 @@ fn dirOpenDirWasi(
63286262 try current_thread.checkCancel();
63296263 continue;
63306264 },
6331 .CANCELED => return current_thread.endSyscallCanceled(),
63326265 else => |e| {
63336266 current_thread.endSyscall();
63346267 switch (e) {
......@@ -6387,7 +6320,6 @@ fn dirHardLink(
63876320 try current_thread.checkCancel();
63886321 continue;
63896322 },
6390 .CANCELED => return current_thread.endSyscallCanceled(),
63916323 else => |e| {
63926324 current_thread.endSyscall();
63936325 switch (e) {
......@@ -6437,7 +6369,6 @@ fn dirHardLink(
64376369 try current_thread.checkCancel();
64386370 continue;
64396371 },
6440 .CANCELED => return current_thread.endSyscallCanceled(),
64416372 else => |e| {
64426373 current_thread.endSyscall();
64436374 switch (e) {
......@@ -6506,7 +6437,6 @@ fn fileReadStreamingPosix(userdata: ?*anyopaque, file: File, data: []const []u8)
65066437 try current_thread.checkCancel();
65076438 continue;
65086439 },
6509 .CANCELED => return current_thread.endSyscallCanceled(),
65106440 else => |e| {
65116441 current_thread.endSyscall();
65126442 switch (e) {
......@@ -6540,7 +6470,6 @@ fn fileReadStreamingPosix(userdata: ?*anyopaque, file: File, data: []const []u8)
65406470 try current_thread.checkCancel();
65416471 continue;
65426472 },
6543 .CANCELED => return current_thread.endSyscallCanceled(),
65446473 else => |e| {
65456474 current_thread.endSyscall();
65466475 switch (e) {
......@@ -6627,7 +6556,6 @@ fn fileReadPositionalPosix(userdata: ?*anyopaque, file: File, data: []const []u8
66276556 try current_thread.checkCancel();
66286557 continue;
66296558 },
6630 .CANCELED => return current_thread.endSyscallCanceled(),
66316559 else => |e| {
66326560 current_thread.endSyscall();
66336561 switch (e) {
......@@ -6665,7 +6593,6 @@ fn fileReadPositionalPosix(userdata: ?*anyopaque, file: File, data: []const []u8
66656593 try current_thread.checkCancel();
66666594 continue;
66676595 },
6668 .CANCELED => return current_thread.endSyscallCanceled(),
66696596 else => |e| {
66706597 current_thread.endSyscall();
66716598 switch (e) {
......@@ -6759,7 +6686,6 @@ fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!voi
67596686 try current_thread.checkCancel();
67606687 continue;
67616688 },
6762 .CANCELED => return current_thread.endSyscallCanceled(),
67636689 else => |e| {
67646690 current_thread.endSyscall();
67656691 switch (e) {
......@@ -6793,7 +6719,6 @@ fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!voi
67936719 try current_thread.checkCancel();
67946720 continue;
67956721 },
6796 .CANCELED => return current_thread.endSyscallCanceled(),
67976722 else => |e| {
67986723 current_thread.endSyscall();
67996724 switch (e) {
......@@ -6823,7 +6748,6 @@ fn fileSeekBy(userdata: ?*anyopaque, file: File, offset: i64) File.SeekError!voi
68236748 try current_thread.checkCancel();
68246749 continue;
68256750 },
6826 .CANCELED => return current_thread.endSyscallCanceled(),
68276751 else => |e| {
68286752 current_thread.endSyscall();
68296753 switch (e) {
......@@ -6862,7 +6786,6 @@ fn fileSeekTo(userdata: ?*anyopaque, file: File, offset: u64) File.SeekError!voi
68626786 try current_thread.checkCancel();
68636787 continue;
68646788 },
6865 .CANCELED => return current_thread.endSyscallCanceled(),
68666789 else => |e| {
68676790 current_thread.endSyscall();
68686791 switch (e) {
......@@ -6898,7 +6821,6 @@ fn posixSeekTo(current_thread: *Thread, fd: posix.fd_t, offset: u64) File.SeekEr
68986821 try current_thread.checkCancel();
68996822 continue;
69006823 },
6901 .CANCELED => return current_thread.endSyscallCanceled(),
69026824 else => |e| {
69036825 current_thread.endSyscall();
69046826 switch (e) {
......@@ -6925,7 +6847,6 @@ fn posixSeekTo(current_thread: *Thread, fd: posix.fd_t, offset: u64) File.SeekEr
69256847 try current_thread.checkCancel();
69266848 continue;
69276849 },
6928 .CANCELED => return current_thread.endSyscallCanceled(),
69296850 else => |e| {
69306851 current_thread.endSyscall();
69316852 switch (e) {
......@@ -7011,7 +6932,6 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) std.process.Ex
70116932 try current_thread.checkCancel();
70126933 continue;
70136934 },
7014 .CANCELED => return current_thread.endSyscallCanceled(),
70156935 else => |e| {
70166936 current_thread.endSyscall();
70176937 switch (e) {
......@@ -7040,7 +6960,6 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) std.process.Ex
70406960 try current_thread.checkCancel();
70416961 continue;
70426962 },
7043 .CANCELED => return current_thread.endSyscallCanceled(),
70446963 else => |e| {
70456964 current_thread.endSyscall();
70466965 switch (e) {
......@@ -7194,7 +7113,6 @@ fn fileWritePositional(
71947113 try current_thread.checkCancel();
71957114 continue;
71967115 },
7197 .CANCELED => return current_thread.endSyscallCanceled(),
71987116 else => |e| {
71997117 current_thread.endSyscall();
72007118 switch (e) {
......@@ -7232,7 +7150,6 @@ fn fileWritePositional(
72327150 try current_thread.checkCancel();
72337151 continue;
72347152 },
7235 .CANCELED => return current_thread.endSyscallCanceled(),
72367153 else => |e| {
72377154 current_thread.endSyscall();
72387155 switch (e) {
......@@ -7316,7 +7233,6 @@ fn fileWriteStreaming(
73167233 try current_thread.checkCancel();
73177234 continue;
73187235 },
7319 .CANCELED => return current_thread.endSyscallCanceled(),
73207236 else => |e| {
73217237 current_thread.endSyscall();
73227238 switch (e) {
......@@ -7351,7 +7267,6 @@ fn fileWriteStreaming(
73517267 try current_thread.checkCancel();
73527268 continue;
73537269 },
7354 .CANCELED => return current_thread.endSyscallCanceled(),
73557270 else => |e| {
73567271 current_thread.endSyscall();
73577272 switch (e) {
......@@ -7619,7 +7534,6 @@ fn fileWriteFileStreaming(
76197534 try current_thread.checkCancel();
76207535 continue;
76217536 },
7622 .CANCELED => return current_thread.endSyscallCanceled(),
76237537 else => |e| {
76247538 current_thread.endSyscall();
76257539 assert(error.Unexpected == switch (e) {
......@@ -7692,7 +7606,6 @@ fn fileWriteFileStreaming(
76927606 try current_thread.checkCancel();
76937607 continue;
76947608 },
7695 .CANCELED => return current_thread.endSyscallCanceled(),
76967609 .OPNOTSUPP, .INVAL, .NOSYS => {
76977610 // Give calling code chance to observe before trying
76987611 // something else.
......@@ -7869,7 +7782,6 @@ fn fileWriteFilePositional(
78697782 try current_thread.checkCancel();
78707783 continue;
78717784 },
7872 .CANCELED => return current_thread.endSyscallCanceled(),
78737785 .OPNOTSUPP, .INVAL, .NOSYS => {
78747786 // Give calling code chance to observe before trying
78757787 // something else.
......@@ -8098,7 +8010,6 @@ fn sleepLinux(userdata: ?*anyopaque, timeout: Io.Timeout) Io.SleepError!void {
80988010 try current_thread.checkCancel();
80998011 continue;
81008012 },
8101 .CANCELED => return current_thread.endSyscallCanceled(),
81028013 else => |e| {
81038014 current_thread.endSyscall();
81048015 switch (e) {
......@@ -8176,7 +8087,6 @@ fn sleepPosix(userdata: ?*anyopaque, timeout: Io.Timeout) Io.SleepError!void {
81768087 try current_thread.checkCancel();
81778088 continue;
81788089 },
8179 .CANCELED => return current_thread.endSyscallCanceled(),
81808090 // This prong handles success as well as unexpected errors.
81818091 else => return current_thread.endSyscall(),
81828092 }
......@@ -8250,7 +8160,6 @@ fn netListenIpPosix(
82508160 try current_thread.checkCancel();
82518161 continue;
82528162 },
8253 .CANCELED => return current_thread.endSyscallCanceled(),
82548163 else => |e| {
82558164 current_thread.endSyscall();
82568165 switch (e) {
......@@ -8414,7 +8323,6 @@ fn netListenUnixPosix(
84148323 try current_thread.checkCancel();
84158324 continue;
84168325 },
8417 .CANCELED => return current_thread.endSyscallCanceled(),
84188326 else => |e| {
84198327 current_thread.endSyscall();
84208328 switch (e) {
......@@ -8538,7 +8446,6 @@ fn posixBindUnix(
85388446 try current_thread.checkCancel();
85398447 continue;
85408448 },
8541 .CANCELED => return current_thread.endSyscallCanceled(),
85428449 else => |e| {
85438450 current_thread.endSyscall();
85448451 switch (e) {
......@@ -8583,7 +8490,6 @@ fn posixBind(
85838490 try current_thread.checkCancel();
85848491 continue;
85858492 },
8586 .CANCELED => return current_thread.endSyscallCanceled(),
85878493 else => |e| {
85888494 current_thread.endSyscall();
85898495 switch (e) {
......@@ -8619,7 +8525,6 @@ fn posixConnect(
86198525 try current_thread.checkCancel();
86208526 continue;
86218527 },
8622 .CANCELED => return current_thread.endSyscallCanceled(),
86238528 else => |e| {
86248529 current_thread.endSyscall();
86258530 switch (e) {
......@@ -8666,7 +8571,6 @@ fn posixConnectUnix(
86668571 try current_thread.checkCancel();
86678572 continue;
86688573 },
8669 .CANCELED => return current_thread.endSyscallCanceled(),
86708574 else => |e| {
86718575 current_thread.endSyscall();
86728576 switch (e) {
......@@ -8711,7 +8615,6 @@ fn posixGetSockName(
87118615 try current_thread.checkCancel();
87128616 continue;
87138617 },
8714 .CANCELED => return current_thread.endSyscallCanceled(),
87158618 else => |e| {
87168619 current_thread.endSyscall();
87178620 switch (e) {
......@@ -8779,7 +8682,6 @@ fn setSocketOption(current_thread: *Thread, fd: posix.fd_t, level: i32, opt_name
87798682 try current_thread.checkCancel();
87808683 continue;
87818684 },
8782 .CANCELED => return current_thread.endSyscallCanceled(),
87838685 else => |e| {
87848686 current_thread.endSyscall();
87858687 switch (e) {
......@@ -9109,7 +9011,6 @@ fn openSocketPosix(
91099011 switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFD, @as(usize, posix.FD_CLOEXEC)))) {
91109012 .SUCCESS => break,
91119013 .INTR => continue,
9112 .CANCELED => return current_thread.endSyscallCanceled(),
91139014 else => |err| {
91149015 current_thread.endSyscall();
91159016 return posix.unexpectedErrno(err);
......@@ -9123,7 +9024,6 @@ fn openSocketPosix(
91239024 try current_thread.checkCancel();
91249025 continue;
91259026 },
9126 .CANCELED => return current_thread.endSyscallCanceled(),
91279027 else => |e| {
91289028 current_thread.endSyscall();
91299029 switch (e) {
......@@ -9225,7 +9125,6 @@ fn netAcceptPosix(userdata: ?*anyopaque, listen_fd: net.Socket.Handle) net.Serve
92259125 try current_thread.checkCancel();
92269126 continue;
92279127 },
9228 .CANCELED => return current_thread.endSyscallCanceled(),
92299128 else => |e| {
92309129 current_thread.endSyscall();
92319130 switch (e) {
......@@ -9334,7 +9233,6 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
93349233 try current_thread.checkCancel();
93359234 continue;
93369235 },
9337 .CANCELED => return current_thread.endSyscallCanceled(),
93389236 else => |e| {
93399237 current_thread.endSyscall();
93409238 switch (e) {
......@@ -9367,7 +9265,6 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
93679265 try current_thread.checkCancel();
93689266 continue;
93699267 },
9370 .CANCELED => return current_thread.endSyscallCanceled(),
93719268 else => |e| {
93729269 current_thread.endSyscall();
93739270 switch (e) {
......@@ -9603,7 +9500,6 @@ fn netSendOne(
96039500 try current_thread.checkCancel();
96049501 continue;
96059502 },
9606 .CANCELED => return current_thread.endSyscallCanceled(),
96079503 else => |e| {
96089504 current_thread.endSyscall();
96099505 switch (e) {
......@@ -9680,7 +9576,6 @@ fn netSendMany(
96809576 try current_thread.checkCancel();
96819577 continue;
96829578 },
9683 .CANCELED => return current_thread.endSyscallCanceled(),
96849579 else => |e| {
96859580 current_thread.endSyscall();
96869581 switch (e) {
......@@ -9813,7 +9708,6 @@ fn netReceivePosix(
98139708 continue :recv;
98149709 },
98159710 .INTR => continue,
9816 .CANCELED => return .{ current_thread.endSyscallCanceled(), message_i },
98179711
98189712 .FAULT => |err| return .{ errnoBug(err), message_i },
98199713 .INVAL => |err| return .{ errnoBug(err), message_i },
......@@ -9822,7 +9716,6 @@ fn netReceivePosix(
98229716 }
98239717 },
98249718 .INTR => continue,
9825 .CANCELED => return .{ current_thread.endSyscallCanceled(), message_i },
98269719
98279720 .BADF => |err| return .{ errnoBug(err), message_i },
98289721 .NFILE => return .{ error.SystemFdQuotaExceeded, message_i },
......@@ -9942,7 +9835,6 @@ fn netWritePosix(
99429835 try current_thread.checkCancel();
99439836 continue;
99449837 },
9945 .CANCELED => return current_thread.endSyscallCanceled(),
99469838 else => |e| {
99479839 current_thread.endSyscall();
99489840 switch (e) {
......@@ -10040,8 +9932,7 @@ fn netWriteWindows(
100409932 else => |err| err,
100419933 };
100429934 switch (wsa_error) {
10043 .EINTR => continue,
10044 .ECANCELLED, .E_CANCELLED, .OPERATION_ABORTED => return current_thread.endSyscallCanceled(),
9935 .EINTR, .ECANCELLED, .E_CANCELLED, .OPERATION_ABORTED => continue,
100459936 .NOTINITIALISED => {
100469937 try initializeWsa(t);
100479938 continue;
......@@ -10160,7 +10051,6 @@ fn netInterfaceNameResolve(
1016010051 try current_thread.checkCancel();
1016110052 continue;
1016210053 },
10163 .CANCELED => return current_thread.endSyscallCanceled(),
1016410054 else => |e| {
1016510055 current_thread.endSyscall();
1016610056 switch (e) {
......@@ -10464,7 +10354,6 @@ fn netLookupFallible(
1046410354 try current_thread.checkCancel();
1046510355 continue;
1046610356 },
10467 .CANCELED => return current_thread.endSyscallCanceled(),
1046810357 else => |e| {
1046910358 current_thread.endSyscall();
1047010359 return posix.unexpectedErrno(e);