Keep a shared HTTP/2 connection open on close/1; honour direct connect_timeout - #959
Merged
Merged
Conversation
close/1 stopped a pooled HTTP/2 connection even while other callers had streams on it. On a shared connection it now resets only the caller's own streams; the idle timer still closes the connection once no stream is open.
connect_direct/4 waited on the dial with the 8000 ms default, so a larger connect_timeout was cut short and ended as an exit in the caller. hackney_conn:connect/2 now returns an error on timeout or a dead conn, and the stop after a failed dial is bounded. Fixes #945
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two fixes.
close/1 on a shared HTTP/2 connection.
hackney:close/1stopped a pooled HTTP/2 connection even when other callers had streams open on it, so they all failed. Shared connections already count their users: each stream monitors its own caller, and when the last stream ends the pool's idle timer closes the connection (#939).close/1bypassed that. On a shared connection,release_held/1, whichclose/1calls first, now resets and drops only the calling process's streams, the same cleanup as when a stream's caller dies. Unshared and HTTP/1.1 connections are unchanged. HTTP/3 is not covered: pooled HTTP/3 connections have no per-stream caller tracking or idle close yet.connect_timeout without a pool (#945).
connect_direct/4waited on the dial withhackney_conn:connect/1, which has an 8000 ms default. A largerconnect_timeoutwas cut to 8 s and ended as an exit in the caller.connect_direct/4now passes itsconnect_timeout, andhackney_conn:connect/2returns{error, connect_timeout}or{error, Reason}instead of exiting. That also covers the HTTP/3 dial, which passed a timeout but did not catch the exit.hackney:stop_conn/1is bounded like the pool's, so a dial stuck in the transport no longer holds the caller. The pool keeps its own guardedconnect_connection/2, whichhackney_pool_safety_testsrequires.Tests, all failing on master: two in
hackney_http2_shared_conn_testsforclose/1, andhackney_direct_connect_timeout_testsfor a 9 s timeout with an 8.3 s dial and for a stuck dial that must return{error, connect_timeout}within the deadline.Fixes #945