--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+func isConnError(err error) bool {
+ return false
+}
--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+func isConnError(err error) bool {
+ return false
+}
--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+
+package net
+
+import "syscall"
+
+func isConnError(err error) bool {
+ if se, ok := err.(syscall.Errno); ok {
+ return se == syscall.ECONNRESET || se == syscall.ECONNABORTED
+ }
+ return false
+}
--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+import "syscall"
+
+func isConnError(err error) bool {
+ if se, ok := err.(syscall.Errno); ok {
+ return se == syscall.WSAECONNRESET || se == syscall.WSAECONNABORTED
+ }
+ return false
+}
}
func (e *OpError) Temporary() bool {
+ // Treat ECONNRESET and ECONNABORTED as temporary errors when
+ // they come from calling accept. See issue 6163.
+ if e.Op == "accept" && isConnError(e.Err) {
+ return true
+ }
+
if ne, ok := e.Err.(*os.SyscallError); ok {
t, ok := ne.Err.(temporary)
return ok && t.Temporary()
}
withTCPConnPair(t, client, server)
}
+
+// Issue 24808: verify that ECONNRESET is not temporary for read.
+func TestNotTemporaryRead(t *testing.T) {
+ t.Parallel()
+ server := func(cs *TCPConn) error {
+ cs.SetLinger(0)
+ // Give the client time to get stuck in a Read.
+ time.Sleep(20 * time.Millisecond)
+ cs.Close()
+ return nil
+ }
+ client := func(ss *TCPConn) error {
+ _, err := ss.Read([]byte{0})
+ if err == nil {
+ return errors.New("Read succeeded unexpectedly")
+ } else if err == io.EOF {
+ // This happens on NaCl and Plan 9.
+ return nil
+ } else if ne, ok := err.(Error); !ok {
+ return fmt.Errorf("unexpected error %v", err)
+ } else if ne.Temporary() {
+ return fmt.Errorf("unexpected temporary error %v", err)
+ }
+ return nil
+ }
+ withTCPConnPair(t, client, server)
+}
}
func (e Errno) Temporary() bool {
- return e == EINTR || e == EMFILE || e == ECONNRESET || e == ECONNABORTED || e.Timeout()
+ return e == EINTR || e == EMFILE || e.Timeout()
}
func (e Errno) Timeout() bool {
}
func (e Errno) Temporary() bool {
- return e == EINTR || e == EMFILE || e == WSAECONNABORTED || e == WSAECONNRESET || e.Timeout()
+ return e == EINTR || e == EMFILE || e.Timeout()
}
func (e Errno) Timeout() bool {