{
volatile pthread_descr self = thread_self();
sigset_t unblock, initial_mask;
- int retsleep, already_canceled, was_signalled;
+ int already_canceled = 0;
+ int was_signalled = 0;
sigjmp_buf jmpbuf;
pthread_extricate_if extr;
struct timeval now;
struct timespec reltime;
-requeue_and_wait_again:
-
/* Compute a time offset relative to now. */
__gettimeofday (&now, NULL);
reltime.tv_nsec = abstime->tv_nsec - now.tv_usec * 1000;
if (reltime.tv_sec < 0)
return ETIMEDOUT;
- retsleep = 0;
- already_canceled = 0;
- was_signalled = 0;
-
/* Set up extrication interface */
extr.pu_object = cond;
extr.pu_extricate_func = cond_extricate_func;
sigemptyset(&unblock);
sigaddset(&unblock, __pthread_sig_restart);
sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
- /* Sleep for the required duration */
- retsleep = __libc_nanosleep(&reltime, NULL);
+ /* Sleep for the required duration. If woken by a signal, resume waiting
+ as required by Single Unix Specification. */
+ while (__libc_nanosleep(&reltime, &reltime) != 0)
+ ;
/* Block the restart signal again */
sigprocmask(SIG_SETMASK, &initial_mask, NULL);
was_signalled = 0;
} else {
- retsleep = -1;
was_signalled = 1;
}
THREAD_SETMEM(self, p_signal_jmp, NULL);
if (was_on_queue) {
__pthread_set_own_extricate_if(self, 0);
pthread_mutex_lock(mutex);
-
- if (retsleep == 0)
- return ETIMEDOUT;
- /* Woken by a signal: resume waiting as required by Single Unix
- Specification. */
- goto requeue_and_wait_again;
+ return ETIMEDOUT;
}
suspend(self);
{
volatile pthread_descr self = thread_self();
sigset_t unblock, initial_mask;
- int retsleep, already_canceled, was_signalled;
+ int already_canceled = 0;
+ int was_signalled = 0;
sigjmp_buf jmpbuf;
pthread_extricate_if extr;
struct timeval now;
struct timespec reltime;
- requeue_and_wait_again:
-
/* Compute a time offset relative to now. */
__gettimeofday (&now, NULL);
reltime.tv_nsec = abstime->tv_nsec - now.tv_usec * 1000;
if (reltime.tv_sec < 0)
return ETIMEDOUT;
- retsleep = 0;
already_canceled = 0;
was_signalled = 0;
sigemptyset(&unblock);
sigaddset(&unblock, __pthread_sig_restart);
sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
- /* Sleep for the required duration */
- retsleep = __libc_nanosleep(&reltime, NULL);
+ /* Sleep for the required duration. If woken by a signal, resume waiting
+ as required by Single Unix Specification. */
+ while (__libc_nanosleep(&reltime, &reltime) != 0)
+ ;
/* Block the restart signal again */
sigprocmask(SIG_SETMASK, &initial_mask, NULL);
was_signalled = 0;
} else {
- retsleep = -1;
was_signalled = 1;
}
THREAD_SETMEM(self, p_signal_jmp, NULL);
if (was_on_queue) {
__pthread_set_own_extricate_if(self, 0);
pthread_mutex_lock(mutex);
-
- if (retsleep == 0)
- return ETIMEDOUT;
- /* Woken by a signal: resume waiting as required by Single Unix
- Specification. */
- goto requeue_and_wait_again;
+ return ETIMEDOUT;
}
/* Eat the outstanding restart() from the signaller */