authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2020-05-04 00:42:12-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-04 13:48:34-04:00
log75b699b2c624d62a4b6717f00bd0856b86c3f990
tree5272df9ae5ae091215b763a26e32dfa83369b6a6
parent9b788b765c1557a414710872fa9c11fce1f8c504

os.zig: add ETIMEDOUT error case to read function

According to documentation ETIMEDOUT (110) is a valid error code for the read function. I just had my long-running (been running for about 7 weeks) network program crash because it did not handle the ETIMEDOUT error code from "read".

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

lib/std/os.zig+2
...@@ -292,6 +292,7 @@ pub const ReadError = error{...@@ -292,6 +292,7 @@ pub const ReadError = error{
292 OperationAborted,292 OperationAborted,
293 BrokenPipe,293 BrokenPipe,
294 ConnectionResetByPeer,294 ConnectionResetByPeer,
295 ConnectionTimedOut,
295296
296 /// This error occurs when no global event loop is configured,297 /// This error occurs when no global event loop is configured,
297 /// and reading from the file descriptor would block.298 /// and reading from the file descriptor would block.
...@@ -351,6 +352,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {...@@ -351,6 +352,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
351 ENOBUFS => return error.SystemResources,352 ENOBUFS => return error.SystemResources,
352 ENOMEM => return error.SystemResources,353 ENOMEM => return error.SystemResources,
353 ECONNRESET => return error.ConnectionResetByPeer,354 ECONNRESET => return error.ConnectionResetByPeer,
355 ETIMEDOUT => return error.ConnectionTimedOut,
354 else => |err| return unexpectedErrno(err),356 else => |err| return unexpectedErrno(err),
355 }357 }
356 }358 }
lib/std/zig/system.zig+1
...@@ -837,6 +837,7 @@ pub const NativeTargetInfo = struct {...@@ -837,6 +837,7 @@ pub const NativeTargetInfo = struct {
837 error.BrokenPipe => return error.UnableToReadElfFile,837 error.BrokenPipe => return error.UnableToReadElfFile,
838 error.Unseekable => return error.UnableToReadElfFile,838 error.Unseekable => return error.UnableToReadElfFile,
839 error.ConnectionResetByPeer => return error.UnableToReadElfFile,839 error.ConnectionResetByPeer => return error.UnableToReadElfFile,
840 error.ConnectionTimedOut => return error.UnableToReadElfFile,
840 error.Unexpected => return error.Unexpected,841 error.Unexpected => return error.Unexpected,
841 error.InputOutput => return error.FileSystem,842 error.InputOutput => return error.FileSystem,
842 };843 };
src-self-hosted/stage2.zig+1
...@@ -841,6 +841,7 @@ export fn stage2_libc_parse(stage1_libc: *Stage2LibCInstallation, libc_file_z: [...@@ -841,6 +841,7 @@ export fn stage2_libc_parse(stage1_libc: *Stage2LibCInstallation, libc_file_z: [
841 error.EndOfStream => return .EndOfFile,841 error.EndOfStream => return .EndOfFile,
842 error.IsDir => return .IsDir,842 error.IsDir => return .IsDir,
843 error.ConnectionResetByPeer => unreachable,843 error.ConnectionResetByPeer => unreachable,
844 error.ConnectionTimedOut => unreachable,
844 error.OutOfMemory => return .OutOfMemory,845 error.OutOfMemory => return .OutOfMemory,
845 error.Unseekable => unreachable,846 error.Unseekable => unreachable,
846 error.SharingViolation => return .SharingViolation,847 error.SharingViolation => return .SharingViolation,