Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_dns: Fix FD leak #60

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions test/resolv/test_dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,10 @@ def test_multiple_servers_with_timeout_and_truncated_tcp_fallback
u1.send(msg[0...512], 0, client_address, client_port)
end

tcp_server1_thread = Thread.new { t1.accept; t1.close }
tcp_server1_thread = Thread.new do
# Keep this socket open so that the client experiences a timeout
t1.accept
end

tcp_server2_thread = Thread.new do
ct = t2.accept
Expand Down Expand Up @@ -800,7 +803,7 @@ def test_multiple_servers_with_timeout_and_truncated_tcp_fallback
ct.send(msg, 0)
ct.close
end
result, = assert_join_threads([client_thread, udp_server1_thread, tcp_server1_thread, tcp_server2_thread])
result, _, tcp_server1_socket, = assert_join_threads([client_thread, udp_server1_thread, tcp_server1_thread, tcp_server2_thread])
assert_instance_of(Array, result)
assert_equal(50, result.length)
result.each_with_index do |rr, i|
Expand All @@ -809,6 +812,8 @@ def test_multiple_servers_with_timeout_and_truncated_tcp_fallback
assert_equal("192.0.2.#{i}", rr.address.to_s)
assert_equal(3600, rr.ttl)
end
ensure
tcp_server1_socket&.close
end
end
end
Expand Down