authorgravatar for kernel@jfarr.ccJan Hendrik Farr <kernel@jfarr.cc> 2024-06-16 03:29:34+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-08 01:12:26-07:00
logca012e5b69b9ff275c6e366c0348219d1c816f18
tree8a82fa41a2709de3377beb853988b8abc8c3f7de
parent6976a5da19bf45f315eba2a0047977c6e659b2b3

std.posix: read on timerfd can return error.Canceled


4 files changed, 8 insertions(+), 0 deletions(-)

lib/compiler/fmt.zig+1
...@@ -185,6 +185,7 @@ const FmtError = error{...@@ -185,6 +185,7 @@ const FmtError = error{
185 BrokenPipe,185 BrokenPipe,
186 Unexpected,186 Unexpected,
187 WouldBlock,187 WouldBlock,
188 Canceled,
188 FileClosed,189 FileClosed,
189 DestinationAddressRequired,190 DestinationAddressRequired,
190 DiskQuota,191 DiskQuota,
lib/std/posix.zig+5
...@@ -791,6 +791,10 @@ pub const ReadError = error{...@@ -791,6 +791,10 @@ pub const ReadError = error{
791 /// and reading from the file descriptor would block.791 /// and reading from the file descriptor would block.
792 WouldBlock,792 WouldBlock,
793793
794 /// reading a timerfd with CANCEL_ON_SET will lead to this error
795 /// when the clock goes through a discontinuous change
796 Canceled,
797
794 /// In WASI, this error occurs when the file descriptor does798 /// In WASI, this error occurs when the file descriptor does
795 /// not hold the required rights to read from it.799 /// not hold the required rights to read from it.
796 AccessDenied,800 AccessDenied,
...@@ -851,6 +855,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {...@@ -851,6 +855,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
851 .INVAL => unreachable,855 .INVAL => unreachable,
852 .FAULT => unreachable,856 .FAULT => unreachable,
853 .AGAIN => return error.WouldBlock,857 .AGAIN => return error.WouldBlock,
858 .CANCELED => return error.Canceled,
854 .BADF => return error.NotOpenForReading, // Can be a race condition.859 .BADF => return error.NotOpenForReading, // Can be a race condition.
855 .IO => return error.InputOutput,860 .IO => return error.InputOutput,
856 .ISDIR => return error.IsDir,861 .ISDIR => return error.IsDir,
lib/std/zig/system.zig+1
...@@ -1141,6 +1141,7 @@ fn preadAtLeast(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usi...@@ -1141,6 +1141,7 @@ fn preadAtLeast(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usi
1141 const len = file.pread(buf[i..], offset + i) catch |err| switch (err) {1141 const len = file.pread(buf[i..], offset + i) catch |err| switch (err) {
1142 error.OperationAborted => unreachable, // Windows-only1142 error.OperationAborted => unreachable, // Windows-only
1143 error.WouldBlock => unreachable, // Did not request blocking mode1143 error.WouldBlock => unreachable, // Did not request blocking mode
1144 error.Canceled => unreachable, // timerfd is unseekable
1144 error.NotOpenForReading => unreachable,1145 error.NotOpenForReading => unreachable,
1145 error.SystemResources => return error.SystemResources,1146 error.SystemResources => return error.SystemResources,
1146 error.IsDir => return error.UnableToReadElfFile,1147 error.IsDir => return error.UnableToReadElfFile,
src/link.zig+1
...@@ -350,6 +350,7 @@ pub const File = struct {...@@ -350,6 +350,7 @@ pub const File = struct {
350 SocketNotConnected,350 SocketNotConnected,
351 NotOpenForReading,351 NotOpenForReading,
352 WouldBlock,352 WouldBlock,
353 Canceled,
353 AccessDenied,354 AccessDenied,
354 Unexpected,355 Unexpected,
355 DiskQuota,356 DiskQuota,