mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: fix broken setDefaultSockopts
R=rsc, bradfitz CC=golang-dev https://golang.org/cl/5536068
This commit is contained in:
parent
8d66a416cb
commit
743c2d0f48
8 changed files with 44 additions and 35 deletions
|
|
@ -10,14 +10,15 @@ import (
|
|||
"syscall"
|
||||
)
|
||||
|
||||
func setDefaultSockopts(s, f, p int) {
|
||||
func setDefaultSockopts(s, f, t int) {
|
||||
switch f {
|
||||
case syscall.AF_INET6:
|
||||
// Allow both IP versions even if the OS default is otherwise.
|
||||
syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0)
|
||||
}
|
||||
|
||||
if f == syscall.AF_UNIX || p == syscall.IPPROTO_TCP {
|
||||
if f == syscall.AF_UNIX ||
|
||||
(f == syscall.AF_INET || f == syscall.AF_INET6) && t == syscall.SOCK_STREAM {
|
||||
// Allow reuse of recently-used addresses.
|
||||
syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue