From 50e39069518a0c2643cd5e3189ad087b5fbed0c6 Mon Sep 17 00:00:00 2001 From: Kenta Iwasaki <63115601+lithdew@users.noreply.github.com> Date: Fri, 4 Sep 2020 02:57:08 +0900 Subject: [PATCH] os: return error.SocketNotListening for EINVAL on accept (#6226) --- lib/std/net.zig | 3 +++ lib/std/os.zig | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/std/net.zig b/lib/std/net.zig index 5a1407c35..45d8f07f0 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -1641,6 +1641,9 @@ pub const StreamServer = struct { /// by the socket buffer limits, not by the system memory. SystemResources, + /// Socket is not listening for new connections. + SocketNotListening, + ProtocolFailure, /// Firewall rules forbid connection. diff --git a/lib/std/os.zig b/lib/std/os.zig index e8431c386..2e4cc3aed 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -2802,6 +2802,9 @@ pub const AcceptError = error{ /// by the socket buffer limits, not by the system memory. SystemResources, + /// Socket is not listening for new connections. + SocketNotListening, + ProtocolFailure, /// Firewall rules forbid connection. @@ -2870,7 +2873,7 @@ pub fn accept( EBADF => unreachable, // always a race condition ECONNABORTED => return error.ConnectionAborted, EFAULT => unreachable, - EINVAL => unreachable, + EINVAL => return error.SocketNotListening, ENOTSOCK => unreachable, EMFILE => return error.ProcessFdQuotaExceeded, ENFILE => return error.SystemFdQuotaExceeded,