From 8525230afdff322688792cbc17a9899e7d755659 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 26 Feb 2007 19:05:13 +0000 Subject: [PATCH] Add rw_wowned() interface to rwlock(9), allowing a kernel thread to determine if it holds an exclusive rwlock reference or not. This is non-ideal, but recursion scenarios in the network stack currently require it. Approved by: jhb --- sys/kern/kern_rwlock.c | 7 +++++++ sys/sys/rwlock.h | 1 + 2 files changed, 8 insertions(+) diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index a59de60008fd..18e9a544153c 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -108,6 +108,13 @@ rw_sysinit(void *arg) rw_init(args->ra_rw, args->ra_desc); } +int +rw_wowned(struct rwlock *rw) +{ + + return (rw_wowner(rw) == curthread); +} + void _rw_wlock(struct rwlock *rw, const char *file, int line) { diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h index 98692a79dc14..13a54365a4d5 100644 --- a/sys/sys/rwlock.h +++ b/sys/sys/rwlock.h @@ -124,6 +124,7 @@ void rw_init(struct rwlock *rw, const char *name); void rw_destroy(struct rwlock *rw); void rw_sysinit(void *arg); +int rw_wowned(struct rwlock *rw); void _rw_wlock(struct rwlock *rw, const char *file, int line); void _rw_wunlock(struct rwlock *rw, const char *file, int line); void _rw_rlock(struct rwlock *rw, const char *file, int line);