Unregister thread specific data destructor when a corresponding dso

is unloaded.
This commit is contained in:
David Xu 2010-08-27 05:20:22 +00:00
parent 8e60ce996b
commit ed0ee6af2e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=211860
3 changed files with 23 additions and 0 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);
}