aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Xu <davidxu@FreeBSD.org>2010-08-27 05:20:22 +0000
committerDavid Xu <davidxu@FreeBSD.org>2010-08-27 05:20:22 +0000
commited0ee6af2e78cc10527d2c26abbe1946e54f3c98 (patch)
tree137b977fc58ece89238e716a36c46fa110e72b22
parent8e60ce996b14d8d41112ad374e3b2d6fc02b6823 (diff)
downloadsrc-ed0ee6af2e78cc10527d2c26abbe1946e54f3c98.tar.gz
src-ed0ee6af2e78cc10527d2c26abbe1946e54f3c98.zip
Unregister thread specific data destructor when a corresponding dso
is unloaded.
Notes
Notes: svn path=/head/; revision=211860
-rw-r--r--lib/libthr/thread/thr_fork.c1
-rw-r--r--lib/libthr/thread/thr_private.h1
-rw-r--r--lib/libthr/thread/thr_spec.c21
3 files changed, 23 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c
index b1c221eca83d..f20942d42be9 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 f92913bc92bc..f261810e7e99 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 0740d6bac851..86dc79430f15 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);
+}