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.
This also increases performance slightly, see patch for benchmarks.
I also intend to support this in the "openssl" extension as well as
supporting connect_nonblock if this is accepted.
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=1000000Dir.mktmpdir('nb_bench')do|path|sock_path="#{path}/test.sock"s=UNIXServer.new(sock_path)Benchmark.bmbmdo|x|x.report("default")donr.timesdobegins.accept_nonblockrescueIO::WaitReadableendendendx.report("exception: false")donr.timesdobegins.accept_nonblock(exception: false)rescueIO::WaitReadableabort"should not raise"endendendx.report("exception: false (cached arg)")doarg={exception: false}nr.timesdobegins.accept_nonblock(arg)rescueIO::WaitReadableabort"should not raise"endendendendend
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