Commit graph

19 commits

Author SHA1 Message Date
Samuel Williams
87fb44dff6
Introduce Fiber Scheduler blocking_region hook. (#11963) 2024-10-31 17:26:37 +13:00
Yusuke Endoh
d84b062b63 Prevent warning: assigned but unused variable - message 2024-09-17 13:56:04 +09:00
KJ Tsanaktsidis
e08d5239b6 Ensure fiber scheduler is woken up when close interrupts read
If one thread is reading and another closes that socket, the close
blocks waiting for the read to abort cleanly. This ensures that Ruby is
totally done with the file descriptor _BEFORE_ we tell the OS to close
and potentially re-use it.

When the read is correctly terminated, the close should be unblocked.
That currently works if closing is happening on a thread, but if it's
happening on a fiber with a fiber scheduler, it does NOT work.

This patch ensures that if the close happened in a fiber scheduled
thread, that the scheduler is notified that the fiber is unblocked.

[Bug #20723]
2024-09-17 10:11:44 +10:00
Nobuyoshi Nakada
ab637cad2b [Bug #19624] Clean up backquote IO
It should not be hidden, since it can be grabbed by a fiber scheduler.
2023-09-21 10:23:14 +09:00
Samuel Williams
0b2613f443
rb_io_puts should not write zero length strings. (#7806) 2023-05-15 11:13:51 +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
8a420670a2
Introduce Fiber::Scheduler#io_select hook for non-blocking IO.select. (#6559) 2022-10-15 19:59:04 +13:00
Hiroshi SHIBATA
f95039af75
Use omit instead of skip without the default gems tests 2022-01-11 21:17:59 +09:00
Samuel Williams
42d3231154
Introduce io_result wrapper for passing [-errno, size] in VALUE. 2021-12-18 18:19:30 +13:00
Lars Kanis
9c0582704f Fix example fiber scheduler reg. writable events
There were two issues:

1. When an IO object is waiting for writablility only (as in test_tcp_accept) the selected hash is empty.
   Therefore selected[fiber] returns nil but needs to default to 0 in order to be or'ed with IO::WRITABLE.

2. When an IO object is waiting for read- or writability (as in test_tcp_connect), but only one of these
   two events arrive, the Fiber and IO object need to be removed from the other `@readable` or `@writable` list.
2021-08-26 21:49:12 +12:00
Samuel Williams
611e711085 Test incorrect behaviour of rb_io_wait_readable/writable. 2021-03-30 23:16:59 +13:00
Samuel Williams
a08ee8330d Rename to Fiber#set_scheduler. 2020-11-07 23:39:50 +13:00
Samuel Williams
132453fa52 Rename Fiber{} to Fiber.schedule{}. 2020-09-14 16:44:09 +12:00
Yusuke Endoh
098e8c2873 Suppress "assigned but unused variable" warnings 2020-07-23 23:44:25 +09:00
Nobuyoshi Nakada
d2bf6133f6
Remove trailing spaces [ci skip] 2020-07-20 13:34:16 +09:00
Samuel Williams
9f6a3d0306 Add multi-threaded I/O test. 2020-07-20 13:20:58 +12:00
Samuel Williams
e6e9cef06e Improve consistency of tests. 2020-07-20 13:20:58 +12:00
Hiroshi SHIBATA
d48c92aa04
Rename TestScheduler* to TestFiber for convention of the test directory 2020-05-23 16:44:57 +09:00
Samuel Williams
6fa8455ebb Move test/scheduler -> test/fiber [Bug #16892][ruby-core:98366]. 2020-05-15 13:26:23 +12:00
Renamed from test/scheduler/test_io.rb (Browse further)