svn commit: r211860 - head/lib/libthr/thread

David Xu davidxu at FreeBSD.org
Fri Aug 27 05:20:23 UTC 2010


Author: davidxu
Date: Fri Aug 27 05:20:22 2010
New Revision: 211860
URL: http://svn.freebsd.org/changeset/base/211860

Log:
  Unregister thread specific data destructor when a corresponding dso
  is unloaded.

Modified:
  head/lib/libthr/thread/thr_fork.c
  head/lib/libthr/thread/thr_private.h
  head/lib/libthr/thread/thr_spec.c

Modified: head/lib/libthr/thread/thr_fork.c
==============================================================================
--- head/lib/libthr/thread/thr_fork.c	Fri Aug 27 03:23:07 2010	(r211859)
+++ head/lib/libthr/thread/thr_fork.c	Fri Aug 27 05:20:22 2010	(r211860)
@@ -114,6 +114,7 @@ __pthread_cxa_finalize(struct dl_phdr_in
 		}
 	}
 	THR_UMUTEX_UNLOCK(curthread, &_thr_atfork_lock);
+	_thr_tsd_unload(phdr_info);
 }
 
 __weak_reference(_fork, fork);

Modified: head/lib/libthr/thread/thr_private.h
==============================================================================
--- head/lib/libthr/thread/thr_private.h	Fri Aug 27 03:23:07 2010	(r211859)
+++ head/lib/libthr/thread/thr_private.h	Fri Aug 27 05:20:22 2010	(r211860)
@@ -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
 

Modified: head/lib/libthr/thread/thr_spec.c
==============================================================================
--- head/lib/libthr/thread/thr_spec.c	Fri Aug 27 03:23:07 2010	(r211859)
+++ head/lib/libthr/thread/thr_spec.c	Fri Aug 27 05:20:22 2010	(r211860)
@@ -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);
+}


More information about the svn-src-all mailing list