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

* cont.c (rb_fiber_resume): raise an "double resume" error when root

fiber is going to be resumed.  [ruby-dev:42523]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2010-11-03 17:08:25 +00:00
parent 5098e6f7df
commit a9afb7e5c6
3 changed files with 14 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Thu Nov 4 02:04:25 2010 Yusuke Endoh <mame@tsg.ne.jp>
* cont.c (rb_fiber_resume): raise an "double resume" error when root
fiber is going to be resumed. [ruby-dev:42523]
Wed Nov 3 14:17:18 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Nov 3 14:17:18 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/ostruct.rb (OpenStruct#delete_field): also undefine * lib/ostruct.rb (OpenStruct#delete_field): also undefine

2
cont.c
View file

@ -1292,7 +1292,7 @@ rb_fiber_resume(VALUE fibval, int argc, VALUE *argv)
rb_fiber_t *fib; rb_fiber_t *fib;
GetFiberPtr(fibval, fib); GetFiberPtr(fibval, fib);
if (fib->prev != Qnil) { if (fib->prev != Qnil || fib->cont.type == ROOT_FIBER_CONTEXT) {
rb_raise(rb_eFiberError, "double resume"); rb_raise(rb_eFiberError, "double resume");
} }

View file

@ -189,5 +189,13 @@ class TestFiber < Test::Unit::TestCase
f1.transfer f1.transfer
}, '[ruby-dev:40833]' }, '[ruby-dev:40833]'
end end
def test_resume_root_fiber
assert_raise(FiberError) do
Thread.new do
Fiber.current.resume
end.join
end
end
end end