diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-04-17 15:42:12 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-04-25 00:26:48 +0000 |
commit | d422f54619b5b6e6301eaa3e9f22cfa7b65063c8 (patch) | |
tree | 23c599e3a59f33116cb9caad4aaa91a87ec03c0b /src/net/dial_test.go | |
parent | 396833caef83b20f38199f9d74cb3e768b2fd478 (diff) | |
download | go-d422f54619b5b6e6301eaa3e9f22cfa7b65063c8.tar.gz go-d422f54619b5b6e6301eaa3e9f22cfa7b65063c8.zip |
os, net: define and use os.ErrDeadlineExceeded
If an I/O operation fails because a deadline was exceeded,
return os.ErrDeadlineExceeded. We used to return poll.ErrTimeout,
an internal error, and told users to check the Timeout method.
However, there are other errors with a Timeout method that returns true,
notably syscall.ETIMEDOUT which is returned for a keep-alive timeout.
Checking errors.Is(err, os.ErrDeadlineExceeded) should permit code
to reliably tell why it failed.
This change does not affect the handling of net.Dialer.Deadline,
nor does it change the handling of net.DialContext when the context
deadline is exceeded. Those cases continue to return an error
reported as "i/o timeout" for which Timeout is true, but that error
is not os.ErrDeadlineExceeded.
Fixes #31449
Change-Id: I0323f42e944324c6f2578f00c3ac90c24fe81177
Reviewed-on: https://go-review.googlesource.com/c/go/+/228645
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Diffstat (limited to 'src/net/dial_test.go')
-rw-r--r-- | src/net/dial_test.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/net/dial_test.go b/src/net/dial_test.go index aedf643e98..01582489de 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -9,7 +9,6 @@ package net import ( "bufio" "context" - "internal/poll" "internal/testenv" "io" "os" @@ -540,8 +539,8 @@ func TestDialerPartialDeadline(t *testing.T) { {now, noDeadline, 1, noDeadline, nil}, // Step the clock forward and cross the deadline. {now.Add(-1 * time.Millisecond), now, 1, now, nil}, - {now.Add(0 * time.Millisecond), now, 1, noDeadline, poll.ErrTimeout}, - {now.Add(1 * time.Millisecond), now, 1, noDeadline, poll.ErrTimeout}, + {now.Add(0 * time.Millisecond), now, 1, noDeadline, errTimeout}, + {now.Add(1 * time.Millisecond), now, 1, noDeadline, errTimeout}, } for i, tt := range testCases { deadline, err := partialDeadline(tt.now, tt.deadline, tt.addrs) |