Skip to content

Commit

Permalink
[SSI] Handle Finished() calls prior to response posting.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Mar 14, 2018
1 parent 27d4a17 commit d470513
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
18 changes: 13 additions & 5 deletions src/XrdSsi/XrdSsiSessReal.cc
Expand Up @@ -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="<<tP<<" id=" <<tP->ID());

// Delete this task or place it on the free list
//
Expand Down Expand Up @@ -389,7 +394,7 @@ bool XrdSsiSessReal::XeqEvent(XrdCl::XRootDStatus *status,
// Lock out mutex. Note that events like shutdown unlock the mutex
//
sessMutex.Lock();
XrdSsiTaskReal *tP = attBase;
XrdSsiTaskReal *ztP, *ntP, *tP = attBase;

// If we are not in the open phase then this is due to a close event. Simply
// do a shutdown and return to stop event processing.
Expand Down Expand Up @@ -441,11 +446,14 @@ bool XrdSsiSessReal::XeqEvent(XrdCl::XRootDStatus *status,
sessNode = strdup(currNode.c_str());
} else sessNode = strdup("Unknown!");

// Execute each pending request.
// Execute each pending request. Make sure not to reference the task object
// chain pointer after invoking SendRequest() as it may become invalid.
//
do {if (!tP->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
//
Expand Down
21 changes: 16 additions & 5 deletions src/XrdSsi/XrdSsiTaskReal.cc
Expand Up @@ -459,22 +459,33 @@ 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;
}

// Establish the endpoint
//
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
//
Expand Down

0 comments on commit d470513

Please sign in to comment.