Skip to content

Commit 565835a

Browse files
committed
fix potential deadlock
1 parent c7b7362 commit 565835a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/scheduler.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,11 @@ void Scheduler::next() { // NOLINT
406406
// If there are no triggered actions at the event, then release the
407407
// current tag and go back to the start of the loop
408408
if (triggered_actions_->empty()) {
409+
// It is important to unlock the mutex here. Otherwise we could enter a deadlock as
410+
// releasing a tag also requires holding the downstream mutex.
411+
lock.unlock();
409412
release_current_tag();
413+
lock.lock();
410414
}
411415
}
412416
}
@@ -534,6 +538,7 @@ void Scheduler::register_release_tag_callback(const ReleaseTagCallback& callback
534538
}
535539

536540
void Scheduler::release_current_tag() {
541+
log_.debug() << "Release tag " << logical_time_;
537542
for (const auto& callback : release_tag_callbacks_) {
538543
callback(logical_time_);
539544
}

0 commit comments

Comments
 (0)