]> Cypherpunks repositories - gostls13.git/commitdiff
net: use better error messages on windows
authorAlex Brainman <alex.brainman@gmail.com>
Fri, 2 Nov 2012 00:07:22 +0000 (11:07 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Fri, 2 Nov 2012 00:07:22 +0000 (11:07 +1100)
Fixes #4320.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6810064

src/pkg/net/fd_unix.go
src/pkg/net/fd_windows.go
src/pkg/net/net.go

index 828e998e3eaf23cb08767760b80afd4e23a8bd59..ee82ead0266c75f0a85dca8432ac60af1a656e66 100644 (file)
@@ -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.
index f94f08295f2ddd3644c3b51ac882b236c01cec18..040439ab3b06ae254c656d79ab04c553b241e71f 100644 (file)
@@ -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.
index 9ebcdbe996cde22c7c4bdd0261619ded64af703a..d6563e0a2301b2ea89ed1d0e560b1cf702bb01fa 100644 (file)
@@ -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