Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2017-03-07 17:15:47 +0300
committerCorinna Vinschen <corinna@vinschen.de>2017-03-07 17:15:47 +0300
commit49505a907f3fb690e7db81dde9b70067664c1d83 (patch)
tree33222e8e263aa231749d3df6920b034d3ab43cad /winsup
parent88443b0a2258993a20fb5d1d886860646e5202cc (diff)
Cygwin: pthread_cond_wait: Do as Linux and BSD do.
POSIX states as follows about pthread_cond_wait: If a signal is delivered to a thread waiting for a condition variable, upon return from the signal handler the thread resumes waiting for the condition variable as if it was not interrupted, or it returns zero due to spurious wakeup. Cygwin so far employs the latter behaviour, while Linux and BSD employ the former one. Align Cygwin behaviour to Linux and BSD. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/thread.cc27
1 files changed, 5 insertions, 22 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 7084657e0..8cae82cfe 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -1266,24 +1266,14 @@ pthread_cond::wait (pthread_mutex_t mutex, PLARGE_INTEGER timeout)
++mutex->condwaits;
mutex->unlock ();
- rv = cygwait (sem_wait, timeout, cw_cancel | cw_sig_eintr);
+ rv = cygwait (sem_wait, timeout, cw_cancel | cw_sig_restart);
mtx_out.lock ();
- if (rv != WAIT_OBJECT_0)
- {
- /*
- * It might happen that a signal is sent while the thread got canceled
- * or timed out. Try to take one.
- * If the thread gets one than a signal|broadcast is in progress.
- */
- if (WaitForSingleObject (sem_wait, 0) == WAIT_OBJECT_0)
- /*
- * thread got cancelled ot timed out while a signalling is in progress.
- * Set wait result back to signaled
- */
- rv = WAIT_OBJECT_0;
- }
+ if (rv != WAIT_OBJECT_0 && WaitForSingleObject (sem_wait, 0) == WAIT_OBJECT_0)
+ /* Thread got cancelled ot timed out while a signalling is in progress.
+ Set wait result back to signaled */
+ rv = WAIT_OBJECT_0;
InterlockedDecrement (&waiting);
@@ -1301,13 +1291,6 @@ pthread_cond::wait (pthread_mutex_t mutex, PLARGE_INTEGER timeout)
if (rv == WAIT_CANCELED)
pthread::static_cancel_self ();
- else if (rv == WAIT_SIGNALED)
- /* SUSv3 states: If a signal is delivered to a thread waiting for a
- condition variable, upon return from the signal handler the thread
- resumes waiting for the condition variable as if it was not
- interrupted, or it shall return zero due to spurious wakeup.
- We opt for the latter choice here. */
- return 0;
else if (rv == WAIT_TIMEOUT)
return ETIMEDOUT;