Skip to content

Commit

Permalink
[Server] Make endsess more reliable.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Mar 12, 2018
1 parent 76ed756 commit f1b80ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/Xrd/XrdLink.cc
Expand Up @@ -1277,12 +1277,11 @@ int XrdLink::Terminate(const XrdLink *owner, int fdnum, unsigned int inst)
XrdSysCondVar killDone(0);
XrdLink *lp;
char buff[1024], *cp;
int wTime, didKW = KillCnt & KillXwt;
int wTime, killTries;

// Find the correspodning link
//
KillCnt = KillCnt & KillMsk;
if (!(lp = fd2link(fdnum, inst))) return (didKW ? -EPIPE : -ESRCH);
if (!(lp = fd2link(fdnum, inst))) return -ESRCH;

// If this is self termination, then indicate that to the caller
//
Expand Down Expand Up @@ -1314,18 +1313,22 @@ int XrdLink::Terminate(const XrdLink *owner, int fdnum, unsigned int inst)

// Check if we have too many tries here
//
if (lp->KillCnt > KillMax)
killTries = lp->KillCnt & KillMsk;
if (killTries > KillMax)
{lp->opMutex.UnLock();
return -ETIME;
}
wTime = lp->KillCnt++;

// Wait time increases as we have more unsuccessful kills. Update numbers.
//
wTime = killTries++;
lp->KillCnt = killTries | KillXwt;

// Make sure we can disable this link. Of not, then force the caller to wait
// a tad more than the read timeout interval.
//
if (!(lp->isEnabled) || lp->InUse > 1 || lp->KillcvP)
{wTime = wTime*2+waitKill;
KillCnt |= KillXwt;
lp->opMutex.UnLock();
return (wTime > 60 ? 60: wTime);
}
Expand All @@ -1344,7 +1347,7 @@ int XrdLink::Terminate(const XrdLink *owner, int fdnum, unsigned int inst)

// Now wait for the link to shutdown. This avoids lock problems.
//
if (killDone.Wait(int(killWait))) {wTime += killWait; KillCnt |= KillXwt;}
if (killDone.Wait(int(killWait))) wTime += killWait;
else wTime = -EPIPE;
killDone.UnLock();

Expand Down
3 changes: 1 addition & 2 deletions src/XrdXrootd/XrdXrootdXeq.cc
Expand Up @@ -706,13 +706,12 @@ int XrdXrootdProtocol::do_Endsess()
TRACEP(LOGIN, "endsess " <<sessID.Pid <<':' <<sessID.FD <<'.' <<sessID.Inst
<<" rc=" <<rc <<" (" <<strerror(rc < 0 ? -rc : EAGAIN) <<")");

// Return result
// Return result. We only return obvious problems (exclude ESRCH and EPIPE).
//
if (rc > 0)
return (rc = Response.Send(kXR_wait, rc, "session still active")) ? rc:1;

if (rc == -EACCES)return Response.Send(kXR_NotAuthorized, "not session owner");
if (rc == -ESRCH) return Response.Send(kXR_NotFound, "session not found");
if (rc == -ETIME) return Response.Send(kXR_Cancelled,"session not ended");

return Response.Send();
Expand Down

0 comments on commit f1b80ae

Please sign in to comment.