Skip to content

Commit

Permalink
Merge pull request #304 from orocos-toolchain/fix-race-condition-when…
Browse files Browse the repository at this point in the history
…-waiting-for-functions

Fix race condition when waiting for functions
  • Loading branch information
meyerj authored Oct 21, 2019
2 parents 5389930 + a1d6b88 commit 058536d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rtt/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ namespace RTT
assert(foo);
if ( foo->execute() == false ){
foo->unloaded();
{
// There's no need to hold the lock while
// processing the queue. But we must hold the
// lock once between foo->execute() and the
// broadcast to avoid the race condition in
// waitForMessagesInternal().
MutexLock locker( msg_lock );
}
msg_cond.broadcast(); // required for waitForFunctions() (3rd party thread)
} else {
f_queue->enqueue( foo );
Expand Down

0 comments on commit 058536d

Please # to comment.