summaryrefslogtreecommitdiff
path: root/libgo/go/net/sock_posix.go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-21 07:03:38 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-21 07:03:38 +0000
commit79a796b7d3db5d100eedfc774954a6b44944363a (patch)
tree72455aea0286937aa08cc141e5efc800e4626577 /libgo/go/net/sock_posix.go
parent7224cf54b3af2b931fb83af65f9cfab5c1df814a (diff)
downloadgcc-79a796b7d3db5d100eedfc774954a6b44944363a.tar.gz
libgo: Update to current version of master library.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193688 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/net/sock_posix.go')
-rw-r--r--libgo/go/net/sock_posix.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/libgo/go/net/sock_posix.go b/libgo/go/net/sock_posix.go
index dc5247a7f38..78417fd2ee7 100644
--- a/libgo/go/net/sock_posix.go
+++ b/libgo/go/net/sock_posix.go
@@ -11,12 +11,13 @@ package net
import (
"io"
"syscall"
+ "time"
)
var listenerBacklog = maxListenerBacklog()
// Generic socket creation.
-func socket(net string, f, t, p int, ipv6only bool, ulsa, ursa syscall.Sockaddr, toAddr func(syscall.Sockaddr) Addr) (fd *netFD, err error) {
+func socket(net string, f, t, p int, ipv6only bool, ulsa, ursa syscall.Sockaddr, deadline time.Time, toAddr func(syscall.Sockaddr) Addr) (fd *netFD, err error) {
// See ../syscall/exec_unix.go for description of ForkLock.
syscall.ForkLock.RLock()
s, err := syscall.Socket(f, t, p)
@@ -32,13 +33,19 @@ func socket(net string, f, t, p int, ipv6only bool, ulsa, ursa syscall.Sockaddr,
return nil, err
}
- var blsa syscall.Sockaddr
if ulsa != nil {
- if blsa, err = listenerSockaddr(s, f, ulsa, toAddr); err != nil {
+ // We provide a socket that listens to a wildcard
+ // address with reusable UDP port when the given ulsa
+ // is an appropriate UDP multicast address prefix.
+ // This makes it possible for a single UDP listener
+ // to join multiple different group addresses, for
+ // multiple UDP listeners that listen on the same UDP
+ // port to join the same group address.
+ if ulsa, err = listenerSockaddr(s, f, ulsa, toAddr); err != nil {
closesocket(s)
return nil, err
}
- if err = syscall.Bind(s, blsa); err != nil {
+ if err = syscall.Bind(s, ulsa); err != nil {
closesocket(s)
return nil, err
}
@@ -50,21 +57,20 @@ func socket(net string, f, t, p int, ipv6only bool, ulsa, ursa syscall.Sockaddr,
}
if ursa != nil {
+ if !deadline.IsZero() {
+ fd.wdeadline = deadline.UnixNano()
+ }
if err = fd.connect(ursa); err != nil {
closesocket(s)
fd.Close()
return nil, err
}
fd.isConnected = true
+ fd.wdeadline = 0
}
lsa, _ := syscall.Getsockname(s)
- var laddr Addr
- if ulsa != nil && blsa != ulsa {
- laddr = toAddr(ulsa)
- } else {
- laddr = toAddr(lsa)
- }
+ laddr := toAddr(lsa)
rsa, _ := syscall.Getpeername(s)
raddr := toAddr(rsa)
fd.setAddr(laddr, raddr)