| ... | @@ -882,6 +882,8 @@ fn dirMakePosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: | ... | @@ -882,6 +882,8 @@ fn dirMakePosix(userdata: ?*anyopaque, dir: Io.Dir, sub_path: []const u8, mode: |
| 882 | switch (posix.errno(posix.system.mkdirat(dir.handle, sub_path_posix, mode))) { | 882 | switch (posix.errno(posix.system.mkdirat(dir.handle, sub_path_posix, mode))) { |
| 883 | .SUCCESS => return, | 883 | .SUCCESS => return, |
| 884 | .INTR => continue, | 884 | .INTR => continue, |
| | 885 | .CANCELED => return error.Canceled, |
| | 886 | |
| 885 | .ACCES => return error.AccessDenied, | 887 | .ACCES => return error.AccessDenied, |
| 886 | .BADF => |err| return errnoBug(err), | 888 | .BADF => |err| return errnoBug(err), |
| 887 | .PERM => return error.PermissionDenied, | 889 | .PERM => return error.PermissionDenied, |
| ... | @@ -940,6 +942,8 @@ fn dirStatPathLinux( | ... | @@ -940,6 +942,8 @@ fn dirStatPathLinux( |
| 940 | switch (linux.E.init(rc)) { | 942 | switch (linux.E.init(rc)) { |
| 941 | .SUCCESS => return statFromLinux(&statx), | 943 | .SUCCESS => return statFromLinux(&statx), |
| 942 | .INTR => continue, | 944 | .INTR => continue, |
| | 945 | .CANCELED => return error.Canceled, |
| | 946 | |
| 943 | .ACCES => return error.AccessDenied, | 947 | .ACCES => return error.AccessDenied, |
| 944 | .BADF => |err| return errnoBug(err), | 948 | .BADF => |err| return errnoBug(err), |
| 945 | .FAULT => |err| return errnoBug(err), | 949 | .FAULT => |err| return errnoBug(err), |
| ... | @@ -973,6 +977,8 @@ fn dirStatPathPosix( | ... | @@ -973,6 +977,8 @@ fn dirStatPathPosix( |
| 973 | switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, flags))) { | 977 | switch (posix.errno(fstatat_sym(dir.handle, sub_path_posix, &stat, flags))) { |
| 974 | .SUCCESS => return statFromPosix(&stat), | 978 | .SUCCESS => return statFromPosix(&stat), |
| 975 | .INTR => continue, | 979 | .INTR => continue, |
| | 980 | .CANCELED => return error.Canceled, |
| | 981 | |
| 976 | .INVAL => |err| return errnoBug(err), | 982 | .INVAL => |err| return errnoBug(err), |
| 977 | .BADF => |err| return errnoBug(err), // Always a race condition. | 983 | .BADF => |err| return errnoBug(err), // Always a race condition. |
| 978 | .NOMEM => return error.SystemResources, | 984 | .NOMEM => return error.SystemResources, |
| ... | @@ -1035,6 +1041,8 @@ fn fileStatPosix(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File | ... | @@ -1035,6 +1041,8 @@ fn fileStatPosix(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File |
| 1035 | switch (posix.errno(fstat_sym(file.handle, &stat))) { | 1041 | switch (posix.errno(fstat_sym(file.handle, &stat))) { |
| 1036 | .SUCCESS => return statFromPosix(&stat), | 1042 | .SUCCESS => return statFromPosix(&stat), |
| 1037 | .INTR => continue, | 1043 | .INTR => continue, |
| | 1044 | .CANCELED => return error.Canceled, |
| | 1045 | |
| 1038 | .INVAL => |err| return errnoBug(err), | 1046 | .INVAL => |err| return errnoBug(err), |
| 1039 | .BADF => |err| return errnoBug(err), | 1047 | .BADF => |err| return errnoBug(err), |
| 1040 | .NOMEM => return error.SystemResources, | 1048 | .NOMEM => return error.SystemResources, |
| ... | @@ -1060,6 +1068,8 @@ fn fileStatLinux(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File | ... | @@ -1060,6 +1068,8 @@ fn fileStatLinux(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File |
| 1060 | switch (linux.E.init(rc)) { | 1068 | switch (linux.E.init(rc)) { |
| 1061 | .SUCCESS => return statFromLinux(&statx), | 1069 | .SUCCESS => return statFromLinux(&statx), |
| 1062 | .INTR => continue, | 1070 | .INTR => continue, |
| | 1071 | .CANCELED => return error.Canceled, |
| | 1072 | |
| 1063 | .ACCES => |err| return errnoBug(err), | 1073 | .ACCES => |err| return errnoBug(err), |
| 1064 | .BADF => |err| return errnoBug(err), | 1074 | .BADF => |err| return errnoBug(err), |
| 1065 | .FAULT => |err| return errnoBug(err), | 1075 | .FAULT => |err| return errnoBug(err), |
| ... | @@ -1090,6 +1100,8 @@ fn fileStatWasi(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File. | ... | @@ -1090,6 +1100,8 @@ fn fileStatWasi(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File. |
| 1090 | switch (std.os.wasi.fd_filestat_get(file.handle, &stat)) { | 1100 | switch (std.os.wasi.fd_filestat_get(file.handle, &stat)) { |
| 1091 | .SUCCESS => return statFromWasi(&stat), | 1101 | .SUCCESS => return statFromWasi(&stat), |
| 1092 | .INTR => continue, | 1102 | .INTR => continue, |
| | 1103 | .CANCELED => return error.Canceled, |
| | 1104 | |
| 1093 | .INVAL => |err| return errnoBug(err), | 1105 | .INVAL => |err| return errnoBug(err), |
| 1094 | .BADF => |err| return errnoBug(err), | 1106 | .BADF => |err| return errnoBug(err), |
| 1095 | .NOMEM => return error.SystemResources, | 1107 | .NOMEM => return error.SystemResources, |
| ... | @@ -1253,6 +1265,7 @@ fn dirCreateFilePosix( | ... | @@ -1253,6 +1265,7 @@ fn dirCreateFilePosix( |
| 1253 | switch (posix.errno(rc)) { | 1265 | switch (posix.errno(rc)) { |
| 1254 | .SUCCESS => break @intCast(rc), | 1266 | .SUCCESS => break @intCast(rc), |
| 1255 | .INTR => continue, | 1267 | .INTR => continue, |
| | 1268 | .CANCELED => return error.Canceled, |
| 1256 | | 1269 | |
| 1257 | .FAULT => |err| return errnoBug(err), | 1270 | .FAULT => |err| return errnoBug(err), |
| 1258 | .INVAL => return error.BadPathName, | 1271 | .INVAL => return error.BadPathName, |
| ... | @@ -1296,6 +1309,7 @@ fn dirCreateFilePosix( | ... | @@ -1296,6 +1309,7 @@ fn dirCreateFilePosix( |
| 1296 | switch (posix.errno(posix.system.flock(fd, lock_flags))) { | 1309 | switch (posix.errno(posix.system.flock(fd, lock_flags))) { |
| 1297 | .SUCCESS => break, | 1310 | .SUCCESS => break, |
| 1298 | .INTR => continue, | 1311 | .INTR => continue, |
| | 1312 | .CANCELED => return error.Canceled, |
| 1299 | | 1313 | |
| 1300 | .BADF => |err| return errnoBug(err), | 1314 | .BADF => |err| return errnoBug(err), |
| 1301 | .INVAL => |err| return errnoBug(err), // invalid parameters | 1315 | .INVAL => |err| return errnoBug(err), // invalid parameters |
| ... | @@ -1314,6 +1328,7 @@ fn dirCreateFilePosix( | ... | @@ -1314,6 +1328,7 @@ fn dirCreateFilePosix( |
| 1314 | switch (posix.errno(rc)) { | 1328 | switch (posix.errno(rc)) { |
| 1315 | .SUCCESS => break @intCast(rc), | 1329 | .SUCCESS => break @intCast(rc), |
| 1316 | .INTR => continue, | 1330 | .INTR => continue, |
| | 1331 | .CANCELED => return error.Canceled, |
| 1317 | else => |err| return posix.unexpectedErrno(err), | 1332 | else => |err| return posix.unexpectedErrno(err), |
| 1318 | } | 1333 | } |
| 1319 | }; | 1334 | }; |
| ... | @@ -1323,6 +1338,7 @@ fn dirCreateFilePosix( | ... | @@ -1323,6 +1338,7 @@ fn dirCreateFilePosix( |
| 1323 | switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFL, fl_flags))) { | 1338 | switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFL, fl_flags))) { |
| 1324 | .SUCCESS => break, | 1339 | .SUCCESS => break, |
| 1325 | .INTR => continue, | 1340 | .INTR => continue, |
| | 1341 | .CANCELED => return error.Canceled, |
| 1326 | else => |err| return posix.unexpectedErrno(err), | 1342 | else => |err| return posix.unexpectedErrno(err), |
| 1327 | } | 1343 | } |
| 1328 | } | 1344 | } |
| ... | @@ -1383,6 +1399,7 @@ fn dirOpenFile( | ... | @@ -1383,6 +1399,7 @@ fn dirOpenFile( |
| 1383 | switch (posix.errno(rc)) { | 1399 | switch (posix.errno(rc)) { |
| 1384 | .SUCCESS => break @intCast(rc), | 1400 | .SUCCESS => break @intCast(rc), |
| 1385 | .INTR => continue, | 1401 | .INTR => continue, |
| | 1402 | .CANCELED => return error.Canceled, |
| 1386 | | 1403 | |
| 1387 | .FAULT => |err| return errnoBug(err), | 1404 | .FAULT => |err| return errnoBug(err), |
| 1388 | .INVAL => return error.BadPathName, | 1405 | .INVAL => return error.BadPathName, |
| ... | @@ -1426,6 +1443,7 @@ fn dirOpenFile( | ... | @@ -1426,6 +1443,7 @@ fn dirOpenFile( |
| 1426 | switch (posix.errno(posix.system.flock(fd, lock_flags))) { | 1443 | switch (posix.errno(posix.system.flock(fd, lock_flags))) { |
| 1427 | .SUCCESS => break, | 1444 | .SUCCESS => break, |
| 1428 | .INTR => continue, | 1445 | .INTR => continue, |
| | 1446 | .CANCELED => return error.Canceled, |
| 1429 | | 1447 | |
| 1430 | .BADF => |err| return errnoBug(err), | 1448 | .BADF => |err| return errnoBug(err), |
| 1431 | .INVAL => |err| return errnoBug(err), // invalid parameters | 1449 | .INVAL => |err| return errnoBug(err), // invalid parameters |
| ... | @@ -1444,6 +1462,7 @@ fn dirOpenFile( | ... | @@ -1444,6 +1462,7 @@ fn dirOpenFile( |
| 1444 | switch (posix.errno(rc)) { | 1462 | switch (posix.errno(rc)) { |
| 1445 | .SUCCESS => break @intCast(rc), | 1463 | .SUCCESS => break @intCast(rc), |
| 1446 | .INTR => continue, | 1464 | .INTR => continue, |
| | 1465 | .CANCELED => return error.Canceled, |
| 1447 | else => |err| return posix.unexpectedErrno(err), | 1466 | else => |err| return posix.unexpectedErrno(err), |
| 1448 | } | 1467 | } |
| 1449 | }; | 1468 | }; |
| ... | @@ -1453,6 +1472,7 @@ fn dirOpenFile( | ... | @@ -1453,6 +1472,7 @@ fn dirOpenFile( |
| 1453 | switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFL, fl_flags))) { | 1472 | switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFL, fl_flags))) { |
| 1454 | .SUCCESS => break, | 1473 | .SUCCESS => break, |
| 1455 | .INTR => continue, | 1474 | .INTR => continue, |
| | 1475 | .CANCELED => return error.Canceled, |
| 1456 | else => |err| return posix.unexpectedErrno(err), | 1476 | else => |err| return posix.unexpectedErrno(err), |
| 1457 | } | 1477 | } |
| 1458 | } | 1478 | } |
| ... | @@ -1526,6 +1546,8 @@ fn fileReadStreaming(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io.File | ... | @@ -1526,6 +1546,8 @@ fn fileReadStreaming(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io.File |
| 1526 | switch (std.os.wasi.fd_read(file.handle, dest.ptr, dest.len, &nread)) { | 1546 | switch (std.os.wasi.fd_read(file.handle, dest.ptr, dest.len, &nread)) { |
| 1527 | .SUCCESS => return nread, | 1547 | .SUCCESS => return nread, |
| 1528 | .INTR => continue, | 1548 | .INTR => continue, |
| | 1549 | .CANCELED => return error.Canceled, |
| | 1550 | |
| 1529 | .INVAL => |err| return errnoBug(err), | 1551 | .INVAL => |err| return errnoBug(err), |
| 1530 | .FAULT => |err| return errnoBug(err), | 1552 | .FAULT => |err| return errnoBug(err), |
| 1531 | .BADF => |err| return errnoBug(err), | 1553 | .BADF => |err| return errnoBug(err), |
| ... | @@ -1547,6 +1569,8 @@ fn fileReadStreaming(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io.File | ... | @@ -1547,6 +1569,8 @@ fn fileReadStreaming(userdata: ?*anyopaque, file: Io.File, data: [][]u8) Io.File |
| 1547 | switch (posix.errno(rc)) { | 1569 | switch (posix.errno(rc)) { |
| 1548 | .SUCCESS => return @intCast(rc), | 1570 | .SUCCESS => return @intCast(rc), |
| 1549 | .INTR => continue, | 1571 | .INTR => continue, |
| | 1572 | .CANCELED => return error.Canceled, |
| | 1573 | |
| 1550 | .INVAL => |err| return errnoBug(err), | 1574 | .INVAL => |err| return errnoBug(err), |
| 1551 | .FAULT => |err| return errnoBug(err), | 1575 | .FAULT => |err| return errnoBug(err), |
| 1552 | .SRCH => return error.ProcessNotFound, | 1576 | .SRCH => return error.ProcessNotFound, |
| ... | @@ -1647,6 +1671,8 @@ fn fileReadPositional(userdata: ?*anyopaque, file: Io.File, data: [][]u8, offset | ... | @@ -1647,6 +1671,8 @@ fn fileReadPositional(userdata: ?*anyopaque, file: Io.File, data: [][]u8, offset |
| 1647 | switch (std.os.wasi.fd_pread(file.handle, dest.ptr, dest.len, offset, &nread)) { | 1671 | switch (std.os.wasi.fd_pread(file.handle, dest.ptr, dest.len, offset, &nread)) { |
| 1648 | .SUCCESS => return nread, | 1672 | .SUCCESS => return nread, |
| 1649 | .INTR => continue, | 1673 | .INTR => continue, |
| | 1674 | .CANCELED => return error.Canceled, |
| | 1675 | |
| 1650 | .INVAL => |err| return errnoBug(err), | 1676 | .INVAL => |err| return errnoBug(err), |
| 1651 | .FAULT => |err| return errnoBug(err), | 1677 | .FAULT => |err| return errnoBug(err), |
| 1652 | .AGAIN => |err| return errnoBug(err), | 1678 | .AGAIN => |err| return errnoBug(err), |
| ... | @@ -1672,6 +1698,8 @@ fn fileReadPositional(userdata: ?*anyopaque, file: Io.File, data: [][]u8, offset | ... | @@ -1672,6 +1698,8 @@ fn fileReadPositional(userdata: ?*anyopaque, file: Io.File, data: [][]u8, offset |
| 1672 | switch (posix.errno(rc)) { | 1698 | switch (posix.errno(rc)) { |
| 1673 | .SUCCESS => return @bitCast(rc), | 1699 | .SUCCESS => return @bitCast(rc), |
| 1674 | .INTR => continue, | 1700 | .INTR => continue, |
| | 1701 | .CANCELED => return error.Canceled, |
| | 1702 | |
| 1675 | .INVAL => |err| return errnoBug(err), | 1703 | .INVAL => |err| return errnoBug(err), |
| 1676 | .FAULT => |err| return errnoBug(err), | 1704 | .FAULT => |err| return errnoBug(err), |
| 1677 | .SRCH => return error.ProcessNotFound, | 1705 | .SRCH => return error.ProcessNotFound, |
| ... | @@ -1711,6 +1739,8 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr | ... | @@ -1711,6 +1739,8 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr |
| 1711 | switch (posix.errno(posix.system.llseek(fd, offset, &result, posix.SEEK.SET))) { | 1739 | switch (posix.errno(posix.system.llseek(fd, offset, &result, posix.SEEK.SET))) { |
| 1712 | .SUCCESS => return, | 1740 | .SUCCESS => return, |
| 1713 | .INTR => continue, | 1741 | .INTR => continue, |
| | 1742 | .CANCELED => return error.Canceled, |
| | 1743 | |
| 1714 | .BADF => |err| return errnoBug(err), // Always a race condition. | 1744 | .BADF => |err| return errnoBug(err), // Always a race condition. |
| 1715 | .INVAL => return error.Unseekable, | 1745 | .INVAL => return error.Unseekable, |
| 1716 | .OVERFLOW => return error.Unseekable, | 1746 | .OVERFLOW => return error.Unseekable, |
| ... | @@ -1731,6 +1761,8 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr | ... | @@ -1731,6 +1761,8 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr |
| 1731 | switch (std.os.wasi.fd_seek(fd, @bitCast(offset), .SET, &new_offset)) { | 1761 | switch (std.os.wasi.fd_seek(fd, @bitCast(offset), .SET, &new_offset)) { |
| 1732 | .SUCCESS => return, | 1762 | .SUCCESS => return, |
| 1733 | .INTR => continue, | 1763 | .INTR => continue, |
| | 1764 | .CANCELED => return error.Canceled, |
| | 1765 | |
| 1734 | .BADF => |err| return errnoBug(err), // Always a race condition. | 1766 | .BADF => |err| return errnoBug(err), // Always a race condition. |
| 1735 | .INVAL => return error.Unseekable, | 1767 | .INVAL => return error.Unseekable, |
| 1736 | .OVERFLOW => return error.Unseekable, | 1768 | .OVERFLOW => return error.Unseekable, |
| ... | @@ -1748,6 +1780,8 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr | ... | @@ -1748,6 +1780,8 @@ fn fileSeekTo(userdata: ?*anyopaque, file: Io.File, offset: u64) Io.File.SeekErr |
| 1748 | switch (posix.errno(lseek_sym(fd, @bitCast(offset), posix.SEEK.SET))) { | 1780 | switch (posix.errno(lseek_sym(fd, @bitCast(offset), posix.SEEK.SET))) { |
| 1749 | .SUCCESS => return, | 1781 | .SUCCESS => return, |
| 1750 | .INTR => continue, | 1782 | .INTR => continue, |
| | 1783 | .CANCELED => return error.Canceled, |
| | 1784 | |
| 1751 | .BADF => |err| return errnoBug(err), // Always a race condition. | 1785 | .BADF => |err| return errnoBug(err), // Always a race condition. |
| 1752 | .INVAL => return error.Unseekable, | 1786 | .INVAL => return error.Unseekable, |
| 1753 | .OVERFLOW => return error.Unseekable, | 1787 | .OVERFLOW => return error.Unseekable, |
| ... | @@ -1845,6 +1879,7 @@ fn sleepLinux(userdata: ?*anyopaque, timeout: Io.Timeout) Io.SleepError!void { | ... | @@ -1845,6 +1879,7 @@ fn sleepLinux(userdata: ?*anyopaque, timeout: Io.Timeout) Io.SleepError!void { |
| 1845 | } }, &timespec, &timespec))) { | 1879 | } }, &timespec, &timespec))) { |
| 1846 | .SUCCESS => return, | 1880 | .SUCCESS => return, |
| 1847 | .INTR => continue, | 1881 | .INTR => continue, |
| | 1882 | .CANCELED => return error.Canceled, |
| 1848 | .INVAL => return error.UnsupportedClock, | 1883 | .INVAL => return error.UnsupportedClock, |
| 1849 | else => |err| return posix.unexpectedErrno(err), | 1884 | else => |err| return posix.unexpectedErrno(err), |
| 1850 | } | 1885 | } |
| ... | @@ -1907,6 +1942,7 @@ fn sleepPosix(userdata: ?*anyopaque, timeout: Io.Timeout) Io.SleepError!void { | ... | @@ -1907,6 +1942,7 @@ fn sleepPosix(userdata: ?*anyopaque, timeout: Io.Timeout) Io.SleepError!void { |
| 1907 | try t.checkCancel(); | 1942 | try t.checkCancel(); |
| 1908 | switch (posix.errno(posix.system.nanosleep(&timespec, &timespec))) { | 1943 | switch (posix.errno(posix.system.nanosleep(&timespec, &timespec))) { |
| 1909 | .INTR => continue, | 1944 | .INTR => continue, |
| | 1945 | .CANCELED => return error.Canceled, |
| 1910 | else => return, // This prong handles success as well as unexpected errors. | 1946 | else => return, // This prong handles success as well as unexpected errors. |
| 1911 | } | 1947 | } |
| 1912 | } | 1948 | } |
| ... | @@ -2024,6 +2060,8 @@ fn posixBindUnix(t: *Threaded, fd: posix.socket_t, addr: *const posix.sockaddr, | ... | @@ -2024,6 +2060,8 @@ fn posixBindUnix(t: *Threaded, fd: posix.socket_t, addr: *const posix.sockaddr, |
| 2024 | switch (posix.errno(posix.system.bind(fd, addr, addr_len))) { | 2060 | switch (posix.errno(posix.system.bind(fd, addr, addr_len))) { |
| 2025 | .SUCCESS => break, | 2061 | .SUCCESS => break, |
| 2026 | .INTR => continue, | 2062 | .INTR => continue, |
| | 2063 | .CANCELED => return error.Canceled, |
| | 2064 | |
| 2027 | .ACCES => return error.AccessDenied, | 2065 | .ACCES => return error.AccessDenied, |
| 2028 | .ADDRINUSE => return error.AddressInUse, | 2066 | .ADDRINUSE => return error.AddressInUse, |
| 2029 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | 2067 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, |
| ... | @@ -2052,6 +2090,8 @@ fn posixBind(t: *Threaded, socket_fd: posix.socket_t, addr: *const posix.sockadd | ... | @@ -2052,6 +2090,8 @@ fn posixBind(t: *Threaded, socket_fd: posix.socket_t, addr: *const posix.sockadd |
| 2052 | switch (posix.errno(posix.system.bind(socket_fd, addr, addr_len))) { | 2090 | switch (posix.errno(posix.system.bind(socket_fd, addr, addr_len))) { |
| 2053 | .SUCCESS => break, | 2091 | .SUCCESS => break, |
| 2054 | .INTR => continue, | 2092 | .INTR => continue, |
| | 2093 | .CANCELED => return error.Canceled, |
| | 2094 | |
| 2055 | .ADDRINUSE => return error.AddressInUse, | 2095 | .ADDRINUSE => return error.AddressInUse, |
| 2056 | .BADF => |err| return errnoBug(err), // always a race condition if this error is returned | 2096 | .BADF => |err| return errnoBug(err), // always a race condition if this error is returned |
| 2057 | .INVAL => |err| return errnoBug(err), // invalid parameters | 2097 | .INVAL => |err| return errnoBug(err), // invalid parameters |
| ... | @@ -2071,6 +2111,8 @@ fn posixConnect(t: *Threaded, socket_fd: posix.socket_t, addr: *const posix.sock | ... | @@ -2071,6 +2111,8 @@ fn posixConnect(t: *Threaded, socket_fd: posix.socket_t, addr: *const posix.sock |
| 2071 | switch (posix.errno(posix.system.connect(socket_fd, addr, addr_len))) { | 2111 | switch (posix.errno(posix.system.connect(socket_fd, addr, addr_len))) { |
| 2072 | .SUCCESS => return, | 2112 | .SUCCESS => return, |
| 2073 | .INTR => continue, | 2113 | .INTR => continue, |
| | 2114 | .CANCELED => return error.Canceled, |
| | 2115 | |
| 2074 | .ADDRNOTAVAIL => return error.AddressUnavailable, | 2116 | .ADDRNOTAVAIL => return error.AddressUnavailable, |
| 2075 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | 2117 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, |
| 2076 | .AGAIN, .INPROGRESS => return error.WouldBlock, | 2118 | .AGAIN, .INPROGRESS => return error.WouldBlock, |
| ... | @@ -2100,6 +2142,7 @@ fn posixConnectUnix(t: *Threaded, fd: posix.socket_t, addr: *const posix.sockadd | ... | @@ -2100,6 +2142,7 @@ fn posixConnectUnix(t: *Threaded, fd: posix.socket_t, addr: *const posix.sockadd |
| 2100 | switch (posix.errno(posix.system.connect(fd, addr, addr_len))) { | 2142 | switch (posix.errno(posix.system.connect(fd, addr, addr_len))) { |
| 2101 | .SUCCESS => return, | 2143 | .SUCCESS => return, |
| 2102 | .INTR => continue, | 2144 | .INTR => continue, |
| | 2145 | .CANCELED => return error.Canceled, |
| 2103 | | 2146 | |
| 2104 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | 2147 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, |
| 2105 | .AGAIN => return error.WouldBlock, | 2148 | .AGAIN => return error.WouldBlock, |
| ... | @@ -2129,6 +2172,8 @@ fn posixGetSockName(t: *Threaded, socket_fd: posix.fd_t, addr: *posix.sockaddr, | ... | @@ -2129,6 +2172,8 @@ fn posixGetSockName(t: *Threaded, socket_fd: posix.fd_t, addr: *posix.sockaddr, |
| 2129 | switch (posix.errno(posix.system.getsockname(socket_fd, addr, addr_len))) { | 2172 | switch (posix.errno(posix.system.getsockname(socket_fd, addr, addr_len))) { |
| 2130 | .SUCCESS => break, | 2173 | .SUCCESS => break, |
| 2131 | .INTR => continue, | 2174 | .INTR => continue, |
| | 2175 | .CANCELED => return error.Canceled, |
| | 2176 | |
| 2132 | .BADF => |err| return errnoBug(err), // always a race condition | 2177 | .BADF => |err| return errnoBug(err), // always a race condition |
| 2133 | .FAULT => |err| return errnoBug(err), | 2178 | .FAULT => |err| return errnoBug(err), |
| 2134 | .INVAL => |err| return errnoBug(err), // invalid parameters | 2179 | .INVAL => |err| return errnoBug(err), // invalid parameters |
| ... | @@ -2146,6 +2191,8 @@ fn setSocketOption(t: *Threaded, fd: posix.fd_t, level: i32, opt_name: u32, opti | ... | @@ -2146,6 +2191,8 @@ fn setSocketOption(t: *Threaded, fd: posix.fd_t, level: i32, opt_name: u32, opti |
| 2146 | switch (posix.errno(posix.system.setsockopt(fd, level, opt_name, o.ptr, @intCast(o.len)))) { | 2191 | switch (posix.errno(posix.system.setsockopt(fd, level, opt_name, o.ptr, @intCast(o.len)))) { |
| 2147 | .SUCCESS => return, | 2192 | .SUCCESS => return, |
| 2148 | .INTR => continue, | 2193 | .INTR => continue, |
| | 2194 | .CANCELED => return error.Canceled, |
| | 2195 | |
| 2149 | .BADF => |err| return errnoBug(err), // always a race condition | 2196 | .BADF => |err| return errnoBug(err), // always a race condition |
| 2150 | .NOTSOCK => |err| return errnoBug(err), // always a race condition | 2197 | .NOTSOCK => |err| return errnoBug(err), // always a race condition |
| 2151 | .INVAL => |err| return errnoBug(err), | 2198 | .INVAL => |err| return errnoBug(err), |
| ... | @@ -2245,12 +2292,15 @@ fn openSocketPosix( | ... | @@ -2245,12 +2292,15 @@ fn openSocketPosix( |
| 2245 | switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFD, @as(usize, posix.FD_CLOEXEC)))) { | 2292 | switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFD, @as(usize, posix.FD_CLOEXEC)))) { |
| 2246 | .SUCCESS => break, | 2293 | .SUCCESS => break, |
| 2247 | .INTR => continue, | 2294 | .INTR => continue, |
| | 2295 | .CANCELED => return error.Canceled, |
| 2248 | else => |err| return posix.unexpectedErrno(err), | 2296 | else => |err| return posix.unexpectedErrno(err), |
| 2249 | } | 2297 | } |
| 2250 | }; | 2298 | }; |
| 2251 | break fd; | 2299 | break fd; |
| 2252 | }, | 2300 | }, |
| 2253 | .INTR => continue, | 2301 | .INTR => continue, |
| | 2302 | .CANCELED => return error.Canceled, |
| | 2303 | |
| 2254 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | 2304 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, |
| 2255 | .INVAL => return error.ProtocolUnsupportedBySystem, | 2305 | .INVAL => return error.ProtocolUnsupportedBySystem, |
| 2256 | .MFILE => return error.ProcessFdQuotaExceeded, | 2306 | .MFILE => return error.ProcessFdQuotaExceeded, |
| ... | @@ -2294,12 +2344,14 @@ fn netAcceptPosix(userdata: ?*anyopaque, listen_fd: net.Socket.Handle) net.Serve | ... | @@ -2294,12 +2344,14 @@ fn netAcceptPosix(userdata: ?*anyopaque, listen_fd: net.Socket.Handle) net.Serve |
| 2294 | switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFD, @as(usize, posix.FD_CLOEXEC)))) { | 2344 | switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFD, @as(usize, posix.FD_CLOEXEC)))) { |
| 2295 | .SUCCESS => break, | 2345 | .SUCCESS => break, |
| 2296 | .INTR => continue, | 2346 | .INTR => continue, |
| | 2347 | .CANCELED => return error.Canceled, |
| 2297 | else => |err| return posix.unexpectedErrno(err), | 2348 | else => |err| return posix.unexpectedErrno(err), |
| 2298 | } | 2349 | } |
| 2299 | }; | 2350 | }; |
| 2300 | break fd; | 2351 | break fd; |
| 2301 | }, | 2352 | }, |
| 2302 | .INTR => continue, | 2353 | .INTR => continue, |
| | 2354 | .CANCELED => return error.Canceled, |
| 2303 | .AGAIN => |err| return errnoBug(err), | 2355 | .AGAIN => |err| return errnoBug(err), |
| 2304 | .BADF => |err| return errnoBug(err), // always a race condition | 2356 | .BADF => |err| return errnoBug(err), // always a race condition |
| 2305 | .CONNABORTED => return error.ConnectionAborted, | 2357 | .CONNABORTED => return error.ConnectionAborted, |
| ... | @@ -2343,6 +2395,7 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net. | ... | @@ -2343,6 +2395,7 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net. |
| 2343 | switch (std.os.wasi.fd_read(fd, dest.ptr, dest.len, &n)) { | 2395 | switch (std.os.wasi.fd_read(fd, dest.ptr, dest.len, &n)) { |
| 2344 | .SUCCESS => return n, | 2396 | .SUCCESS => return n, |
| 2345 | .INTR => continue, | 2397 | .INTR => continue, |
| | 2398 | .CANCELED => return error.Canceled, |
| 2346 | | 2399 | |
| 2347 | .INVAL => |err| return errnoBug(err), | 2400 | .INVAL => |err| return errnoBug(err), |
| 2348 | .FAULT => |err| return errnoBug(err), | 2401 | .FAULT => |err| return errnoBug(err), |
| ... | @@ -2364,6 +2417,7 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net. | ... | @@ -2364,6 +2417,7 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net. |
| 2364 | switch (posix.errno(rc)) { | 2417 | switch (posix.errno(rc)) { |
| 2365 | .SUCCESS => return @intCast(rc), | 2418 | .SUCCESS => return @intCast(rc), |
| 2366 | .INTR => continue, | 2419 | .INTR => continue, |
| | 2420 | .CANCELED => return error.Canceled, |
| 2367 | | 2421 | |
| 2368 | .INVAL => |err| return errnoBug(err), | 2422 | .INVAL => |err| return errnoBug(err), |
| 2369 | .FAULT => |err| return errnoBug(err), | 2423 | .FAULT => |err| return errnoBug(err), |
| ... | @@ -2464,6 +2518,7 @@ fn netSendOne( | ... | @@ -2464,6 +2518,7 @@ fn netSendOne( |
| 2464 | return; | 2518 | return; |
| 2465 | }, | 2519 | }, |
| 2466 | .INTR => continue, | 2520 | .INTR => continue, |
| | 2521 | .CANCELED => return error.Canceled, |
| 2467 | | 2522 | |
| 2468 | .ACCES => return error.AccessDenied, | 2523 | .ACCES => return error.AccessDenied, |
| 2469 | .ALREADY => return error.FastOpenAlreadyInProgress, | 2524 | .ALREADY => return error.FastOpenAlreadyInProgress, |
| ... | @@ -2531,13 +2586,15 @@ fn netSendMany( | ... | @@ -2531,13 +2586,15 @@ fn netSendMany( |
| 2531 | } | 2586 | } |
| 2532 | return n; | 2587 | return n; |
| 2533 | }, | 2588 | }, |
| | 2589 | .INTR => continue, |
| | 2590 | .CANCELED => return error.Canceled, |
| | 2591 | |
| 2534 | .AGAIN => |err| return errnoBug(err), | 2592 | .AGAIN => |err| return errnoBug(err), |
| 2535 | .ALREADY => return error.FastOpenAlreadyInProgress, | 2593 | .ALREADY => return error.FastOpenAlreadyInProgress, |
| 2536 | .BADF => |err| return errnoBug(err), // Always a race condition. | 2594 | .BADF => |err| return errnoBug(err), // Always a race condition. |
| 2537 | .CONNRESET => return error.ConnectionResetByPeer, | 2595 | .CONNRESET => return error.ConnectionResetByPeer, |
| 2538 | .DESTADDRREQ => |err| return errnoBug(err), // The socket is not connection-mode, and no peer address is set. | 2596 | .DESTADDRREQ => |err| return errnoBug(err), // The socket is not connection-mode, and no peer address is set. |
| 2539 | .FAULT => |err| return errnoBug(err), // An invalid user space address was specified for an argument. | 2597 | .FAULT => |err| return errnoBug(err), // An invalid user space address was specified for an argument. |
| 2540 | .INTR => continue, | | |
| 2541 | .INVAL => |err| return errnoBug(err), // Invalid argument passed. | 2598 | .INVAL => |err| return errnoBug(err), // Invalid argument passed. |
| 2542 | .ISCONN => |err| return errnoBug(err), // connection-mode socket was connected already but a recipient was specified | 2599 | .ISCONN => |err| return errnoBug(err), // connection-mode socket was connected already but a recipient was specified |
| 2543 | .MSGSIZE => return error.MessageOversize, | 2600 | .MSGSIZE => return error.MessageOversize, |
| ... | @@ -2654,6 +2711,7 @@ fn netReceive( | ... | @@ -2654,6 +2711,7 @@ fn netReceive( |
| 2654 | continue :recv; | 2711 | continue :recv; |
| 2655 | }, | 2712 | }, |
| 2656 | .INTR => continue, | 2713 | .INTR => continue, |
| | 2714 | .CANCELED => return .{ error.Canceled, message_i }, |
| 2657 | | 2715 | |
| 2658 | .FAULT => |err| return .{ errnoBug(err), message_i }, | 2716 | .FAULT => |err| return .{ errnoBug(err), message_i }, |
| 2659 | .INVAL => |err| return .{ errnoBug(err), message_i }, | 2717 | .INVAL => |err| return .{ errnoBug(err), message_i }, |
| ... | @@ -2662,6 +2720,7 @@ fn netReceive( | ... | @@ -2662,6 +2720,7 @@ fn netReceive( |
| 2662 | } | 2720 | } |
| 2663 | }, | 2721 | }, |
| 2664 | .INTR => continue, | 2722 | .INTR => continue, |
| | 2723 | .CANCELED => return .{ error.Canceled, message_i }, |
| 2665 | | 2724 | |
| 2666 | .BADF => |err| return .{ errnoBug(err), message_i }, | 2725 | .BADF => |err| return .{ errnoBug(err), message_i }, |
| 2667 | .NFILE => return .{ error.SystemFdQuotaExceeded, message_i }, | 2726 | .NFILE => return .{ error.SystemFdQuotaExceeded, message_i }, |
| ... | @@ -2780,6 +2839,8 @@ fn netInterfaceNameResolve( | ... | @@ -2780,6 +2839,8 @@ fn netInterfaceNameResolve( |
| 2780 | switch (posix.errno(posix.system.ioctl(sock_fd, posix.SIOCGIFINDEX, @intFromPtr(&ifr)))) { | 2839 | switch (posix.errno(posix.system.ioctl(sock_fd, posix.SIOCGIFINDEX, @intFromPtr(&ifr)))) { |
| 2781 | .SUCCESS => return .{ .index = @bitCast(ifr.ifru.ivalue) }, | 2840 | .SUCCESS => return .{ .index = @bitCast(ifr.ifru.ivalue) }, |
| 2782 | .INTR => continue, | 2841 | .INTR => continue, |
| | 2842 | .CANCELED => return error.Canceled, |
| | 2843 | |
| 2783 | .INVAL => |err| return errnoBug(err), // Bad parameters. | 2844 | .INVAL => |err| return errnoBug(err), // Bad parameters. |
| 2784 | .NOTTY => |err| return errnoBug(err), | 2845 | .NOTTY => |err| return errnoBug(err), |
| 2785 | .NXIO => |err| return errnoBug(err), | 2846 | .NXIO => |err| return errnoBug(err), |
| ... | @@ -2968,6 +3029,7 @@ fn netLookupFallible( | ... | @@ -2968,6 +3029,7 @@ fn netLookupFallible( |
| 2968 | .NONAME => return error.UnknownHostName, | 3029 | .NONAME => return error.UnknownHostName, |
| 2969 | .SYSTEM => switch (posix.errno(-1)) { | 3030 | .SYSTEM => switch (posix.errno(-1)) { |
| 2970 | .INTR => continue, | 3031 | .INTR => continue, |
| | 3032 | .CANCELED => return error.Canceled, |
| 2971 | else => |e| return posix.unexpectedErrno(e), | 3033 | else => |e| return posix.unexpectedErrno(e), |
| 2972 | }, | 3034 | }, |
| 2973 | else => return error.Unexpected, | 3035 | else => return error.Unexpected, |
| ... | @@ -3754,7 +3816,7 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void { | ... | @@ -3754,7 +3816,7 @@ pub fn futexWake(ptr: *const std.atomic.Value(u32), max_waiters: u32) void { |
| 3754 | const status = c.__ulock_wake(flags, ptr, 0); | 3816 | const status = c.__ulock_wake(flags, ptr, 0); |
| 3755 | if (status >= 0) return; | 3817 | if (status >= 0) return; |
| 3756 | switch (@as(c.E, @enumFromInt(-status))) { | 3818 | switch (@as(c.E, @enumFromInt(-status))) { |
| 3757 | .INTR => continue, // spurious wake() | 3819 | .INTR, .CANCELED => continue, // spurious wake() |
| 3758 | .FAULT => assert(!is_debug), // __ulock_wake doesn't generate EFAULT according to darwin pthread_cond_t | 3820 | .FAULT => assert(!is_debug), // __ulock_wake doesn't generate EFAULT according to darwin pthread_cond_t |
| 3759 | .NOENT => return, // nothing was woken up | 3821 | .NOENT => return, // nothing was woken up |
| 3760 | .ALREADY => assert(!is_debug), // only for UL.Op.WAKE_THREAD | 3822 | .ALREADY => assert(!is_debug), // only for UL.Op.WAKE_THREAD |