Skip to content

Commit

Permalink
Fixed bug 3258 - SDL_TryLockMutex blocks for pthreads with FAKE_RECUR…
Browse files Browse the repository at this point in the history
…SIVE_MUTEX

Ian Abbott

I just spotted what I think is a bug in "src/thread/pthread/SDL_sysmutex.c" in the SDL_TryLockMutex function when FAKE_RECURSIVE_MUTEX is defined (for an implementation of Pthreads with no recursive mutex support).  It calls pthread_mutex_lock instead of pthread_mutex_trylock, so it will block until the mutex is available instead of returning SDL_MUTEX_TIMEDOUT if it cannot lock the mutex immediately.
  • Loading branch information
slouken committed Aug 12, 2017
1 parent b5ea3c6 commit 7229397
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/thread/pthread/SDL_sysmutex.c
Expand Up @@ -134,7 +134,7 @@ SDL_TryLockMutex(SDL_mutex * mutex)
We set the locking thread id after we obtain the lock
so unlocks from other threads will fail.
*/
if (pthread_mutex_lock(&mutex->id) == 0) {
if (pthread_mutex_trylock(&mutex->id) == 0) {
mutex->owner = this_thread;
mutex->recursive = 0;
} else if (errno == EBUSY) {
Expand Down

0 comments on commit 7229397

Please sign in to comment.