Misaki Shioi
52f6de4196
Replace SocketError with Socket::ResolutionError in rsock_raise_socket_error
...
rsock_raise_socket_error is called only when getaddrinfo and getaddrname fail
2023-11-30 13:27:19 +09:00
Nobuyoshi Nakada
1a24442193
test/socket/test_addrinfo.rb: Suppress Errno::EACCES on Windows
2022-12-21 15:18:34 +09:00
Hiroshi SHIBATA
55cdb8b013
Use omit instead of skip: test/socket/**/*.rb
2021-12-28 20:29:54 +09:00
Hiroshi SHIBATA
940a19e4b3
Use Test::Unit::AssertionFailedError instead of MiniTest::Assertion for test-unit migration
2021-09-06 18:34:15 +09:00
Nobuyoshi Nakada
e9974a466a
Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661]
2021-05-21 18:26:07 +09:00
Kir Shatrov
2038cc6cab
Make Socket.getaddrinfo interruptible ( #2827 )
...
Before, Socket.getaddrinfo was using a blocking getaddrinfo(3) call.
That didn't allow to wrap it into Timeout.timeout or interrupt the thread in any way.
Combined with the default 10 sec resolv timeout on many Unix systems, this can
have a very noticeable effect on production Ruby apps being not
resilient to DNS outages and timing out name resolution, and being unable to fail fast even
with Timeout.timeout.
Since we already have support for getaddrinfo_a(3), the async version
of getaddrinfo, we should be able to make Socket.getaddrinfo leverage that
when getaddrinfo_a version is available in the system (hence #ifdef
HAVE_GETADDRINFO_A).
Related tickets:
https://bugs.ruby-lang.org/issues/16476
https://bugs.ruby-lang.org/issues/16381
https://bugs.ruby-lang.org/issues/14997
2020-08-27 16:39:13 +09:00
Yusuke Endoh
3d71388710
test/socket/test_addrinfo.rb: Fix syntax error
...
Sorry!
2020-06-04 11:29:39 +09:00
Yusuke Endoh
980655ce83
test/socket/test_addrinfo.rb: Suppress Errno::EACCES when addr is in use
...
MinGW seems to raise Errno::EACCES instead of EADDRINUSE when bind fails
due to in use.
https://github.com/ruby/ruby/runs/736825846
```
2) Error:
TestSocketAddrinfo#test_connect_from:
Errno::EACCES: Permission denied - bind(2) for 0.0.0.0:49721
D:/a/ruby/ruby/build/.ext/common/socket.rb:54:in `bind'
D:/a/ruby/ruby/build/.ext/common/socket.rb:54:in `connect_internal'
D:/a/ruby/ruby/build/.ext/common/socket.rb:114:in `connect_from'
D:/a/ruby/ruby/src/test/socket/test_addrinfo.rb:379:in `block in test_connect_from'
D:/a/ruby/ruby/src/test/socket/test_addrinfo.rb:374:in `open'
D:/a/ruby/ruby/src/test/socket/test_addrinfo.rb:374:in `test_connect_from'
```
2020-06-04 11:24:19 +09:00
Masaki Matsushita
f5024de002
Remove check of ai.protocol
...
Solaris 10 returns addrinfo.ai_protocol as 0, not 6.
2019-09-10 12:39:49 +09:00
Masaki Matsushita
0e9d56f5e7
Support timeout for Addrinfo
...
Addrinfo.getaddrinfo and .foreach now accepts :timeout in seconds as
a keyword argument. If getaddrinfo_a(3) is available, the timeout will be
applied for name resolution. Otherwise, it will be ignored.
Socket.tcp accepts :resolv_timeout to use this feature.
This commit is retry of 6382f5cc91
.
Test was failed on Solaris machines which don't have "http" in
/etc/services. In this commit, use "ssh" instead.
2019-09-10 10:10:59 +09:00
Masaki Matsushita
c4efbf663e
Revert "Support timeout for Addrinfo"
...
This reverts commit 6382f5cc91
.
test failed on Solaris.
2019-09-09 20:34:51 +09:00
Masaki Matsushita
8c09de38c5
Fix expected ip_port
2019-09-09 18:44:42 +09:00
Masaki Matsushita
0fb2457d79
Fix service name for test
...
change service name to fix failed test on Solaris
2019-09-09 18:35:19 +09:00
Masaki Matsushita
461663f52a
Fix domain name for test
2019-09-09 15:05:38 +09:00
Masaki Matsushita
6382f5cc91
Support timeout for Addrinfo
...
Addrinfo.getaddrinfo and .foreach now accepts :timeout in seconds as
a keyword argument. If getaddrinfo_a(3) is available, the timeout will be
applied for name resolution. Otherwise, it will be ignored.
Socket.tcp accepts :resolv_timeout to use this feature.
2019-09-09 14:34:05 +09: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
usa
3912e4fa3b
* ext/socket/raddrinfo.c (host_str, port_str): Use StringValueCStr
...
instead of (Safe)StringValue, to detect NUL byte in the string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30 15:33:06 +00:00
usa
0e94f4a002
* test/socket/test_addrinfo.rb (TestSocketAddrinfo#test_addrinfo_ip): previous
...
test logic depended on platform specific implementation. use more portable
logic. this fixes a test failure on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30 12:51:14 +00:00
nobu
632097082b
test_addrinfo.rb: signle digit address
...
* test/socket/test_addrinfo.rb (test_addrinfo_ip): use single
digit address so that the values are same in both decimal and
octal. some platform zero-prefixed dotted-decimal is parsed as
an octal value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30 11:23:32 +00:00
nobu
94a91b1d60
raddrinfo.c: fix for SHARABLE_MIDDLE_SUBSTRING
...
* ext/socket/raddrinfo.c (host_str, port_str): use RSTRING_LEN
instead of strlen, since RSTRING_PTR StringValueCStr may not be
NUL-terminated when SHARABLE_MIDDLE_SUBSTRING=1. reported by
@tmtms, http://twitter.com/tmtms/status/736910516229005312
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30 07:28:55 +00:00
nobu
bfc9c3766f
test_addrinfo.rb: special hostnames
...
* test/socket/test_addrinfo.rb (test_addrinfo_ip): add tests for
special hostnames, <any> and <broadcast>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-30 06:12:13 +00:00
odaira
bf5d2c74c9
* test/socket/test_addrinfo.rb (test_ipv6_address_predicates):
...
IN6_IS_ADDR_V4COMPAT and IN6_IS_ADDR_V4MAPPED are broken
on AIX, so skip related tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-05 00:54:17 +00:00
akr
373e87a74d
* ext/socket/lib/socket.rb: Specify frozen_string_literal: true.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-14 13:15:33 +00:00
nobu
14d10e054f
test_addrinfo.rb: relax memory usage criterion
...
* test/socket/test_addrinfo.rb (test_marshal_memory_leak): relax
the criterion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-10 01:02:55 +00:00
nobu
816504c29c
raddrinfo.c: fix memory leak
...
* ext/socket/raddrinfo.c (addrinfo_mload): fix memory leak of
addrinfo. [ruby-dev:48923] [Bug #11051 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-08 23:24:10 +00:00
hsbt
93156392dd
* test/socket/test_addrinfo.rb: remove unused variables.
...
* test/socket/test_nonblock.rb: ditto.
* test/socket/test_socket.rb: ditto.
* test/socket/test_unix.rb: ditto.
* test/testunit/test_parallel.rb: ditto.
* test/webrick/test_filehandler.rb: ditto.
* test/xmlrpc/test_features.rb: ditto.
* test/zlib/test_zlib.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-18 12:05:09 +00:00
naruse
643f5308e6
Check if there is no error before reconnect [Bug #4387 ]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-30 00:40:54 +00:00
drbrain
3efea48a70
* ext/socket/raddrinfo.c (addrinfo_ipv6_unique_local_p): Added
...
Addrinfo#ipv6_unique_local? to detect RFC 4193 unique local
addresses. Part of #6692
* ext/socket/rubysocket.h: Add IN6_IS_ADDR_UNIQUE_LOCAL macro if
missing.
* test/socket/test_addrinfo.rb: Test for ipv6_unqiue_local?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-20 00:32:35 +00:00
akr
268d1a2244
* ext/socket/lib/socket.rb (family_addrinfo): return the given
...
addrinfo object.
Patch by Ippei Obayashi. [ruby-dev:45095] [Bug #5845 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-09 11:11:24 +00:00
nobu
7f46fadd9d
* lib/test/unit.rb (assert_include): add alias.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-12 14:17:54 +00:00
akr
6dea556eb7
* test/socket/test_addrinfo.rb: extract Errno::EADDRINUSE as a method.
...
* test/socket/test_socket.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-01 12:42:50 +00:00
usa
520647325b
* test/socket/test_addrinfo.rb: ipaddr.rb defines Socket::AF_INET6 as an Object
...
if the constant is not available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-19 02:55:38 +00:00
usa
229b4e4c37
* ext/socket/socket.c (socket_s_ip_address_list): drop inactive
...
adapters.
* test/socket/test_{nonblock,addrinfo,socket}.rb: skip some tests on
Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-17 13:40:59 +00:00
akr
32004e3c46
don't use /tmp as example socket path.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-18 14:04:54 +00:00
akr
758f9510a6
use IO::WaitWritable.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-19 12:45:40 +00:00
akr
c4049f4cb6
* io.c (rb_mWaitReadable): defined.
...
(rb_mWaitWritable): defined.
(io_getpartial): extend IO::WaitReadable on EWOULDBLOCK and EAGAIN.
(rb_io_write_nonblock): extend IO::WaitWritable on EWOULDBLOCK and
EAGAIN.
* error.c (make_errno_exc): extracted from rb_sys_fail.
(rb_mod_sys_fail): new function.
* include/ruby/ruby.h (rb_mod_sys_fail): declared.
(rb_mWaitReadable): declared.
(rb_mWaitWritable): declared.
* ext/socket/init.c (rsock_s_recvfrom_nonblock): extend
IO::WaitReadable on EWOULDBLOCK and EAGAIN.
(rsock_s_accept_nonblock): extend IO::WaitReadable on EWOULDBLOCK,
EAGAIN, ECONNABORTED and EPROTO.
* ext/socket/socket.c (sock_connect_nonblock): extend IO::WaitWritable
on EINPROGRESS.
* ext/socket/ancdata.c (bsock_sendmsg_internal): extend
IO::WaitWritable on EWOULDBLOCK and EAGAIN.
(bsock_recvmsg_internal): extend IO::WaitReadable on EWOULDBLOCK and
EAGAIN.
* ext/openssl/ossl_ssl.c (ossl_ssl_read_internal): raise SSLError
extended by IO::WaitReadable/IO::WaitWritable on
SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE.
* ext/openssl/ossl.c (ossl_make_error): extracted from ossl_raise.
(ossl_exc_new): new function.
* ext/openssl/ossl.h (ossl_exc_new): declared.
* lib/net/protocol.rb (rbuf_fill): rescue IO::WaitReadable and
IO::WaitWritable.
[ruby-core:22539], [ruby-dev:38140]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-19 11:40:38 +00:00
akr
03149710e8
* ext/socket/raddrinfo.c (init_unix_addrinfo): add socktype argument.
...
(addrinfo_initialize): follow init_unix_addrinfo change.
(addrinfo_s_unix): add optional argument: socktype
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-08 04:53:17 +00:00
akr
b83188dc1e
add a test.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-07 12:33:25 +00:00
akr
2b8ab6c54f
* test/socket/test_addrinfo.rb (test_family_addrinfo): don't use
...
www.ruby-lang.org.
http://d.hatena.ne.jp/nagachika/20090204/working_for_0f0e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-07 12:28:15 +00:00
akr
88f04bdd32
* ext/socket: AddrInfo is renamed to Addrinfo. [ruby-dev:37876]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 11:01:43 +00:00
akr
0d0fe1a5ad
don't connect to unspecified address (0.0.0.0). OpenBSD reject it.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-05 00:09:39 +00:00
akr
1934c7a80b
test relaxed.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-04 15:42:13 +00:00
akr
3eab19122b
add tests.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-04 15:34:32 +00:00
akr
9845b50c11
relax tests for IPv4 compat/mapped IPv6 addresss.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-04 13:38:24 +00:00
akr
1643d1c28a
add tests.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-03 06:12:23 +00:00
akr
2df1053c1d
add a test.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-02 23:30:46 +00:00
akr
352dcd9ee7
* test/socket/test_addrinfo.rb: use AddrInfo.getaddrinfo to generate
...
IPv6 address. AddrInfo.ip generates IPv4 address for IPv4 mapped
IPv6 address if --with-lookup-order-hack=INET.
[ruby-dev:37868]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-02 10:59:17 +00:00
akr
f1137963e3
* ext/socket/raddrinfo.c (addrinfo_ipv4_private_p): new method.
...
(addrinfo_ipv4_loopback_p): ditto.
(addrinfo_ipv4_multicast_p): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-01 12:28:50 +00:00
akr
849e730f15
* ext/socket/raddrinfo.c (addrinfo_ipv6_unspecified_p): new method.
...
(addrinfo_ipv6_loopback_p): ditto.
(addrinfo_ipv6_multicast_p): ditto.
(addrinfo_ipv6_linklocal_p): ditto.
(addrinfo_ipv6_sitelocal_p): ditto.
(addrinfo_ipv6_v4mapped_p): ditto.
(addrinfo_ipv6_v4compat_p): ditto.
(addrinfo_ipv6_mc_nodelocal_p): ditto.
(addrinfo_ipv6_mc_linklocal_p): ditto.
(addrinfo_ipv6_mc_sitelocal_p): ditto.
(addrinfo_ipv6_mc_orglocal_p): ditto.
(addrinfo_ipv6_mc_global_p): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-31 11:09:51 +00:00
akr
db881044bc
* ext/socket/raddrinfo.c (addrinfo_inspect_sockaddr): new
...
method AddrInfo#inspect_sockaddr.
(inspect_sockaddr): extracted from addrinfo_inspect.
(addrinfo_inspect): use inspect_sockaddr.
(Init_addrinfo): define the new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-18 08:03:24 +00:00