aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--ext/openssl/ossl_ssl.c6
-rw-r--r--test/openssl/test_ssl.rb18
3 files changed, 30 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 96a2e6c143..eea5c17909 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jan 29 04:29:54 2014 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * 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@tenderlovemaking.com>
* ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value.
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index 484e48a01c..a95ab3d1d0 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1431,7 +1431,11 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
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:
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb
index a13f0e1a9c..18c0bce95b 100644
--- a/test/openssl/test_ssl.rb
+++ b/test/openssl/test_ssl.rb
@@ -169,6 +169,24 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
}
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)