Ensure https proxy connections don't clog up the ConnectionPool #580
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #562. Despite lots of back and forth on this issue, it turns out
there's a simpler diagnosis & fix that worrying too much about when
sockets will throw when
close
ing (which we should certainly get allcleaned up one day).
The real issue here is in
ConnectionPool.sslupgrade
which waseffectively swapping our
Connection
that we formally "acquired" fromthe connection pool with a new one that had a https-ssl-upgraded
SSLContext
to do the request tunneling. The issue with just swappingthe
Connection
is that the original connection was never properly"released" to the connection pool, so connections were acquired, but
never released, and eventually we hit the
connection_limit
. Theproposed solution here (which works locally to avoid getting hung up on
the connection pool clogging), is to introduce a new
kill!(c::Connection)
method that "releases" a connection withoutreturning it to the connection pool. So we signal to the pool that a
connection has finished, but it's not put back in the queue to be
re-used, which is what we want. I should note that this does mean that
proxied https requests then don't really respect the
connection_limit
,but also note that it never has due to this "swapping".