From 04cfa2febae5d2827d6b3b06a3c26d2586ea04e3 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Tue, 27 Sep 2005 09:02:54 +0000 Subject: [PATCH] Fix Recursive Mutexes to handle ThreadID==0 (bug #779) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1884 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 ++ sc2/src/sc2code/libs/threads/sdl/sdlthreads.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 7e3066552..b31eaf2e0 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.5: +- Fixed Recursive Mutexes to still work even if the ThreadID is 0 + (bug 779) - Michael - Permit independent selection of graphics driver and resolution in setup menu - Michael - Changed comm subtitle caching to use own context instead of diff --git a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c index 8c7713afe..c68eb1dea 100644 --- a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c +++ b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c @@ -547,7 +547,7 @@ LockRecursiveMutex_SDL (RecursiveMutex val) { RecM *mtx = (RecM *)val; Uint32 thread_id = SDL_ThreadID(); - if (mtx->thread_id != thread_id) + if (!mtx->locks || mtx->thread_id != thread_id) { #ifdef TRACK_CONTENTION if (mtx->thread_id && (mtx->syncClass & TRACK_CONTENTION_CLASSES)) @@ -567,7 +567,7 @@ UnlockRecursiveMutex_SDL (RecursiveMutex val) { RecM *mtx = (RecM *)val; Uint32 thread_id = SDL_ThreadID(); - if (mtx->thread_id != thread_id) + if (!mtx->locks || mtx->thread_id != thread_id) { #ifdef NAMED_SYNCHRO fprintf (stderr, "'%s' attempted to unlock %s when it didn't hold it\n", MyThreadName (), mtx->name);