Commit be2cfc6a authored by Sam Lantinga's avatar Sam Lantinga

Fixed bug #570

SDL_SemWaitTimeout in src/thread/generic/SDL_syssem.c line 179 (SVN trunk):

--sem->count;

should be

if (retval == 0) {
    --sem->count;
}

Without this, sem->count will underflow on timeout effectively breaking the
semaphore. It appears that the implementation has been wrong since the initial
revision.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403844
parent d4c29047
...@@ -176,7 +176,9 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) ...@@ -176,7 +176,9 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
sem->count_lock, timeout); sem->count_lock, timeout);
} }
--sem->waiters_count; --sem->waiters_count;
if (retval == 0) {
--sem->count; --sem->count;
}
SDL_UnlockMutex(sem->count_lock); SDL_UnlockMutex(sem->count_lock);
return retval; return retval;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment