]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
htl: support cancellation during pthread_once
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 9 Feb 2020 19:43:43 +0000 (19:43 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 9 Feb 2020 19:43:46 +0000 (19:43 +0000)
sysdeps/htl/pt-once.c

index 0581f7bd6c5951238090348a41347dd7ad790763..7f86e28006bb7f4b347bf98eb28c2393d1811417 100644 (file)
 
 #include <pt-internal.h>
 
+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;
        }