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
Labels
Milestone

Comments

@PieterD
Copy link
Contributor

@PieterD 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

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 2, 2014

Comment 1:

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

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Sep 15, 2014

Comment 2:

Status changed to Thinking.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc 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
@bradfitz bradfitz removed the release-go1.5 label 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

This comment has been minimized.

Copy link

@bsed 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

This comment has been minimized.

Copy link

@problame 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
Projects
None yet
6 participants
You can’t perform that action at this time.