summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormembar <membar@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-31 03:36:38 +0000
committermembar <membar@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-31 03:36:38 +0000
commit9d4702a0f93f376d3579ab3855de0245c28daf20 (patch)
treeab5178c3a445c4eabae09bbe11ede4c98ba1445d
parent123d02f4d7835d5fd8b2e1049807f3021ad9e3eb (diff)
downloadppe42-gcc-9d4702a0f93f376d3579ab3855de0245c28daf20.tar.gz
ppe42-gcc-9d4702a0f93f376d3579ab3855de0245c28daf20.zip
PR libgcj/12647:
* win32-threads.cc (_Jv_CondWait): Respect mutex's refcount when releasing and reacquiring it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73118 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog6
-rw-r--r--libjava/win32-threads.cc21
2 files changed, 25 insertions, 2 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 7385af65418..799b490bf00 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,11 @@
2003-10-30 Mohan Embar <gnustuff@thisiscool.com>
+ PR libgcj/12647:
+ * win32-threads.cc (_Jv_CondWait): Respect mutex's
+ refcount when releasing and reacquiring it.
+
+2003-10-30 Mohan Embar <gnustuff@thisiscool.com>
+
* win32.cc: (dirExists) Internal helper function to
test for directory existence.
(getUserHome) New helper function refactored out
diff --git a/libjava/win32-threads.cc b/libjava/win32-threads.cc
index 1f3d0c57b22..9e3981db3dd 100644
--- a/libjava/win32-threads.cc
+++ b/libjava/win32-threads.cc
@@ -126,7 +126,18 @@ _Jv_CondWait(_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint na
else if (millis == 0) time = INFINITE;
else time = millis;
- _Jv_MutexUnlock (mu);
+ // Record the current lock depth, so it can be restored
+ // when we reacquire it.
+ int count = mu->refcount;
+ int curcount = count;
+
+ // Call _Jv_MutexUnlock repeatedly until this thread
+ // has completely released the monitor.
+ while (curcount > 0)
+ {
+ _Jv_MutexUnlock (mu);
+ --curcount;
+ }
// Set up our array of three events:
// - the auto-reset event (for notify())
@@ -164,7 +175,13 @@ _Jv_CondWait(_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint na
if (last_waiter)
ResetEvent (cv->ev[1]);
- _Jv_MutexLock (mu);
+ // Call _Jv_MutexLock repeatedly until the mutex's refcount is the
+ // same as before we originally released it.
+ while (curcount < count)
+ {
+ _Jv_MutexLock (mu);
+ ++curcount;
+ }
return interrupted ? _JV_INTERRUPTED : 0;
}
OpenPOWER on IntegriCloud