1
0
mirror of https://github.com/golang/go synced 2024-11-23 06:10:05 -07:00

net: update SOCK_CLOEXEC comment

For #45964
For #59359

Change-Id: I7fd295a096e5776102e057789d157da681df9073
Reviewed-on: https://go-review.googlesource.com/c/go/+/501939
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Ian Lance Taylor 2023-06-08 17:21:56 -07:00 committed by Gopher Robot
parent bd00528d04
commit 19b814b80b

View File

@ -19,11 +19,9 @@ import (
// descriptor as nonblocking and close-on-exec. // descriptor as nonblocking and close-on-exec.
func sysSocket(family, sotype, proto int) (int, error) { func sysSocket(family, sotype, proto int) (int, error) {
s, err := socketFunc(family, sotype|syscall.SOCK_NONBLOCK|syscall.SOCK_CLOEXEC, proto) s, err := socketFunc(family, sotype|syscall.SOCK_NONBLOCK|syscall.SOCK_CLOEXEC, proto)
// On Linux the SOCK_NONBLOCK and SOCK_CLOEXEC flags were // TODO: We can remove the fallback on Linux and *BSD,
// introduced in 2.6.27 kernel and on FreeBSD both flags were // as currently supported versions all support accept4
// introduced in 10 kernel. If we get an EINVAL error on Linux // with SOCK_CLOEXEC, but Solaris does not. See issue #59359.
// or EPROTONOSUPPORT error on FreeBSD, fall back to using
// socket without them.
switch err { switch err {
case nil: case nil:
return s, nil return s, nil