mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
fix race condition in monitorWait
We don't want to check Thread::waiting until we have re-acquired the monitor, since another thread might notify us between releasing Thread::lock and acquiring the monitor.
This commit is contained in:
parent
3bc37d6e2a
commit
e92674cb73
@ -2508,7 +2508,6 @@ monitorWait(Thread* t, object monitor, int64_t time)
|
||||
|
||||
bool interrupted;
|
||||
unsigned depth;
|
||||
bool stillWaiting;
|
||||
|
||||
PROTECT(t, monitor);
|
||||
|
||||
@ -2524,13 +2523,11 @@ monitorWait(Thread* t, object monitor, int64_t time)
|
||||
ENTER(t, Thread::IdleState);
|
||||
|
||||
interrupted = t->lock->wait(t->systemThread, time);
|
||||
|
||||
stillWaiting = t->waiting;
|
||||
}
|
||||
|
||||
monitorAcquire(t, monitor);
|
||||
|
||||
if (stillWaiting) {
|
||||
if (t->waiting) {
|
||||
monitorRemoveWait(t, monitor);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user