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--
branch : SDL-1.2
This commit is contained in:
Sam Lantinga
2009-09-21 07:32:26 +00:00
parent c3a2a2984c
commit 61770dff5b

View File

@@ -165,7 +165,9 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
sem->count_lock, timeout);
}
--sem->waiters_count;
--sem->count;
if (retval == 0) {
--sem->count;
}
SDL_UnlockMutex(sem->count_lock);
return retval;