summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2026-04-09 14:19:02 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2026-04-09 14:19:02 +0900
commitc091c186e425b659f7aa88ffeac20a41a27b0582 (patch)
tree7558853ee4f53161d017b9fadfb95a41f90a8d26
parent4b6a467a4a8998dcd50a54f610ccbaebdae279c1 (diff)
Fix thread leaks
Wait for terminated threads to finish.
-rw-r--r--ext/socket/lib/socket.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index 36fcceaee9..465b74964f 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -924,15 +924,11 @@ class Socket < BasicSocket
end
end
ensure
- hostname_resolution_threads.each do |thread|
- thread.exit
- end
+ hostname_resolution_threads.each(&:exit).each(&:join)
hostname_resolution_result&.close
- connecting_sockets.each_key do |connecting_socket|
- connecting_socket.close
- end
+ connecting_sockets.each_key(&:close)
end
private_class_method :tcp_with_fast_fallback