Skip to content

Commit e886ed7

Browse files
committed
avoid deadlock
unlock the mutex before trying to schedule an empty upstream event, which requires holding the upstream mutex.
1 parent fc7a6a5 commit e886ed7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/reactor-cpp/connection.hh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ public:
147147

148148
// Insert an empty event into the upstream event queue. This ensures that we
149149
// will get notified and woken up as soon as the tag becomes safe to process.
150+
// It is important to unlock the mutex here. Otherwise we could enter a deadlock as
151+
// scheduling the upstream event also requires holding the upstream mutex.
152+
lock.unlock();
150153
bool result = this->upstream_port()->environment()->scheduler()->schedule_empty_async_at(tag);
154+
lock.lock();
151155

152156
// If inserting the empty event was not successful, then this is because the upstream
153157
// scheduler already processes a later event. In this case, it is safe to assume that

0 commit comments

Comments
 (0)