Skip to content

Commit

Permalink
[SSI] Prevent request ID conflicts with reusable resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Apr 6, 2018
1 parent e341f47 commit 29958f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/XrdSsi/XrdSsiSessReal.cc
Expand Up @@ -170,13 +170,20 @@ XrdSsiTaskReal *XrdSsiSessReal::NewTask(XrdSsiRequest *reqP)
// Allocate a task object for this request
//
if ((tP = freeTask)) freeTask = tP->attList.next;
else {if (!alocLeft || !(tP = new XrdSsiTaskReal(this, nextTID)))
else {if (!alocLeft || !(tP = new XrdSsiTaskReal(this)))
{XrdSsiUtils::RetErr(*reqP, "Too many active requests.", EMLINK);
return 0;
}
alocLeft--; nextTID++;
alocLeft--;
}

// We always set a new task ID to avoid ID collisions. his is good for over
// 194 days if we have 1 request/second. In practice. this will work for a
// couple of years before wrapping. By then the ID's should be free.
//
tP->SetTaskID(nextTID++);
nextTID &= XrdSsiRRInfo::idMax;

// Initialize the task and return its pointer
//
tP->Init(reqP, reqP->GetTimeOut());
Expand Down
8 changes: 4 additions & 4 deletions src/XrdSsi/XrdSsiTaskReal.hh
Expand Up @@ -83,14 +83,14 @@ int SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen, bool &last);

bool SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen);

void SetTaskID(short tid) {tskID = tid;}
void SetTaskID(uint32_t tid) {tskID = tid;}

bool XeqEvent(XrdCl::XRootDStatus *status, XrdCl::AnyObject **respP);

XrdSsiTaskReal(XrdSsiSessReal *sP, short tid)
XrdSsiTaskReal(XrdSsiSessReal *sP)
: XrdSsiEvent("TaskReal"),
XrdSsiStream(XrdSsiStream::isPassive),
sessP(sP), mdResp(0), wPost(0), tskID(tid),
sessP(sP), mdResp(0), wPost(0), tskID(0),
mhPend(false), defer(false)
{}

Expand All @@ -116,8 +116,8 @@ XrdSysSemaphore *wPost;
char *dataBuff;
int dataRlen;
TaskStat tStat;
uint32_t tskID;
unsigned short tmOut;
short tskID;
bool mhPend;
bool defer;
};
Expand Down

0 comments on commit 29958f6

Please sign in to comment.