From 07b359273a838a15accafefcbe861be15caaac3a Mon Sep 17 00:00:00 2001 From: Carl Shapiro Date: Mon, 25 Jan 2010 14:48:30 -0800 Subject: [PATCH] Restore the lock owner ahead of calling waitSetRemove. --- vm/Sync.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vm/Sync.c b/vm/Sync.c index 16875e444..015c588ae 100644 --- a/vm/Sync.c +++ b/vm/Sync.c @@ -670,14 +670,15 @@ static void waitMonitor(Thread* self, Monitor* mon, s8 msec, s4 nsec, lockMonitor(self, mon); done: - waitSetRemove(mon, self); - /* - * Put everything back. Again, we hold the pthread mutex, so the order - * here isn't significant. + * We remove our thread from wait set after restoring the count + * and owner fields so the subroutine can check that the calling + * thread owns the monitor. Aside from that, the order of member + * updates is not order sensitive as we hold the pthread mutex. */ mon->owner = self; mon->lockCount = prevLockCount; + waitSetRemove(mon, self); /* set self->status back to THREAD_RUNNING, and self-suspend if needed */ dvmChangeStatus(self, THREAD_RUNNING); -- 2.11.0