diff options
| author | chai <chaifix@163.com> | 2019-01-31 18:38:35 +0800 |
|---|---|---|
| committer | chai <chaifix@163.com> | 2019-01-31 18:38:35 +0800 |
| commit | 2ec55fd974a63b705a4777c256d2222c874fa043 (patch) | |
| tree | 48f1fea59ee9fc713a28a9aac3f05b98dc5ae66f /Source/3rdParty/SDL2/src/thread/pthread/SDL_sysmutex.c | |
| parent | c581dfbf1e849f393861d15e82aa6446c0c1c310 (diff) | |
*SDL project
Diffstat (limited to 'Source/3rdParty/SDL2/src/thread/pthread/SDL_sysmutex.c')
| -rw-r--r-- | Source/3rdParty/SDL2/src/thread/pthread/SDL_sysmutex.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Source/3rdParty/SDL2/src/thread/pthread/SDL_sysmutex.c b/Source/3rdParty/SDL2/src/thread/pthread/SDL_sysmutex.c index e7b5b5c..e514778 100644 --- a/Source/3rdParty/SDL2/src/thread/pthread/SDL_sysmutex.c +++ b/Source/3rdParty/SDL2/src/thread/pthread/SDL_sysmutex.c @@ -116,6 +116,7 @@ int SDL_TryLockMutex(SDL_mutex * mutex) { int retval; + int result; #if FAKE_RECURSIVE_MUTEX pthread_t this_thread; #endif @@ -134,18 +135,20 @@ 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_trylock(&mutex->id) == 0) { + result = pthread_mutex_trylock(&mutex->id); + if (result == 0) { mutex->owner = this_thread; mutex->recursive = 0; - } else if (errno == EBUSY) { + } else if (result == EBUSY) { retval = SDL_MUTEX_TIMEDOUT; } else { retval = SDL_SetError("pthread_mutex_trylock() failed"); } } #else - if (pthread_mutex_trylock(&mutex->id) != 0) { - if (errno == EBUSY) { + result = pthread_mutex_trylock(&mutex->id); + if (result != 0) { + if (result == EBUSY) { retval = SDL_MUTEX_TIMEDOUT; } else { retval = SDL_SetError("pthread_mutex_trylock() failed"); |
