67 if (manNode) {free(manNode); manNode = 0;}
81 XrdSsiSessReal *XrdSsiServReal::Alloc(
const char *sName,
int uent,
bool hold)
97 {myMutex.Lock(); actvSes--; myMutex.UnLock();}
106 bool XrdSsiServReal::GenURL(
XrdSsiResource *rP,
char *buff,
int blen,
int uEnt)
108 static const char affTab[] =
"\0\0n\0w\0s\0S";
109 const char *xUsr, *xAt, *iSep, *iVal, *tVar, *tVal, *uVar, *uVal;
110 const char *aVar, *aVal, *qVal =
"";
116 if (rP->
hAvoid.length() == 0) tVar = tVal =
"";
117 else {tVar =
"&tried=";
118 tVal = rP->
hAvoid.c_str();
124 if (!(rP->
affinity)) aVar = aVal =
"";
125 else {aVar =
"&cms.aff=";
132 if (rP->
rUser.length() == 0) uVar = uVal =
"";
133 else {uVar =
"&ssi.user=";
134 uVal = rP->
rUser.c_str();
140 if (rP->
rInfo.length() == 0) iSep = iVal =
"";
141 else {iVal = rP->
rInfo.c_str();
148 if (uEnt == 0) xUsr = xAt =
"";
149 else {snprintf(uBuff,
sizeof(uBuff),
"%d", uEnt);
156 n = snprintf(buff, blen,
"xroot://%s%s%s/%s%s%s%s%s%s%s%s%s%s",
157 xUsr, xAt, manNode, rP->
rName.c_str(), qVal,
158 tVar, tVal, aVar, aVal,
159 uVar, uVal, iSep, iVal);
184 if (resRef.
rName.length() == 0)
192 if (resRef.
rOpts & useCache)
193 {mHelp.
Lock(&rcMutex);
194 if (ResReuse(reqRef, resRef, resKey))
return;
206 if (!GenURL(&resRef, epURL,
sizeof(epURL), uEnt))
214 if (!(sObj = Alloc(resRef.
rName.c_str(), uEnt, hold)))
223 if (hold) sObj->
SetKey(resKey.c_str());
229 if (!(sObj->
Provision(&reqRef, epURL))) Recycle(sObj,
false);
235 if (hold) resCache[resKey] = sObj;
245 static const char *
tident = 0;
255 if ((resKey = sObj->
GetKey())) StopReuse(resKey);
261 DEBUG(
"Sess " <<sObj->
GetSID() <<
"# reuse=" <<reuse <<
" free=" <<freeCnt
262 <<
" active=" <<actvSes);
264 doDel = ((actvSes == 0 && doStop) || !reuse || freeCnt >= freeMax);
266 DEBUG(
"reuse=" <<reuse <<
" del=" <<doDel
267 <<
"; sessions: free=" <<freeCnt <<
" active=" <<actvSes);
269 if (doDel) {myMutex.UnLock();
delete sObj;}
287 std::map<std::string, XrdSsiSessReal *>::iterator it;
292 resKey.reserve(resRef.
rUser.size() + resRef.
rName.size() + 2);
293 resKey = resRef.
rUser;
295 resKey += resRef.
rName;
299 it = resCache.find(resKey);
300 if (it == resCache.end())
return false;
307 if (doDiscard || !sesP->
Run(&reqRef))
328 {
if (immed) {myMutex.UnLock();
return false;}
345 static const char *
tident =
"ServReuse";
346 std::map<std::string, XrdSsiSessReal *>::iterator it;
351 it = resCache.find(resKey);
352 if (it != resCache.end())
354 DEBUG(
"resCache " <<resKey <<
" removed.");
static bool isaRetry(XrdSsiRequest *rP, bool reset=false)
std::string rUser
-> Name of the resource user (nil if anonymous)
uint32_t rOpts
Resource options. One or more of he following:
Affinity affinity
Resource affinity.
std::string rInfo
-> Additional information in CGI format
static const uint32_t Reusable
std::string rName
-> Name of the resource to be used
std::string hAvoid
-> Comma separated list of hosts to avoid
static const uint32_t Discard
Resource context may be cached and reused
void ProcessRequest(XrdSsiRequest &reqRef, XrdSsiResource &resRef)
Process a request; client-side or server-side.
void StopReuse(const char *resKey)
void Recycle(XrdSsiSessReal *sObj, bool reuse)
bool Stop(bool immed=false)
Stop the client-side service. This is never called server-side.
void InitSession(XrdSsiServReal *servP, const char *sName, int uent, bool hold, bool newSID=false)
void SetKey(const char *key)
bool Provision(XrdSsiRequest *reqP, const char *epURL)
bool Run(XrdSsiRequest *reqP)
XrdSsiSessReal * nextSess
void UnHold(bool cleanup=true)
static void RetErr(XrdSsiRequest &reqP, const char *eTxt, int eNum)
void Lock(XrdSysMutex *Mutex)