about summary refs log tree commit diff
path: root/src/thread/pthread_key_create.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread/pthread_key_create.c')
-rw-r--r--src/thread/pthread_key_create.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/thread/pthread_key_create.c b/src/thread/pthread_key_create.c
index dc20cc3f..210605c6 100644
--- a/src/thread/pthread_key_create.c
+++ b/src/thread/pthread_key_create.c
@@ -51,15 +51,17 @@ int __pthread_key_delete(pthread_key_t k)
 	pthread_t self = __pthread_self(), td=self;
 
 	__block_app_sigs(&set);
+	__pthread_rwlock_wrlock(&key_lock);
+
 	__tl_lock();
 	do td->tsd[k] = 0;
 	while ((td=td->next)!=self);
 	__tl_unlock();
-	__restore_sigs(&set);
 
-	__pthread_rwlock_wrlock(&key_lock);
 	keys[k] = 0;
+
 	__pthread_rwlock_unlock(&key_lock);
+	__restore_sigs(&set);
 
 	return 0;
 }