summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_lock.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index c4588491077..55c3c7bd868 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_lock.c,v 1.37 2011/07/06 21:41:37 art Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.38 2011/08/28 02:35:34 guenther Exp $ */
/*
* Copyright (c) 1995
@@ -49,7 +49,9 @@
*/
/*
- * Acquire a resource.
+ * Acquire a resource. We sleep on the address of the lk_sharecount
+ * member normally; if waiting for it to drain we sleep on the address
+ * of the lk_waitcount member instead.
*/
#define ACQUIRE(lkp, error, extflags, drain, wanted) \
do { \
@@ -58,9 +60,8 @@ do { \
(lkp)->lk_flags |= LK_WAITDRAIN; \
else \
(lkp)->lk_waitcount++; \
- /* XXX Cast away volatile. */ \
error = tsleep((drain) ? \
- (void *)&(lkp)->lk_flags : (void *)(lkp), \
+ &(lkp)->lk_waitcount : &(lkp)->lk_sharecount, \
(lkp)->lk_prio, (lkp)->lk_wmesg, (lkp)->lk_timo); \
if ((drain) == 0) \
(lkp)->lk_waitcount--; \
@@ -197,7 +198,7 @@ lockmgr(__volatile struct lock *lkp, u_int flags, void *notused)
lkp->lk_flags &= ~LK_HAVE_EXCL;
SETHOLDER(lkp, LK_NOPROC, LK_NOCPU);
if (lkp->lk_waitcount)
- wakeup((void *)(lkp));
+ wakeup(&lkp->lk_sharecount);
break;
case LK_EXCLUSIVE:
@@ -266,7 +267,7 @@ lockmgr(__volatile struct lock *lkp, u_int flags, void *notused)
panic("lockmgr: release of unlocked lock!");
#endif
if (lkp->lk_waitcount)
- wakeup((void *)(lkp));
+ wakeup(&lkp->lk_sharecount);
break;
case LK_DRAIN:
@@ -309,7 +310,7 @@ lockmgr(__volatile struct lock *lkp, u_int flags, void *notused)
(LK_HAVE_EXCL | LK_WANT_EXCL)) == 0 &&
lkp->lk_sharecount == 0 && lkp->lk_waitcount == 0)) {
lkp->lk_flags &= ~LK_WAITDRAIN;
- wakeup((void *)&lkp->lk_flags);
+ wakeup(&lkp->lk_waitcount);
}
return (error);
}