# HG changeset patch # User Ryan C. Gordon # Date 1147909368 0 # Node ID 536b0704b7d85d53295f2d3ad69d5d2aee22cd33 # Parent d5d3a6fe05a1efda96c15e1f0e751df0ae1424fb Make sure sem_wait didn't return early with EINTR. Fixes Bugzilla #231. diff -r d5d3a6fe05a1 -r 536b0704b7d8 src/thread/dc/SDL_syssem.c --- a/src/thread/dc/SDL_syssem.c Wed May 17 18:57:04 2006 +0000 +++ b/src/thread/dc/SDL_syssem.c Wed May 17 23:42:48 2006 +0000 @@ -19,6 +19,9 @@ Sam Lantinga slouken@libsdl.org */ + +#include + #include "SDL_config.h" /* An implementation of semaphores using mutexes and condition variables */ @@ -135,13 +138,15 @@ int SDL_SemWait(SDL_sem *sem) { + int retval; + if ( ! sem ) { SDL_SetError("Passed a NULL semaphore"); return -1; } - sem_wait(&sem->sem); - return 0; + while ( ((retval = sem_wait(&sem->sem)) == -1) && (errno == EINTR) ) {} + return retval; } Uint32 SDL_SemValue(SDL_sem *sem) diff -r d5d3a6fe05a1 -r 536b0704b7d8 src/thread/pthread/SDL_syssem.c --- a/src/thread/pthread/SDL_syssem.c Wed May 17 18:57:04 2006 +0000 +++ b/src/thread/pthread/SDL_syssem.c Wed May 17 23:42:48 2006 +0000 @@ -23,6 +23,7 @@ #include #include +#include #include "SDL_thread.h" #include "SDL_timer.h" @@ -86,7 +87,7 @@ return -1; } - retval = sem_wait(&sem->sem); + while ( ((retval = sem_wait(&sem->sem)) == -1) && (errno == EINTR) ) {} if ( retval < 0 ) { SDL_SetError("sem_wait() failed"); } diff -r d5d3a6fe05a1 -r 536b0704b7d8 src/thread/riscos/SDL_syssem.c --- a/src/thread/riscos/SDL_syssem.c Wed May 17 18:57:04 2006 +0000 +++ b/src/thread/riscos/SDL_syssem.c Wed May 17 23:42:48 2006 +0000 @@ -19,6 +19,9 @@ Sam Lantinga slouken@libsdl.org */ + +#include + #include "SDL_config.h" /* RISC OS semiphores based on linux code */ @@ -132,7 +135,7 @@ return -1; } - retval = sem_wait(sem->sem); + while ( ((retval = sem_wait(sem->sem)) == -1) && (errno == EINTR) ) {} if ( retval < 0 ) { SDL_SetError("sem_wait() failed"); }