fix: do not schedule deferred HEv2 ipv4 tcp handshake if the connection has already been closed by the sibling connection

This commit is contained in:
HoneyryderChuck 2025-02-10 18:10:25 +00:00
parent 5333def40d
commit ed8fafd11d

View File

@ -76,12 +76,16 @@ module HTTPX
"resolver #{FAMILY_TYPES[RECORD_TYPES[family]]}: " \
"answer #{FAMILY_TYPES[RECORD_TYPES[family]]} #{connection.peer.host}: #{addresses.inspect}"
end
return if connection.state == :closed
if @current_selector && # if triggered by early resolve, session may not be here yet
!connection.io &&
connection.options.ip_families.size > 1 &&
family == Socket::AF_INET &&
addresses.first.to_s != connection.peer.host.to_s
log { "resolver #{FAMILY_TYPES[RECORD_TYPES[family]]}: applying resolution delay..." }
@current_selector.after(0.05) do
unless connection.state == :closed ||
# double emission check