From 739e6e3de58f7f82e37f145a769b16fb141e561f Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Thu, 22 Mar 2007 16:01:16 +0000 Subject: [PATCH] STABLE14-tvolser-locking-updates-20070322 rework locking in tvolser slightly to avoid potential transaction leak (cherry picked from commit 1c9ede0bcf892ccc3b9b5cae819c7d94b0407b38) --- src/volser/voltrans.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/volser/voltrans.c b/src/volser/voltrans.c index 8a137bca3c..d95bb2fcac 100644 --- a/src/volser/voltrans.c +++ b/src/volser/voltrans.c @@ -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; }