1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/openssl
normal c18df6d87c connect_nonblock supports "exception: false"
This is for consistency with accept_nonblock arguments and gives a
minor speedup from avoiding exceptions.
[ruby-core:68838] [Feature #11024]

* ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock):
  support `exception: false'
* (get_no_exception): move function location
* ext/socket/socket.c (sock_connect_nonblock):
  support `exception: false'
* test/openssl/test_pair.rb (test_connect_accept_nonblock_no_exception):
  test `exception: false' on connect,
  rename from `test_accept_nonblock_no_exception'
* test/socket/test_nonblock.rb (test_connect_nonblock_no_exception):
  new test

Benchmark results:

default            0.050000   0.100000   0.150000 (  0.151307)
exception: false   0.030000   0.080000   0.110000 (  0.108840)

----------------------------8<-----------------------
require 'socket'
require 'benchmark'
require 'io/wait'
require 'tmpdir'

host = '127.0.0.1'
serv = TCPServer.new(host, 0) # UNIX sockets may not hit EINPROGRESS

nr = 5000 # few iterations to avoid running out of ports

addr = serv.getsockname
pid = fork do
  begin
    serv.accept.close
  rescue => e
    warn "#$$: #{e.message} (#{e.class})"
  end while true
end
at_exit { Process.kill(:TERM, pid) }
serv.close

Benchmark.bmbm do |x|
  x.report("default") do
    nr.times do
      s = Socket.new(:INET, :STREAM)
      s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1)
      begin
        s.connect_nonblock(addr)
      rescue IO::WaitWritable
        s.wait_writable
      end
      s.close
    end
  end
  x.report("exception: false") do
    nr.times do
      s = Socket.new(:INET, :STREAM)
      s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1)
      case s.connect_nonblock(addr, exception: false)
      when :wait_writable
        s.wait_writable
      end
      s.close
    end
  end
end

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 01:41:51 +00:00
..
test_asn1.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_bn.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_buffering.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_cipher.rb test_cipher.rb: ignore wrap mode erros 2015-02-13 02:06:31 +00:00
test_config.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_digest.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_engine.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_fips.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_hmac.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_ns_spki.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_ocsp.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_pair.rb connect_nonblock supports "exception: false" 2015-04-12 01:41:51 +00:00
test_partial_record_read.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_pkcs5.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_pkcs7.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_pkcs12.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_pkey_dh.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_pkey_dsa.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_pkey_ec.rb * test/openssl/test_pkey_ec.rb: ignored tests with old OpenSSL. 2014-12-13 09:33:33 +00:00
test_pkey_rsa.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_random.rb test_random.rb: add 2015-02-12 09:36:55 +00:00
test_ssl.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_ssl_session.rb * test/openssl/test_ssl_session.rb (OpenSSL#test_ctx_client_session_cb): 2015-01-02 06:10:07 +00:00
test_x509cert.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_x509crl.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_x509ext.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_x509name.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_x509req.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
test_x509store.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00
utils.rb test/openssl: skip old OpenSSL 2014-12-13 03:05:43 +00:00