about summary refs log tree commit diff
path: root/nptl/sem_wait.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sem_wait.c')
-rw-r--r--nptl/sem_wait.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/nptl/sem_wait.c b/nptl/sem_wait.c
index 84b523a768..b242c08d2e 100644
--- a/nptl/sem_wait.c
+++ b/nptl/sem_wait.c
@@ -23,6 +23,19 @@
 int
 __new_sem_wait (sem_t *sem)
 {
+  /* We need to check whether we need to act upon a cancellation request here
+     because POSIX specifies that cancellation points "shall occur" in
+     sem_wait and sem_timedwait, which also means that they need to check
+     this regardless whether they block or not (unlike "may occur"
+     functions).  See the POSIX Rationale for this requirement: Section
+     "Thread Cancellation Overview" [1] and austin group issue #1076 [2]
+     for thoughs on why this may be a suboptimal design.
+
+     [1] http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap02.html
+     [2] http://austingroupbugs.net/view.php?id=1076 for thoughts on why this
+   */
+  __pthread_testcancel ();
+
   if (__new_sem_wait_fast ((struct new_sem *) sem, 0) == 0)
     return 0;
   else