Close on owner death during HTTP/1.1 reads; hand tunnel sockets to the conn - #952
Merged
Merged
Conversation
The response read is a passive recv inside the state callback, so a conn waiting on the server saw its owner's 'DOWN' only once the read returned. Read in slices of at most a second and look for the 'DOWN' between them, putting it back so the state's owner clause stops the conn.
CONNECT and SOCKS5 tunnels are dialed in the caller, which stayed the socket's controlling process. After set_owner/2 the socket still closed when the opener died. start_conn_with_socket now moves it to the conn.
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.
Follow-up to #951, fixing the two limits it left.
Blocking HTTP/1.1 reads. The response is read with a passive recv inside the state callback, so a conn waiting on the server saw its owner's
'DOWN'only once the read returned.recv_data/1andstream_body_chunk/1now go throughowner_recv/1. It reads in slices of at most 1 s and looks for the owner's'DOWN'between them. The'DOWN'is put back in the mailbox, so the state's existing owner clause stops the conn.recv_timeoutstill bounds the whole read. For pooled conns the behaviour is unchanged, only sooner: the owner's'DOWN'already stopped them after the read.Tunnel sockets. CONNECT and SOCKS5 tunnels are dialed in the caller, which stayed the socket's controlling process. After
set_owner/2, the socket still closed when the opener died, and active-mode messages went to the opener.start_conn_with_socketnow moves the socket to the conn withcontrolling_process. A caller passing a socket it does not own (not_owner) keeps the old behaviour.Tests in
hackney_direct_owner_tests: the in-flight cases now keep the server silent. New cases cover a blocked async body read, a pooled conn (itsmax_per_hostslot comes back), andset_owneron CONNECT and SOCKS5 tunnels. The 6 new or changed cases fail on master.