Commit 4b6c71b1 authored by Zhang Jingwang's avatar Zhang Jingwang Committed by Dries Kimpe
Browse files

Fix a race condition in state machine mode.

Resuming an active state machine might lead to an assertion. So if
it is an active state machine, we need to wait for it to complete
first and then resume it.
parent 414a48b6
......@@ -57,16 +57,16 @@ namespace sm
void resumeSM (next_method_t n, iofwdevent::CBException status =
iofwdevent::CBException ())
{
{
while (true) {
boost::mutex::scoped_lock l(state_lock_);
if (running_) continue; // busy wait for other threads to complete.
// assert needs to be inside lock to prevent store/load race.
ALWAYS_ASSERT(!next_);
setNextMethod (n, status);
}
break;
}
if (!running_)
{
/* if we are in poll mode, execute the next state now ! */
if(poll_)
{
......@@ -77,7 +77,6 @@ namespace sm
{
smm_.schedule(this);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment