OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/ubik/lock.c File Reference

Locks hang off of each transaction, with all the transaction hanging off of the appropriate dbase. More...

#include <afsconfig.h>
#include <afs/param.h>
#include <roken.h>
#include <afs/opr.h>
#include <lock.h>
#include "ubik.h"
#include "ubik_int.h"

Defines

#define UBIK_INTERNALS   1
#define WouldReadBlock(lock)   ((((lock)->excl_locked & WRITE_LOCK) || (lock)->wait_states) ? 0 : 1)
#define WouldWriteBlock(lock)   ((((lock)->excl_locked & WRITE_LOCK) || (lock)->readers_reading) ? 0 : 1)

Functions

void ulock_Init (void)
 locks
int ulock_getLock (struct ubik_trans *atrans, int atype, int await)
 Set a transaction lock.
void ulock_relLock (struct ubik_trans *atrans)
 Release the transaction lock.
void ulock_Debug (struct ubik_debug *aparm)
 debugging hooks

Variables

struct Lock rwlock

Detailed Description

Locks hang off of each transaction, with all the transaction hanging off of the appropriate dbase.

This package expects to be used in a two-phase locking protocol, so it doesn't provide a way to release anything but all of the locks in the transaction.

At present, it doesn't support the setting of more than one byte-position lock at a time, that is the length field must be 1. This doesn't mean that a single transaction can't set more than one lock, however.

It is the responsibility of the user to avoid deadlock by setting locks in a partial order.

#EWOULDBLOCK has been replaced in this file by #EAGAIN. Many Unix's but not all (eg. HP) do not replace #EWOULDBLOCK with #EAGAIN. The bad news is this goes over the wire. The good news is that the code path is never triggered as it requires ulock_getLock to be called with await = 0. And ulock_SetLock isn't even used in this code base. Since NT doesn't have a native #EAGAIN, we are replacing all instances of #EWOULDBLOCK with #EAGAIN.


Function Documentation

int ulock_getLock ( struct ubik_trans atrans,
int  atype,
int  await 
)

Set a transaction lock.

Parameters:
atypeis #LOCKREAD or #LOCKWRITE.
awaitis TRUE if you want to wait for the lock instead of returning #EWOULDBLOCK.
Note:
The #DBHOLD lock must be held.
 All Data Structures Files Functions Variables