summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorart <art@openbsd.org>2001-11-07 02:44:10 +0000
committerart <art@openbsd.org>2001-11-07 02:44:10 +0000
commitbabff26f53b7f7343f7ddd005732848a261129d2 (patch)
treec12625825ecab0c49f742d311f0bdfead5be14af
parentAdd MacOS X for Intel (or Darwin for Intel, or whatever the correct (diff)
downloadwireguard-openbsd-babff26f53b7f7343f7ddd005732848a261129d2.tar.xz
wireguard-openbsd-babff26f53b7f7343f7ddd005732848a261129d2.zip
new flag to lockmgr. LK_RECURSEFAIL - even if the lock can recurse fail.
-rw-r--r--sys/kern/kern_lock.c9
-rw-r--r--sys/sys/lock.h21
2 files changed, 18 insertions, 12 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index a40ee24d847..1da1663f8d0 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_lock.c,v 1.9 1999/07/09 15:17:59 art Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.10 2001/11/07 02:44:10 art Exp $ */
/*
* Copyright (c) 1995
@@ -318,8 +318,13 @@ lockmgr(lkp, flags, interlkp, p)
/*
* Recursive lock.
*/
- if ((extflags & LK_CANRECURSE) == 0)
+ if ((extflags & LK_CANRECURSE) == 0) {
+ if (extflags & LK_RECURSEFAIL) {
+ error = EDEADLK;
+ break;
+ }
panic("lockmgr: locking against myself");
+ }
lkp->lk_exclusivecount++;
COUNT(p, 1);
break;
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
index 1f6d285289e..1683e5693a4 100644
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lock.h,v 1.7 2001/10/26 02:28:47 art Exp $ */
+/* $OpenBSD: lock.h,v 1.8 2001/11/07 02:44:10 art Exp $ */
/*
* Copyright (c) 1995
@@ -113,30 +113,31 @@ struct lock {
* or passed in as arguments to the lock manager. The LK_REENABLE flag may be
* set only at the release of a lock obtained by drain.
*/
-#define LK_EXTFLG_MASK 0x00000070 /* mask of external flags */
+#define LK_EXTFLG_MASK 0x00000770 /* mask of external flags */
#define LK_NOWAIT 0x00000010 /* do not sleep to await lock */
#define LK_SLEEPFAIL 0x00000020 /* sleep, then return failure */
#define LK_CANRECURSE 0x00000040 /* allow recursive exclusive lock */
#define LK_REENABLE 0x00000080 /* lock is be reenabled after drain */
+#define LK_RECURSEFAIL 0x00000100 /* fail if recursive exclusive lock */
/*
* Internal lock flags.
*
* These flags are used internally to the lock manager.
*/
-#define LK_WANT_UPGRADE 0x00000100 /* waiting for share-to-excl upgrade */
-#define LK_WANT_EXCL 0x00000200 /* exclusive lock sought */
-#define LK_HAVE_EXCL 0x00000400 /* exclusive lock obtained */
-#define LK_WAITDRAIN 0x00000800 /* process waiting for lock to drain */
-#define LK_DRAINING 0x00004000 /* lock is being drained */
-#define LK_DRAINED 0x00008000 /* lock has been decommissioned */
+#define LK_WANT_UPGRADE 0x00001000 /* waiting for share-to-excl upgrade */
+#define LK_WANT_EXCL 0x00002000 /* exclusive lock sought */
+#define LK_HAVE_EXCL 0x00004000 /* exclusive lock obtained */
+#define LK_WAITDRAIN 0x00008000 /* process waiting for lock to drain */
+#define LK_DRAINING 0x00040000 /* lock is being drained */
+#define LK_DRAINED 0x00080000 /* lock has been decommissioned */
/*
* Control flags
*
* Non-persistent external flags.
*/
-#define LK_INTERLOCK 0x00010000 /* unlock passed simple lock after
+#define LK_INTERLOCK 0x00100000 /* unlock passed simple lock after
getting lk_interlock */
-#define LK_RETRY 0x00020000 /* vn_lock: retry until locked */
+#define LK_RETRY 0x00200000 /* vn_lock: retry until locked */
/*
* Lock return status.