]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: remove fallback path in accept
authorTobias Klauser <tklauser@distanz.ch>
Tue, 9 Aug 2022 15:45:01 +0000 (17:45 +0200)
committerGopher Robot <gobot@golang.org>
Thu, 18 Aug 2022 16:12:31 +0000 (16:12 +0000)
Support for operating system versions requiring the fallback to
CloseOnExec/SetNonblock was dropped from recent Go versions. The minimum
Linux kernel version is 2.6.32 as of Go 1.18. FreeBSD 10 is no longer
supported as of Go 1.13.

Follows a similar change for net.sysSocket in CL 403634 and
syscall.Socket in CL 422374.

For #45964

Change-Id: I60848415742a1d8204e1fda585462ff35ad6722f
Reviewed-on: https://go-review.googlesource.com/c/go/+/422375
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/internal/poll/sock_cloexec.go

index e106b28377b6626ad0531c886ad33ca35cc1bf93..4fb9f004bbfe4a5d300bd739d0adca3e34390697 100644 (file)
@@ -15,36 +15,8 @@ import "syscall"
 // descriptor as nonblocking and close-on-exec.
 func accept(s int) (int, syscall.Sockaddr, string, error) {
        ns, sa, err := Accept4Func(s, syscall.SOCK_NONBLOCK|syscall.SOCK_CLOEXEC)
-       // On Linux the accept4 system call was introduced in 2.6.28
-       // 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.
-       switch err {
-       case nil:
-               return ns, sa, "", nil
-       default: // errors other than the ones listed
-               return -1, sa, "accept4", 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.
-       // It is probably okay to hold the lock across syscall.Accept
-       // because we have put fd.sysfd into non-blocking mode.
-       // However, a call to the File method will put it back into
-       // blocking mode. We can't take that risk, so no use of ForkLock here.
-       ns, sa, err = AcceptFunc(s)
-       if err == nil {
-               syscall.CloseOnExec(ns)
-       }
        if err != nil {
-               return -1, nil, "accept", err
-       }
-       if err = syscall.SetNonblock(ns, true); err != nil {
-               CloseFunc(ns)
-               return -1, nil, "setnonblock", err
+               return -1, sa, "accept4", err
        }
        return ns, sa, "", nil
 }