From 0626d9b91c8e64dbbe90fd966ea95d2c80f9632e Mon Sep 17 00:00:00 2001 From: headius Date: Mon, 8 Apr 2013 19:58:55 +0000 Subject: Fix #6154 by introducing new EAGAIN/EWOULDBLOCK/EINPROGRESS subclasses that include WaitReadable or WaitWritable rather than extending them into the exception object each time. * error.c: Capture EGAIN, EWOULDBLOCK, EINPROGRESS exceptions and export them for use in WaitReadable/Writable exceptions. * io.c: Create versions of EAGAIN, EWOULDBLOCK, EINPROGRESS that include WaitReadable and WaitWritable. Add rb_readwrite_sys_fail for nonblocking failures using those exceptions. Use that function in io_getpartial and io_write_nonblock instead of rb_mod_sys_fail * ext/openssl/ossl_ssl.c: Add new SSLError subclasses that include WaitReadable and WaitWritable. Use those classes for write_would_block and read_would_block instead of rb_mod_sys_fail. * ext/socket/ancdata.c: Use rb_readwrite_sys_fail instead of rb_mod_sys_fail in bsock_sendmsg_internal and bsock_recvmsg_internal. * ext/socket/init.c: Use rb_readwrite_sys_fail instead of rb_mod_sys_fail in rsock_s_recvfrom_nonblock and rsock_s_connect_nonblock. * ext/socket/socket.c: Use rb_readwrite_sys_fail instead of rb_mod_sys_fail in sock_connect_nonblock. * include/ruby/ruby.h: Export rb_readwrite_sys_fail for use instead of rb_mod_sys_fail. Introduce new constants RB_IO_WAIT_READABLE and RB_IO_WAIT_WRITABLE for first arg to rb_readwrite_sys_fail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_pair.rb | 2 +- test/socket/test_unix.rb | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb index 12af6aeff5..fa36725b58 100644 --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -141,7 +141,7 @@ class OpenSSL::TestPair < Test::Unit::TestCase def test_read_nonblock ssl_pair {|s1, s2| err = nil - assert_raise(OpenSSL::SSL::SSLError) { + assert_raise(OpenSSL::SSL::SSLErrorWaitReadable) { begin s2.read_nonblock(10) ensure diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index faf70f2e19..38d8333f2a 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -348,7 +348,13 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase def test_dgram_pair s1, s2 = UNIXSocket.pair(Socket::SOCK_DGRAM) - assert_raise(Errno::EAGAIN) { s1.recv_nonblock(10) } + begin + s1.recv_nonblock(10) + fail + rescue => e + assert(IO::EAGAINWaitReadable === e) + assert(IO::WaitReadable === e) + end s2.send("", 0) s2.send("haha", 0) s2.send("", 0) @@ -357,7 +363,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase assert_equal("haha", s1.recv(10)) assert_equal("", s1.recv(10)) assert_equal("", s1.recv(10)) - assert_raise(Errno::EAGAIN) { s1.recv_nonblock(10) } + assert_raise(IO::EAGAINWaitReadable) { s1.recv_nonblock(10) } ensure s1.close if s1 s2.close if s2 -- cgit v1.2.3