Check fiber backward when switching with Fiber#transfer

Previously, if the caller of `Fiber#resume` had a C function call, an inconsistency would occur.
This commit is contained in:
dearblue
2023-12-04 22:20:44 +09:00
parent 42308c42b5
commit 4f1c1c16da
+12 -1
View File
@@ -167,6 +167,17 @@ fiber_check_cfunc(mrb_state *mrb, struct mrb_context *c)
}
}
static void
fiber_check_cfunc_recursive(mrb_state *mrb, struct mrb_context *c)
{
for (;; c = c->prev) {
fiber_check_cfunc(mrb, c);
if (c == mrb->root_c || !c->prev) {
break;
}
}
}
static void
fiber_switch_context(mrb_state *mrb, struct mrb_context *c)
{
@@ -370,7 +381,7 @@ fiber_transfer(mrb_state *mrb, mrb_value self)
const mrb_value* a;
mrb_int len;
fiber_check_cfunc(mrb, mrb->c);
fiber_check_cfunc_recursive(mrb, mrb->c);
mrb_get_args(mrb, "*!", &a, &len);
if (c->status == MRB_FIBER_RESUMED) {