((((lock)->excl_locked & WRITE_LOCK) || (lock)->readers_reading) ? 0 : 1)
struct Lock rwlock;
-int rwlockinit = 1;
+
+/*!
+ * \Initialize locks
+ */
+void
+ulock_Init(void)
+{
+ Lock_Init(&rwlock);
+}
/*!
* \brief Set a transaction lock.
{
struct ubik_dbase *dbase = atrans->dbase;
- /* On first pass, initialize the lock */
- if (rwlockinit) {
- Lock_Init(&rwlock);
- rwlockinit = 0;
- }
-
if ((atype != LOCKREAD) && (atype != LOCKWRITE))
return EINVAL;
void
ulock_relLock(struct ubik_trans *atrans)
{
- if (rwlockinit)
- return;
-
if (atrans->locktype == LOCKWRITE && (atrans->flags & TRREADWRITE)) {
ubik_print("Ubik: Internal Error: unlocking write lock with "
"TRREADWRITE?\n");
void
ulock_Debug(struct ubik_debug *aparm)
{
- if (rwlockinit) {
- aparm->anyReadLocks = 0;
- aparm->anyWriteLocks = 0;
- } else {
- aparm->anyReadLocks = rwlock.readers_reading;
- aparm->anyWriteLocks = ((rwlock.excl_locked == WRITE_LOCK) ? 1 : 0);
- }
+ aparm->anyReadLocks = rwlock.readers_reading;
+ aparm->anyWriteLocks = ((rwlock.excl_locked == WRITE_LOCK) ? 1 : 0);
}
/*\}*/
/*! \name lock.c */
+extern void ulock_Init(void);
extern int ulock_getLock(struct ubik_trans *atrans, int atype, int await);
extern void ulock_relLock(struct ubik_trans *atrans);
extern void ulock_Debug(struct ubik_debug *aparm);