On Sat, Jul 2, 2011 at 5:20 PM, Federico Schwindt <[email protected]> wrote:
> you should only do that if key is valid, not always. also
> specific_data might be NULL.
> i don't think this is correct.

Hmm,  yeah.  How about:


Index: uthread/uthread_spec.c
===================================================================
RCS file: /cvs/src/lib/libpthread/uthread/uthread_spec.c,v
retrieving revision 1.10
diff -u -p -r1.10 uthread_spec.c
--- uthread/uthread_spec.c      2 Jul 2011 17:12:02 -0000       1.10
+++ uthread/uthread_spec.c      3 Jul 2011 15:04:58 -0000
@@ -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);

Reply via email to