From d8374a76e270e4be9b7c1492704dbedd07cbc0a3 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 29 Nov 2007 08:03:45 -0700 Subject: [PATCH] check again for entry in monitorMap after entering the exclusive state in objectMonitor() in case another thread beat us to creating a monitor for the object --- src/machine.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/machine.cpp b/src/machine.cpp index 510745ffdd..c094602a9c 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2715,6 +2715,17 @@ objectMonitor(Thread* t, object o, bool createNew) ENTER(t, Thread::ExclusiveState); + p = hashMapFind(t, t->m->monitorMap, o, objectHash, objectEqual); + if (p) { + if (DebugMonitors) { + fprintf(stderr, "found monitor %p for object %x\n", + static_cast(pointerValue(t, p)), + objectHash(t, o)); + } + + return static_cast(pointerValue(t, p)); + } + System::Monitor* m; System::Status s = t->m->system->make(&m); expect(t, t->m->system->success(s));