mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									2ee916752c
								
							
						
					
					
						commit
						e25f3587bd
					
				
					 3 changed files with 30 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue