Skip to content

Commit cfbbb50

Browse files
shioimmhsbt
authored andcommitted
Do not wait connection attempt delay without in progress fds (#12087)
Do not wait Connection Attempt Delay without in progress fds Reset Connection Attempt Delay when connection fails and there is no other socket connection in progress. This is intended to resolve an issue that was temporarily worked around in Pull Request #12062. `TCPServer::new` (used in tests such as `TestNetHTTP_v1_2_chunked#test_timeout_during_non_chunked_streamed_HTTP_session_write`) can only connect over either IPv6 or IPv4, depending on the environment. Since HEv2 attempts to connect over IPv6 first, environments where IPv6 connections are unavailable return ECONNREFUSED immediately. In such cases, the client should immediately retry the connection over IPv4. However, HEv2 includes a specification for a "Connection Attempt Delay," where it waits 250ms after the previous connection attempt before starting the next one. This delay causes Net::OpenTimeout (100ms) to be exceeded while waiting for the next connection attempt to start. With this change, when a connection attempt fails, if there are sockets still attempting to connect and there are addresses yet to be tried, the Connection Attempt Delay will be resetted, allowing the next connection attempt to start immediately. --- Additionally, the following minor fixes have been made: - The `nfds` value used for select(2) is now reset with each wait.
1 parent d18ab3d commit cfbbb50

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/net/http/test_http.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ def test_timeout_during_HTTP_session_write
568568
conn.open_timeout = EnvUtil.apply_timeout_scale(0.1)
569569

570570
th = Thread.new do
571-
err = !windows? ? [Net::WriteTimeout, Net::OpenTimeout] : Net::ReadTimeout
572-
assert_raise(*err) do
571+
err = !windows? ? Net::WriteTimeout : Net::ReadTimeout
572+
assert_raise(err) do
573573
assert_warning(/Content-Type did not set/) do
574574
conn.post('/', "a"*50_000_000)
575575
end
@@ -600,7 +600,7 @@ def test_timeout_during_non_chunked_streamed_HTTP_session_write
600600
req.body_stream = StringIO.new(data)
601601

602602
th = Thread.new do
603-
assert_raise(Net::WriteTimeout, Net::OpenTimeout) { conn.request(req) }
603+
assert_raise(Net::WriteTimeout) { conn.request(req) }
604604
end
605605
assert th.join(10)
606606
}

0 commit comments

Comments
 (0)