diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-06-30 20:41:34 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-06-30 20:41:34 -0400 |
commit | 6f8326cacd08bf7d1966743086855fc36574bf74 (patch) | |
tree | 0e974e28ad3c04a712cfe18b2a33ad46ac0ba27f /nptl/sysdeps/unix | |
parent | 89f654c57b3b9a6aee480e25e37f88f06c898901 (diff) | |
download | glibc-6f8326cacd08bf7d1966743086855fc36574bf74.tar.gz glibc-6f8326cacd08bf7d1966743086855fc36574bf74.tar.xz glibc-6f8326cacd08bf7d1966743086855fc36574bf74.zip |
Fix robust mutex handling after fork
Diffstat (limited to 'nptl/sysdeps/unix')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/fork.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/fork.c b/nptl/sysdeps/unix/sysv/linux/fork.c index 524d72c587..80fb147788 100644 --- a/nptl/sysdeps/unix/sysv/linux/fork.c +++ b/nptl/sysdeps/unix/sysv/linux/fork.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2007, 2008 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2007, 2008, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -29,6 +29,7 @@ #include <ldsodefs.h> #include <bits/stdio-lock.h> #include <atomic.h> +#include <pthreadP.h> unsigned long int *__fork_generation_pointer; @@ -86,8 +87,8 @@ __libc_fork (void) just go away. The unloading code works in the order of the list. - While executing the registered handlers we are building a - list of all the entries so that we can go backward later on. */ + While executing the registered handlers we are building a + list of all the entries so that we can go backward later on. */ while (1) { /* Execute the handler if there is one. */ @@ -154,6 +155,24 @@ __libc_fork (void) GL(dl_cpuclock_offset) = now; #endif +#ifdef __NR_set_robust_list + /* Initialize the robust mutex list which has been reset during + the fork. We do not check for errors since if it fails here + it failed at process start as well and noone could have used + robust mutexes. We also do not have to set + self->robust_head.futex_offset since we inherit the correct + value from the parent. */ +# ifdef SHARED + if (__builtin_expect (__libc_pthread_functions_init, 0)) + PTHFCT_CALL (ptr_set_robust, (self)); +# else + extern __typeof (__nptl_set_robust) __nptl_set_robust + __attribute__((weak)); + if (__builtin_expect (__nptl_set_robust != NULL, 0)) + __nptl_set_robust (self); +# endif +#endif + /* Reset the file list. These are recursive mutexes. */ fresetlockfiles (); @@ -170,10 +189,10 @@ __libc_fork (void) allp->handler->child_handler (); /* Note that we do not have to wake any possible waiter. - This is the only thread in the new process. The count - may have been bumped up by other threads doing a fork. - We reset it to 1, to avoid waiting for non-existing - thread(s) to release the count. */ + This is the only thread in the new process. The count + may have been bumped up by other threads doing a fork. + We reset it to 1, to avoid waiting for non-existing + thread(s) to release the count. */ allp->handler->refcntr = 1; /* XXX We could at this point look through the object pool |