svn commit: r208936 - stable/8/lib/libthr/thread

Brian Somers brian at FreeBSD.org
Wed Jun 9 07:31:41 UTC 2010


Author: brian
Date: Wed Jun  9 07:31:41 2010
New Revision: 208936
URL: http://svn.freebsd.org/changeset/base/208936

Log:
  MFC r197477 - clean up keys deleted via pthread_key_delete()
  
  PR:		135462
  Approved by:	re (kib)
  Nod timeout:	davidxu

Modified:
  stable/8/lib/libthr/thread/thr_spec.c
Directory Properties:
  stable/8/lib/libthr/   (props changed)

Modified: stable/8/lib/libthr/thread/thr_spec.c
==============================================================================
--- stable/8/lib/libthr/thread/thr_spec.c	Wed Jun  9 07:31:32 2010	(r208935)
+++ stable/8/lib/libthr/thread/thr_spec.c	Wed Jun  9 07:31:41 2010	(r208936)
@@ -131,9 +131,19 @@ _thread_cleanupspecific(void)
 				curthread->specific[key].data = NULL;
 				curthread->specific_data_count--;
 			}
+			else if (curthread->specific[key].data != NULL) {
+				/* 
+				 * This can happen if the key is deleted via
+				 * pthread_key_delete without first setting the value
+				 * to NULL in all threads.  POSIX says that the
+				 * destructor is not invoked in this case.
+				 */
+				curthread->specific[key].data = NULL;
+				curthread->specific_data_count--;
+			}
 
 			/*
-			 * If there is a destructore, call it
+			 * If there is a destructor, call it
 			 * with the key table entry unlocked:
 			 */
 			if (destructor != NULL) {


More information about the svn-src-all mailing list