Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Checking errors for EPIPE and ECONNRESET requires syscall #8319

Open
PieterD opened this issue Jul 2, 2014 · 5 comments
Open

net: Checking errors for EPIPE and ECONNRESET requires syscall #8319

PieterD opened this issue Jul 2, 2014 · 5 comments
Labels
Milestone

Comments

@PieterD
Copy link
Contributor

PieterD commented Jul 2, 2014

Reading and writing can cause EPIPE and ECONNRESET to be returned in addition to io.EOF.

_, err := conn.Write(data)
if oe, ok := err.(*net.OpError); ok && (oe.Err == syscall.EPIPE || oe.Err ==
syscall.ECONNRESET) {
    return fmt.Errorf("Connection closed")
}

_, err := conn.Read(data)
oe, ok := err.(*net.OpError)
if err == io.EOF || ok && oe.Err == syscall.ECONNRESET {
    return fmt.Errorf("Connection closed")
}

This isn't the neatest solution, and if we're going to freeze and possibly internalize
syscall, this is going to have to go.

Perhaps something similar to os.IsExist? I'm thinking net.IsReset or net.IsClosed.

Or we could simply return io.EOF for both. I don't know.

And what about other operating systems? Do they have similar problems?
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.4.

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 2:

Status changed to Thinking.

@rsc
Copy link
Contributor

rsc commented Oct 28, 2014

Comment 3:

I don't know what to do about this. 
We could use io.ErrUnexpectedEOF for Read, and maybe for Write too. Unclear.
I'm not thrilled about hacks in net because writing to pipes has the same problem.
But I'm not thrilled about hacks in os either.
Leaving for 1.5.

Labels changed: added release-go1.5, removed release-go1.4.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc removed the repo-main label Apr 14, 2015
@rsc rsc modified the milestones: Unplanned, Go1.5 Jul 15, 2015
jonaz referenced this issue in stampzilla/stampzilla-go Aug 17, 2015
@bsed
Copy link

bsed commented Oct 13, 2017

"readfull EOF:*net.OpError read tcp 172.19.13.222:51753->172.19.5.50:9091: wsarecv: An established connection was aborted by the software in your host machine.

@problame
Copy link

problame commented Jul 17, 2019

This could be resolved using the go1.13 errors.Is(syscall.ECONNRESET), correct? ref zrepl/zrepl#190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants