diff options
author | 2014-07-09 13:32:00 +0000 | |
---|---|---|
committer | 2014-07-09 13:32:00 +0000 | |
commit | a5d9e1e8d1a8914f4ac7f85c1ec4194f157bfb81 (patch) | |
tree | b187afe08c03f0f72cedd307a878bd1c55d5c608 /sys/kern/kern_rwlock.c | |
parent | Simplify error path of DH_check_pub_key() (diff) | |
download | wireguard-openbsd-a5d9e1e8d1a8914f4ac7f85c1ec4194f157bfb81.tar.xz wireguard-openbsd-a5d9e1e8d1a8914f4ac7f85c1ec4194f157bfb81.zip |
Teach rw_status() and rrw_status() to return LK_EXCLOTHER if it's write
locked by a different thread. Teach lockstatus() to return LK_EXCLUSIVE
if an exclusive lock is held by some other thread.
ok beck@ tedu@
Diffstat (limited to 'sys/kern/kern_rwlock.c')
-rw-r--r-- | sys/kern/kern_rwlock.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index a472b616400..e1def9e874d 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_rwlock.c,v 1.21 2014/01/21 01:48:44 tedu Exp $ */ +/* $OpenBSD: kern_rwlock.c,v 1.22 2014/07/09 13:32:00 guenther Exp $ */ /* * Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org> @@ -256,8 +256,12 @@ rw_exit(struct rwlock *rwl) int rw_status(struct rwlock *rwl) { - if (rwl->rwl_owner & RWLOCK_WRLOCK) - return RW_WRITE; + if (rwl->rwl_owner & RWLOCK_WRLOCK) { + if (RW_PROC(curproc) == RW_PROC(rwl->rwl_owner)) + return RW_WRITE; + else + return RW_WRITE_OTHER; + } if (rwl->rwl_owner) return RW_READ; return (0); |