aboutsummaryrefslogtreecommitdiffstats
path: root/cont.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-10-21 16:54:58 -0700
committerGitHub <noreply@github.com>2019-10-21 16:54:58 -0700
commitfa8ac91e957a076f6df1adaecad7896817138009 (patch)
treec8871b6dd46412100ba615b99860bd5c081eacaa /cont.c
parentf37cc1c719f12d2cad6032aa4e6f4236f0604992 (diff)
downloadruby-fa8ac91e957a076f6df1adaecad7896817138009.tar.gz
Fix Fiber#transfer
Fiber#transfer previously made it impossible to resume the fiber if it was transferred to (no resuming the target of Fiber#transfer). However, the documentation specifies that you cannot resume a fiber that has transferred to another fiber (no resuming the source of Fiber#transfer), unless control is transferred back. Fix the code by setting the transferred flag on the current/source fiber, and unsetting the transferred flag on the target fiber. Fixes [Bug #9664] Fixes [Bug #12555]
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/cont.c b/cont.c
index 61f42b386f..8e1dc6db87 100644
--- a/cont.c
+++ b/cont.c
@@ -2226,7 +2226,8 @@ static VALUE
rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fiber_value)
{
rb_fiber_t *fiber = fiber_ptr(fiber_value);
- fiber->transferred = 1;
+ fiber_current()->transferred = 1;
+ fiber->transferred = 0;
return fiber_switch(fiber, argc, argv, 0, PASS_KW_SPLAT);
}