summaryrefslogtreecommitdiff
path: root/test/socket
diff options
context:
space:
mode:
authorMasaki Matsushita <glass.saga@gmail.com>2020-11-26 16:07:28 +0900
committerMasaki Matsushita <glass.saga@gmail.com>2020-12-04 23:31:51 +0900
commit94d49ed31c39002335eeee65d42463139f561954 (patch)
tree86ca5d184fb8e52540664ec8b087bdb93a2e0c5b /test/socket
parent1cfc6e7b7a92c1a624182392ba702d3dcb2eba98 (diff)
Add a hook before fork() for getaddrinfo_a()
We need stop worker threads in getaddrinfo_a() before fork(). This change adds a hook before fork() that cancel all outstanding requests and wait for all ongoing requests. Then, it waits for all worker threads to be finished. Fixes [Bug #17220]
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_socket.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index f1ec927c4c..04d677c747 100644
--- a/test/socket/test_socket.rb
+++ b/test/socket/test_socket.rb
@@ -102,6 +102,16 @@ class TestSocket < Test::Unit::TestCase
assert_nothing_raised('[ruby-core:29427]'){ TCPServer.open('localhost', 0) {} }
end
+ def test_getaddrinfo_after_fork
+ skip "fork not supported" unless Process.respond_to?(:fork)
+ assert_normal_exit(<<-"end;", '[ruby-core:100329] [Bug #17220]')
+ require "socket"
+ Socket.getaddrinfo("localhost", nil)
+ pid = fork { Socket.getaddrinfo("localhost", nil) }
+ assert_equal pid, Timeout.timeout(30) { Process.wait(pid) }
+ end;
+ end
+
def test_getnameinfo
assert_raise(SocketError) { Socket.getnameinfo(["AF_UNIX", 80, "0.0.0.0"]) }