summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2021-03-13 17:56:17 +0900
committerNARUSE, Yui <naruse@airemix.jp>2021-03-13 17:56:17 +0900
commite050dd53230cb354e816415f8a937901f79ec395 (patch)
treec5c1503b2a6bf91e631cdb035f39e1867a30aa61
parentb20e2c3f2a3ce227b9cf32d2bf02db0ac67eccb5 (diff)
merge revision(s) f6d5de8f33fe715d939e3e77b8ef73d88bcd6c9f: [Backport #17659]
[ruby/io-wait] Declare as Ractor-safe Fixes https://bugs.ruby-lang.org/issues/17659 https://github.com/ruby/io-wait/commit/ba338b4764 --- ext/io/wait/wait.c | 4 ++++ test/io/wait/test_ractor.rb | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/io/wait/test_ractor.rb
-rw-r--r--ext/io/wait/wait.c4
-rw-r--r--test/io/wait/test_ractor.rb22
-rw-r--r--version.h2
3 files changed, 27 insertions, 1 deletions
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index 73bc77a294..c5de8967cd 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -275,6 +275,10 @@ io_wait(int argc, VALUE *argv, VALUE io)
void
Init_wait(void)
{
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ RB_EXT_RACTOR_SAFE(true);
+#endif
+
rb_define_method(rb_cIO, "nread", io_nread, 0);
rb_define_method(rb_cIO, "ready?", io_ready_p, 0);
diff --git a/test/io/wait/test_ractor.rb b/test/io/wait/test_ractor.rb
new file mode 100644
index 0000000000..3d286af77f
--- /dev/null
+++ b/test/io/wait/test_ractor.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+require 'test/unit'
+require 'rbconfig'
+require 'io/wait'
+
+class TestIOWaitInRactor < Test::Unit::TestCase
+ def setup
+ omit unless defined? Ractor
+ end
+
+ def test_ractor
+ ext = "/io/wait.#{RbConfig::CONFIG['DLEXT']}"
+ path = $".find {|path| path.end_with?(ext)}
+ assert_in_out_err(%W[-r#{path}], <<-"end;", ["true"], [])
+ $VERBOSE = nil
+ r = Ractor.new do
+ $stdout.equal?($stdout.wait_writable)
+ end
+ puts r.take
+ end;
+ end
+end
diff --git a/version.h b/version.h
index 3c2bc70b98..47232597a9 100644
--- a/version.h
+++ b/version.h
@@ -12,7 +12,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 55
+#define RUBY_PATCHLEVEL 56
#define RUBY_RELEASE_YEAR 2021
#define RUBY_RELEASE_MONTH 3