diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-07-16 06:54:42 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-07-16 06:54:42 +0000 |
commit | be47d6eceffd2c5dbbc1566d5eea490527fb2bd4 (patch) | |
tree | 0e8fda573576bb4181dba29d0e88380a8c38fafd /libgo/go/net/fd_windows.go | |
parent | efb30cdeb003fd7c585ee0d7657340086abcbd9e (diff) | |
download | gcc-be47d6eceffd2c5dbbc1566d5eea490527fb2bd4.tar.gz |
libgo: Update to Go 1.1.1.
From-SVN: r200974
Diffstat (limited to 'libgo/go/net/fd_windows.go')
-rw-r--r-- | libgo/go/net/fd_windows.go | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/libgo/go/net/fd_windows.go b/libgo/go/net/fd_windows.go index ea6ef10ec1a..fefd174bafa 100644 --- a/libgo/go/net/fd_windows.go +++ b/libgo/go/net/fd_windows.go @@ -37,6 +37,7 @@ func sysInit() { } canCancelIO = syscall.LoadCancelIoEx() == nil if syscall.LoadGetAddrInfo() == nil { + lookupPort = newLookupPort lookupIP = newLookupIP } } @@ -53,18 +54,17 @@ func canUseConnectEx(net string) bool { return syscall.LoadConnectEx() == nil } -func dialTimeout(net, addr string, timeout time.Duration) (Conn, error) { +func resolveAndDial(net, addr string, localAddr Addr, deadline time.Time) (Conn, error) { if !canUseConnectEx(net) { // Use the relatively inefficient goroutine-racing // implementation of DialTimeout. - return dialTimeoutRace(net, addr, timeout) + return resolveAndDialChannel(net, addr, localAddr, deadline) } - deadline := time.Now().Add(timeout) - _, addri, err := resolveNetAddr("dial", net, addr, deadline) + ra, err := resolveAddr("dial", net, addr, deadline) if err != nil { return nil, err } - return dialAddr(net, addr, addri, deadline) + return dial(net, addr, localAddr, ra, deadline) } // Interface for all IO operations. @@ -137,12 +137,18 @@ type resultSrv struct { iocp syscall.Handle } +func runtime_blockingSyscallHint() + func (s *resultSrv) Run() { var o *syscall.Overlapped var key uint32 var r ioResult for { - r.err = syscall.GetQueuedCompletionStatus(s.iocp, &(r.qty), &key, &o, syscall.INFINITE) + r.err = syscall.GetQueuedCompletionStatus(s.iocp, &(r.qty), &key, &o, 0) + if r.err == syscall.Errno(syscall.WAIT_TIMEOUT) && o == nil { + runtime_blockingSyscallHint() + r.err = syscall.GetQueuedCompletionStatus(s.iocp, &(r.qty), &key, &o, syscall.INFINITE) + } switch { case r.err == nil: // Dequeued successfully completed IO packet. @@ -358,22 +364,23 @@ func (o *connectOp) Name() string { return "ConnectEx" } -func (fd *netFD) connect(ra syscall.Sockaddr) error { +func (fd *netFD) connect(la, ra syscall.Sockaddr) error { if !canUseConnectEx(fd.net) { return syscall.Connect(fd.sysfd, ra) } // ConnectEx windows API requires an unconnected, previously bound socket. - var la syscall.Sockaddr - switch ra.(type) { - case *syscall.SockaddrInet4: - la = &syscall.SockaddrInet4{} - case *syscall.SockaddrInet6: - la = &syscall.SockaddrInet6{} - default: - panic("unexpected type in connect") - } - if err := syscall.Bind(fd.sysfd, la); err != nil { - return err + if la == nil { + switch ra.(type) { + case *syscall.SockaddrInet4: + la = &syscall.SockaddrInet4{} + case *syscall.SockaddrInet6: + la = &syscall.SockaddrInet6{} + default: + panic("unexpected type in connect") + } + if err := syscall.Bind(fd.sysfd, la); err != nil { + return err + } } // Call ConnectEx API. var o connectOp @@ -618,15 +625,10 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (*netFD, error) { defer fd.decref() // Get new socket. - // See ../syscall/exec_unix.go for description of ForkLock. - syscall.ForkLock.RLock() - s, err := syscall.Socket(fd.family, fd.sotype, 0) + s, err := sysSocket(fd.family, fd.sotype, 0) if err != nil { - syscall.ForkLock.RUnlock() return nil, &OpError{"socket", fd.net, fd.laddr, err} } - syscall.CloseOnExec(s) - syscall.ForkLock.RUnlock() // Associate our new socket with IOCP. onceStartServer.Do(startServer) |