summaryrefslogtreecommitdiff
path: root/test/openssl/ssl_server.rb
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-20 15:57:40 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-20 15:57:40 +0000
commitf9bdcf54952717b79e2ae274bfc4f2b14187c726 (patch)
treec0aa2e7a446ec412afbf88f2794379d80546a88e /test/openssl/ssl_server.rb
parent86d21234a41ed2a126ae8fd6ed85325f344491d9 (diff)
* test/openssl/test_ssl.rb: use Process.kill to kill child process
instead of waiting for closing popen-ed IO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl/ssl_server.rb')
-rw-r--r--test/openssl/ssl_server.rb23
1 files changed, 11 insertions, 12 deletions
diff --git a/test/openssl/ssl_server.rb b/test/openssl/ssl_server.rb
index 53e520379bb..ce3c6132cd8 100644
--- a/test/openssl/ssl_server.rb
+++ b/test/openssl/ssl_server.rb
@@ -49,30 +49,29 @@ Socket.do_not_reverse_lookup = true
tcps = TCPServer.new("0.0.0.0", port)
ssls = OpenSSL::SSL::SSLServer.new(tcps, ctx)
ssls.start_immediately = start_immediately
-ssock = nil
Thread.start{
- while line = $stdin.gets
- if /STARTTLS/ =~ line
- ssock && ssock.accept
- end
+ while true
+ $stdin.gets || exit
end
- exit
}
$stdout.sync = true
$stdout.puts Process.pid
loop do
- s = ssls.accept
- ssock = s
+ ssl = ssls.accept
Thread.start{
q = Queue.new
- th = Thread.start{ s.write(q.shift) while true }
- while line = s.gets
+ th = Thread.start{ ssl.write(q.shift) while true }
+ while line = ssl.gets
+ if line =~ /^STARTTLS$/
+ ssl.accept
+ next
+ end
q.push(line)
end
- th.kill
- s.close unless s.closed?
+ th.kill if q.empty?
+ ssl.close
}
end