70 : curitem ->dlvar .next);\
71 curitem ->dlvar .prev-> dlvar .next = curitem ->dlvar .next;\
72 curitem ->dlvar .next-> dlvar .prev = curitem ->dlvar .prev;\
73 curitem ->dlvar .next = curitem;\
74 curitem ->dlvar .prev = curitem
75
76
77
78
79
80namespace
81{
82 std::string dsProperty("DataServer");
84
85 Atomic(uint32_t) sidVal(0);
86}
87
88
89
90
91
93{
95
98}
99
100
101
102
103
104namespace
105{
106class CleanUp :
public XrdJob
107{
108public:
109
110void DoIt() {sessP->Lock();
111 sessP->Unprovision();
112 delete this;
113 }
114
116 ~CleanUp() {}
117
118private:
120};
121}
122
123
124
125
126
128{
130
131 if (resKey) free(resKey);
132 if (sessName) free(sessName);
133 if (sessNode) free(sessNode);
134
135 while((tP = freeTask)) {freeTask = tP->
attList.
next;
delete tP;}
136}
137
138
139
140
141
143 int uent, bool hold, bool newSID)
144{
146 requestP = 0;
147 uEnt = uent;
148 attBase = 0;
149 freeTask = 0;
150 myService = servP;
151 nextTID = 0;
153 isHeld = hold;
154 inOpen = false;
155 noReuse = false;
156 if (resKey) {free(resKey); resKey = 0;}
157 if (sessName) free(sessName);
158 sessName = (sName ? strdup(sName) : 0);
159 if (sessNode) free(sessNode);
160 sessNode = 0;
161 if (newSID)
162 {if (servP == 0) sessID = 0xffffffff;
167 DEBUG(
"new sess for "<<sName<<
" uent="<<uent<<
" hold="<<hold);
168 }
169 } else {
170 DEBUG(
"reuse sess for "<<sName<<
" uent="<<uent<<
" hold="<<hold);
171 }
172}
173
174
175
176
177
178
179
181{
184
185
186
190 return 0;
191 }
192 alocLeft--;
193 }
194
195
196
197
198
201
202
203
205 DEBUG(
"New task=" <<tP <<
" id=" <<tP->
ID());
206
207
208
209 if ((ptP = attBase)) {
INSERT(attList, ptP, tP);}
210 else attBase = tP;
211
212
213
214
217 return tP;
218}
219
220
221
222
223
225{
230
231
232
234
235
236
237 DEBUG(
"Provisioning " <<epURL);
238 epStatus =
epFile.
Open((
const std::string)epURL, oFlags,
242
243
244
245
246 if (!epStatus.
IsOK())
247 {std::string eTxt;
251 return false;
252 }
253
254
255
256 NewTask(reqP);
257 inOpen = true;
258 return true;
259}
260
261
262
263
264
266{
268
269
270
271 DEBUG((isHeld ?
"Recycling":
"Deleting")<<
" task="<<tP<<
" id=" <<tP->
ID());
272
273
274
275 if (!isHeld) delete tP;
278 freeTask = tP;
279 }
280}
281
282
283
284
285
287{
290
291
292
293 if (noReuse) return false;
294
295
296
298
299
300
301 tP = NewTask(reqP);
302
303
304
305 if (!inOpen && tP && !tP->
SendRequest(sessNode)) noReuse =
true;
306 return true;
307}
308
309
310
311
312
313
314
316{
318
319
320
321 while((tP = ntP)) {ntP = tP->
attList.
next;
delete tP;}
322 freeTask = 0;
323
324
325
326 if (onClose && !epStatus.
IsOK())
327 {std::string eText;
329 char mBuff[1024];
330 snprintf(mBuff, sizeof(mBuff), "Unprovision: %s@%s error; %d",
331 sessName, sessNode, eNum);
332 Log.
Emsg(
"Shutdown", mBuff, eText.c_str());
334 myService->
Recycle(
this,
false);
335 } else {
336 if (sessName) {free(sessName); sessName = 0;}
337 if (sessNode) {free(sessNode); sessNode = 0;}
339 myService->
Recycle(
this, !noReuse);
340 }
341}
342
343
344
345
346
348{
350
351
353
354
355
357 {
REMOVE(attBase, attList, tP);}
358 RelTask(tP);
359
360
361
363
364
365
366
367
368
369
370
371
372
373 if (!inOpen)
376 } else {
377 DEBUG(
"Unprovision deferred for " <<sessName);
379 }
380}
381
382
383
384
385
387{
389
390
391
392 if (isHeld && resKey && myService) myService->
StopReuse(resKey);
393
394
395
396 isHeld = false;
398}
399
400
401
402
403
404
405
406
408{
411
412
413
414 DEBUG(
"Closing " <<sessName);
415
416
417
418
419
420 if (!
epFile.
IsOpen()) {Shutdown(uStat,
false);
return false;}
422 if (!uStat.
IsOK()) {Shutdown(uStat,
true);
return false;}
424 }
425 return true;
426}
427
428
429
430
431
434{
435
436
437
440
441
442
443
444 if (!inOpen)
445 {Shutdown(*status, true);
446 return -1;
447 }
448
449
450
451
452 inOpen = false;
453 noReuse = !status->
IsOK();
454
455
456
457
458 if (!tP)
459 {if (isHeld)
461 return 1;
462 }
463 if (!status->
IsOK()) {Shutdown(*status,
false);
return -1;}
464 else {
if (!isHeld)
return (
Unprovision() ? 1 : -1);
466 }
467 return 1;
468 }
469
470
471
472
473
478 while(tP != attBase);
480 return -1;
481 }
482
483
484
485 std::string currNode;
487 {if (sessNode) free(sessNode);
488 sessNode = strdup(currNode.c_str());
489 } else sessNode = strdup("Unknown!");
490
491
492
493
494 ztP = attBase;
497 tP = ntP;
498 } while(tP != ztP);
499
500
501
503 return 0;
504}
#define REMOVE(dlbase, dlvar, curitem)
#define INSERT(dlvar, curitem, newitem)
XRootDStatus Close(ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
bool IsOpen() const
Check if the file is open.
XRootDStatus Open(const std::string &url, OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
bool GetProperty(const std::string &name, std::string &value) const
Handle an async response.
void Schedule(XrdJob *jp)
static void SetMutex(XrdSsiRequest *rP, XrdSsiMutex *mP)
static bool isaRetry(XrdSsiRequest *rP, bool reset=false)
static const unsigned int idMax
void BindRequest(XrdSsiRequest &rqstR)
void StopReuse(const char *resKey)
void Recycle(XrdSsiSessReal *sObj, bool reuse)
void InitSession(XrdSsiServReal *servP, const char *sName, int uent, bool hold, bool newSID=false)
bool Provision(XrdSsiRequest *reqP, const char *epURL)
bool Run(XrdSsiRequest *reqP)
int XeqEvent(XrdCl::XRootDStatus *status, XrdCl::AnyObject **respP)
void UnHold(bool cleanup=true)
void TaskFinished(XrdSsiTaskReal *tP)
void Init(XrdSsiRequest *rP, unsigned short tmo=0)
void SchedError(XrdSsiErrInfo *eInfo=0)
bool SendRequest(const char *node)
void SetTaskID(uint32_t tid, uint32_t sid)
static int GetErr(XrdCl::XRootDStatus &Status, std::string &eText)
static void RetErr(XrdSsiRequest &reqP, const char *eTxt, int eNum)
static void SetErr(XrdCl::XRootDStatus &Status, XrdSsiErrInfo &eInfo)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Flags
Open flags, may be or'd when appropriate.
@ Read
Open only for reading.
bool IsOK() const
We're fine.