]> Cypherpunks repositories - gostls13.git/commit
os, net: define and use os.ErrDeadlineExceeded
authorIan Lance Taylor <iant@golang.org>
Fri, 17 Apr 2020 22:42:12 +0000 (15:42 -0700)
committerIan Lance Taylor <iant@golang.org>
Sat, 25 Apr 2020 00:26:48 +0000 (00:26 +0000)
commitd422f54619b5b6e6301eaa3e9f22cfa7b65063c8
tree23c599e3a59f33116cb9caad4aaa91a87ec03c0b
parent396833caef83b20f38199f9d74cb3e768b2fd478
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>
20 files changed:
doc/go1.15.html
src/internal/poll/fd.go
src/internal/poll/fd_plan9.go
src/internal/poll/fd_poll_js.go
src/internal/poll/fd_poll_runtime.go
src/internal/poll/fd_windows.go
src/net/dial.go
src/net/dial_test.go
src/net/dnsclient_unix_test.go
src/net/error_test.go
src/net/net.go
src/net/pipe.go
src/net/rawconn_test.go
src/net/timeout_test.go
src/net/unixsock_test.go
src/os/error.go
src/os/file.go
src/os/os_test.go
src/os/os_unix_test.go
src/os/timeout_test.go