From: Derrick Brashear Date: Thu, 22 Mar 2007 15:58:45 +0000 (+0000) Subject: tvolser-locking-updates-20070322 X-Git-Tag: BP-openafs-windows-kdfs-ifs~753 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=1c9ede0bcf892ccc3b9b5cae819c7d94b0407b38;p=packages%2Fo%2Fopenafs.git tvolser-locking-updates-20070322 rework locking in tvolser slightly to avoid potential transaction leak --- diff --git a/src/volser/voltrans.c b/src/volser/voltrans.c index b6bad2928..0ef9acba1 100644 --- a/src/volser/voltrans.c +++ b/src/volser/voltrans.c @@ -137,21 +137,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; @@ -168,18 +171,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; }