mirror of https://github.com/golang/go.git
net: remove fallback path in sysSocket
Support for operating system versions requiring this fallback path 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. Change-Id: I7e74768146dd43a36d0d26fcb08eed9ace82189f Reviewed-on: https://go-review.googlesource.com/c/go/+/403634 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
356c8c5452
commit
35d02791b9
|
|
@ -10,7 +10,6 @@
|
|||
package net
|
||||
|
||||
import (
|
||||
"internal/poll"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
|
@ -19,32 +18,8 @@ import (
|
|||
// descriptor as nonblocking and close-on-exec.
|
||||
func sysSocket(family, sotype, proto int) (int, error) {
|
||||
s, err := socketFunc(family, sotype|syscall.SOCK_NONBLOCK|syscall.SOCK_CLOEXEC, proto)
|
||||
// On Linux the SOCK_NONBLOCK and SOCK_CLOEXEC flags were
|
||||
// introduced in 2.6.27 kernel and on FreeBSD both flags were
|
||||
// introduced in 10 kernel. If we get an EINVAL error on Linux
|
||||
// or EPROTONOSUPPORT error on FreeBSD, fall back to using
|
||||
// socket without them.
|
||||
switch err {
|
||||
case nil:
|
||||
return s, nil
|
||||
default:
|
||||
return -1, os.NewSyscallError("socket", err)
|
||||
case syscall.EPROTONOSUPPORT, syscall.EINVAL:
|
||||
}
|
||||
|
||||
// See ../syscall/exec_unix.go for description of ForkLock.
|
||||
syscall.ForkLock.RLock()
|
||||
s, err = socketFunc(family, sotype, proto)
|
||||
if err == nil {
|
||||
syscall.CloseOnExec(s)
|
||||
}
|
||||
syscall.ForkLock.RUnlock()
|
||||
if err != nil {
|
||||
return -1, os.NewSyscallError("socket", err)
|
||||
}
|
||||
if err = syscall.SetNonblock(s, true); err != nil {
|
||||
poll.CloseFunc(s)
|
||||
return -1, os.NewSyscallError("setnonblock", err)
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue