about summary refs log tree commit diff
path: root/db2/include/lock.h
diff options
context:
space:
mode:
Diffstat (limited to 'db2/include/lock.h')
-rw-r--r--db2/include/lock.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/db2/include/lock.h b/db2/include/lock.h
index 47a38b8783..13364ca7a5 100644
--- a/db2/include/lock.h
+++ b/db2/include/lock.h
@@ -4,7 +4,7 @@
  * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  *
- *	@(#)lock.h	10.15 (Sleepycat) 5/10/98
+ *	@(#)lock.h	10.17 (Sleepycat) 1/3/99
  */
 
 typedef struct __db_lockobj	DB_LOCKOBJ;
@@ -22,6 +22,12 @@ typedef struct __db_lockobj	DB_LOCKOBJ;
  */
 #define DB_LOCK_MAXID		0x7fffffff
 
+/* Check for region catastrophic shutdown. */
+#define	LOCK_PANIC_CHECK(lt) {						\
+	if ((lt)->region->hdr.panic)					\
+		return (DB_RUNRECOVERY);				\
+}
+
 /*
  * The lock region consists of:
  *	The DB_LOCKREGION structure (sizeof(DB_LOCKREGION)).
@@ -135,10 +141,24 @@ struct __db_lock {
 	u_int32_t	refcount;	/* Reference count the lock. */
 	db_lockmode_t	mode;		/* What sort of lock. */
 	ssize_t		obj;		/* Relative offset of object struct. */
+	size_t		txnoff;		/* Offset of holding transaction. */
 	db_status_t	status;		/* Status of this lock. */
 };
 
 /*
+ * This is a serious layering violation.  To support nested transactions, we
+ * need to be able to tell that a lock is held by a transaction (as opposed to
+ * some other locker) and to be able to traverse the parent/descendent chain.
+ * In order to do this, each lock held by a transaction maintains a reference
+ * to the shared memory transaction structure so it can be accessed during lock
+ * promotion.  As the structure is in shared memory, we cannot store a pointer
+ * to it, so we use the offset within the region.  As nothing lives at region
+ * offset 0, we use that to indicate that there is no transaction associated
+ * with the current lock.
+ */
+#define TXN_IS_HOLDING(L)	((L)->txnoff != 0 /* INVALID_REG_OFFSET */)
+
+/*
  * We cannot return pointers to the user (else we cannot easily grow regions),
  * so we return offsets in the region.  These must be converted to and from
  * regular pointers.  Always use the macros below.