mirror of
https://github.com/corda/corda.git
synced 2025-01-23 04:48:09 +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;
|
bool interrupted;
|
||||||
unsigned depth;
|
unsigned depth;
|
||||||
bool stillWaiting;
|
|
||||||
|
|
||||||
PROTECT(t, monitor);
|
PROTECT(t, monitor);
|
||||||
|
|
||||||
@ -2524,13 +2523,11 @@ monitorWait(Thread* t, object monitor, int64_t time)
|
|||||||
ENTER(t, Thread::IdleState);
|
ENTER(t, Thread::IdleState);
|
||||||
|
|
||||||
interrupted = t->lock->wait(t->systemThread, time);
|
interrupted = t->lock->wait(t->systemThread, time);
|
||||||
|
|
||||||
stillWaiting = t->waiting;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
monitorAcquire(t, monitor);
|
monitorAcquire(t, monitor);
|
||||||
|
|
||||||
if (stillWaiting) {
|
if (t->waiting) {
|
||||||
monitorRemoveWait(t, monitor);
|
monitorRemoveWait(t, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user