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:
Joel Dice 2010-02-02 12:24:05 -07:00
parent 3bc37d6e2a
commit e92674cb73

View File

@ -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);
}