summaryrefslogtreecommitdiff
path: root/test/openssl/utils.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-01 11:41:30 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-01 11:41:30 +0000
commita7c425cbf32f70b53caa178f1f16cec168ecb456 (patch)
tree9c9643447ae859ccc20db1348a67d224f684b647 /test/openssl/utils.rb
parentbfd540cd75f7dcdd87b08266008056a0030c31a6 (diff)
* test/openssl/utils.rb (start_server, server_loop): Use a
pipe to stop server instead of shutdown/close a listening socket. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl/utils.rb')
-rw-r--r--test/openssl/utils.rb25
1 files changed, 12 insertions, 13 deletions
diff --git a/test/openssl/utils.rb b/test/openssl/utils.rb
index 4df14056e4a..42a119309e1 100644
--- a/test/openssl/utils.rb
+++ b/test/openssl/utils.rb
@@ -240,10 +240,14 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
ssl.close rescue nil
end
- def server_loop(ctx, ssls, server_proc, threads)
+ def server_loop(ctx, ssls, stop_pipe_r, server_proc, threads)
loop do
ssl = nil
begin
+ readable, = IO.select([ssls, stop_pipe_r])
+ if readable.include? stop_pipe_r
+ return
+ end
ssl = ssls.accept
rescue OpenSSL::SSL::SSLError
retry
@@ -286,13 +290,15 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
retry
end
+ stop_pipe_r, stop_pipe_w = IO.pipe
+
ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
ssls.start_immediately = start_immediately
begin
server = Thread.new do
Thread.current.abort_on_exception = true
- server_loop(ctx, ssls, server_proc, threads)
+ server_loop(ctx, ssls, stop_pipe_r, server_proc, threads)
end
$stderr.printf("%s started: pid=%d port=%d\n", SSL_SERVER, $$, port) if $DEBUG
@@ -300,14 +306,7 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
block.call(server, port.to_i)
ensure
begin
- begin
- tcps.shutdown
- rescue Errno::ENOTCONN
- # when `Errno::ENOTCONN: Socket is not connected' on some platforms,
- # call #close instead of #shutdown.
- tcps.close
- tcps = nil
- end if (tcps)
+ stop_pipe_w.close
if (server)
server.join(5)
if server.alive?
@@ -320,9 +319,9 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOPeVkJ8ePao0eLAgEC
end
end
ensure
- threads.each {|th|
- th.join
- }
+ stop_pipe_r.close if !stop_pipe_r.closed?
+ stop_pipe_w.close if !stop_pipe_w.closed?
+ assert_join_threads(threads)
end
def starttls(ssl)