diff --git a/src/XrdSsi/XrdSsiSessReal.cc b/src/XrdSsi/XrdSsiSessReal.cc index 38f0b2bf9e3..a9a47ca0a95 100644 --- a/src/XrdSsi/XrdSsiSessReal.cc +++ b/src/XrdSsi/XrdSsiSessReal.cc @@ -237,6 +237,11 @@ bool XrdSsiSessReal::Provision(XrdSsiRequest *reqP, const char *epURL) void XrdSsiSessReal::RelTask(XrdSsiTaskReal *tP) // sessMutex locked! { + EPNAME("RelTask"); + +// Do some debugging here +// + DEBUG((isHeld ? "Recycling" : "Deleting")<<" task="<SendRequest(sessNode)) noReuse = true; - tP = tP->attList.next; - } while(tP != attBase); + ztP = attBase; + do {ntP = tP->attList.next; + if (!tP->SendRequest(sessNode)) noReuse = true; + tP = ntP; + } while(tP != ztP); // We are done, field the next event // diff --git a/src/XrdSsi/XrdSsiTaskReal.cc b/src/XrdSsi/XrdSsiTaskReal.cc index d18104ebec1..4a0c5984049 100644 --- a/src/XrdSsi/XrdSsiTaskReal.cc +++ b/src/XrdSsi/XrdSsiTaskReal.cc @@ -459,12 +459,13 @@ bool XrdSsiTaskReal::SendRequest(const char *node) int reqBlen; // We must be in pend state to send a request. If we are not then the request -// must have been cancelled. It also means we have a logic error since this -// should never have happened. Issue a message and ignore this request. +// must have been cancelled. It also means we have a logic error if the +// state is not isDead as we can't finish off the task and leak memory. // if (tStat != isPend) - {Log.Emsg("SendRequest", "Invalid state", statName[tStat], - "; should be isPend!"); + {if (tStat == isDead) sessP->TaskFinished(this); + else Log.Emsg("SendRequest", "Invalid state", statName[tStat], + "; should be isPend!"); return false; } @@ -472,9 +473,19 @@ bool XrdSsiTaskReal::SendRequest(const char *node) // XrdSsiRRAgent::SetNode(XrdSsiRRAgent::Request(this), node); -// Get the request information +// Get the request information. Make sure to defer Finish() calls. // + defer = true; reqBuff = XrdSsiRRAgent::Request(this)->GetRequest(reqBlen); + defer = false; + +// It's possible that GetRequest() called finished so process that here. +// + if (tStat == isDead) + {sessP->TaskFinished(this); + return false; + } + // Construct the info for this request //