diff options
author | 2011-12-28 04:59:31 +0000 | |
---|---|---|
committer | 2011-12-28 04:59:31 +0000 | |
commit | 1bbb51b7c7b26224d8ceef9e36ec869b4343a38f (patch) | |
tree | 7d68c44d9d21a8e168f82264b923916c422d221c /lib/librthread/rthread.c | |
parent | These utilities were already part of 1BSD, and some authors are known. (diff) | |
download | wireguard-openbsd-1bbb51b7c7b26224d8ceef9e36ec869b4343a38f.tar.xz wireguard-openbsd-1bbb51b7c7b26224d8ceef9e36ec869b4343a38f.zip |
pthread_self() may be much cheaper and never more expensive than getthrid()
so prefer it for identifying the current thread
Diffstat (limited to 'lib/librthread/rthread.c')
-rw-r--r-- | lib/librthread/rthread.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c index 313dddcd513..b4016f656d5 100644 --- a/lib/librthread/rthread.c +++ b/lib/librthread/rthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.c,v 1.48 2011/12/27 17:33:21 guenther Exp $ */ +/* $OpenBSD: rthread.c,v 1.49 2011/12/28 04:59:31 guenther Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -277,10 +277,11 @@ int pthread_join(pthread_t thread, void **retval) { int e; + pthread_t self = pthread_self(); if (thread == NULL) e = EINVAL; - else if (thread->tid == getthrid()) + else if (thread == self) e = EDEADLK; else if (thread->flags & THREAD_DETACHED) e = EINVAL; |