Skip to content

Commit c091c18

Browse files
committed
Fix thread leaks
Wait for terminated threads to finish.
1 parent 4b6a467 commit c091c18

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

ext/socket/lib/socket.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -924,15 +924,11 @@ def self.tcp_with_fast_fallback(host, port, local_host = nil, local_port = nil,
924924
end
925925
end
926926
ensure
927-
hostname_resolution_threads.each do |thread|
928-
thread.exit
929-
end
927+
hostname_resolution_threads.each(&:exit).each(&:join)
930928

931929
hostname_resolution_result&.close
932930

933-
connecting_sockets.each_key do |connecting_socket|
934-
connecting_socket.close
935-
end
931+
connecting_sockets.each_key(&:close)
936932
end
937933
private_class_method :tcp_with_fast_fallback
938934

0 commit comments

Comments
 (0)