public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Noah Goldstein <goldstein.w.n@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>,
	Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [PATCH v2] nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
Date: Wed, 13 Jul 2022 09:57:24 -0300	[thread overview]
Message-ID: <5eb7357d-9c85-4831-9d2f-79461328452b@linaro.org> (raw)
In-Reply-To: <CAFUsyf+dcjzhBMrJhCAyT6uJpk+P0UD2O0EBcrX8D0Uyz7N+wg@mail.gmail.com>



On 12/07/22 18:27, Noah Goldstein wrote:
>> diff --git a/nptl/cleanup_defer.c b/nptl/cleanup_defer.c
>> index f8181a40e8..eb0bc77740 100644
>> --- a/nptl/cleanup_defer.c
>> +++ b/nptl/cleanup_defer.c
>> @@ -30,9 +30,22 @@ ___pthread_register_cancel_defer (__pthread_unwind_buf_t *buf)
>>     ibuf->priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
>>     ibuf->priv.data.cleanup = THREAD_GETMEM (self, cleanup);
>>
>> -  /* Disable asynchronous cancellation for now.  */
>> -  ibuf->priv.data.canceltype = THREAD_GETMEM (self, canceltype);
>> -  THREAD_SETMEM (self, canceltype, PTHREAD_CANCEL_DEFERRED);
>> +  int cancelhandling = atomic_load_relaxed (&self->cancelhandling);
>> +  if (__glibc_unlikely (cancelhandling & CANCELTYPE_BITMASK))
>> +    {
>> +      int newval;
>> +      do
>> +       {
>> +         newval = cancelhandling & ~CANCELTYPE_BITMASK;
>> +       }
>> +      while (!atomic_compare_exchange_weak_acquire (&self->cancelhandling,
>> +                                                   &cancelhandling,
>> +                                                   newval));
>> +    }
>> +
>> +  ibuf->priv.data.canceltype = (cancelhandling & CANCELTYPE_BITMASK
>> +                               ? PTHREAD_CANCEL_ASYNCHRONOUS
>> +                               : PTHREAD_CANCEL_DEFERRED);
>>
>>     /* Store the new cleanup handler info.  */
>>     THREAD_SETMEM (self, cleanup_jmp_buf, (struct pthread_unwind_buf *) buf);
>> @@ -54,9 +67,26 @@ ___pthread_unregister_cancel_restore (__pthread_unwind_buf_t *buf)
>>
>>     THREAD_SETMEM (self, cleanup_jmp_buf, ibuf->priv.data.prev);
>>
>> -  THREAD_SETMEM (self, canceltype, ibuf->priv.data.canceltype);
>> -  if (ibuf->priv.data.canceltype == PTHREAD_CANCEL_ASYNCHRONOUS)
>> -    __pthread_testcancel ();
>> +  if (ibuf->priv.data.canceltype == PTHREAD_CANCEL_DEFERRED)
>> +    return;
>> +
>> +  int cancelhandling = atomic_load_relaxed (&self->cancelhandling);
>> +  if (cancelhandling & CANCELTYPE_BITMASK)
> 
> should this be:
> if((cancelhandling & CANCELTYPE_BITMASK) == 0)
> ?

Yes, I will fix it.

      parent reply	other threads:[~2022-07-13 12:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 15:49 Adhemerval Zanella
2022-04-14 18:26 ` Adhemerval Zanella
2022-04-19 10:44 ` Szabolcs Nagy
2022-04-19 12:18   ` Adhemerval Zanella
2022-04-19 12:23     ` Adhemerval Zanella
2022-04-19 12:10 ` Szabolcs Nagy
2022-04-19 12:30   ` Adhemerval Zanella
2022-04-19 12:46     ` Szabolcs Nagy
2022-04-19 13:12       ` Adhemerval Zanella
2022-07-12 21:27 ` Noah Goldstein
2022-07-12 21:28   ` Noah Goldstein
2022-07-13 12:57   ` Adhemerval Zanella Netto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5eb7357d-9c85-4831-9d2f-79461328452b@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=fweimer@redhat.com \
    --cc=goldstein.w.n@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).