comparison src/thread/dc/SDL_syssem.c @ 1851:536b0704b7d8

Make sure sem_wait didn't return early with EINTR. Fixes Bugzilla #231.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 17 May 2006 23:42:48 +0000
parents d910939febfa
children c121d94672cb a1b03ba2fcd0
comparison
equal deleted inserted replaced
1850:d5d3a6fe05a1 1851:536b0704b7d8
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22
23 #include <errno.h>
24
22 #include "SDL_config.h" 25 #include "SDL_config.h"
23 26
24 /* An implementation of semaphores using mutexes and condition variables */ 27 /* An implementation of semaphores using mutexes and condition variables */
25 28
26 #include "SDL_timer.h" 29 #include "SDL_timer.h"
133 return retval; 136 return retval;
134 } 137 }
135 138
136 int SDL_SemWait(SDL_sem *sem) 139 int SDL_SemWait(SDL_sem *sem)
137 { 140 {
141 int retval;
142
138 if ( ! sem ) { 143 if ( ! sem ) {
139 SDL_SetError("Passed a NULL semaphore"); 144 SDL_SetError("Passed a NULL semaphore");
140 return -1; 145 return -1;
141 } 146 }
142 147
143 sem_wait(&sem->sem); 148 while ( ((retval = sem_wait(&sem->sem)) == -1) && (errno == EINTR) ) {}
144 return 0; 149 return retval;
145 } 150 }
146 151
147 Uint32 SDL_SemValue(SDL_sem *sem) 152 Uint32 SDL_SemValue(SDL_sem *sem)
148 { 153 {
149 if ( ! sem ) { 154 if ( ! sem ) {