This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[hurd,commited 1/2] htl: support cancellation during pthread_once


---
 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 <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;
 	}
-- 
2.24.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]