# HG changeset patch
# User alex
# Date 1075062571 0
# Node ID b5805b819ff9c6dfc02ef5d608d98a1d2330d719
# Parent  0bbdbc75532f67436b9db9b05e84522f6aabeb8c
reviewed the locking codes, a mutex should be unlocked before destroying it

diff -r 0bbdbc75532f -r b5805b819ff9 loader/win32.c
--- a/loader/win32.c	Sun Jan 25 20:03:47 2004 +0000
+++ b/loader/win32.c	Sun Jan 25 20:29:31 2004 +0000
@@ -1379,6 +1379,8 @@
 	cs->locked=0;
 	pthread_mutex_unlock(&(cs->mutex));
     }
+    else
+	printf("Win32 Warning: Unlocking unlocked Critical Section %p!!\n", c);
     return;
 }
 
@@ -1394,6 +1396,18 @@
     //    struct CRITSECT* cs=(struct CRITSECT*)c;
     dbgprintf("DeleteCriticalSection(0x%x)\n",c);
 
+    if (!cs)
+    {
+	printf("Win32 Warning: Deleting uninitialized Critical Section %p!!\n", c);
+	return;
+    }
+    
+    if (cs->locked)
+    {
+	printf("Win32 Warning: Deleting unlocked Critical Section %p!!\n", c);
+	pthread_mutex_unlock(&(cs->mutex));
+    }
+
 #ifndef GARBAGE
     pthread_mutex_destroy(&(cs->mutex));
     // released by GarbageCollector in my_relase otherwise