diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-09-01 07:09:46 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-09-01 07:09:46 +0000 |
commit | c19c7fe99f28ff76bf9904913f142f7198090e5b (patch) | |
tree | dfbeee15a5a85f759457c54a057c371bd4c76be9 /lib/libthr/thread/thr_fork.c | |
parent | 78488718dc41493f72bb1e6ca786aa1092fb2a6d (diff) | |
download | FreeBSD-src-c19c7fe99f28ff76bf9904913f142f7198090e5b.zip FreeBSD-src-c19c7fe99f28ff76bf9904913f142f7198090e5b.tar.gz |
In function __pthread_cxa_finalize(), also make code for removing
atfork handler be async-signal safe.
Diffstat (limited to 'lib/libthr/thread/thr_fork.c')
-rw-r--r-- | lib/libthr/thread/thr_fork.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c index c70096e..c15e8f9 100644 --- a/lib/libthr/thread/thr_fork.c +++ b/lib/libthr/thread/thr_fork.c @@ -100,22 +100,29 @@ _pthread_atfork(void (*prepare)(void), void (*parent)(void), void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info) { + atfork_head temp_list = TAILQ_HEAD_INITIALIZER(temp_list); struct pthread *curthread; struct pthread_atfork *af, *af1; _thr_check_init(); curthread = _get_curthread(); + THR_CRITICAL_ENTER(curthread); _thr_rwl_wrlock(&_thr_atfork_lock); TAILQ_FOREACH_SAFE(af, &_thr_atfork_list, qe, af1) { if (__elf_phdr_match_addr(phdr_info, af->prepare) || __elf_phdr_match_addr(phdr_info, af->parent) || __elf_phdr_match_addr(phdr_info, af->child)) { TAILQ_REMOVE(&_thr_atfork_list, af, qe); - free(af); + TAILQ_INSERT_TAIL(&temp_list, af, qe); } } _thr_rwl_unlock(&_thr_atfork_lock); + THR_CRITICAL_LEAVE(curthread); + while ((af = TAILQ_FIRST(&temp_list)) != NULL) { + TAILQ_REMOVE(&temp_list, af, qe); + free(af); + } _thr_tsd_unload(phdr_info); _thr_sigact_unload(phdr_info); } |