From 3ec72f078c207f53348809d304ba37ba5f915629 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 1 Nov 2014 14:12:11 +0000 Subject: * test/openssl/utils.rb (start_server): Don't close sockets before threads finished. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/utils.rb | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'test/openssl/utils.rb') diff --git a/test/openssl/utils.rb b/test/openssl/utils.rb index e3240a0d1e..f878845354 100644 --- a/test/openssl/utils.rb +++ b/test/openssl/utils.rb @@ -299,28 +299,31 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx) ssls.start_immediately = start_immediately - server = Thread.new do - server_loop(ctx, ssls, stop_pipe_r, ignore_ssl_accept_error, server_proc, threads) - end - threads.unshift server + begin + server = Thread.new do + server_loop(ctx, ssls, stop_pipe_r, ignore_ssl_accept_error, server_proc, threads) + end + threads.unshift server - $stderr.printf("%s started: pid=%d port=%d\n", SSL_SERVER, $$, port) if $DEBUG + $stderr.printf("%s started: pid=%d port=%d\n", SSL_SERVER, $$, port) if $DEBUG - th = Thread.new do + th = Thread.new do + begin + block.call(server, port.to_i) + ensure + stop_pipe_w.close + end + end begin - block.call(server, port.to_i) - ensure - stop_pipe_w.close + th.join + rescue Exception + threads.unshift th end - end - begin - th.join - rescue Exception - threads.unshift th + ensure + assert_join_threads(threads) end ensure tcps.close if tcps - assert_join_threads(threads) end } end -- cgit v1.2.3