1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/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
..
lib * ext/openssl/lib/openssl/x509.rb 2014-11-20 15:39:03 +00:00
depend Update dependencies. 2014-12-19 13:34:54 +00:00
deprecation.rb
extconf.rb openssl: check RAND_edg to support libressl 2015-02-12 09:34:02 +00:00
openssl_missing.c
openssl_missing.h
ossl.c
ossl.h * ext/openssl/ossl.h: avoid to build failure of Windows environment. 2015-01-03 02:50:31 +00:00
ossl_asn1.c ossl_asn1.c: fix doc 2015-02-21 22:56:06 +00:00
ossl_asn1.h
ossl_bio.c
ossl_bio.h
ossl_bn.c ossl_bn.c: [DOC] expand rdocs [ci skip] 2015-02-21 23:28:47 +00:00
ossl_bn.h
ossl_cipher.c ossl_cipher.c: workaround of OpenSSL API 2014-12-23 02:42:16 +00:00
ossl_cipher.h
ossl_config.c
ossl_config.h
ossl_digest.c ossl_digest.c: typed data 2014-12-12 21:57:44 +00:00
ossl_digest.h
ossl_engine.c ossl_engine.c: typed data 2014-12-12 21:57:49 +00:00
ossl_engine.h
ossl_hmac.c ossl_hmac.c: typed data 2014-12-12 21:57:56 +00:00
ossl_hmac.h
ossl_ns_spki.c ossl_ns_spki.c: typed data 2014-12-12 21:58:03 +00:00
ossl_ns_spki.h
ossl_ocsp.c ossl_ocsp.c: typed data 2014-12-12 21:58:22 +00:00
ossl_ocsp.h
ossl_pkcs5.c
ossl_pkcs5.h
ossl_pkcs7.c ossl_pkcs7.c: typed data 2014-12-12 22:38:01 +00:00
ossl_pkcs7.h
ossl_pkcs12.c ossl_pkcs12.c: typed data 2014-12-12 22:37:53 +00:00
ossl_pkcs12.h
ossl_pkey.c use rb_funcallv 2015-02-16 04:08:52 +00:00
ossl_pkey.h ossl_pkey.c: typed data 2014-12-12 23:19:07 +00:00
ossl_pkey_dh.c
ossl_pkey_dsa.c
ossl_pkey_ec.c ossl_pkey_ec.c: typed data 2014-12-12 23:19:24 +00:00
ossl_pkey_rsa.c
ossl_rand.c openssl: check RAND_edg to support libressl 2015-02-12 09:34:02 +00:00
ossl_rand.h
ossl_ssl.c connect_nonblock supports "exception: false" 2015-04-12 01:41:51 +00:00
ossl_ssl.h ossl_ssl.c: typed data 2014-12-12 21:58:34 +00:00
ossl_ssl_session.c * ext/openssl/ossl.h: avoid to build failure of Windows environment. 2015-01-03 02:50:31 +00:00
ossl_version.h
ossl_x509.c
ossl_x509.h
ossl_x509attr.c ossl_x509attr.c: typed data 2014-12-12 23:38:44 +00:00
ossl_x509cert.c ossl_x509cert.c: typed data 2014-12-12 23:38:55 +00:00
ossl_x509crl.c ossl_x509crl.c: typed data 2014-12-12 23:39:04 +00:00
ossl_x509ext.c ossl_x509ext.c: typed data 2014-12-12 23:46:42 +00:00
ossl_x509name.c ossl_x509name.c: typed data 2014-12-12 23:59:19 +00:00
ossl_x509req.c ossl_x509req.c: typed data 2014-12-12 23:59:28 +00:00
ossl_x509revoked.c ossl_x509revoked.c: typed data 2014-12-12 23:59:36 +00:00
ossl_x509store.c ossl_x509store.c: typed data 2014-12-13 00:06:54 +00:00
ruby_missing.h