mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
STABLE14-tvolser-locking-updates-20070322
rework locking in tvolser slightly to avoid potential transaction leak (cherry picked from commit 1c9ede0bcf892ccc3b9b5cae819c7d94b0407b38)
This commit is contained in:
parent
27eeffdced
commit
739e6e3de5
@ -138,21 +138,24 @@ DeleteTrans(register struct volser_trans *atrans, afs_int32 lock)
|
||||
register struct volser_trans *tt, **lt;
|
||||
afs_int32 error;
|
||||
|
||||
if (lock) VTRANS_LOCK;
|
||||
if (atrans->refCount > 1) {
|
||||
/* someone else is using it now */
|
||||
atrans->refCount--;
|
||||
atrans->tflags |= TTDeleted;
|
||||
if (lock) VTRANS_UNLOCK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* otherwise we zap it ourselves */
|
||||
if (lock) VTRANS_LOCK;
|
||||
lt = &allTrans;
|
||||
for (tt = *lt; tt; lt = &tt->next, tt = *lt) {
|
||||
if (tt == atrans) {
|
||||
if (tt->volume)
|
||||
VDetachVolume(&error, tt->volume);
|
||||
tt->volume = NULL;
|
||||
if (tt->rxCallPtr)
|
||||
rxi_CallError(tt->rxCallPtr, RX_CALL_DEAD);
|
||||
*lt = tt->next;
|
||||
free(tt);
|
||||
if (lock) VTRANS_UNLOCK;
|
||||
@ -169,18 +172,22 @@ DeleteTrans(register struct volser_trans *atrans, afs_int32 lock)
|
||||
afs_int32
|
||||
TRELE(register struct volser_trans *at)
|
||||
{
|
||||
VTRANS_LOCK;
|
||||
if (at->refCount == 0) {
|
||||
Log("TRELE: bad refcount\n");
|
||||
VTRANS_UNLOCK;
|
||||
return VOLSERTRELE_ERROR;
|
||||
}
|
||||
|
||||
at->time = FT_ApproxTime(); /* we're still using it */
|
||||
if (at->refCount == 1 && (at->tflags & TTDeleted)) {
|
||||
DeleteTrans(at, 1);
|
||||
DeleteTrans(at, 0);
|
||||
VTRANS_UNLOCK;
|
||||
return 0;
|
||||
}
|
||||
/* otherwise simply drop refcount */
|
||||
at->refCount--;
|
||||
VTRANS_UNLOCK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user