summaryrefslogtreecommitdiff
path: root/nptl/libc-cancellation.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/libc-cancellation.c')
-rw-r--r--nptl/libc-cancellation.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/nptl/libc-cancellation.c b/nptl/libc-cancellation.c
index cf24f1c0f2..cada464d2b 100644
--- a/nptl/libc-cancellation.c
+++ b/nptl/libc-cancellation.c
@@ -86,15 +86,13 @@ __libc_disable_asynccancel (int oldtype)
return;
struct pthread *self = THREAD_SELF;
+ int newval;
-#ifdef THREAD_ATOMIC_AND
- THREAD_ATOMIC_AND (self, cancelhandling, ~CANCELTYPE_BITMASK);
-#else
int oldval = THREAD_GETMEM (self, cancelhandling);
while (1)
{
- int newval = oldval & ~CANCELTYPE_BITMASK;
+ newval = oldval & ~CANCELTYPE_BITMASK;
if (newval == oldval)
break;
@@ -107,7 +105,17 @@ __libc_disable_asynccancel (int oldtype)
/* Prepare the next round. */
oldval = curval;
}
-#endif
+
+ /* We cannot return when we are being canceled. Upon return the
+ thread might be things which would have to be undone. The
+ following loop should loop until the cancellation signal is
+ delivered. */
+ while (__builtin_expect ((newval & (CANCELING_BITMASK | CANCELED_BITMASK))
+ == CANCELING_BITMASK, 0))
+ {
+ lll_futex_wait (&self->cancelhandling, newval, LLL_PRIVATE);
+ newval = THREAD_GETMEM (self, cancelhandling);
+ }
}