diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-21 06:56:33 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-21 06:56:33 +0000 |
commit | 7fd155cf0f088f763dfb6353f251319775549b77 (patch) | |
tree | 7c0753f342b346115e93de4a40442b32b9879c9e /test/openssl/test_pair.rb | |
parent | f65d706529969593b318e79ca26bf03c11b6347b (diff) | |
download | ruby-7fd155cf0f088f763dfb6353f251319775549b77.tar.gz |
* ext/openssl/ossl_ssl.c (write_would_block): defined.
(read_would_block): defined.
(ossl_start_ssl): add nonblock argument.
(ossl_ssl_connect): follow ossl_start_ssl change.
(ossl_ssl_connect_nonblock): new method.
(ossl_ssl_accept): follow ossl_start_ssl change.
(ossl_ssl_accept_nonblock): new method.
(ossl_ssl_read_internal): use write_would_block and
read_would_block.
(ossl_ssl_write_internal): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl/test_pair.rb')
-rw-r--r-- | test/openssl/test_pair.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb index a6f1e4f55d..fb0662f501 100644 --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -192,6 +192,62 @@ class OpenSSL::TestPair < Test::Unit::TestCase } end + def test_connect_accept_nonblock + host = "127.0.0.1" + port = 0 + ctx = OpenSSL::SSL::SSLContext.new() + ctx.ciphers = "ADH" + serv = TCPServer.new(host, port) + ssls = OpenSSL::SSL::SSLServer.new(serv, ctx) + + port = serv.connect_address.ip_port + + sock1 = TCPSocket.new(host, port) + sock2 = serv.accept + serv.close + + th = Thread.new { + s2 = OpenSSL::SSL::SSLSocket.new(sock2, ctx) + s2.sync_close = true + begin + sleep 0.2 + s2.accept_nonblock + rescue IO::WaitReadable + IO.select([s2]) + retry + rescue IO::WaitWritable + IO.select(nil, [s2]) + retry + end + s2 + } + + sleep 0.1 + ctx = OpenSSL::SSL::SSLContext.new() + ctx.ciphers = "ADH" + s1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx) + begin + sleep 0.2 + s1.connect_nonblock + rescue IO::WaitReadable + IO.select([s1]) + retry + rescue IO::WaitWritable + IO.select(nil, [s1]) + retry + end + s1.sync_close = true + + s2 = th.value + + s1.print "a\ndef" + assert_equal("a\n", s2.gets) + ensure + serv.close if serv && !serv.closed? + sock1.close if sock1 && !sock1.closed? + sock2.close if sock2 && !sock2.closed? + end + end end |