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 aaf2d070a8 accept_nonblock supports "exception: false"
This is analogous to functionality found in IO#read_nonblock and
IO#wait_nonblock.  Raising exceptions for common failures on
non-blocking servers is expensive and makes $DEBUG too noisy.

Benchmark results:
                                    user     system      total        real
default                         2.790000   0.870000   3.660000 (  3.671597)
exception: false                1.120000   0.800000   1.920000 (  1.922032)
exception: false (cached arg)   0.820000   0.770000   1.590000 (  1.589267)
--------------------- benchmark script ------------------------
require 'socket'
require 'benchmark'
require 'tmpdir'
nr = 1000000
Dir.mktmpdir('nb_bench') do |path|
  sock_path = "#{path}/test.sock"
  s = UNIXServer.new(sock_path)
  Benchmark.bmbm do |x|
    x.report("default") do
      nr.times do
        begin
          s.accept_nonblock
        rescue IO::WaitReadable
        end
      end
    end
    x.report("exception: false") do
      nr.times do
        begin
          s.accept_nonblock(exception: false)
        rescue IO::WaitReadable
          abort "should not raise"
        end
      end
    end
    x.report("exception: false (cached arg)") do
      arg = { exception: false }
      nr.times do
        begin
          s.accept_nonblock(arg)
        rescue IO::WaitReadable
          abort "should not raise"
        end
      end
    end
  end
end

* ext/socket/init.c (rsock_s_accept_nonblock):
  support exception: false
  [ruby-core:66385] [Feature #10532]
* ext/socket/init.c (rsock_init_socket_init): define new symbols
* ext/socket/rubysocket.h: adjust prototype
* ext/socket/socket.c (sock_accept_nonblock): support exception: false
* ext/openssl/ossl_ssl.c (ossl_ssl_accept_nonblock): ditto
* ext/socket/socket.c (Init_socket): adjust accept_nonblock definition
* ext/openssl/ossl_ssl.c (Init_ossl_ssl): ditto
* ext/socket/tcpserver.c (rsock_init_tcpserver): ditto
* ext/socket/unixserver.c (rsock_init_unixserver): ditto
* ext/socket/tcpserver.c (tcp_accept_nonblock): adjust
  rsock_s_accept_nonblock call
* ext/socket/unixserver.c (unix_accept_nonblock): ditto
* ext/openssl/ossl_ssl.c (ossl_start_ssl): support no_exception
* ext/openssl/ossl_ssl.c (ossl_ssl_connect): adjust ossl_start_ssl call
* ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock): ditto
* ext/openssl/ossl_ssl.c (ossl_ssl_accept): ditto
* test/socket/test_nonblock.rb (test_accept_nonblock): test for
  "exception :false"
* test/socket/test_tcp.rb (test_accept_nonblock): new test
* test/socket/test_unix.rb (test_accept_nonblock): ditto
* test/openssl/test_pair.rb (test_accept_nonblock_no_exception): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12 03:03:04 +00:00
..
-test- cstr.c: nil iff terminated validly 2015-01-27 04:09:04 +00:00
bigdecimal bigdecimal.c: format specifiers 2015-02-04 07:32:58 +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 Update dependencies. 2014-12-19 13:34:54 +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 protoize no-arguments functions 2014-09-30 05:25:32 +00:00
fiber
fiddle libffi: workaround of VC12 ml 2015-01-24 15:42:27 +00:00
gdbm use 0 for reserved 2014-12-01 06:38:04 +00:00
io io/wait: fix return value for buffered read 2015-03-01 21:03:22 +00:00
json * ext/json: merge upstream from flori/json 2015-02-13 05:19:12 +00:00
mathn
nkf nkf.c: add semicolon 2014-12-26 06:09:31 +00:00
objspace * internal.h: use T_IMEMO to represent `struct MEMO' value. 2015-03-11 23:13:01 +00:00
openssl accept_nonblock supports "exception: false" 2015-03-12 03:03:04 +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 * ext/pty/pty.c: AIX supports autopush. Patch by Perry Smith [ruby-core:58539] [Bug #9144] 2015-02-27 23:32:48 +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 accept_nonblock supports "exception: false" 2015-03-12 03:03:04 +00:00
stringio stringio.c: don't raise after close 2015-03-09 07:34: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 * ext/win32ole/win32ole.c: separate WIN32OLE::VARIANT src file 2014-08-02 14:55:36 +00:00
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