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.Response)Body.Close() does not work with gzip compression #1724

Closed
gopherbot opened this issue Apr 21, 2011 · 2 comments
Closed

(*http.Response)Body.Close() does not work with gzip compression #1724

gopherbot opened this issue Apr 21, 2011 · 2 comments

Comments

@gopherbot
Copy link

by tarmigan:

Rev 96744c61ffcf "gc: fix copy([]int, string) error message"

When I run the attached program on OSX, the http.Get() dnslookup fails after a while in
C.getaddrinfo in cgo_unix.go.  Once the dns lookup fails, I get "open main.go: too
many open files".  So I think dns lookup is failing because there are too many open
files.

lsof on the process lists around 261 open files once it's hung.  (osx open file limit is
a low 256 by default).

I believe the problem is with (*http.Response).Body.Close() for a gzipped response. 
When the response is gzip enabled, the body will be gzip.NewReader.  The Close() method
on a gzip Reader will NOT close the original connection, but will only close the
decompressor created by flate.NewReader().

If I comment out line 536 of src/pkg/http/transport.go the problem goes away.

Not sure what the correct fix is, so I'm only creating an issue.

Thanks,
Tarmigan


Which compiler are you using (5g, 6g, 8g, gccgo)?


Which operating system are you using?


Which revision are you using?  (hg identify)


Please provide any additional information below.

Attachments:

  1. main.go (685 bytes)
@rsc
Copy link
Contributor

rsc commented Apr 21, 2011

Comment 1:

we definitely have to make sure to do the lower-level close too

Owner changed to @bradfitz.

Status changed to Accepted.

@bradfitz
Copy link
Contributor

Comment 2:

This issue was closed by revision 750b6c6.

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