diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-08-27 05:20:22 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-08-27 05:20:22 +0000 |
commit | ca3cfe473f54b36adf014a42d55d46b968e8ef77 (patch) | |
tree | 137b977fc58ece89238e716a36c46fa110e72b22 /lib | |
parent | 4190ab4bbd5d07a0a9a2831a54c6313faef67286 (diff) | |
download | FreeBSD-src-ca3cfe473f54b36adf014a42d55d46b968e8ef77.zip FreeBSD-src-ca3cfe473f54b36adf014a42d55d46b968e8ef77.tar.gz |
Unregister thread specific data destructor when a corresponding dso
is unloaded.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libthr/thread/thr_fork.c | 1 | ||||
-rw-r--r-- | lib/libthr/thread/thr_private.h | 1 | ||||
-rw-r--r-- | lib/libthr/thread/thr_spec.c | 21 |
3 files changed, 23 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c index b1c221e..f20942d 100644 --- a/lib/libthr/thread/thr_fork.c +++ b/lib/libthr/thread/thr_fork.c @@ -114,6 +114,7 @@ __pthread_cxa_finalize(struct dl_phdr_info *phdr_info) } } THR_UMUTEX_UNLOCK(curthread, &_thr_atfork_lock); + _thr_tsd_unload(phdr_info); } __weak_reference(_fork, fork); diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index f92913b..f261810 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -739,6 +739,7 @@ _thr_check_init(void) struct dl_phdr_info; void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info); +void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden; __END_DECLS diff --git a/lib/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c index 0740d6b..86dc794 100644 --- a/lib/libthr/thread/thr_spec.c +++ b/lib/libthr/thread/thr_spec.c @@ -36,6 +36,7 @@ #include <errno.h> #include <pthread.h> #include "un-namespace.h" +#include "libc_private.h" #include "thr_private.h" @@ -235,3 +236,23 @@ _pthread_getspecific(pthread_key_t key) data = NULL; return (__DECONST(void *, data)); } + +void +_thr_tsd_unload(struct dl_phdr_info *phdr_info) +{ + struct pthread *curthread = _get_curthread(); + void (*destructor)(void *); + int key; + + THR_LOCK_ACQUIRE(curthread, &_keytable_lock); + for (key = 0; key < PTHREAD_KEYS_MAX; key++) { + if (_thread_keytable[key].allocated) { + destructor = _thread_keytable[key].destructor; + if (destructor != NULL) { + if (__elf_phdr_match_addr(phdr_info, destructor)) + _thread_keytable[key].destructor = NULL; + } + } + } + THR_LOCK_RELEASE(curthread, &_keytable_lock); +} |