From patchwork Sun Feb 9 19:51:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 37802 Received: (qmail 112490 invoked by alias); 9 Feb 2020 19:51:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 112482 invoked by uid 89); 9 Feb 2020 19:51:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited 1/2] htl: support cancellation during pthread_once Date: Sun, 9 Feb 2020 20:51:31 +0100 Message-Id: <20200209195132.294255-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 --- sysdeps/htl/pt-once.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sysdeps/htl/pt-once.c b/sysdeps/htl/pt-once.c index 0581f7bd6c..7f86e28006 100644 --- a/sysdeps/htl/pt-once.c +++ b/sysdeps/htl/pt-once.c @@ -21,6 +21,13 @@ #include +static void +clear_once_control (void *arg) +{ + pthread_once_t *once_control = arg; + __pthread_spin_unlock (&once_control->__lock); +} + int __pthread_once (pthread_once_t *once_control, void (*init_routine) (void)) { @@ -33,7 +40,10 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void)) if (once_control->__run == 0) { + pthread_cleanup_push (clear_once_control, once_control); init_routine (); + pthread_cleanup_pop (0); + atomic_full_barrier (); once_control->__run = 1; }