Commit d6bc9793 by Mohan Embar Committed by Mohan Embar

re PR libgcj/12647 ([win32] wait() does not release monitor correctly)

	PR libgcj/12647:
	* win32-threads.cc (_Jv_CondWait): Respect mutex's
	refcount when releasing and reacquiring it.

From-SVN: r73118
parent 748e241e
2003-10-30 Mohan Embar <gnustuff@thisiscool.com> 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 * win32.cc: (dirExists) Internal helper function to
test for directory existence. test for directory existence.
(getUserHome) New helper function refactored out (getUserHome) New helper function refactored out
......
...@@ -126,7 +126,18 @@ _Jv_CondWait(_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint na ...@@ -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 if (millis == 0) time = INFINITE;
else time = millis; 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: // Set up our array of three events:
// - the auto-reset event (for notify()) // - the auto-reset event (for notify())
...@@ -164,7 +175,13 @@ _Jv_CondWait(_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint na ...@@ -164,7 +175,13 @@ _Jv_CondWait(_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint na
if (last_waiter) if (last_waiter)
ResetEvent (cv->ev[1]); 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; return interrupted ? _JV_INTERRUPTED : 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment