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

HTTP Conn needs a timeout #213

Closed
gopherbot opened this issue Nov 15, 2009 · 6 comments
Closed

HTTP Conn needs a timeout #213

gopherbot opened this issue Nov 15, 2009 · 6 comments

Comments

@gopherbot
Copy link
Contributor

by david.titarenco:

What steps will reproduce the problem?

func HelloServer(c *http.Conn, req *http.Request) {
        for {
                io.WriteString(c, "This is the song that never ends. );
                c.Flush();
        }
}

What is the expected output? What do you see instead?
As a rule of thumb, HTTP servers (and most network servers in general) have
timeouts to prevent infinite-length connections. A timeout goroutine is
necessary to prevent high-volume fd saturation.

What is your $GOOS?  $GOARCH?
GOARCH=386
GOROOT=/home/go
GOOS=linux

Which revision are you sync'ed to?  (hg log -l 1)
4065:ce0a8285caf5

Please provide any additional information below.
I'm working on an implementation of this.
@gopherbot
Copy link
Contributor Author

Comment 1 by david.titarenco:

CL: http://golang.org/cl/155060

@rsc
Copy link
Contributor

rsc commented Nov 16, 2009

Comment 2:

Owner changed to r...@golang.org.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 2, 2009

Comment 3:

Labels changed: added packagechange.

@bradfitz
Copy link
Contributor

bradfitz commented Mar 4, 2011

Comment 4:

Now that we have the http.Server struct, we at least have a place to put this option.
But I'm not sure what it helps.  It certainly wouldn't help the example above since it'd
then just spin forever which is arguably worse than a fd shortage.  A fd shortage isn't
even quite realistic nowadays.  I've done hundreds of thousands of fds in a single
process on a moderate machine years ago.
I feel that anybody who wants a timeout on a handler could wrap it in another Handler
that used a time.Timer to send an error to the client at least.  But in lieu of ways to
kill fellow goroutines forcefully (which opens up a huge can of worms), I don't really
see anything to do here.

@bradfitz
Copy link
Contributor

Comment 5:

Labels changed: added pkg-http.

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

Comment 6:

This issue was closed by revision 4787e70.

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

3 participants