/* create a new transaction, returning ptr to same with high ref count */
struct volser_trans *
-NewTrans(avol, apart)
- afs_int32 avol;
- afs_int32 apart;
+NewTrans(afs_int32 avol, afs_int32 apart)
{
/* set volid, next, partition */
register struct volser_trans *tt;
/* find a trans, again returning with high ref count */
struct volser_trans *
-FindTrans(atrans)
- register afs_int32 atrans;
+FindTrans(register afs_int32 atrans)
{
register struct volser_trans *tt;
VTRANS_LOCK;
}
/* delete transaction if refcount == 1, otherwise queue delete for later. Does implicit TRELE */
-DeleteTrans(atrans)
- register struct volser_trans *atrans;
+afs_int32
+DeleteTrans(register struct volser_trans *atrans, afs_int32 lock)
{
register struct volser_trans *tt, **lt;
afs_int32 error;
}
/* otherwise we zap it ourselves */
- VTRANS_LOCK;
+ if (lock) VTRANS_LOCK;
lt = &allTrans;
for (tt = *lt; tt; lt = &tt->next, tt = *lt) {
if (tt == atrans) {
tt->volume = NULL;
*lt = tt->next;
free(tt);
- VTRANS_UNLOCK;
+ if (lock) VTRANS_UNLOCK;
return 0;
}
}
- VTRANS_UNLOCK;
+ if (lock) VTRANS_UNLOCK;
return -1; /* failed to find the transaction in the generic list */
}
/* THOLD is a macro defined in volser.h */
/* put a transaction back */
-TRELE(at)
- register struct volser_trans *at;
+afs_int32
+TRELE(register struct volser_trans *at)
{
if (at->refCount == 0) {
Log("TRELE: bad refcount\n");
at->time = FT_ApproxTime(); /* we're still using it */
if (at->refCount == 1 && (at->tflags & TTDeleted)) {
- DeleteTrans(at);
+ DeleteTrans(at, 1);
return 0;
}
/* otherwise simply drop refcount */
#define OLDTRANSTIME 600 /* seconds */
#define OLDTRANSWARN 300 /* seconds */
static int GCDeletes = 0;
+afs_int32
GCTrans()
{
register struct volser_trans *tt, *nt;
if (tt->time + OLDTRANSTIME < now) {
Log("trans %u on volume %u has timed out\n", tt->tid, tt->volid);
tt->refCount++; /* we're using it now */
- DeleteTrans(tt); /* drops refCount or deletes it */
+ DeleteTrans(tt, 0); /* drops refCount or deletes it */
GCDeletes++;
}
}