Skip to content

Commit 50a8915

Browse files
committed
Fixed race checking fiber status.
1 parent a1df78d commit 50a8915

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

machine/builtin/fiber.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ namespace rubinius {
7474
}
7575

7676
void Fiber::restart(STATE) {
77-
if(!vm()->suspended_p()) {
78-
Exception::raise_fiber_error(state, "attempt to restart non-suspended fiber");
79-
}
80-
8177
{
8278
std::lock_guard<std::mutex> guard(state->vm()->thread()->fiber_mutex());
8379

80+
if(!vm()->suspended_p()) {
81+
Exception::raise_fiber_error(state, "attempt to restart non-suspended fiber");
82+
}
83+
8484
while(vm()->suspended_p()) {
8585
std::lock_guard<std::mutex> guard(vm()->wait_mutex());
8686
vm()->wait_condition().notify_one();
@@ -93,7 +93,10 @@ namespace rubinius {
9393
; // spin wait
9494
}
9595

96-
state->vm()->thread()->current_fiber(state, this);
96+
{
97+
std::lock_guard<std::mutex> guard(state->vm()->thread()->fiber_mutex());
98+
state->vm()->thread()->current_fiber(state, this);
99+
}
97100
}
98101

99102
void Fiber::suspend(STATE) {

0 commit comments

Comments
 (0)