Skip to content

Commit

Permalink
Merge pull request #53 from fuweid/me-errclosed-for-read-reset-connec…
Browse files Browse the repository at this point in the history
…tion

return ErrClosed if read: connection reset by peer
  • Loading branch information
crosbymichael committed Oct 23, 2019
2 parents 012175f + 6e416ea commit 7a6a229
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,12 @@ func filterCloseErr(err error) error {
case strings.Contains(err.Error(), "use of closed network connection"):
return ErrClosed
default:
// if we have an epipe on a write, we cast to errclosed
if oerr, ok := err.(*net.OpError); ok && oerr.Op == "write" {
if serr, ok := oerr.Err.(*os.SyscallError); ok && serr.Err == syscall.EPIPE {
// if we have an epipe on a write or econnreset on a read , we cast to errclosed
if oerr, ok := err.(*net.OpError); ok && (oerr.Op == "write" || oerr.Op == "read") {
serr, sok := oerr.Err.(*os.SyscallError)
if sok && ((serr.Err == syscall.EPIPE && oerr.Op == "write") ||
(serr.Err == syscall.ECONNRESET && oerr.Op == "read")) {

return ErrClosed
}
}
Expand Down

0 comments on commit 7a6a229

Please sign in to comment.