Unregister thread specific data destructor when a corresponding dso
is unloaded.
This commit is contained in:
parent
8e60ce996b
commit
ed0ee6af2e
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user