summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_ractor.rb10
-rw-r--r--ractor.c4
2 files changed, 14 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index 86a033cba8..0720c01caa 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -309,6 +309,16 @@ assert_equal 'ok', %q{
end
}
+# a ractor with closed outgoing port should terminate
+assert_equal 'ok', %q{
+ Ractor.new do
+ close_outgoing
+ end
+
+ true until Ractor.count == 1
+ :ok
+}
+
# multiple Ractors can receive (wait) from one Ractor
assert_equal '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]', %q{
pipe = Ractor.new do
diff --git a/ractor.c b/ractor.c
index 350e9c7b3f..1e32c1b95e 100644
--- a/ractor.c
+++ b/ractor.c
@@ -1288,6 +1288,10 @@ ractor_create(rb_execution_context_t *ec, VALUE self, VALUE loc, VALUE name, VAL
static void
ractor_yield_atexit(rb_execution_context_t *ec, rb_ractor_t *cr, VALUE v, bool exc)
{
+ if (cr->outgoing_port_closed) {
+ return;
+ }
+
ASSERT_ractor_unlocking(cr);
struct rb_ractor_basket basket;