1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2014-11-01 11:41:30 +00:00
parent bfd540cd75
commit a7c425cbf3
2 changed files with 17 additions and 13 deletions

View file

@ -1,3 +1,8 @@
Sat Nov 1 20:40:18 2014 Tanaka Akira <akr@fsij.org>
* test/openssl/utils.rb (start_server, server_loop): Use a
pipe to stop server instead of shutdown/close a listening socket.
Sat Nov 1 19:24:59 2014 Tanaka Akira <akr@fsij.org>
* test/ruby/envutil.rb (assert_join_threads): New assertion to

View file

@ -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)