Commit 50e3906951

Kenta Iwasaki <63115601+lithdew@users.noreply.github.com>
2020-09-03 19:57:08
os: return error.SocketNotListening for EINVAL on accept (#6226)
1 parent 9695479
Changed files (2)
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.
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,