* io.c (rb_readwrite_syserr_fail): works with the given errno than
thread local errno.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c, io.c, util.c: prefer rb_syserr_fail with saved errno
over setting errno then call rb_sys_fail, not to be clobbered
potentially and to reduce thread local errno accesses.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
buffer fullness is more robust to detect the message is too big for
the buffer.
AIX 7.1 recvmsg doesn't set MSG_TRUNC for rflags when MSG_PEEK is
given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
when EMSGSIZE occurs on non HAVE_STRUCT_MSGHDR_MSG_CONTROL platforms
(such as, Windows). fixes a test error revealed by r52625.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ancdata.c (bsock_recvmsg_internal): use 4096 as
default size to match pre-r52610, which also maps to a common
page size.
Oops; absolutely no idea why I made this typo...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
of clen must be nil.
* ext/socket/ancdata.c (bsock_sendmsg_internal): handle nil of clen.
fixes test errors introduced at r52602.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/bigdecimal/bigdecimal.c: use RARRAY_CONST_PTR just fore
reference instead of RARRAY_PTR, to keep the array WB-protected.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/openssl/ossl_ssl.c (ossl_sslctx_set_ssl_version): use
rb_sym2str to get rid of inadvertent ID creations.
* ext/socket/ancdata.c (ancillary_inspect): ditto.
* ext/socket/option.c (sockopt_inspect): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Using 8K stack is probably too much. As reference, ALLOCV falls
back to heap allocation at a mere 1K. Since
bsock_recvmsg_internal is a function which will always allocate
and can trigger GC, it is in our best interest to minimize
stack usage to avoid scanning 8K of stack on GC.
[ruby-core:69595] [Feature #11263]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
As documented before, exceptions are expensive and IO::Wait*able are too
common in socket applications to be the exceptional case. Datagram
sockets deserve the same API which stream sockets are allowed with
read_nonblock and write_nonblock.
Note: this does not offer a performance advantage under optimal
conditions when both ends are equally matched in speed, but it it
does make debug output cleaner by avoiding exceptions whenever
the receiver slows down.
* ext/socket/ancdata.c (bsock_sendmsg_internal, bsock_recvmsg_internal):
support "exception: false" kwarg
* ext/socket/init.c (rsock_s_recvfrom_nonblock):
ditto
* ext/socket/init.c (rsock_s_recvfrom_nonblock): use rsock_opt_false_p
* ext/socket/socket.c (sock_connect_nonblock): ditto
* ext/socket/rubysocket.h (rsock_opt_false_p): new function
* ext/socket/basicsocket.c (bsock_recv_nonblock): update rdoc
* ext/socket/udpsocket.c (udp_recvfrom_nonblock): ditto
* test/socket/test_nonblock.rb: new tests
[ruby-core:69542] [Feature #11229]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We call memset to zero `mh' a few lines above anyways, making
explicitly zero-ing each field unnecessary.
Compilers optimize this code away anyways, but it still costs me
4 lines of my small terminal and even smaller attention span.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
parsed even on systems without HAVE_STRUCT_MSGHDR_MSG_CONTROL
to prevent SEGV caused by passing Qnil to RARRAY_LENINT and
to preserve behavior before r50776.
[Bug #11224] [ruby-core:69468] [Bug #11225] [ruby-core:69469]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ancdata.c (bsock_sendmsg_internal): avoid msg_control
ptr if msg_controllen is zero to fix portability problems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Systems without HAVE_STRUCT_MSGHDR_MSG_CONTROL still need
controls to be nil for the check after argument parsing.
Note: not actually tested on a real system without msg_control
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This should make the code more maintainable and make it easier to
add keyword argument support for "exception: false" in the future.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
See doc/extension.rdoc for explanation.
[ruby-core:69419] [Feature #11198]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ancdata.c (bsock_sendmsg_internal,
bsock_recvmsg_internal):
avoid redundant fcntl on Linux
[ruby-core:69154] [Feature #11145]
* ext/socket/init.c (rsock_s_recvfrom_nonblock): ditto
* ext/socket/rubysocket.h (MSG_DONTWAIT_RELIABLE): new macro
MSG_DONTWAIT is enough to force non-blocking I/O under Linux,
so avoid changing the state of a socket. This will allow certain
threads to do a non-destructive non-blocking "peek" while others
block (without relying on an extra ppoll syscall).
We shall be conservative about enabling this feature since some
OSes may have incomplete support for MSG_DONTWAIT. I shall
defer to a FreeBSD expert to enable that for FreeBSD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The control buffer may be used throughout the function, so
prevent the string from being lost to GC.
* ext/socket/ancdata.c (bsock_recvmsg_internal): GC guard
[Bug #11123]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error
(bsock_recvmsg_internal): ditto
* test/socket/test_unix.rb: test above for infinite loop
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
controls_num to raise NotImplementedError appropriately.
(bsock_recvmsg_internal): Raise NotImplementedError if
:scm_rights=>true is given on platforms which don't have
4.4BSD style control message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
ext/socket/ancdata.c: Use HAVE_STRUCT_MSGHDR_MSG_CONTROL instead
of HAVE_ST_MSG_CONTROL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
suppress warning.
Bionic defines socklen_t as int.
Bionic defines msg_controllen as unsigned int (__kernel_size_t)
instead of socklen_t as POSIX.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
anc_inspect_ipv6_pktinfo if !HAVE_TYPE_STRUCT_IN6_PKTINFO.
anc_inspect_ipv6_pktinfo is not defined in the case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ancdata.c (bsock_sendmsg_internal): suppress warnings on
platforms where msghdr does not have msg_control.
* ext/socket/ancdata.c (bsock_recvmsg_internal): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
subclasses that include WaitReadable or WaitWritable rather than
extending them into the exception object each time.
* error.c: Capture EGAIN, EWOULDBLOCK, EINPROGRESS exceptions and
export them for use in WaitReadable/Writable exceptions.
* io.c: Create versions of EAGAIN, EWOULDBLOCK, EINPROGRESS that
include WaitReadable and WaitWritable. Add rb_readwrite_sys_fail
for nonblocking failures using those exceptions. Use that
function in io_getpartial and io_write_nonblock instead of
rb_mod_sys_fail
* ext/openssl/ossl_ssl.c: Add new SSLError subclasses that include
WaitReadable and WaitWritable. Use those classes for
write_would_block and read_would_block instead of rb_mod_sys_fail.
* ext/socket/ancdata.c: Use rb_readwrite_sys_fail instead of
rb_mod_sys_fail in bsock_sendmsg_internal and
bsock_recvmsg_internal.
* ext/socket/init.c: Use rb_readwrite_sys_fail instead of
rb_mod_sys_fail in rsock_s_recvfrom_nonblock and
rsock_s_connect_nonblock.
* ext/socket/socket.c: Use rb_readwrite_sys_fail instead of
rb_mod_sys_fail in sock_connect_nonblock.
* include/ruby/ruby.h: Export rb_readwrite_sys_fail for use instead
of rb_mod_sys_fail. Introduce new constants RB_IO_WAIT_READABLE and
RB_IO_WAIT_WRITABLE for first arg to rb_readwrite_sys_fail.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
socket address returned from recvmsg().
* ext/socket/init.c (recvfrom_blocking): ignore truncated part of
socket address returned from recvfrom().
(rsock_s_recvfrom_nonblock): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ancdata.c (nogvl_sendmsg_func): explicitly cast via VALUE
to suppress a warning on mingw64.
* ext/socket/option.c: declare inet_ntop() for mingw64 which has the
function but lacks arpa/inet.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e