mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 13:38:01 +00:00
ubik: add lock initialization function
Add a new lock initialization function and call it from the initialization sequence. Users of the locks can assume that they are already initialized. Change-Id: I8e86f460cb705c8de12bac9367358c93f1423591 Reviewed-on: http://gerrit.openafs.org/4141 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
parent
ba80a8a88b
commit
d6a627d1e5
@ -54,7 +54,15 @@
|
||||
((((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.
|
||||
@ -69,12 +77,6 @@ ulock_getLock(struct ubik_trans *atrans, int atype, int await)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -135,9 +137,6 @@ ulock_getLock(struct ubik_trans *atrans, int atype, int await)
|
||||
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");
|
||||
@ -167,11 +166,6 @@ ulock_relLock(struct ubik_trans *atrans)
|
||||
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);
|
||||
}
|
||||
|
@ -424,6 +424,7 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
|
||||
return code;
|
||||
|
||||
udisk_Init(ubik_nBuffers);
|
||||
ulock_Init();
|
||||
|
||||
ubik_callPortal = myPort;
|
||||
/* try to get an additional security object */
|
||||
|
@ -437,6 +437,7 @@ extern int udisk_end(struct ubik_trans *atrans);
|
||||
/*\}*/
|
||||
|
||||
/*! \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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user