1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ignore yield_atexit if outgoing port is closed

If outgoing_port is closed, Ractor.yield never successes.
[Bug #17310]
This commit is contained in:
Koichi Sasada 2020-11-11 01:55:28 +09:00
parent db31ace934
commit deed21bb08
Notes: git 2020-11-11 18:11:17 +09:00
2 changed files with 14 additions and 0 deletions

View file

@ -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

View file

@ -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;