Navigation Menu

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: Socket connection stuck in SYN_SENT when connection fails #2349

Closed
gopherbot opened this issue Oct 8, 2011 · 5 comments
Closed

net: Socket connection stuck in SYN_SENT when connection fails #2349

gopherbot opened this issue Oct 8, 2011 · 5 comments

Comments

@gopherbot
Copy link

by chrisfarms:

I have been using http.Client with proxy connections and have noticed that a ton of
connections get stuck in SYN_SENT after a while. Eventually resulting in "too many
open files" errors which obviously causes serious problems.

To see this issue I have included a little example program [syn_stuck.go] that will open
a large number of HTTP connections via non-existant proxy, and then tell you to go check
"lsof". I've tried it on both OSX and Linux with same results.

After a bit of digging I believe the issue is with net/sock.go:56 .... when an
fd.connect() fails the socket is not closed. (patch attached). 

Running syn_stuck + lsof after the patch gives the expected result.

Attachments:

  1. syn_stuck.go (1778 bytes)
  2. syn_stuck_fix.diff (302 bytes)
@mikioh
Copy link
Contributor

mikioh commented Oct 8, 2011

Comment 1:

Thank you for your investigation and patch sent.
Do you have a plan to contribute it by yourself?
<http://golang.org/doc/contribute.html>;

@gopherbot
Copy link
Author

Comment 2 by chrisfarms:

I created a CL ... but I can't see how I could write a test for this. If someone points
me in the right direction I will... but since socket() does not return anything testable
when the issue occurs I don't see how :/

@rsc
Copy link
Contributor

rsc commented Oct 11, 2011

Comment 3:

This issue was closed by revision 4b74956.

Status changed to Fixed.

@robpike
Copy link
Contributor

robpike commented Dec 1, 2011

Comment 4:

Accidentally closed by typo in other CL

Status changed to Accepted.

@mikioh
Copy link
Contributor

mikioh commented Dec 1, 2011

Comment 5:

This issue was already fixed by:
changeset:   9995:7d78fe7f328e
user:        Chris Farmiloe <chrisfarms@gmail.com>
date:        Tue Oct 11 12:53:16 2011 -0400
files:       src/pkg/net/sock.go
description:
net: fix socket leak in case of Dial failure

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants