From ebdd83920b6b97103c93325dbdae13aa32018f78 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 7 Jun 2007 03:48:13 +0000 Subject: * cont.c (cont_restore_1): fix to check root fiber [ruby-dev:30911]. * test/ruby/test_fiber.rb: add a test. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ cont.c | 7 +++++-- test/ruby/test_fiber.rb | 10 +++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c75d85f81..434a2507e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Jun 7 12:48:33 2007 Koichi Sasada + + * cont.c (cont_restore_1): fix to check root fiber [ruby-dev:30911]. + + * test/ruby/test_fiber.rb: add a test. + Thu Jun 07 07:24:36 2007 NARUSE, Yui * lib/json/common.rb: Ponder offering parse! method. diff --git a/cont.c b/cont.c index 4210ab97d..97a805d0a 100644 --- a/cont.c +++ b/cont.c @@ -173,11 +173,14 @@ cont_restore_1(rb_context_t *cont) } else { /* continuation */ + VALUE fval; + th->fiber = sth->fiber; + fval = th->fiber ? th->fiber : th->root_fiber; - if (th->fiber) { + if (fval) { rb_context_t *fcont; - GetContPtr(th->fiber, fcont); + GetContPtr(fval, fcont); th->stack_size = fcont->saved_thread.stack_size; th->stack = fcont->saved_thread.stack; } diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index c99e302b1..6c67a5815 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -116,7 +116,15 @@ class TestFiber < Test::Unit::TestCase f2 = Fiber.new do c.call end - assert_equal(f1.yield, :ok) + assert_equal(:ok, f1.yield) + + assert_equal(:ok, + callcc {|c| + Fiber.new { + c.call :ok + }.yield + } + ) end end -- cgit