authorgravatar for kenta@lithdew.netlithdew <kenta@lithdew.net> 2021-04-12 17:26:28+09:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-14 16:40:06-07:00
log81adcd533e168bee9a16f30f690cf72aa99c1eb6
tree6a735567853932ee1d422e75542e6d82344ff212
parent5a3ea9beced660c9cc463b921a1581cc07855dd6

os/posix: handle ECONNRESET for write/writev


2 files changed, 6 insertions(+), 0 deletions(-)

lib/std/os.zig+5
...@@ -675,6 +675,9 @@ pub const WriteError = error{...@@ -675,6 +675,9 @@ pub const WriteError = error{
675 /// This error occurs when no global event loop is configured,675 /// This error occurs when no global event loop is configured,
676 /// and reading from the file descriptor would block.676 /// and reading from the file descriptor would block.
677 WouldBlock,677 WouldBlock,
678
679 /// Connection reset by peer.
680 ConnectionResetByPeer,
678} || UnexpectedError;681} || UnexpectedError;
679682
680/// Write to a file descriptor.683/// Write to a file descriptor.
...@@ -752,6 +755,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {...@@ -752,6 +755,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
752 ENOSPC => return error.NoSpaceLeft,755 ENOSPC => return error.NoSpaceLeft,
753 EPERM => return error.AccessDenied,756 EPERM => return error.AccessDenied,
754 EPIPE => return error.BrokenPipe,757 EPIPE => return error.BrokenPipe,
758 ECONNRESET => return error.ConnectionResetByPeer,
755 else => |err| return unexpectedErrno(err),759 else => |err| return unexpectedErrno(err),
756 }760 }
757 }761 }
...@@ -820,6 +824,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {...@@ -820,6 +824,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {
820 ENOSPC => return error.NoSpaceLeft,824 ENOSPC => return error.NoSpaceLeft,
821 EPERM => return error.AccessDenied,825 EPERM => return error.AccessDenied,
822 EPIPE => return error.BrokenPipe,826 EPIPE => return error.BrokenPipe,
827 ECONNRESET => return error.ConnectionResetByPeer,
823 else => |err| return unexpectedErrno(err),828 else => |err| return unexpectedErrno(err),
824 }829 }
825 }830 }
src/main.zig+1
...@@ -2859,6 +2859,7 @@ const FmtError = error{...@@ -2859,6 +2859,7 @@ const FmtError = error{
2859 Unseekable,2859 Unseekable,
2860 NotOpenForWriting,2860 NotOpenForWriting,
2861 UnsupportedEncoding,2861 UnsupportedEncoding,
2862 ConnectionResetByPeer,
2862} || fs.File.OpenError;2863} || fs.File.OpenError;
28632864
2864fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) FmtError!void {2865fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) FmtError!void {