authorgravatar for 63115601+lithdew@users.noreply.github.comKenta Iwasaki <63115601+lithdew@users.noreply.github.com> 2020-09-04 02:57:08+09:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-09-03 13:57:08-04:00
log50e39069518a0c2643cd5e3189ad087b5fbed0c6
treea8998ecbe97dfe5a5616191440ae5758dd613a66
parent969547902b49d6b21af762fb24ed591789b9d2a4
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

os: return error.SocketNotListening for EINVAL on accept (#6226)


2 files changed, 7 insertions(+), 1 deletions(-)

lib/std/net.zig+3
...@@ -1641,6 +1641,9 @@ pub const StreamServer = struct {...@@ -1641,6 +1641,9 @@ pub const StreamServer = struct {
1641 /// by the socket buffer limits, not by the system memory.1641 /// by the socket buffer limits, not by the system memory.
1642 SystemResources,1642 SystemResources,
16431643
1644 /// Socket is not listening for new connections.
1645 SocketNotListening,
1646
1644 ProtocolFailure,1647 ProtocolFailure,
16451648
1646 /// Firewall rules forbid connection.1649 /// Firewall rules forbid connection.
lib/std/os.zig+4-1
...@@ -2802,6 +2802,9 @@ pub const AcceptError = error{...@@ -2802,6 +2802,9 @@ pub const AcceptError = error{
2802 /// by the socket buffer limits, not by the system memory.2802 /// by the socket buffer limits, not by the system memory.
2803 SystemResources,2803 SystemResources,
28042804
2805 /// Socket is not listening for new connections.
2806 SocketNotListening,
2807
2805 ProtocolFailure,2808 ProtocolFailure,
28062809
2807 /// Firewall rules forbid connection.2810 /// Firewall rules forbid connection.
...@@ -2870,7 +2873,7 @@ pub fn accept(...@@ -2870,7 +2873,7 @@ pub fn accept(
2870 EBADF => unreachable, // always a race condition2873 EBADF => unreachable, // always a race condition
2871 ECONNABORTED => return error.ConnectionAborted,2874 ECONNABORTED => return error.ConnectionAborted,
2872 EFAULT => unreachable,2875 EFAULT => unreachable,
2873 EINVAL => unreachable,2876 EINVAL => return error.SocketNotListening,
2874 ENOTSOCK => unreachable,2877 ENOTSOCK => unreachable,
2875 EMFILE => return error.ProcessFdQuotaExceeded,2878 EMFILE => return error.ProcessFdQuotaExceeded,
2876 ENFILE => return error.SystemFdQuotaExceeded,2879 ENFILE => return error.SystemFdQuotaExceeded,