* include/ruby/ruby.h (UNREACHABLE_RETURN): UNREACHABLE at the end
of non-void functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Make this behavior is consistent with our other FD-allocating
methods.
EMFILE and ENFILE are not documented nor can I trigger them when
using UNIXSocket#recv_io. However, ENOMEM is documented, and
I've triggered EMSGSIZE on FreeBSD and truncated messages when
an EMFILE condition is hit on my system.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (internal_write_func, internal_writev_func): retry at
unexpected EPROTOTYPE on macOS, to get rid of a kernel bug.
[ruby-core:86690] [Bug #14713]
* ext/socket/init.c (rsock_{sendto,send,write}_blocking): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Also, as it's in the middle of the list of 4 arguments, 3rd and 4th arguments
(trim_mode, eoutvar) are changed to keyword arguments.
Old ways to specify arguments are deprecated and warned now.
bin/erb: deprecate -S option.
We'll remove all of deprecated ones at Ruby 2.7+.
enc/make_encmake.rb: stopped using deprecated interface
ext/etc/mkconstants.rb: ditto
ext/socket/mkconstants.rb: ditto
sample/ripper/ruby2html.rb: ditto
spec/ruby/library/erb/defmethod/def_erb_method_spec.rb: ditto
spec/ruby/library/erb/new_spec.rb: ditto
test/erb/test_erb.rb: ditto
test/erb/test_erb_command.rb: ditto
tool/generic_erb.rb: ditto
tool/ruby_vm/helpers/dumper.rb: ditto
tool/transcode-tblgen.rb: ditto
lib/rdoc/erbio.rb: ditto
lib/rdoc/generator/darkfish.rb: ditto
[Feature #14256]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/lib/socket.rb (Addrinfo#connect_internal): make
protected for Addrinfo#connect_to, instead of private and send.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/getaddrinfo.c (ai_errlist): used only if gai_strerror
is missing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ifaddr.c (ifaddr_memsize): do not count the whole
rb_ifaddr_t array for each elements. the header size is
included in the first element for the time being.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/ifaddr.c (struct rb_ifaddr_tag): removed set but
unused member root.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
IO#read_nonblock and IO#write_nonblock take into account
buffered data, so the Linux-only BasicSocket#read_nonblock
and BasicSocket#write_nonblock methods must, too.
This bug was only introduced in r58400
("socket: avoid fcntl for read/write_nonblock on Linux")
and does not affect any stable release.
* ext/socket/basicsocket.c (rsock_init_basicsocket):
* ext/socket/init.c (rsock_s_recvfrom_nonblock):
* ext/socket/init.c (rsock_init_socket_init):
* ext/socket/lib/socket.rb (def read_nonblock):
* ext/socket/lib/socket.rb (def write_nonblock):
* ext/socket/rubysocket.h (static inline void rsock_maybe_wait_fd):
* test/socket/test_basicsocket.rb (def test_read_write_nonblock):
[Feature #13362]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
TCPSocket.gethostbyname has problems similar to
Socket.gethostbyname.
An example of the problem which only the address family of
the first address is returned:
```
pp TCPSocket.gethostbyname("www.wide.ad.jp")
#=> ["www.wide.ad.jp",
[],
10,
"2001:200:dff:fff1:216:3eff:fe4b:651c",
"203.178.137.58"]
```
The address family of the first address, AF_INET6 (10), is
returned but
the address family of the second address, AF_INET, is not
returned.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Addrinfo.getaddrinfo is recommended instead of
Socket.gethostbyname.
Addrinfo#getnameinfo is recommended instead of
Socket.gethostbyaddr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Feature #13097]
I confirmed current ruby (Ruby 2.4 and trunk) uses
gethostbyname() and gethostbyaddr().
Socket.gethostbyname uses getaddrinfo() and gethostbyname().
Socket.gethostbyaddr uses gethostbyaddr().
Socket.gethostbyname uses gethostbyname() to obtain alias hostnames.
RFC 3493 defines getaddrinfo()/getnameinfo() and
describes the problems of gethostbyname()/gethostbyaddr().
The problems are difficult protocol handling and thread-unsafety.
Since Ruby has GVL, the thread-unsafety doesn't cause wrong result.
But it may block other threads until finishing DNS query.
Socket.gethostbyname has the protocol handling problem.
It returns only one address family:
```
% ruby -rpp -rsocket -e 'pp Socket.gethostbyname("www.wide.ad.jp")'
["www.wide.ad.jp",
[],
10,
" \x01\x02\x00\r\xFF\xFF\xF1\x02\x16>\xFF\xFEKe\x1C",
"\xCB\xB2\x89:"]
```
www.wide.ad.jp has one IPv6 address and one IPv4 address.
But Socket.gethostbyname returns only one address family, 10 (AF_INET6),
which is the address family of the first address.
Also, Socket.gethostbyname and Socket.gethostbyaddr uses
4-bytes binary IPv4 address and 16-bytes binary IPv6 address.
This is not usual in other socket API in Ruby.
(Most socket API uses binary sockaddr string or Addrinfo object)
I think Socket.gethostbyname and Socket.gethostbyaddr are too far
from recommendable API.
So, I added deprecation description for documents for them.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/extconf.rb: use system getaddrinfo, getnameinfo, and
freeaddrinfo on Windows if they are provided. they conflict
with addrinfo.h and cannot compile. conftest.exe linked against
msvcr90.dll segfaults when invoked in extconf.rb for unknown
reason, and failed to check them.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/depend: separate constdefs.c and constdefs.h so that
only one process will run when parallel building.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
On platforms where MSG_DONTWAIT works reliably on all sockets
(so far, I know of Linux), we can avoid fcntl syscalls and
implement IO#write_nonblock and IO#read_nonblock in terms of the
socket-specific send and recv family of syscalls.
This avoids side effects on the socket, and also encourages
generic code to be written in cases where IO wrappers like
OpenSSL::SSL::SSLSocket are used.
Perhaps in the future, side-effect-free non-blocking I/O can
be standard on all files and OSes: https://cr.yp.to/unix/nonblock.html
* ext/socket/lib/socket.rb (read_nonblock, write_nonblock):
Linux-specific wrapper without side effects
[ruby-core:80780] [Feature #13362]
* test/socket/test_basicsocket.rb (test_read_write_nonblock):
new test
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Symbol proc is shorter human and machine code;
and also avoids needing to name variables.
* ext/socket/lib/socket.rb (Socket.udp_server_sockets): use symbol proc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/lib/socket.rb (Socket.udp_server_sockets): remove duplicated
addresses before passing it to ip_sockets_port0 because it causes
Errno::EADDRINUSE and retry forever.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/basicsocket.c (rsock_bsock_send): show proper system
call name in the exception message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Onigumo 6 (r57045) introduced new onigumo.h header file, which is
required from quite much everywhere. This commit adds necessary
dependencies.
Note: ruby/oniguruma.h now includes onigumo.h,
ruby/io.h includes oniguruma.h,
ruby/encoding.h also includes oniguruma.h,
and internal.h includes encoding.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
gc.c (gc_mark_children, case T_DATA) does not use
the dmark function pointer if DATA_PTR is NULL
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Update docs to reflect EOF behavior change of read_nonblock and
write_nonblock when using `exception: false`.
[Fix GH-1527]
Author: Russell Davis <russell-stripe@users.noreply.github.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
send(2) and sendto(2) syscalls return `ssize_t', use the
proper type and macro for converting to a Numeric VALUE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Made possible by r56795, this reduces human and byte code size.
* ext/socket/lib/socket.rb (self.ip_sockets_port0,
self.tcp_server_sockets_port0,
self.tcp_server_sockets,
self.udp_server_sockets): use symbol proc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/lib/socket.rb: remove unnecessary closed checks,
close on closed socket no longer raises an exception.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/socket/lib/socket.rb (UDPSocket#recvfrom_nonblock): [DOC] Remove
a false statement "If _maxlen_ is omitted, its default value is
65536." maxlen, the first parameter, cannot be omitted as the method
signature indicates. This hasn't changed ever since it was first
implemented.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e