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

proxy: initialize ReverseProxy.Transport earlier and fix TCP connection leak #2134

Merged
merged 1 commit into from
Apr 28, 2018

Conversation

crvv
Copy link

@crvv crvv commented Apr 24, 2018

1. What does this change do, exactly?

Fix a bug introduced in 98de336, #2070
98de336#diff-a71769529a289e215ba922059611256bL309

Before 98de336, proxy used http.DefaultTransport for every request.
After 98de336, proxy creates a new http.Transport for every request.
Then caddy will create a lot of TCP connections and won't reuse them.

I found this because github.com/transmission/transmission can only have 1024 file descriptors, And it encounters error too many files open frequently when I upgraded caddy to 0.10.13.

2. Please link to the relevant issues.

See 1.

3. Which documentation changes (if any) need to be made because of this PR?

None.

4. Checklist

  • I have written tests and verified that they fail without my change
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I am willing to help maintain this change if there are issues with it later

@crvv
Copy link
Author

crvv commented Apr 24, 2018

CI failed because of
golang/go#25048
golang/lint#397

@mholt mholt added the under review 🧐 Review is pending before merging label Apr 24, 2018
@mholt
Copy link
Member

mholt commented Apr 24, 2018

Re-running CI tests.

Pinging @tchaudhry91

@tchaudhry91
Copy link

Ah! Yes, this makes sense.
I can check the broken test also tomorrow morning. Unfortunately, do not have access to my dev system right now.

Copy link

@tchaudhry91 tchaudhry91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@mholt
Copy link
Member

mholt commented Apr 27, 2018

Thank you @crvv! This is definitely an improvement, and I really appreciate you taking the lead to just go ahead and fix it.

I will merge this in just a bit; gonna give the folks in #2140 a chance to try it out as well.

When we merge this, I will invite you to be a collaborator on the project, so you can more easily make patches without having to fork the repo. 👍

@mholt mholt removed the under review 🧐 Review is pending before merging label Apr 28, 2018
@mholt mholt merged commit fe664c0 into caddyserver:master Apr 28, 2018
@crvv
Copy link
Author

crvv commented Apr 29, 2018

I am very glad to become a collaborator. Thanks.

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

Successfully merging this pull request may close these issues.

None yet

3 participants