Skip to content

Commit 72b0fb5

Browse files
benburkertianlancetaylor
authored andcommitted
net: map context errors from aborted dial to internal net package errors
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>
1 parent dfd7f35 commit 72b0fb5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/net/dial_unix_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ func TestDialContextCancelRace(t *testing.T) {
102102
if !ok || oe.Op != "dial" {
103103
t.Fatalf("Dial error = %#v; want dial *OpError", err)
104104
}
105-
if oe.Err != ctx.Err() {
106-
t.Errorf("DialContext = (%v, %v); want OpError with error %v", c, err, ctx.Err())
105+
106+
if oe.Err != errCanceled {
107+
t.Errorf("DialContext = (%v, %v); want OpError with error %v", c, err, errCanceled)
107108
}
108109
}

src/net/fd_unix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (fd *netFD) connect(ctx context.Context, la, ra syscall.Sockaddr) (rsa sysc
121121
// == nil). Because we've now poisoned the connection
122122
// by making it unwritable, don't return a successful
123123
// dial. This was issue 16523.
124-
ret = ctxErr
124+
ret = mapErr(ctxErr)
125125
fd.Close() // prevent a leak
126126
}
127127
}()

0 commit comments

Comments
 (0)