b685de12d2
PR go/52583 net: Solaris fixes. In particular fix fd_select.go to handle the case where a file descriptor is closed by one goroutine while another goroutine is waiting for it. From-SVN: r186801
48 lines
935 B
Go
48 lines
935 B
Go
// Copyright 2012 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build solaris
|
|
|
|
// Sockets for Solaris
|
|
|
|
package net
|
|
|
|
import (
|
|
"syscall"
|
|
)
|
|
|
|
func maxListenerBacklog() int {
|
|
// The kernel does not track the limit.
|
|
return syscall.SOMAXCONN
|
|
}
|
|
|
|
func listenerSockaddr(s, f int, la syscall.Sockaddr, toAddr func(syscall.Sockaddr) Addr) (syscall.Sockaddr, error) {
|
|
a := toAddr(la)
|
|
if a == nil {
|
|
return la, nil
|
|
}
|
|
switch v := a.(type) {
|
|
case *TCPAddr, *UnixAddr:
|
|
err := setDefaultListenerSockopts(s)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
case *UDPAddr:
|
|
if v.IP.IsMulticast() {
|
|
err := setDefaultMulticastSockopts(s)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch f {
|
|
case syscall.AF_INET:
|
|
v.IP = IPv4zero
|
|
case syscall.AF_INET6:
|
|
v.IP = IPv6unspecified
|
|
}
|
|
return v.sockaddr(f)
|
|
}
|
|
}
|
|
return la, nil
|
|
}
|