Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Aug 2010 05:20:22 +0000 (UTC)
From:      David Xu <davidxu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r211860 - head/lib/libthr/thread
Message-ID:  <201008270520.o7R5KMCG064569@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008270520.o7R5KMCG064569>