summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2013-11-02 22:37:18 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2013-11-02 22:37:18 +0000
commitbd5de7550a69940f21c8270e136472a895d298a6 (patch)
treed9469666d2121d54a3a8dc8bf99c2fc619c8d83d
parent3d37548f8b46dd5adce6ca9d524b3d9a8259573e (diff)
remove unnecessary spinlock that slowed down pthread_getspecific.
original report and fix provided by John Carr. ok guenther kettenis
-rw-r--r--lib/librthread/rthread_tls.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/librthread/rthread_tls.c b/lib/librthread/rthread_tls.c
index 8f0ffe38933..c16b0dd243a 100644
--- a/lib/librthread/rthread_tls.c
+++ b/lib/librthread/rthread_tls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_tls.c,v 1.15 2013/07/30 16:19:33 guenther Exp $ */
+/* $OpenBSD: rthread_tls.c,v 1.16 2013/11/02 22:37:17 tedu Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -96,7 +96,6 @@ _rthread_findstorage(pthread_key_t key)
struct rthread_storage *rs;
pthread_t self;
- _spinlock(&rkeyslock);
if (!rkeys[key].used) {
rs = NULL;
goto out;
@@ -119,7 +118,6 @@ _rthread_findstorage(pthread_key_t key)
}
out:
- _spinunlock(&rkeyslock);
return (rs);
}
@@ -169,8 +167,8 @@ _rthread_tls_destructors(pthread_t thread)
void (*destructor)(void *) =
rkeys[rs->keyid].destructor;
void *data = rs->data;
- _spinunlock(&rkeyslock);
rs->data = NULL;
+ _spinunlock(&rkeyslock);
destructor(data);
_spinlock(&rkeyslock);
}