From 5fb39cc6a2621602d33c6b226742795318a279ea Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 3 Apr 2014 16:10:45 -0400 Subject: [PATCH] net: accept a few more errors in Accept4 wrapper Fixes #7271. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/84170043 --- src/pkg/net/sock_cloexec.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pkg/net/sock_cloexec.go b/src/pkg/net/sock_cloexec.go index 18ff64388c..dec81855b6 100644 --- a/src/pkg/net/sock_cloexec.go +++ b/src/pkg/net/sock_cloexec.go @@ -49,8 +49,13 @@ func accept(s int) (int, syscall.Sockaddr, error) { // kernel and on FreeBSD it was introduced in 10 kernel. If we // get an ENOSYS error on both Linux and FreeBSD, or EINVAL // error on Linux, fall back to using accept. - if err == nil || (err != syscall.ENOSYS && err != syscall.EINVAL) { + switch err { + default: // nil and errors other than the ones listed return ns, sa, err + case syscall.ENOSYS: // syscall missing + case syscall.EINVAL: // some Linux use this instead of ENOSYS + case syscall.EACCES: // some Linux use this instead of ENOSYS + case syscall.EFAULT: // some Linux use this instead of ENOSYS } // See ../syscall/exec_unix.go for description of ForkLock. -- 2.50.0