summaryrefslogtreecommitdiff
path: root/src/internal/poll/fd_poll_runtime.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-04-07 15:53:19 -0700
committerIan Lance Taylor <iant@golang.org>2017-04-26 00:03:14 +0000
commitfb4b4342fe298fda640bfa74f24b7bd58519deba (patch)
treec7a059175bfb5630b432a5efe5d467abc59c2794 /src/internal/poll/fd_poll_runtime.go
parent2fb2ebc32ee37a66e3d6a77ff9450665153a604c (diff)
downloadgo-git-fb4b4342fe298fda640bfa74f24b7bd58519deba.tar.gz
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>
Diffstat (limited to 'src/internal/poll/fd_poll_runtime.go')
-rw-r--r--src/internal/poll/fd_poll_runtime.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/internal/poll/fd_poll_runtime.go b/src/internal/poll/fd_poll_runtime.go
index b1e3a84fc2..08b40c2720 100644
--- a/src/internal/poll/fd_poll_runtime.go
+++ b/src/internal/poll/fd_poll_runtime.go
@@ -62,36 +62,36 @@ func (pd *pollDesc) evict() {
runtime_pollUnblock(pd.runtimeCtx)
}
-func (pd *pollDesc) prepare(mode int) error {
+func (pd *pollDesc) prepare(mode int, isFile bool) error {
if pd.runtimeCtx == 0 {
return nil
}
res := runtime_pollReset(pd.runtimeCtx, mode)
- return convertErr(res)
+ return convertErr(res, isFile)
}
-func (pd *pollDesc) prepareRead() error {
- return pd.prepare('r')
+func (pd *pollDesc) prepareRead(isFile bool) error {
+ return pd.prepare('r', isFile)
}
-func (pd *pollDesc) prepareWrite() error {
- return pd.prepare('w')
+func (pd *pollDesc) prepareWrite(isFile bool) error {
+ return pd.prepare('w', isFile)
}
-func (pd *pollDesc) wait(mode int) error {
+func (pd *pollDesc) wait(mode int, isFile bool) error {
if pd.runtimeCtx == 0 {
return errors.New("waiting for unsupported file type")
}
res := runtime_pollWait(pd.runtimeCtx, mode)
- return convertErr(res)
+ return convertErr(res, isFile)
}
-func (pd *pollDesc) waitRead() error {
- return pd.wait('r')
+func (pd *pollDesc) waitRead(isFile bool) error {
+ return pd.wait('r', isFile)
}
-func (pd *pollDesc) waitWrite() error {
- return pd.wait('w')
+func (pd *pollDesc) waitWrite(isFile bool) error {
+ return pd.wait('w', isFile)
}
func (pd *pollDesc) waitCanceled(mode int) {
@@ -101,12 +101,12 @@ func (pd *pollDesc) waitCanceled(mode int) {
runtime_pollWaitCanceled(pd.runtimeCtx, mode)
}
-func convertErr(res int) error {
+func convertErr(res int, isFile bool) error {
switch res {
case 0:
return nil
case 1:
- return ErrClosing
+ return errClosing(isFile)
case 2:
return ErrTimeout
}