summaryrefslogtreecommitdiff
path: root/ext/socket
AgeCommit message (Collapse)Author
2019-02-08Removed moving toplevel header since r12501nobu
Moving public headers was 12-years ago, no depend files would expect ruby.h in the top source directory now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31Fix indents [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-29disable non-blocking pipes and sockets by defaultnormal
There seems to be a compatibility problems with Rails + Rack::Deflater; so we revert this incompatibility. This effectively reverts r65922; but keeps the bugfixes to better support non-blocking sockets and pipes for future use. [Bug #15356] [Bug #14968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22socket: disable nonblocking-by-default on win32normal
Perhaps this fixes test failures reported by Greg and k0kubun. However, the failure of certain tests to handle non-blocking I/O seems to indicate pre-existing problems on win32 platforms. Somebody knowledgeable about win32 should be able to fix it. [ruby-core:89973] [ruby-core:89976] [ruby-core:89977] [Bug #14968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22ext/socket/init.c (rsock_socket0): non-blocking for non-SOCK_NONBLOCKnormal
We need to make sockets non-blocking for systems without SOCK_CLOEXEC/SOCK_NONBLOCK macros at all. [ruby-core:89965] [Bug #14968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22io + socket: make pipes and sockets nonblocking by defaultnormal
All normal Ruby IO methods (IO#read, IO#gets, IO#write, ...) are all capable of appearing to be "blocking" when presented with a file description with the O_NONBLOCK flag set; so there is little risk of incompatibility within Ruby-using programs. The biggest compatibility risk is when spawning external programs. As a result, stdin, stdout, and stderr are now always made blocking before exec-family calls. This change will make an event-oriented MJIT usable if it is waiting on pipes on POSIX_like platforms. It is ALSO necessary to take advantage of (proposed lightweight concurrency (aka "auto-Fiber") or any similar proposal for network concurrency: https://bugs.ruby-lang.org/issues/13618 Named-pipe (FIFO) are NOT yet non-blocking by default since they are rarely-used and may introduce compatibility problems and extra syscall overhead for a common path. Please revert this commit if there are problems and if I am afk since I am afk a lot, lately. [ruby-core:89950] [Bug #14968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-11Use friendlier terminology in rubysocket.h commentnobu
[Fix GH-2008] From: Juanito Fatas <juanito.fatas@shopify.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-11Revert "Use friendlier terminology in rubysocket.h comment"nobu
This reverts commit dcd41bbbdb021b5e0e74f8a33c2c58cecf595f29. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-11Use friendlier terminology in rubysocket.h commentnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08ext/socket/init.c (wait_connectable): bail out early on some errorsnormal
This becomes necesary if sockets become non-blocking by default <https://bugs.ruby-lang.org/issues/14968>; but it's always been possible to make sockets non-blocking anyways. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-05fix a typo [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-05fix typonaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-05AIX doesn't set OptionLength for boolean optionsnaruse
https://rubyci.org/logs/rubyci.s3.amazonaws.com/aix71_ppc/ruby-trunk/log/20180904T103302Z.fail.html.gz https://www.ibm.com/support/knowledgecenter/ja/ssw_aix_72/com.ibm.aix.commtrf2/getsockopt.htm git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-24UNREACHABLE_RETURNnobu
* 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
2018-06-25comma at the end of enum is a C99ismshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-24UNIXSocket#recv_io: trigger GC when out of FDsnormal
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
2018-04-30io.c: workaround for EPROTOTYPEnobu
* 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
2018-03-28unixsocket.c: abstract namespacenobu
* ext/socket/unixsocket.c (unixsock_path_value): fix r62991 for Linux abstract namespace. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28unixsocket.c: check NUL bytesnobu
* ext/socket/unixsocket.c (rsock_init_unixsock): check NUL bytes. https://hackerone.com/reports/302997 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-02search winsock libraries explicitlynobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-27Refactor ERB version checking for keyword argumentsk0kubun
Improving code like r62590. See r62529 for details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-22erb.rb: deprecate safe_level of ERB.newk0kubun
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
2018-02-17socket.rb: protected connect_internalnobu
* 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
2018-01-23init.c: encode socket error messagenobu
* ext/socket/init.c (rsock_raise_socket_error): on Windows, encode error messages from wide characters to the default encodings. [ruby-core:84972] [Bug #14384] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-23getaddrinfo.c: ai_errlistnobu
* 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
2018-01-15raddrinfo.c: fix parse_numeric_portnobu
* ext/socket/raddrinfo.c (parse_numeric_port): necessary regardless of GETADDRINFO_EMU. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22ifaddr.c: get_ifaddrsnobu
* ext/socket/ifaddr.c (get_ifaddrs): extract ifaddrs from Socket::Ifaddr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04ifaddr.c: fix memsizenobu
* 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
2017-12-03ifaddr.c: unused membernobu
* 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
2017-11-07socket.c,tcpsocket.c: improve deprecation noticesstomar
* ext/socket/socket.c: [DOC] fix grammar in deprecation notices. * ext/socket/tcpsocket.c: [DOC] ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07ext/socket/ifaddr.c: [DOC] fix typostomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27socket: fix BasicSocket#*_nonblock buffering bugs from r58400normal
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
2017-10-22Fixed misspelling words.hsbt
These are detected by https://github.com/client9/misspell git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Add missing `buf` parameter to `recv_nonblock` doc [ci skip]nobu
[Fix GH-1725] From: yuuji.yaginuma <yuuji.yaginuma@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21reference Socket.getaddrinfo to Addrinfo.getaddrinfo.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21deprecate TCPSocket.gethostbyname.akr
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
2017-10-21Describe recommended-methods.akr
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
2017-10-21Deprecation document for gethostbyname,gethostbyaddr.akr
[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
2017-10-21add example for Socket.gethostbyaddr.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-11socket.c: null byte at Socket.getnameinfonobu
* ext/socket/socket.c (sock_s_getnameinfo): check null byte. patched by tommy (Masahiro Tomita) in [ruby-dev:50286]. [Bug #13994] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-31Add Socket::Ifaddr.vhid on supported platforms [Feature #13803]naruse
patched by Alan Somers git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-25socket: system getaddrinfo on Windowsnobu
* 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
2017-05-08separate constdefs.c and constdefs.hnobu
* 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
2017-04-19socket: avoid fcntl for read/write_nonblock on Linuxnormal
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
2017-04-14IPSocket#inspectnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-11Socket.udp_server_sockets: use symbol procnormal
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
2017-04-09Get rid of inifinity retry loop in Socket.udp_server_socketsusa
* 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
2017-04-08basicsocket.c: proper system call namenobu
* 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
2017-03-22ruby tool/update-deps --fixshyouhei
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
2017-03-09ext/socket/raddrinfo.c (addrinfo_mark): avoid needless branchnormal
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