Commit graph

316 commits

Author SHA1 Message Date
Misaki Shioi
52c2660163 Fixup with review comment
https://github.com/ruby/ruby/pull/9088#discussion_r1411490445
2023-12-01 12:20:03 +09:00
Misaki Shioi
1bfd30a1e3 Relax test conditions to velify Socket::ResolutionError#error_code
The test for Socket::ResolutionError#error_code fails in the FreeBSD environment with this test condition. Because Socket::ResolutionError#error_code returns Socket::EAI_FAIL instead of Socket::EAI_FAMILY.

20231130T103002Z.fail.html.gz

This PR avoids the test failure by relaxing the condition.

Also changed the domain for testing to `example.com`.
2023-12-01 12:20:03 +09:00
Hiroshi SHIBATA
722cb9a56d
Skip test_resolurion_error_error_code with FreeBSD environment
20231130T103002Z.fail.html.gz
2023-11-30 20:17:27 +09:00
Nobuyoshi Nakada
e6d4441618
Fix the argument order 2023-11-30 13:36:11 +09:00
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
Yusuke Endoh
f26d53e905 Reduce the number of times IO is passed in send_io/recv_io test
Since Linux 4.5, sendmsg(2) fails with ETOOMANYREFS if the number of
"in-flight" IOs, which has been sent by sendmsg(2) but has not yet
accepted by recvmsg(2), exceeds the RLIMIT_NOFILE resource limit.

20231025T090004Z.fail.html.gz
```
  1) Error:
TestSocket_UNIXSocket#test_fd_passing_race_condition:
Errno::ETOOMANYREFS: Too many references: cannot splice - sendmsg(2)
```

This change reduces the number of times of IO passing under 1024,
which is a default limit in many environments.
2023-10-25 20:37:21 +09:00
Nobuyoshi Nakada
54a5623e26
Strip trailing spaces [ci skip] 2023-10-25 18:58:52 +09:00
Hiroshi SHIBATA
1649486834
Fixup 5461bc18f8 2023-10-25 18:49:37 +09:00
Hiroshi SHIBATA
5461bc18f8
omit failing test at arm64-neoverse-n1 2023-10-25 16:47:26 +09:00
Nobuyoshi Nakada
94e79e4c2d
Fix failures when all network interfaces are down 2023-09-30 19:03:04 +09:00
Nobuyoshi Nakada
94d7c70801
Fix test thread leakage 2023-09-24 09:50:01 +09:00
Jean Boussier
0270210e49 TestSocket_UNIXSocket: stop testing empty packets
OpenBSD and Solaris behave differently here.

Linux does deliver the empty packet, which is questionable
as it's undistinguishable from a closed connection.

It seems that OpenBSD and Solaris simply drop it.

We could test the platform before doing the assertion, but
it would likely be fragile, and the entire web recommend
to not ever send an empty packet, so the value of this
assertion is low.
2023-08-31 16:43:58 +02:00
Jean Boussier
bcc905100f BasicSocket#recv* return nil rather than an empty packet
[Bug #19012]

man recvmsg(2) states:

> Return Value
> These calls return the number of bytes received, or -1 if an error occurred.
> The return value will be 0 when the peer has performed an orderly shutdown.

Not too sure how one is supposed to make the difference between a packet of
size 0 and a closed connection.
2023-08-30 10:07:18 +02:00
Takashi Kokubun
195e32977f Skip test_udp_server on s390x RHEL 7.1
It seems like it never succeeds on this CI.
2023-03-11 20:51:49 -08:00
Takashi Kokubun
2e875549a9 s/MJIT/RJIT/ 2023-03-06 23:44:01 -08:00
Nobuyoshi Nakada
1a24442193
test/socket/test_addrinfo.rb: Suppress Errno::EACCES on Windows 2022-12-21 15:18:34 +09:00
Yusuke Endoh
096ffebbbf Prevent a "warning: assigned but unused variable - s2" 2022-11-18 14:39:40 +09:00
Samuel Williams
ea8a7287e2
Add support for sockaddr_un on Windows. (#6513)
* Windows: Fix warning about undefined if_indextoname()

* Windows: Fix UNIXSocket on MINGW and make .pair more reliable

* Windows: Use nonblock=true for read tests with scheduler

* Windows: Move socket detection from File.socket? to File.stat

Add S_IFSOCK to Windows and interpret reparse points accordingly.
Enable tests that work now.

* Windows: Use wide-char functions to UNIXSocket

This fixes behaviour with non-ASCII characters.
It also fixes deletion of temporary UNIXSocket.pair files.

* Windows: Add UNIXSocket tests for specifics of Windows impl.

* Windows: fix VC build due to missing _snwprintf

Avoid usage of _snwprintf, since it fails linking ruby.dll like so:

  linking shared-library x64-vcruntime140-ruby320.dll
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l

whereas linking miniruby.exe succeeds.

This patch uses snprintf on the UTF-8 string instead.

Also remove branch GetWindowsDirectoryW, since it doesn't work.

* Windows: Fix dangling symlink test failures

Co-authored-by: Lars Kanis <kanis@comcard.de>
2022-11-17 14:50:25 -08:00
Samuel Williams
e4f91bbdba
Add IO#timeout attribute and use it for blocking IO operations. (#5653) 2022-10-07 21:48:38 +13:00
Hiroshi SHIBATA
bfa6d0f6d7
fixup 8cd6f2a087
we should handle ensure block when omit this test
2022-09-07 09:41:28 +09:00
Hiroshi SHIBATA
8cd6f2a087
omit random failure tests with FreeBSD
20220906T043002Z.fail.html.gz
  20220905T103002Z.fail.html.gz
2022-09-06 16:27:12 +09:00
Hiroshi SHIBATA
55cdb8b013
Use omit instead of skip: test/socket/**/*.rb 2021-12-28 20:29:54 +09:00
Takashi Kokubun
1a63468831
Prepare for removing RubyVM::JIT (#5262) 2021-12-13 23:07:46 -08:00
Naohisa Goto
f8f2885bd0 Revert "test/socket/test_socket.rb: skip on Solaris"
This reverts commit 27fb9d272d.

The test failure on Solaris 10 is due to incomplete IPv6 configuration
on the CI server, that have already been fixed.

Reference for the fix: https://centrify.force.com/support/Article/KB-1179-X11-Forwarding-fails-with-Centrify-OpenSSH-5-0-Solaris/
2021-11-30 00:07:30 +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
Yusuke Endoh
27fb9d272d test/socket/test_socket.rb: skip on Solaris
The test fails on Solaris 10. Maybe due to the IPv6 configuration on the
server, but I have no idea at all. I've asked @ngoto to investigate the
issue, so will tentatively skip the tests on Solaris

20210729T040002Z.fail.html.gz
2021-07-29 13:51:43 +09:00
Nobuyoshi Nakada
e9974a466a
Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661] 2021-05-21 18:26:07 +09:00
Nobuyoshi Nakada
c711093559 Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661] 2021-05-20 21:56:58 +09:00
Nobuyoshi Nakada
d0a05fd4b4
Fixed FD leaks 2021-03-08 10:08:40 +09:00
Andrew Aladjev
0d76636117 added mutexes for socket and connection lists on win32 2021-02-23 16:20:01 +09:00
Takashi Kokubun
e1fee7f949
Rename RubyVM::MJIT to RubyVM::JIT
because the name "MJIT" is an internal code name, it's inconsistent with
--jit while they are related to each other, and I want to discourage future
JIT implementation-specific (e.g. MJIT-specific) APIs by this rename.

[Feature #17490]
2021-01-13 22:46:51 -08:00
Hiroshi SHIBATA
30f1316401
Skip test when UDP server is no response. 2021-01-13 11:27:30 +09:00
Masaki Matsushita
78f188524f Add connect_timeout to TCPSocket
Add connect_timeout to TCPSocket.new in the same way as Socket.tcp.

Closes [Feature #17187]
2020-12-10 20:52:29 +09:00
Masaki Matsushita
5d8bcc4870 Revert getaddrinfo_a()
getaddrinfo_a() gets stuck after fork().
To avoid this, we need 1 second sleep to wait for internal
worker threads of getaddrinfo_a() to be finished, but that is unacceptable.

[Bug #17220] [Feature #17134] [Feature #17187]
2020-12-07 13:33:53 +09:00
Masaki Matsushita
5e58a9033f Reduce timeout of test_getaddrinfo_after_fork 2020-12-05 17:43:35 +09:00
Benoit Daloze
b4ec4a41c2 Guard all accesses to RubyVM::MJIT with defined?(RubyVM::MJIT) &&
* Otherwise those tests, etc cannot run on alternative Ruby implementations.
2020-12-04 16:45:54 +01:00
Masaki Matsushita
94d49ed31c Add a hook before fork() for getaddrinfo_a()
We need stop worker threads in getaddrinfo_a() before fork().
This change adds a hook before fork() that cancel all outstanding requests
and wait for all ongoing requests. Then, it waits for all worker
threads to be finished.

Fixes [Bug #17220]
2020-12-04 23:31:51 +09:00
Masaki Matsushita
511fe23fa2 Add resolve_timeout to TCPSocket [Feature #17134] 2020-09-25 15:19:14 +09:00
Jeremy Evans
ed27c2514c Update UnixSocket#recv_io tests to handle receiving a UnixSocket
Receiving UnixSocket works fine if you don't provide a mode, and
I think it is reasonable to expect that you should not provide
a mode if klass.for_fd would not accept a mode.

Fixes [Bug #11778]
2020-09-22 15:44:34 -07: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.

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
Samuel Williams
0e3b0fcdba
Thread scheduler for light weight concurrency. 2020-05-14 22:10:55 +12:00
Nobuyoshi Nakada
7397b9f786
Fixed leaked fds 2020-05-06 12:45:01 +09:00
Kazuhiro NISHIYAMA
2f6a8baac6
Test interfaces include localhost
When interfaces do not include localhost,
some other tests may fail.
2019-12-06 16:03:16 +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