]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
htl: Fix initializing the key lock
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 14 Feb 2022 00:38:03 +0000 (01:38 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 14 Feb 2022 18:29:02 +0000 (19:29 +0100)
The static pthread_once_t in the pt-key.h header was creating one
pthread_once_t per includer.  We have to use a shared common
pthread_once_t instead.

sysdeps/htl/pt-key-create.c
sysdeps/htl/pt-key.h

index ca4908c55c0442cddcdb589d0f64f1b429db9b21..f8dc5ac0c5177c51545e9b428bccd8f9bd6905b8 100644 (file)
@@ -24,6 +24,7 @@
 #include <pthreadP.h>
 
 pthread_mutex_t __pthread_key_lock;
+pthread_once_t __pthread_key_once = PTHREAD_ONCE_INIT;
 
 void (**__pthread_key_destructors) (void *arg);
 int __pthread_key_size;
index 34c12d51ab54a1cff68ce1136f4bfb98b34c20c3..ef652ecc6f0a4180670807cd980260846079ad14 100644 (file)
@@ -47,14 +47,15 @@ extern int __pthread_key_invalid_count;
 /* Protects the above variables.  This must be a recursive lock: the
    destructors may call pthread_key_delete.  */
 extern pthread_mutex_t __pthread_key_lock;
+
+/* Protects the initialization of the mutex above.  */
+extern pthread_once_t __pthread_key_once;
 \f
 #include <assert.h>
 
 static inline void
 __pthread_key_lock_ready (void)
 {
-  static pthread_once_t o = PTHREAD_ONCE_INIT;
-
   void do_init (void)
   {
     int err;
@@ -73,5 +74,5 @@ __pthread_key_lock_ready (void)
     assert_perror (err);
   }
 
-  __pthread_once (&o, do_init);
+  __pthread_once (&__pthread_key_once, do_init);
 }