summaryrefslogtreecommitdiff
path: root/test/fiber
AgeCommit message (Collapse)Author
2024-07-06merge revision(s) 5d1702e01a36e11b183fe29ce10780a9b1a41cf0: [Backport #20414]nagachika
Enumerator should use a non-blocking fiber, change `rb_fiber_new` to be non-blocking by default. (#10481)
2023-11-19merge revision(s) 3eaae72855b23158e2148566bb8a7667bfb395cb:nagachika
test/fiber/test_queue.rb: Make the stuck test fail. (#8791) test/fiber/test_queue.rb: Make the stuck tests fail. We observed the 2 tests in the `test/fiber/test_queue.rb` getting stuck in some GCC compilers in Ubuntu ppc64le focal/jammy, even when the timeout `queue.pop(timeout: 0.0001)` is set in the code. This commit is to make the tests fail rather than getting stuck. --- test/fiber/test_queue.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
2023-09-24merge revision(s) 901b6d9c5025a30b3d7a5ed0a2c00baf9cfb061d: [Backport #19853]nagachika
Validate the typed data before dereferencing the internal struct. (#8315) --- process.c | 5 +++-- test/fiber/test_process.rb | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-)
2023-07-22merge revision(s) 0402193723647b8c4f57b1453fe2192ad2788d12: [Backport #19709]nagachika
Fix `Thread#join(timeout)` when running inside the fiber scheduler. (#7903) --- test/fiber/test_thread.rb | 22 ++++++++++++++++++++++ thread.c | 5 +++++ 2 files changed, 27 insertions(+)
2023-07-22merge revision(s) 0b2613f44309bddae45562c9f3a14ed43e56959b: [Backport #19640]nagachika
`rb_io_puts` should not write zero length strings. (#7806) --- io.c | 40 ++++++++++++++++++++++++---------------- test/fiber/test_io.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 16 deletions(-)
2023-07-16merge revision(s) 466aa8010fb49f9ec6c78ea1de4e8ca0965f4fdf: [Backport #19546]nagachika
Fix incorrect usage of `rb_fiber_scheduler_io_(p)(read|write)`. (#7593) --- io_buffer.c | 8 ++++---- scheduler.c | 48 ++++++++++++++++++++++---------------------- test/fiber/test_io_buffer.rb | 33 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 28 deletions(-)
2022-12-20Ensure Fiber storage is only accessed from the Fiber it belongs toBenoit Daloze
Notes: Merged: https://github.com/ruby/ruby/pull/6972
2022-12-20Use an experimental warning for Fiber#storage=Benoit Daloze
Notes: Merged: https://github.com/ruby/ruby/pull/6972
2022-12-20Never use the storage of another Fiber, that violates the whole designBenoit Daloze
* See https://bugs.ruby-lang.org/issues/19078#note-30 Notes: Merged: https://github.com/ruby/ruby/pull/6972
2022-12-17Add tests for `Queue#pop` with fiber scheduler. (#6953)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-12-02Wait killed threadsNobuyoshi Nakada
2022-12-01Introduce `Fiber#storage` for inheritable fiber-scoped variables. (#6612)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-11-17Add support for `sockaddr_un` on Windows. (#6513)Samuel Williams
* 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> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-11-09mutex: Raise a ThreadError when detecting a fiber deadlock (#6680)Jean byroot Boussier
[Bug #19105] If no fiber scheduler is registered and the fiber that owns the lock and the one that try to acquire it both belong to the same thread, we're in a deadlock case. Co-authored-by: Jean Boussier <byroot@ruby-lang.org> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-11-01We don't care about actual hostname resolution. (#6652)Samuel Williams
https://bugs.ruby-lang.org/issues/18380 Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-10-20Avoid missed wakeup with fiber scheduler and Fiber.blocking. (#6588)Samuel Williams
* Ensure that blocked fibers don't prevent valid wakeups. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-10-15Introduce `Fiber::Scheduler#io_select` hook for non-blocking `IO.select`. ↵Samuel Williams
(#6559) Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-10-13Add missing `f.resume` to fiber test. (#6539)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-10-12Simplify implementation of scheduler `io_read` and `io_write`. (#6527)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-10-12Improvements to IO::Buffer implementation and documentation. (#6525)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-10-06Introduce `Fiber.blocking{}` for bypassing the fiber scheduler. (#6498)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-05-25Retain reference to blocking fibers.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/5926
2022-05-09test/fiber/test_scheduler.rb: Remove the test file from $LOADED_FEATURESYusuke Endoh
to prevent the following failure on `make test-all --repeat-count=2` http://ci.rvm.jp/results/trunk-repeat20-asserts@phosphorus-docker/3957774 ``` 1) Error: TestFiberScheduler#test_autoload: NameError: uninitialized constant TestFiberSchedulerAutoload Object.const_get(:TestFiberSchedulerAutoload) ^^^^^^^^^^ ```
2022-05-08Use a proper mutex for autoloading features. (#5788)Samuel Williams
Object#autoload implements a custom per-thread "mutex" for blocking threads waiting on autoloading a feature. This causes problems when used with the fiber scheduler. We swap the implementation to use a Ruby mutex which is fiber aware. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-01-19`rb_fiber_terminate` must not return [Bug #18497]Nobuyoshi Nakada
In a forked process from a fiber, the fiber becomes the only fiber, `fiber_switch` does nothing as there is no other fibers, `rb_fiber_terminate` does not terminate the fiber. In that case, reaches the end of `fiber_entry` finaly, which is declared as "COROUTINE" and should never return. Notes: Merged: https://github.com/ruby/ruby/pull/5468
2022-01-11Use omit instead of skip without the default gems testsHiroshi SHIBATA
2021-12-21Improve interface for get/set/copy.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/5303
2021-12-21test/fiber/test_io_buffer.rb: fix file descriptor leaksKazuki Yamaguchi
I got the warning while running "make test-all": Leaked file descriptor: TestFiberIOBuffer#test_write_nonblock: 9 : #<UNIXSocket:fd 9> Closed file descriptor: TestFiberIOBuffer#test_read_write_blocking: 9 Leaked file descriptor: TestFiberIOBuffer#test_timeout_after: 10 : #<UNIXSocket:fd 10> Closed file descriptor: TestFiberIOBuffer#test_read_nonblock: 10
2021-12-18Introduce io_result wrapper for passing `[-errno, size]` in VALUE.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/5287 Merged-By: ioquatix <samuel@codeotaku.com>
2021-11-23Suppress the “experimental" warnings for `IO::Buffer`Nobuyoshi Nakada
As this warning is emitted just once per processes, needs in each files when parallel testing.
2021-11-10Mark IO::Buffer as experimental.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4621
2021-09-20Add alternative optional hook for `scheduler_close` to allow public usage of ↵Samuel Williams
close. Notes: Merged: https://github.com/ruby/ruby/pull/4658
2021-08-26Fix example fiber scheduler reg. writable eventsLars Kanis
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. Notes: Merged: https://github.com/ruby/ruby/pull/4777
2021-08-03Fix potential hang when joining threads.Samuel Williams
If the thread termination invokes user code after `th->status` becomes `THREAD_KILLED`, and the user unblock function causes that `th->status` to become something else (e.g. `THREAD_RUNNING`), threads waiting in `thread_join_sleep` will hang forever. We move the unblock function call to before the thread status is updated, and allow threads to join as soon as `th->value` becomes defined. This reverts commit 6505c77501f1924571b2fe620c5c7b31ede0cd22. Notes: Merged: https://github.com/ruby/ruby/pull/4689
2021-07-28Revert "Fix potential hang when joining threads."Yusuke Endoh
This reverts commit 13f8521c630a15c87398dee0763e95f59c032a94. http://rubyci.s3.amazonaws.com/solaris11-gcc/ruby-master/log/20210727T230009Z.fail.html.gz http://rubyci.s3.amazonaws.com/solaris11-sunc/ruby-master/log/20210728T000009Z.fail.html.gz This revert is to confirm whether the commit is the cause. If the failures consistently occur after this revert, I'll reintroduce the commit.
2021-07-27Fix potential hang when joining threads.Samuel Williams
If the thread termination invokes user code after `th->status` becomes `THREAD_KILLED`, and the user unblock function causes that `th->status` to become something else (e.g. `THREAD_RUNNING`), threads waiting in `thread_join_sleep` will hang forever. We move the unblock function call to before the thread status is updated, and allow threads to join as soon as `th->value` becomes defined. Notes: Merged: https://github.com/ruby/ruby/pull/4660
2021-06-29Prefer qualified names under ThreadNobuyoshi Nakada
2021-06-15Suppress exception report in inner threadNobuyoshi Nakada
2021-06-15Close leaked file descriptorsNobuyoshi Nakada
2021-06-14Fix fiber scheduler address resolve solaris testsBruno Sutic
Notes: Merged: https://github.com/ruby/ruby/pull/4571
2021-06-14Wake up join list within thread EC context. (#4471)Samuel Williams
* Wake up join list within thread EC context. * Consume items from join list so that they are not re-executed. If `rb_fiber_scheduler_unblock` raises an exception, it can result in a segfault if `rb_threadptr_join_list_wakeup` is not within a valid EC. This change moves `rb_threadptr_join_list_wakeup` into the thread's top level EC which initially caused an infinite loop because on exception will retry. We explicitly remove items from the thread's join list to avoid this situation. * Verify the required scheduler interface. * Test several scheduler hooks methods with broken `unblock` implementation. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2021-06-14Add scheduler hook `Addrinfo.getaddrinfo`. (#4375)Samuel Williams
Co-authored-by: Bruno Sutic <code@brunosutic.com> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2021-03-30Test incorrect behaviour of `rb_io_wait_readable/writable`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4338
2021-03-30Fix handling of timeout accessing scheduler outside of non-blocking context.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Improve timeout tests.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Update method name and add documentation.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-03-30Add hook for `Timeout.timeout`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/4173
2021-02-09Expose scheduler as public interface & bug fixes. (#3945)Samuel Williams
* Rename `rb_scheduler` to `rb_fiber_scheduler`. * Use public interface if available. * Use `rb_check_funcall` where possible. * Don't use `unblock` unless the fiber was non-blocking. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2020-12-23Add verbose nil in testingDelton Ding
Notes: Merged: https://github.com/ruby/ruby/pull/3971
2020-12-23Enable `Fiber.current` and `Fiber#alive?` call inside ractorDelton Ding
Notes: Merged: https://github.com/ruby/ruby/pull/3971