From d0d6227a0da5925acf946a09191f172daf53baf2 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 22 Jan 2021 02:51:53 +0900 Subject: alen should be actions number on ractor_select() alen was number of rs, but it should be actions number (taking ractors + receiving + yielding). --- ractor.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'ractor.c') diff --git a/ractor.c b/ractor.c index e43530610a..0dc1c299e0 100644 --- a/ractor.c +++ b/ractor.c @@ -1035,7 +1035,7 @@ ractor_try_yield(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_b // select(r1, r2, r3, receive: true, yield: obj) static VALUE -ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yielded_value, bool move, VALUE *ret_r) +ractor_select(rb_execution_context_t *ec, const VALUE *rs, const int rs_len, VALUE yielded_value, bool move, VALUE *ret_r) { rb_ractor_t *cr = rb_ec_ractor_ptr(ec); VALUE crv = cr->pub.self; @@ -1044,7 +1044,7 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield bool interrupted = false; enum ractor_wait_status wait_status = 0; bool yield_p = (yielded_value != Qundef) ? true : false; - const int rs_len = alen; + const int alen = rs_len + (yield_p ? 1 : 0); struct ractor_select_action { enum ractor_select_action_type { @@ -1053,7 +1053,7 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield ractor_select_action_yield, } type; VALUE v; - } *actions = ALLOCA_N(struct ractor_select_action, alen + (yield_p ? 1 : 0)); + } *actions = ALLOCA_N(struct ractor_select_action, alen); VM_ASSERT(cr->sync.wait.status == wait_none); VM_ASSERT(cr->sync.wait.wakeup_status == wakeup_none); @@ -1061,7 +1061,7 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield VM_ASSERT(cr->sync.wait.yielded_basket.type == basket_type_none); // setup actions - for (i=0; isync.wait.yielded_basket, yielded_value, move, false, false); } + restart: + // TODO: shuffle actions while (1) { -- cgit v1.2.3