diff options
author | brian <brian@FreeBSD.org> | 2010-06-09 07:31:41 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2010-06-09 07:31:41 +0000 |
commit | 7ebb302abcbc0ab56797f28e24a3769665e41f3c (patch) | |
tree | 471edb7c9c77ca775b4c60f98323ac7c17433fb7 /lib | |
parent | 062421f2843daeed06bc5a29528505bcedbf75d6 (diff) | |
download | FreeBSD-src-7ebb302abcbc0ab56797f28e24a3769665e41f3c.zip FreeBSD-src-7ebb302abcbc0ab56797f28e24a3769665e41f3c.tar.gz |
MFC r197477 - clean up keys deleted via pthread_key_delete()
PR: 135462
Approved by: re (kib)
Nod timeout: davidxu
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libthr/thread/thr_spec.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c index 06d1287..0740d6b 100644 --- a/lib/libthr/thread/thr_spec.c +++ b/lib/libthr/thread/thr_spec.c @@ -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) { |