1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00

nptl: Move cancel state out of cancelhandling

Now that thread cancellation state is not accessed concurrently anymore,
it is possible to move it out the 'cancelhandling'.

The code is also simplified: CANCELLATION_P is replaced with a
internal pthread_testcancel call and the CANCELSTATE_BIT{MASK} is
removed.

With this behavior pthread_setcancelstate does not require to act on
cancellation if cancel type is asynchronous (is already handled either
by pthread_setcanceltype or by the signal handler).

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
This commit is contained in:
Adhemerval Zanella
2020-03-31 15:43:25 -03:00
parent 26cfbb7162
commit 2b51742531
14 changed files with 34 additions and 63 deletions

View File

@@ -23,7 +23,16 @@
void
___pthread_testcancel (void)
{
CANCELLATION_P (THREAD_SELF);
struct pthread *self = THREAD_SELF;
int cancelhandling = THREAD_GETMEM (self, cancelhandling);
if (self->cancelstate == PTHREAD_CANCEL_ENABLE
&& (cancelhandling & CANCELED_BITMASK)
&& !(cancelhandling & EXITING_BITMASK)
&& !(cancelhandling & TERMINATED_BITMASK))
{
THREAD_SETMEM (self, result, PTHREAD_CANCELED);
__do_cancel ();
}
}
versioned_symbol (libc, ___pthread_testcancel, pthread_testcancel, GLIBC_2_34);
versioned_symbol (libc, ___pthread_testcancel, __pthread_testcancel,