ruby-changes:63581
From: Koichi <ko1@a...>
Date: Wed, 11 Nov 2020 18:11:10 +0900 (JST)
Subject: [ruby-changes:63581] deed21bb08 (master): ignore yield_atexit if outgoing port is closed
https://git.ruby-lang.org/ruby.git/commit/?id=deed21bb08 From deed21bb08170431891b65fda26f4a3557c9ffd4 Mon Sep 17 00:00:00 2001 From: Koichi Sasada <ko1@a...> Date: Wed, 11 Nov 2020 01:55:28 +0900 Subject: ignore yield_atexit if outgoing port is closed If outgoing_port is closed, Ractor.yield never successes. [Bug #17310] diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index 86a033c..0720c01 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -309,6 +309,16 @@ assert_equal 'ok', %q{ https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_ractor.rb#L309 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 350e9c7..1e32c1b 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 https://github.com/ruby/ruby/blob/trunk/ractor.c#L1288 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; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/