1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext
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- * ext/-test-/file/fs.c: OpenBSD needs sys/param.h before sys/mount.h. 2015-04-12 00:01:11 +00:00
bigdecimal * bigdecimal: conform to ruby's license. [ruby-core:68466] [Bug #10952] 2015-04-08 07:18:46 +00:00
continuation continuation.c: quiet static-linked-ext 2014-11-27 19:58:04 +00:00
coverage coverage.c: suppress a warning 2015-02-13 23:26:26 +00:00
date mkmf.rb: methods to append flags 2015-04-11 02:00:02 +00:00
dbm dbm.c: fix doc 2014-12-30 00:29:28 +00:00
digest md5init.c: fix a typo 2015-02-11 04:58:22 +00:00
etc win32.c: login name encoding 2014-11-10 08:24:36 +00:00
fcntl
fiber
fiddle * ext/fiddle/depend: Fix "Wrong mix of special targets" error with 2015-04-12 00:10:52 +00:00
gdbm use 0 for reserved 2014-12-01 06:38:04 +00:00
io wait.c: wait_for_single_fd 2015-04-12 00:53:28 +00:00
mathn
nkf nkf.c: add semicolon 2014-12-26 06:09:31 +00:00
objspace * ext/objspace/objspace.c: add ObjectSpace.count_imemo_objects method 2015-04-10 10:38:13 +00:00
openssl connect_nonblock supports "exception: false" 2015-04-12 01:41:51 +00:00
pathname * file.c: NotImplementedError is raised if birthtime is unavailable. 2015-01-19 17:57:03 +00:00
psych * ext/psych/lib/psych.rb: bump psych version. 2015-02-17 18:17:46 +00:00
pty * internal.h (rb_execarg_parent_end): Declared. 2015-04-09 12:44:35 +00:00
racc/cparse cparse.c: typed data 2014-12-03 00:48:59 +00:00
rbconfig/sizeof Update dependencies. 2014-12-19 13:34:54 +00:00
readline readline.c: initialize before rl_refresh_line 2015-01-14 06:43:50 +00:00
ripper Update dependencies. 2014-12-19 13:34:54 +00:00
sdbm _sdbm.c: fix pointers to shift 2015-02-04 08:35:08 +00:00
socket connect_nonblock supports "exception: false" 2015-04-12 01:41:51 +00:00
stringio stringio.c: don't raise after close 2015-03-13 06:04:39 +00:00
strscan Update dependencies. 2014-12-19 13:34:54 +00:00
syslog Update dependencies. 2014-12-19 13:34:54 +00:00
thread thread.c: refine enums 2015-02-27 03:55:00 +00:00
tk use rb_funcallv 2015-02-16 04:08:52 +00:00
win32 * ext/win32/Win32API.rb (initialize): accept both a string and an array 2015-02-25 13:08:01 +00:00
win32ole * ext/win32ole/win32ole.c (Init_win32ole): should not use atexit to 2015-02-04 11:30:37 +00:00
zlib * ext/zlib/zlib.c (rb_gzfile_close): Don't raise on double 2015-03-08 13:52:51 +00:00
.document
extmk.rb extmk.rb: extract CLEANFILES and DISTCLEANFILES 2015-01-21 04:22:07 +00:00
Setup * ext/dl/*: remove DL as it is replaced by Fiddle. 2014-10-31 21:13:09 +00:00
Setup.atheos * ext/dl/*: remove DL as it is replaced by Fiddle. 2014-10-31 21:13:09 +00:00
Setup.emx * ext/dl/*: remove DL as it is replaced by Fiddle. 2014-10-31 21:13:09 +00:00
Setup.nacl * ext/dl/*: remove DL as it is replaced by Fiddle. 2014-10-31 21:13:09 +00:00
Setup.nt * ext/dl/*: remove DL as it is replaced by Fiddle. 2014-10-31 21:13:09 +00:00