diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-07-03 15:26:45 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-07-03 15:26:45 +0000 |
commit | 3bac1b31bb373b447b78a1b1cc3db58287101c68 (patch) | |
tree | 164a77ef24dcbeb894190cd1f593803e2bb18e72 /lib/libpthread/uthread | |
parent | 5fd7c6329beb595c229e7edf6d6b5085468da14f (diff) |
In pthread_key_delete(), only scan other threads if the key was allocated
and handle the case of specific_data being NULL.
Pointed out by fgsch@, ok tedu@
Diffstat (limited to 'lib/libpthread/uthread')
-rw-r--r-- | lib/libpthread/uthread/uthread_spec.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/libpthread/uthread/uthread_spec.c b/lib/libpthread/uthread/uthread_spec.c index eecf07d10e4..f01e91bbf0e 100644 --- a/lib/libpthread/uthread/uthread_spec.c +++ b/lib/libpthread/uthread/uthread_spec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_spec.c,v 1.10 2011/07/02 17:12:02 tedu Exp $ */ +/* $OpenBSD: uthread_spec.c,v 1.11 2011/07/03 15:26:44 guenther Exp $ */ /* * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -84,20 +84,20 @@ pthread_key_delete(pthread_key_t key) /* Lock the key table entry: */ _SPINLOCK(&key_table[key].lock); - if (key_table[key].allocated) + if (key_table[key].allocated) { key_table[key].allocated = 0; - else - ret = EINVAL; - _thread_kern_sig_defer(); - TAILQ_FOREACH(pthread, &_thread_list, tle) { - if (pthread->specific_data[key]) { - pthread->specific_data[key] = NULL; - pthread->specific_data_count--; + _thread_kern_sig_defer(); + TAILQ_FOREACH(pthread, &_thread_list, tle) { + if (pthread->specific_data != NULL && + pthread->specific_data[key]) { + pthread->specific_data[key] = NULL; + pthread->specific_data_count--; + } } - - } - _thread_kern_sig_undefer(); + _thread_kern_sig_undefer(); + } else + ret = EINVAL; /* Unlock the key table entry: */ _SPINUNLOCK(&key_table[key].lock); |