[前][次][番号順一覧][スレッド一覧]

ruby-changes:32653

From: tenderlove <ko1@a...>
Date: Wed, 29 Jan 2014 04:31:58 +0900 (JST)
Subject: [ruby-changes:32653] tenderlove:r44732 (trunk): * ext/openssl/ossl_ssl.c: pass read_nonblock options to underlying IO

tenderlove	2014-01-29 04:31:48 +0900 (Wed, 29 Jan 2014)

  New Revision: 44732

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44732

  Log:
    * ext/openssl/ossl_ssl.c: pass read_nonblock options to underlying IO
      when SSL session has not been started.
    
    * test/openssl/test_ssl.rb: test for change.

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/ossl_ssl.c
    trunk/test/openssl/test_ssl.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44731)
+++ ChangeLog	(revision 44732)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jan 29 04:29:54 2014  Aaron Patterson <aaron@t...>
+
+	* ext/openssl/ossl_ssl.c: pass read_nonblock options to underlying IO
+	  when SSL session has not been started.
+
+	* test/openssl/test_ssl.rb: test for change.
+
 Wed Jan 29 03:49:36 2014  Aaron Patterson <aaron@t...>
 
 	* ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value.
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 44731)
+++ ext/openssl/ossl_ssl.c	(revision 44732)
@@ -1431,7 +1431,11 @@ ossl_ssl_read_internal(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1431
     else {
         ID meth = nonblock ? rb_intern("read_nonblock") : rb_intern("sysread");
         rb_warning("SSL session is not started yet.");
-        return rb_funcall(ossl_ssl_get_io(self), meth, 2, len, str);
+        if (nonblock) {
+          return rb_funcall(ossl_ssl_get_io(self), meth, 3, len, str, opts);
+        } else {
+          return rb_funcall(ossl_ssl_get_io(self), meth, 2, len, str);
+        }
     }
 
   end:
Index: test/openssl/test_ssl.rb
===================================================================
--- test/openssl/test_ssl.rb	(revision 44731)
+++ test/openssl/test_ssl.rb	(revision 44732)
@@ -169,6 +169,24 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_ssl.rb#L169
     }
   end
 
+  def test_read_nonblock_without_session
+    start_server(PORT, OpenSSL::SSL::VERIFY_NONE, false){|server, port|
+      sock = TCPSocket.new("127.0.0.1", port)
+      ssl = OpenSSL::SSL::SSLSocket.new(sock)
+      ssl.sync_close = true
+
+      OpenSSL::TestUtils.silent do
+        assert_equal :wait_readable, ssl.read_nonblock(100, exception: false)
+        ssl.write("abc\n")
+        IO.select [ssl]
+        assert_equal('a', ssl.read_nonblock(1))
+        assert_equal("bc\n", ssl.read_nonblock(100))
+        assert_equal :wait_readable, ssl.read_nonblock(100, exception: false)
+      end
+      ssl.close
+    }
+  end
+
   def test_starttls
     start_server(PORT, OpenSSL::SSL::VERIFY_NONE, false){|server, port|
       sock = TCPSocket.new("127.0.0.1", port)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]