Skip to content

Commit

Permalink
Fixed race checking fiber status.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Jun 20, 2016
1 parent a1df78d commit 50a8915
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions machine/builtin/fiber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ namespace rubinius {
}

void Fiber::restart(STATE) {
if(!vm()->suspended_p()) {
Exception::raise_fiber_error(state, "attempt to restart non-suspended fiber");
}

{
std::lock_guard<std::mutex> guard(state->vm()->thread()->fiber_mutex());

if(!vm()->suspended_p()) {
Exception::raise_fiber_error(state, "attempt to restart non-suspended fiber");
}

while(vm()->suspended_p()) {
std::lock_guard<std::mutex> guard(vm()->wait_mutex());
vm()->wait_condition().notify_one();
Expand All @@ -93,7 +93,10 @@ namespace rubinius {
; // spin wait
}

state->vm()->thread()->current_fiber(state, this);
{
std::lock_guard<std::mutex> guard(state->vm()->thread()->fiber_mutex());
state->vm()->thread()->current_fiber(state, this);
}
}

void Fiber::suspend(STATE) {
Expand Down

0 comments on commit 50a8915

Please sign in to comment.