diff options
Diffstat (limited to 'pthread/pt-testcancel.c')
-rw-r--r-- | pthread/pt-testcancel.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pthread/pt-testcancel.c b/pthread/pt-testcancel.c index 01f1ac9..3ba07b6 100644 --- a/pthread/pt-testcancel.c +++ b/pthread/pt-testcancel.c @@ -25,7 +25,12 @@ void pthread_testcancel (void) { struct __pthread *p = _pthread_self (); + int cancelled; - if (p->cancel_state == PTHREAD_CANCEL_ENABLE && p->cancel_pending) + __pthread_mutex_lock (&p->cancel_lock); + cancelled = (p->cancel_state == PTHREAD_CANCEL_ENABLE) && p->cancel_pending; + __pthread_mutex_unlock (&p->cancel_lock); + + if (cancelled) pthread_exit (PTHREAD_CANCELED); } |