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{
675675 /// This error occurs when no global event loop is configured,
676676 /// and reading from the file descriptor would block.
677677 WouldBlock,
678
679 /// Connection reset by peer.
680 ConnectionResetByPeer,
678681} || UnexpectedError;
679682
680683/// Write to a file descriptor.
......@@ -752,6 +755,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
752755 ENOSPC => return error.NoSpaceLeft,
753756 EPERM => return error.AccessDenied,
754757 EPIPE => return error.BrokenPipe,
758 ECONNRESET => return error.ConnectionResetByPeer,
755759 else => |err| return unexpectedErrno(err),
756760 }
757761 }
......@@ -820,6 +824,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {
820824 ENOSPC => return error.NoSpaceLeft,
821825 EPERM => return error.AccessDenied,
822826 EPIPE => return error.BrokenPipe,
827 ECONNRESET => return error.ConnectionResetByPeer,
823828 else => |err| return unexpectedErrno(err),
824829 }
825830 }
src/main.zig+1
......@@ -2859,6 +2859,7 @@ const FmtError = error{
28592859 Unseekable,
28602860 NotOpenForWriting,
28612861 UnsupportedEncoding,
2862 ConnectionResetByPeer,
28622863} || fs.File.OpenError;
28632864
28642865fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) FmtError!void {