public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] htl: Fix initializing the key lock
@ 2022-02-14 18:29 Samuel Thibault
  0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2022-02-14 18:29 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=06dbfcced3101886029ea3a46bcc98887d60f61e

commit 06dbfcced3101886029ea3a46bcc98887d60f61e
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Mon Feb 14 01:38:03 2022 +0100

    htl: Fix initializing the key lock
    
    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.

Diff:
---
 sysdeps/htl/pt-key-create.c | 1 +
 sysdeps/htl/pt-key.h        | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sysdeps/htl/pt-key-create.c b/sysdeps/htl/pt-key-create.c
index ca4908c55c..f8dc5ac0c5 100644
--- a/sysdeps/htl/pt-key-create.c
+++ b/sysdeps/htl/pt-key-create.c
@@ -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;
diff --git a/sysdeps/htl/pt-key.h b/sysdeps/htl/pt-key.h
index 34c12d51ab..ef652ecc6f 100644
--- a/sysdeps/htl/pt-key.h
+++ b/sysdeps/htl/pt-key.h
@@ -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);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-14 18:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 18:29 [glibc] htl: Fix initializing the key lock Samuel Thibault

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).