From: Alex Brainman Date: Fri, 2 Nov 2012 00:07:22 +0000 (+1100) Subject: net: use better error messages on windows X-Git-Tag: go1.1rc2~1977 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=84e20465fc33f1702d6dfc7ed1c05b457acb1b5b;p=gostls13.git net: use better error messages on windows Fixes #4320. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6810064 --- diff --git a/src/pkg/net/fd_unix.go b/src/pkg/net/fd_unix.go index 828e998e3e..ee82ead026 100644 --- a/src/pkg/net/fd_unix.go +++ b/src/pkg/net/fd_unix.go @@ -7,7 +7,6 @@ package net import ( - "errors" "io" "os" "runtime" @@ -346,8 +345,6 @@ func (fd *netFD) connect(ra syscall.Sockaddr) error { return err } -var errClosing = errors.New("use of closed network connection") - // Add a reference to this fd. // If closing==true, pollserver must be locked; mark the fd as closing. // Returns an error if the fd cannot be used. diff --git a/src/pkg/net/fd_windows.go b/src/pkg/net/fd_windows.go index f94f08295f..040439ab3b 100644 --- a/src/pkg/net/fd_windows.go +++ b/src/pkg/net/fd_windows.go @@ -196,11 +196,12 @@ func (s *ioSrv) ExecIO(oi anOpIface, deadline int64) (int, error) { } // Wait for our request to complete. var r ioResult - var cancelled bool + var cancelled, timeout bool select { case r = <-o.resultc: case <-timer: cancelled = true + timeout = true case <-o.fd.closec: cancelled = true } @@ -220,7 +221,11 @@ func (s *ioSrv) ExecIO(oi anOpIface, deadline int64) (int, error) { // Wait for IO to be canceled or complete successfully. r = <-o.resultc if r.err == syscall.ERROR_OPERATION_ABORTED { // IO Canceled - r.err = syscall.EWOULDBLOCK + if timeout { + r.err = errTimeout + } else { + r.err = errClosing + } } } if r.err != nil { @@ -312,8 +317,6 @@ func (fd *netFD) connect(ra syscall.Sockaddr) error { return syscall.Connect(fd.sysfd, ra) } -var errClosing = errors.New("use of closed network connection") - // Add a reference to this fd. // If closing==true, mark the fd as closing. // Returns an error if the fd cannot be used. diff --git a/src/pkg/net/net.go b/src/pkg/net/net.go index 9ebcdbe996..d6563e0a23 100644 --- a/src/pkg/net/net.go +++ b/src/pkg/net/net.go @@ -221,6 +221,8 @@ func (e *timeoutError) Temporary() bool { return true } var errTimeout error = &timeoutError{} +var errClosing = errors.New("use of closed network connection") + type AddrError struct { Err string Addr string