$NetBSD: patch-al,v 1.2 2003/10/03 17:49:27 mycroft 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)