summaryrefslogtreecommitdiff
path: root/multimedia/xine-lib/patches/patch-al
blob: 58e466db4fa6e3aa12e0c4aa27e431cba337c02a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
$NetBSD: patch-al,v 1.1.1.1 2004/01/26 13:03:38 jmmv Exp $

--- src/libw32dll/wine/win32.c.orig	2003-10-02 12:25:52.000000000 +0000
+++ src/libw32dll/wine/win32.c	2003-10-02 12:21:50.000000000 +0000
@@ -440,9 +440,8 @@
 
     alccnt--;
 
-    if (last_alloc)
-	pthread_mutex_unlock(&memmut);
-    else
+    pthread_mutex_unlock(&memmut);
+    if (!last_alloc)
 	pthread_mutex_destroy(&memmut);
 
     //if (alccnt < 40000) printf("MY_RELEASE: %p\t%ld    (%d)\n", header, header->size, alccnt);
@@ -1350,10 +1349,12 @@
 	printf("wine/win32: Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
     }
     if(cs->locked)
-	if(cs->id==pthread_self())
+	if(cs->id==pthread_self()) {
+	    cs->locked++;
 	    return;
+	}
     pthread_mutex_lock(&(cs->mutex));
-    cs->locked=1;
+    cs->locked++;	/* should always be 1 */
     cs->id=pthread_self();
     return;
 }
@@ -1371,8 +1372,8 @@
 	printf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c);
 	return;
     }
-    cs->locked=0;
-    pthread_mutex_unlock(&(cs->mutex));
+    if (!--cs->locked)
+        pthread_mutex_unlock(&(cs->mutex));
     return;
 }
 static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)