summaryrefslogtreecommitdiff
path: root/test/openssl
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-25 05:22:49 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-25 05:22:49 +0000
commit504453d929da696aa61cdd78397221e0246d9cbc (patch)
treec8bc8c5a8d7571980f766e330c2530a185a33588 /test/openssl
parentbafe3bf3da226f694054aa91ad38266537d0c8bb (diff)
* test/openssl: Join threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl')
-rw-r--r--test/openssl/test_pair.rb9
-rw-r--r--test/openssl/utils.rb13
2 files changed, 17 insertions, 5 deletions
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb
index f627066d76..c7cfd69129 100644
--- a/test/openssl/test_pair.rb
+++ b/test/openssl/test_pair.rb
@@ -83,16 +83,20 @@ end
module OpenSSL::TestEOF1M
def open_file(content)
s1, s2 = ssl_pair
- Thread.new { s2 << content; s2.close }
+ th = Thread.new { s2 << content; s2.close }
yield s1
+ ensure
+ th.join
end
end
module OpenSSL::TestEOF2M
def open_file(content)
s1, s2 = ssl_pair
- Thread.new { s1 << content; s1.close }
+ th = Thread.new { s1 << content; s1.close }
yield s2
+ ensure
+ th.join
end
end
@@ -317,6 +321,7 @@ module OpenSSL::TestPairM
s1.print "a\ndef"
assert_equal("a\n", s2.gets)
ensure
+ th.join
s1.close if s1 && !s1.closed?
s2.close if s2 && !s2.closed?
sock1.close if sock1 && !sock1.closed?
diff --git a/test/openssl/utils.rb b/test/openssl/utils.rb
index ba9714b3fc..f4509f2980 100644
--- a/test/openssl/utils.rb
+++ b/test/openssl/utils.rb
@@ -240,7 +240,7 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
ssl.close rescue nil
end
- def server_loop(ctx, ssls, server_proc)
+ def server_loop(ctx, ssls, server_proc, threads)
loop do
ssl = nil
begin
@@ -249,10 +249,11 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
retry
end
- Thread.start do
+ th = Thread.start do
Thread.current.abort_on_exception = true
server_proc.call(ctx, ssl)
end
+ threads << th
end
rescue Errno::EBADF, IOError, Errno::EINVAL, Errno::ECONNABORTED, Errno::ENOTSOCK, Errno::ECONNRESET
end
@@ -261,6 +262,7 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
ctx_proc = args[:ctx_proc]
server_proc = args[:server_proc]
server_proc ||= method(:readwrite_loop)
+ threads = []
store = OpenSSL::X509::Store.new
store.add_cert(@ca_cert)
@@ -290,7 +292,7 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
begin
server = Thread.new do
Thread.current.abort_on_exception = true
- server_loop(ctx, ssls, server_proc)
+ server_loop(ctx, ssls, server_proc, threads)
end
$stderr.printf("%s started: pid=%d port=%d\n", SSL_SERVER, $$, port) if $DEBUG
@@ -318,6 +320,11 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
tcps.close if (tcps)
end
end
+ ensure
+ threads.each {|th|
+ th.kill
+ th.join
+ }
end
def starttls(ssl)