]> Cypherpunks repositories - gostls13.git/commit
os, net, internal/poll: return consistent error for closed socket
authorIan Lance Taylor <iant@golang.org>
Fri, 7 Apr 2017 22:53:19 +0000 (15:53 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 26 Apr 2017 00:03:14 +0000 (00:03 +0000)
commitfb4b4342fe298fda640bfa74f24b7bd58519deba
treec7a059175bfb5630b432a5efe5d467abc59c2794
parent2fb2ebc32ee37a66e3d6a77ff9450665153a604c
os, net, internal/poll: return consistent error for closed socket

In the past we returned "use of closed network connection" when using
a closed network descriptor in some way. In CL 36799 that was changed
to return "use of closed file or network connection". Because programs
have no access to a value of this error type (see issue #4373) they
resort to doing direct string comparisons (see issue #19252). This CL
restores the old error string so that we don't break programs
unnecessarily with the 1.9 release.

This adds a test to the net package for the expected string.

For symmetry check that the os package returns the expected error,
which for os already exists as os.ErrClosed.

Updates #4373.
Fixed #19252.

Change-Id: I5b83fd12cfa03501a077cad9336499b819f4a38b
Reviewed-on: https://go-review.googlesource.com/39997
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
19 files changed:
src/internal/poll/fd.go
src/internal/poll/fd_mutex.go
src/internal/poll/fd_plan9.go
src/internal/poll/fd_poll_nacl.go
src/internal/poll/fd_poll_runtime.go
src/internal/poll/fd_posix_test.go
src/internal/poll/fd_unix.go
src/internal/poll/fd_windows.go
src/internal/poll/sendfile_bsd.go
src/internal/poll/sendfile_linux.go
src/internal/poll/sendfile_solaris.go
src/internal/poll/writev.go
src/net/error_test.go
src/net/fd_unix.go
src/net/file_test.go
src/net/net_test.go
src/os/file.go
src/os/file_unix.go
src/os/pipe_test.go