mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Add the __libc_single_threaded variable
The variable is placed in libc.so, and it can be true only in an outer libc, not libcs loaded via dlmopen or static dlopen. Since thread creation from inner namespaces does not work, pthread_create can update __libc_single_threaded directly. Using __libc_early_init and its initial flag, implementation of this variable is very straightforward. A future version may reset the flag during fork (but not in an inner namespace), or after joining all threads except one. Reviewed-by: DJ Delorie <dj@redhat.com>
This commit is contained in:
@ -35,6 +35,7 @@
|
||||
#include <tls-setup.h>
|
||||
#include <rseq-internal.h>
|
||||
#include "libioP.h"
|
||||
#include <sys/single_threaded.h>
|
||||
|
||||
#include <shlib-compat.h>
|
||||
|
||||
@ -625,6 +626,10 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
|
||||
{
|
||||
STACK_VARIABLES;
|
||||
|
||||
/* Avoid a data race in the multi-threaded case. */
|
||||
if (__libc_single_threaded)
|
||||
__libc_single_threaded = 0;
|
||||
|
||||
const struct pthread_attr *iattr = (struct pthread_attr *) attr;
|
||||
union pthread_attr_transparent default_attr;
|
||||
bool destroy_default_attr = false;
|
||||
|
Reference in New Issue
Block a user