This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR/12647: MinGW: Respect refcount in _Jv_CondWait


Hi People,

This attempts to fix this:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12647

If I don't hear from anyone in a few days, I'll
check this in. (I still prefer letting things
sit for awhile so people can catch any formatting
errors and stuff.)

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/

ChangeLog
2003-10-23  Mohan Embar  <gnustuff@thisiscool.com>

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

Index: win32-threads.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/win32-threads.cc,v
retrieving revision 1.10
diff -u -2 -r1.10 win32-threads.cc
--- win32-threads.cc	19 Sep 2003 08:28:42 -0000	1.10
+++ win32-threads.cc	23 Oct 2003 09:15:18 -0000
@@ -127,5 +127,16 @@
   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:
@@ -165,5 +176,11 @@
     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;




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]