summaryrefslogtreecommitdiffstats
path: root/lib/libc/net/res_random.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2016-04-05 04:29:21 +0000
committerguenther <guenther@openbsd.org>2016-04-05 04:29:21 +0000
commitc6cbd3558879ed24f06db5fcaccda4429a1dbfab (patch)
tree48014834b26d2a15e16447fa02bebc44e0045c2a /lib/libc/net/res_random.c
parentUpdate example in comment: setlogin doesn't use {PROTO,DEF}_WRAP() now (diff)
downloadwireguard-openbsd-c6cbd3558879ed24f06db5fcaccda4429a1dbfab.tar.xz
wireguard-openbsd-c6cbd3558879ed24f06db5fcaccda4429a1dbfab.zip
Prefer _MUTEX_*LOCK over _THREAD_PRIVATE_MUTEX_*LOCK() when thread-specific
data isn't necessary. ok mpi@, ok&tweak natano@
Diffstat (limited to 'lib/libc/net/res_random.c')
-rw-r--r--lib/libc/net/res_random.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libc/net/res_random.c b/lib/libc/net/res_random.c
index 72b9c41a2a9..763e420bb88 100644
--- a/lib/libc/net/res_random.c
+++ b/lib/libc/net/res_random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_random.c,v 1.23 2015/10/05 02:57:16 guenther Exp $ */
+/* $OpenBSD: res_random.c,v 1.24 2016/04/05 04:29:21 guenther Exp $ */
/*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -230,12 +230,12 @@ __res_randomid(void)
struct timespec ts;
pid_t pid;
u_int r;
- _THREAD_PRIVATE_MUTEX(random);
+ static void *randomid_mutex;
clock_gettime(CLOCK_MONOTONIC, &ts);
pid = getpid();
- _THREAD_PRIVATE_MUTEX_LOCK(random);
+ _MUTEX_LOCK(&randomid_mutex);
if (ru_counter >= RU_MAX || ts.tv_sec > ru_reseed || pid != ru_pid) {
res_initid();
@@ -248,7 +248,7 @@ __res_randomid(void)
r = permute15(ru_seed ^ pmod(ru_g, ru_seed2 + ru_x, RU_N)) | ru_msb;
- _THREAD_PRIVATE_MUTEX_UNLOCK(random);
+ _MUTEX_UNLOCK(&randomid_mutex);
return (r);
}