ruby-changes:36146
From: akr <ko1@a...>
Date: Sat, 1 Nov 2014 23:12:18 +0900 (JST)
Subject: [ruby-changes:36146] akr:r48227 (trunk): * test/openssl/utils.rb (start_server): Don't close sockets before
akr 2014-11-01 23:12:11 +0900 (Sat, 01 Nov 2014) New Revision: 48227 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48227 Log: * test/openssl/utils.rb (start_server): Don't close sockets before threads finished. Modified files: trunk/ChangeLog trunk/test/lib/leakchecker.rb trunk/test/openssl/test_ssl_session.rb trunk/test/openssl/utils.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48226) +++ ChangeLog (revision 48227) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Nov 1 23:11:05 2014 Tanaka Akira <akr@f...> + + * test/openssl/utils.rb (start_server): Don't close sockets before + threads finished. + Sat Nov 1 22:06:24 2014 Tanaka Akira <akr@f...> * test/openssl/test_ssl_session.rb (test_ctx_client_session_cb): Don't Index: test/openssl/utils.rb =================================================================== --- test/openssl/utils.rb (revision 48226) +++ test/openssl/utils.rb (revision 48227) @@ -299,28 +299,31 @@ AQjjxMXhwULlmuR/K+WwlaZPiLIBYalLAZQ7ZbOP https://github.com/ruby/ruby/blob/trunk/test/openssl/utils.rb#L299 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 Index: test/openssl/test_ssl_session.rb =================================================================== --- test/openssl/test_ssl_session.rb (revision 48226) +++ test/openssl/test_ssl_session.rb (revision 48227) @@ -32,11 +32,14 @@ tddwpBAEDjcwMzA5NTYzMTU1MzAwpQMCARM= https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl_session.rb#L32 ctx.session_id_context = self.object_id.to_s sock = TCPSocket.new '127.0.0.1', port - ssl = OpenSSL::SSL::SSLSocket.new sock, ctx - ssl.session = session + begin + ssl = OpenSSL::SSL::SSLSocket.new sock, ctx + ssl.session = session - assert_equal session, ssl.session - sock.close + assert_equal session, ssl.session + ensure + sock.close + end } end Index: test/lib/leakchecker.rb =================================================================== --- test/lib/leakchecker.rb (revision 48226) +++ test/lib/leakchecker.rb (revision 48227) @@ -66,6 +66,7 @@ class LeakChecker https://github.com/ruby/ruby/blob/trunk/test/lib/leakchecker.rb#L66 end puts "Leaked file descriptor: #{test_name}: #{fd}#{str}" } + #system("lsof -p #$$") if !fd_leaked.empty? h.each {|fd, list| next if list.length <= 1 if 1 < list.count {|io, autoclose, inspect| autoclose } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/