Feature #12085
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
~~~ * ext/openssl/lib/openssl/buffering.rb (write_nonblock): document `exception: false' keyword and warn about retrying the using the same object. The following test patch illustrates the problem I encountered: ```diff --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -280,6 +280,33 @@ def test_write_nonblock_with_buffered_data_no_exceptions } } end + def test_write_nonblock_retry + ssl_pair {|s1, s2| + written = String.new + n = 0 + buf = 'a' * 11 + case ret = s1.write_nonblock(buf, exception: false) + when :wait_readable then break + when :wait_writable then break + when Integer + written << buf + n += ret + exp = buf.bytesize + if ret != exp + buf = buf.byteslice(ret, exp - ret) + end + end while true + readed = s2.read(n) + assert_equal written, readed + assert_kind_of Symbol, ret + buf2 = Marshal.load(Marshal.dump(buf)) + assert_raise(OpenSSL::SSL::SSLError) do + s1.write_nonblock(buf2, exception: false) + end + assert_kind_of Integer, s1.write_nonblock(buf, exception: false) + } + end + def tcp_pair host = "127.0.0.1" serv = TCPServer.new(host, 0) ~~~ I do not plan to commit the test change since OpenSSL behavior may be improved in the future. ~~~