diff options
author | Ulrich Drepper <drepper@redhat.com> | 2009-05-15 20:42:36 -0700 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2009-05-15 20:42:36 -0700 |
commit | 9437b427cec6266abd303983848549a5c4ba0d0a (patch) | |
tree | 7d3c7df6abb9a33d4f35a3dc20baa59ff1a53ea1 /nptl/cancellation.c | |
parent | bbc5d74dd0bd1c3dbe7ea8515f081dc7e318272c (diff) | |
download | glibc-9437b427cec6266abd303983848549a5c4ba0d0a.tar.gz glibc-9437b427cec6266abd303983848549a5c4ba0d0a.tar.xz glibc-9437b427cec6266abd303983848549a5c4ba0d0a.zip |
Fix change to prevent cancel signal in unsafe places.
The bits tested to decide when to delay the return when switching off async cancel mode were wrong. Fix that. Also close a race condition in pthread_cancel where the bit indicating the cancellation is unconditionally set even if the cancel type might have changed.
Diffstat (limited to 'nptl/cancellation.c')
-rw-r--r-- | nptl/cancellation.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/nptl/cancellation.c b/nptl/cancellation.c index 4d528cfc2f..2a6f83d28a 100644 --- a/nptl/cancellation.c +++ b/nptl/cancellation.c @@ -72,10 +72,6 @@ __pthread_disable_asynccancel (int oldtype) struct pthread *self = THREAD_SELF; int newval; -#ifdef THREAD_ATOMIC_AND - THREAD_ATOMIC_AND (self, cancelhandling, ~CANCELTYPE_BITMASK); - newval = THREAD_GETMEM (self, cancelhandling); -#else int oldval = THREAD_GETMEM (self, cancelhandling); while (1) @@ -93,13 +89,13 @@ __pthread_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 & CANCELED_BITMASK, 0)) + while (__builtin_expect ((newval & (CANCELING_BITMASK | CANCELED_BITMASK)) + == CANCELING_BITMASK, 0)) { lll_futex_wait (&self->cancelhandling, newval, LLL_PRIVATE); newval = THREAD_GETMEM (self, cancelhandling); |