Граф коммитов

1037 Коммитов

Автор SHA1 Сообщение Дата
nobu 97e05dad7f UNREACHABLE_RETURN
* 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-07-24 05:38:07 +00:00
shyouhei 33d0be1500 comma at the end of enum is a C99ism
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-25 03:14:48 +00:00
normal 8b590c4663 UNIXSocket#recv_io: trigger GC when out of FDs
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-06-24 22:08:15 +00:00
nobu 7727b22eb1 io.c: workaround for EPROTOTYPE
* 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-04-30 02:17:03 +00:00
nobu b78fa27ae0 unixsocket.c: abstract namespace
* 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-28 11:30:27 +00:00
nobu 8794dec6a5 unixsocket.c: check NUL bytes
* 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-28 10:08:57 +00:00
nobu 11bc984efe search winsock libraries explicitly
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-02 04:36:14 +00:00
k0kubun 3406c5d613 Refactor ERB version checking for keyword arguments
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-27 11:12:23 +00:00
k0kubun cc777d09f4 erb.rb: deprecate safe_level of ERB.new
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-22 13:28:25 +00:00
nobu 131dc83145 socket.rb: protected connect_internal
* 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-02-17 07:54:52 +00:00
nobu a41005eb6a init.c: encode socket error message
* 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-23 15:31:22 +00:00
nobu fb6c4ca168 getaddrinfo.c: ai_errlist
* 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-23 15:31:21 +00:00
nobu 995717e15c raddrinfo.c: fix parse_numeric_port
* 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
2018-01-15 07:01:08 +00:00
nobu 70001d5fda ifaddr.c: get_ifaddrs
* 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-22 01:49:00 +00:00
nobu 7101611b76 ifaddr.c: fix memsize
* 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-04 06:08:30 +00:00
nobu 7a936a6362 ifaddr.c: unused member
* 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-12-03 23:54:45 +00:00
stomar b6db783eed socket.c,tcpsocket.c: improve deprecation notices
* 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-07 20:13:00 +00:00
stomar bf6ea09c8f ext/socket/ifaddr.c: [DOC] fix typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 20:09:19 +00:00
normal ba5eb6458a socket: fix BasicSocket#*_nonblock buffering bugs from r58400
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-27 23:26:48 +00:00
hsbt 6693e3e723 Fixed misspelling words.
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-22 11:27:06 +00:00
nobu 6a50386115 Add missing `buf` parameter to `recv_nonblock` doc [ci skip]
[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-22 06:01:07 +00:00
akr dd5b75af34 reference Socket.getaddrinfo to Addrinfo.getaddrinfo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 23:23:05 +00:00
akr d808918583 deprecate TCPSocket.gethostbyname.
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-21 23:19:47 +00:00
akr d88a0f13c2 Describe recommended-methods.
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-21 14:21:52 +00:00
akr b5c6fc8561 Deprecation document for gethostbyname,gethostbyaddr.
[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-21 13:13:02 +00:00
akr 6fba455acb add example for Socket.gethostbyaddr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 12:22:46 +00:00
nobu fb89004a3b socket.c: null byte at Socket.getnameinfo
* 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-10-11 06:16:04 +00:00
naruse e7ddf8788f Add Socket::Ifaddr.vhid on supported platforms [Feature #13803]
patched by Alan Somers

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-31 08:29:38 +00:00
nobu 88a22cbcf2 socket: system getaddrinfo on Windows
* 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-07-25 01:08:51 +00:00
nobu ebbe6782c6 separate constdefs.c and constdefs.h
* 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-05-08 05:31:02 +00:00
normal c32fc82d0e socket: avoid fcntl for read/write_nonblock on Linux
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-19 01:08:16 +00:00
nobu 8c84803d80 IPSocket#inspect
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-14 10:03:43 +00:00
normal abc5e8966c Socket.udp_server_sockets: use symbol proc
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-11 14:56:17 +00:00
usa 49e4df4861 Get rid of inifinity retry loop in Socket.udp_server_sockets
* 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-09 16:19:37 +00:00
nobu 51eaaa898b basicsocket.c: proper system call name
* 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-04-08 03:25:50 +00:00
shyouhei 20c72dc89d ruby tool/update-deps --fix
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-22 06:00:18 +00:00
normal f1de2e0070 ext/socket/raddrinfo.c (addrinfo_mark): avoid needless branch
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
2017-03-09 03:49:47 +00:00
nobu 06c1272677 ext/socket/extconf.rb: fix a typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-27 05:58:31 +00:00
nobu c9447082ec Revert r57690 except for read_nonblock
https://github.com/ruby/ruby/pull/1527#issuecomment-281867551

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23 02:40:17 +00:00
nobu d0cf19d9ed [DOC] mark up literals
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23 02:11:16 +00:00
nobu 95a476c859 [DOC] keyword argument _exception_
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23 02:00:28 +00:00
nobu 53b4bf3134 socket.rb: [DOC] fix nonblock methods
* ext/socket/lib/socket.rb (BasicSocket#recv_nonblock): fix
  exception class and symbol.

* ext/socket/lib/socket.rb (BasicSocket#recvmsg_nonblock): ditto.

* ext/socket/lib/socket.rb (Socket#recvfrom_nonblock): fix the
  method name.

* ext/socket/lib/socket.rb (UDPSocket#recvfrom_nonblock): both.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23 01:54:13 +00:00
nobu d5eef0301a [DOC] {read,write}_nonblock with exception: false
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
2017-02-23 01:15:27 +00:00
normal a34f9c7e9a basicsocket (rsock_bsock_send): do not truncate return value
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
2017-01-16 21:42:05 +00:00
normal 0514a74794 socket: use symbol proc for IO#close loops
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
2016-11-21 23:50:25 +00:00
nobu 6394b63db9 socket.rb: remove closed checks
* 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
2016-11-15 01:39:11 +00:00
nobu bfcb3fb3be socket.rb: kwargs
* ext/socket/lib/socket.rb (connect_{from,to}, connect): let use
  keyword arguments.

* ext/socket/lib/socket.rb (Socket.tcp): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-14 07:53:31 +00:00
rhe 4530a8ef7f socket: fix rdoc of UDPSocket#recvfrom_nonblock
* 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
2016-10-27 05:58:35 +00:00
nobu 4e44f6ef86 [DOC] replace Fixnum with Integer [ci skip]
* numeric.c: [DOC] update document for Integer class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26 06:11:23 +00:00
hsbt 4043565023 * ext/socket/*.c: Add proper require for example to work.
[fix GH-1378][ci skip] Patch by @schneems

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-05 03:57:32 +00:00