]> Cypherpunks repositories - gostls13.git/commitdiff
net: map context errors from aborted dial to internal net package errors
authorBen Burkert <ben@benburkert.com>
Thu, 29 Mar 2018 22:04:58 +0000 (15:04 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 29 Mar 2018 23:39:53 +0000 (23:39 +0000)
Map the error returned when a dial is aborted from the context package
error to the internal net package error. For example, context.Canceled
errors map to errCanceled, and context.DeadlineExceeded errors map to
poll.ErrTimeout.

Fixes #23648

Change-Id: Idf9d3d08052d540740c0b054503aaed931dc5b1e
Reviewed-on: https://go-review.googlesource.com/103518
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/dial_unix_test.go
src/net/fd_unix.go

index 47052547284e580009b40d4628c5ed6822608f08..0adc10d0bdbeab3bbd99d98c143018f72cdf1008 100644 (file)
@@ -102,7 +102,8 @@ func TestDialContextCancelRace(t *testing.T) {
        if !ok || oe.Op != "dial" {
                t.Fatalf("Dial error = %#v; want dial *OpError", err)
        }
-       if oe.Err != ctx.Err() {
-               t.Errorf("DialContext = (%v, %v); want OpError with error %v", c, err, ctx.Err())
+
+       if oe.Err != errCanceled {
+               t.Errorf("DialContext = (%v, %v); want OpError with error %v", c, err, errCanceled)
        }
 }
index dd3c1ed88203b7a31bf2fb0dea02336d70879d09..efe2e184afcb1f6b6a5f38252eed6a6bb0d3cf2d 100644 (file)
@@ -121,7 +121,7 @@ func (fd *netFD) connect(ctx context.Context, la, ra syscall.Sockaddr) (rsa sysc
                                // == nil). Because we've now poisoned the connection
                                // by making it unwritable, don't return a successful
                                // dial. This was issue 16523.
-                               ret = ctxErr
+                               ret = mapErr(ctxErr)
                                fd.Close() // prevent a leak
                        }
                }()