Skip to content

Commit

Permalink
Correct lock loophole introduced by commit d9014d7 that may cause SEGV.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Feb 25, 2015
1 parent 32672af commit 84147c4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/XrdOfs/XrdOfsHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ const char *XrdOfsHandle::PoscUsr()

int XrdOfsHandle::Retire(int &retc, long long *retsz, char *buff, int blen)
{
XrdOssDF *mySSI;
int numLeft;

// Get the global lock as the links field can only be manipulated with it.
Expand All @@ -390,12 +391,14 @@ int XrdOfsHandle::Retire(int &retc, long long *retsz, char *buff, int blen)
{if (buff) strlcpy(buff, Path.Val, blen);
numLeft = 0; OfsStats.Dec(OfsStats.Data.numHandles);
if ( (isRW ? rwTable.Remove(this) : roTable.Remove(this)) )
{Next = Free; Free = this; myMutex.UnLock();
{Next = Free; Free = this;
if (Posc) {Posc->Recycle(); Posc = 0;}
if (Path.Val) {free((void *)Path.Val); Path.Val = (char *)"";}
Path.Len = 0;
if (ssi && ssi != ossDF)
{retc = ssi->Close(retsz); delete ssi; ssi = ossDF;}
if ((mySSI = ssi) && ssi != ossDF)
{ssi = ossDF; myMutex.UnLock();
retc = mySSI->Close(retsz); delete mySSI;
} else myMutex.UnLock();
} else {
myMutex.UnLock();
OfsEroute.Emsg("Retire", "Lost handle to", Path.Val);
Expand Down

0 comments on commit 84147c4

Please sign in to comment.