82{
84
85
86
88 xp->
Init(rsltP, linkP, seceP, nameP, protP);
89 return xp;
90}
91
92
93
94
95
97 const struct iovec *ioV, int ioN, int ioL)
98{
100
101
102
104 {
TRACE(REQ,
"Unable to find request for " <<lP->
ID <<
" sid=" <<*theSID);
105 return 0;
106 }
107
108
109
110 return tP->
bridge->AttnCont(tP, rcode, ioV, ioN, ioL);
111}
112
113
114
115
116
118 const struct iovec *ioV, int ioN, int ioL)
119{
120 int rc;
121
122
123
125 delete tP;
126 runWait = 0;
127
128
129
131 && (!ioN ||
XRD_GETNUM(ioV[0].iov_base) == 0))
133 return 0;
134 }
135
136
137
138 rc =
Send(rcode, ioV, ioN, ioL);
139
140
141
142 if (rc >= 0 && !runWait)
143 {if (runDone)
147 }
150 }
151
152
153
154 return rc;
155}
156
157
158
159
160
162{
163 char buff[128];
164 int rc;
165
166
167
171 if (rc) return false;
172
173
174
176
177
178
179 sprintf(buff, "%s disconnection", pName);
181
182
183
184 TranStack.
Push(&TranLink);
185 return true;
186}
187
188
189
190
191
192bool XrdXrootdTransit::Fail(int ecode, const char *etext)
193{
194 runError = ecode;
195 runEText = etext;
196 return true;
197}
198
199
200
201
202
203int XrdXrootdTransit::Fatal(int rc)
204{
207
208 return (respObj->
Error(rInfo, runError, runEText) ? rc : -1);
209}
210
211
212
213
214
216{
218 TranStack.
Set(qMax, qTTL);
219}
220
221
222
226 const char *nameP,
227 const char *protP
228 )
229{
231 const char *who;
233
234
235
236 runArgs = 0;
237 runALen = 0;
238 runABsz = 0;
239 runError = 0;
240 runStatus = 0;
241 runWait = 0;
242 runWTot = 0;
243 runWMax = 3600;
244 runWCall = false;
245 runDone = false;
246 reInvoke = false;
247 wBuff = 0;
248 wBLen = 0;
249 respObj = respP;
250 pName = protP;
252
253
254
261
262
263
264 strncpy(uname, nameP, sizeof(uname)-1);
265 uname[sizeof(uname)-1] = 0;
268
269
270
271
272
274
275
276
277
281
282
283
286
287
288
293
294
295
301 }
302 }
303
304
305
307
308
309
313
314
315
316 who = (seceP && seceP->
name ? seceP->
name :
"nobody");
318
319
320
322 cTime = time(0);
323
324
325
327}
328
329
330
331
332
334{
335 int rc;
336
337
338
340 else rc = 0;
341
342
343
345 else if (rc != -EINPROGRESS)
Link->
Close();
346}
347
348
349
350
351
353{
354 int rc;
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369do{rc = realProt->
Process((reInvoke ? 0 : lp));
370 if (rc >= 0 && runStatus)
371 {reInvoke = (rc == 0);
372 if (runError) rc = Fatal(rc);
373 else {runDone = false;
375 if (rc >= 0)
376 {if (runWait) rc = -EINPROGRESS;
377 if (!runDone) return rc;
381 }
382 }
383 } else reInvoke = false;
384 } while(rc >= 0 && reInvoke);
385
386
387
388 if (runStatus)
392 }
393
394
395
396 return (rc ? rc : 1);
397}
398
399
400
401
402
404{
405
406
407
411
412
413
414
415
417
418
419
420 if (realProt) realProt->
Recycle(lp, consec, reason);
421
422
423
425
426
427
428 if (runArgs) {free(runArgs); runArgs = 0;}
429
430
431
433
434
435
436 TranStack.
Push(&TranLink);
437}
438
439
440
441
442
444{
446 static char eText[] = "Insufficent memory to re-issue request";
447 static struct iovec ioV[] = {{(char *)&eCode,sizeof(eCode)},
448 {(char *)&eText,sizeof(eText)}};
449 int rc;
450
451
452
453 runWTot += runWait;
454 runWait = 0;
455
456
457
458
459
460 if (!runALen || RunCopy(runArgs, runALen)) {
462 if (rc == 0) {
464 }
465 } while((rc == 0) && !runError && !runWait);
466 }
468
469
470
471 if (rc >= 0 && runWait) return;
472 runWTot = 0;
473
474
475
476 if (runStatus)
480 }
481
482
483
484
487}
488
489
490
491
492
493#define KXR_INDEX(x) x-kXR_auth
494
496{
498
499
500
501 memset(rTab, 0, sizeof(rTab));
522
523
524
525 return rTab;
526}
527
528
529
530
531
532bool XrdXrootdTransit::ReqWrite(char *xdataP, int xdataL)
533{
534
535
536
538
539
540
542 {
Resume = 0; wBuff = xdataP; wBLen = xdataL;
543 return true;
544 }
545
546
547
548
552 return true;
553}
554
555
556
557
558
560{
561 int movLen, rc;
562
563
564
565
569 if (rc) return false;
570
571
572
574
575
576
582
583
584
588
589
590
594
595
596
598
599
600
601
602
605 if (!RunCopy(xdataP, movLen)) return true;
606 if (!runArgs || movLen > runABsz)
607 {if (runArgs) free(runArgs);
608 if (!(runArgs = (char *)malloc(movLen)))
610 runABsz = movLen;
611 }
612 memcpy(runArgs, xdataP, movLen); runALen = movLen;
616 return true;
617 }
618 } else runALen = 0;
619
620
621
622 runError = 0;
624 return true;
625}
626
627
628
629
630
631bool XrdXrootdTransit::RunCopy(char *buffP, int buffL)
632{
633
634
635
639 {Fail(
kXR_ArgTooLong,
"Request argument too long");
return false;}
641 }
642
643
644
647 return true;
648}
649
650
651
652
653
655{
659 int rc;
660 bool aOK;
661
662
663
664 runDone = true;
665 switch(rcode)
668 eMsg = (ioN < 2 ?
"" : (
const char *)ioV[1].iov_base);
669 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
671 break;
673 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
674 aOK = (ioN ? respObj->
Data(rInfo, ioV, ioN, ioL,
true)
675 : respObj->
Done(rInfo));
676 break;
678 aOK = respObj->
Data(rInfo, ioV, ioN, ioL,
false);
679 runDone = false;
680 break;
682 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
684 aOK = respObj->
Redir(rInfo,rc,(
const char *)ioV[1].iov_base);
685 break;
687 return Wait(rInfo, ioV, ioN, ioL);
688 break;
690 runDone = false;
691 return WaitResp(rInfo, ioV, ioN, ioL);
692 break;
693 default:
if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
695 "internal logic error");
696 break;
697 };
698
699
700
701 return (aOK ? 0 : -1);
702}
703
704
705
707{
710 offset, dlen, fdnum);
711
712
713
714 runDone = true;
715 return (respObj->
File(sfInfo, dlen) ? 0 : -1);
716}
717
718
719
721{
724 sfvec, sfvnum, dlen);
725
726
727
728 runDone = true;
729 return (respObj->
File(sfInfo, dlen) ? 0 : -1);
730}
731
732
733
734
735
737 const struct iovec *ioV, int ioN, int ioL)
738{
740
741
742
744 eMsg = (ioN < 2 ?
"reason unknown" : (
const char *)ioV[1].iov_base);
745
746
747
748 if (runWMax <= 0)
749 {int wtime = runWait;
750 runWait = 0;
751 return (respObj->
Wait(rInfo, wtime,
eMsg) ? 0 : -1);
752 }
753
754
755
756 if (runWTot >= runWMax)
757 {runDone = true;
758 runWait = 0;
760 }
761
762
763
764 if (runWait > runWMax) runWait = runWMax;
765
766
767
768 if (runWCall && !(respObj->
Wait(rInfo, runWait,
eMsg)))
return -1;
769
770
771
772 TRACEP(REQ,
"Bridge delaying request " <<runWait <<
" sec (" <<
eMsg <<
")");
774 return 0;
775}
776
777
778
779
780
782 const struct iovec *ioV, int ioN, int ioL)
783{
786 int wTime;
787
788
789
791 eMsg = (ioN < 2 ?
"reason unknown" : (
const char *)ioV[1].iov_base);
792 TRACEP(REQ,
"Bridge waiting for resp; sid=" <<rInfo.
sID.num
793 <<
" wt=" <<wTime <<
" (" <<
eMsg <<
")");
794
795
796
797
798
799
800
801
804
805
806
807 runWait = -1;
808 return 0;
809}
struct ClientRequestHdr header
struct ClientLoginRequest login
XrdOucTrace * XrdXrootdTrace
void Release(XrdBuffer *bp)
XrdBuffer * Obtain(int bsz)
XrdProtocol * setProtocol(XrdProtocol *pp, bool runit=false, bool push=false)
int Close(bool defer=false)
void setID(const char *userid, int procid)
void Enable()
Enable the link to field interrupts.
XrdNetAddrInfo * AddrInfo()
char * ID
Pointer to the client's link identity.
void armBridge()
Mark this link as an in-memory communications bridge (internal use only).
void setProtName(const char *name)
const char * Host() const
unsigned int Inst() const
bool isIPType(IPType ipType) const
void Set(int inQMax, time_t agemax=1800)
void Push(XrdObject< T > *Node)
static void Sanitize(char *instr, char subc='_')
virtual void Recycle(XrdLink *lp=0, int consec=0, const char *reason=0)=0
virtual int Process(XrdLink *lp)=0
void Schedule(XrdJob *jp)
const char * pident
Trace identifier (originator)
XrdNetAddrInfo * addrInfo
Entity's connection details.
const char * tident
Trace identifier always preset.
char prot[XrdSecPROTOIDSIZE]
Auth protocol used (e.g. krb5)
char * name
Entity's name.
unsigned int ueid
Unique ID of entity instance.
char * host
Entity's host name dnr dependent.
virtual void Connect(const XrdSecEntity *client=0)
void Log(int mask, const char *esfx, const char *text1, const char *text2=0, const char *text3=0)
void Register(const char *Uname, const char *Hname, const char *Pname, unsigned int xSID=0)
void Report(const char *Info)
static XrdXrootdStats * SI
static XrdSysError & eDest
static unsigned int getSID()
XrdXrootdMonitor::User Monitor
int(XrdXrootdProtocol::* Resume)()
static XrdScheduler * Sched
int Process(XrdLink *lp) override
void Recycle(XrdLink *lp, int consec, const char *reason) override
XrdXrootdResponse Response
static XrdBuffManager * BPool
static XrdSfsFileSystem * osFS
void setID(unsigned long long id)
static XrdXrootdTransPend * Remove(XrdLink *lP, short sid)
XrdXrootdTransit * bridge
union XrdXrootdTransPend::@185 Pend
static void Clear(XrdXrootdTransit *trP)
bool Run(const char *xreqP, char *xdataP=0, int xdataL=0)
Inject an xrootd request into the protocol stack.
static const char * ReqTable()
Initialize the valid request table.
void Redrive()
Redrive a request after a wait.
int Send(int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle request data response.
void Recycle(XrdLink *lp, int consec, const char *reason)
Handle link shutdown.
static void Init(XrdScheduler *schedP, int qMax, int qTTL)
Perform one-time initialization.
static int Attn(XrdLink *lP, short *theSID, int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle attention response (i.e. async response)
void Proceed()
Resume processing after a waitresp completion.
bool Disc()
Handle dismantlement.
int Process(XrdLink *lp)
Handle link activation (replaces parent activation).
union XrdXrootd::Bridge::Context::@166 sID
associated request stream ID
virtual int File(Bridge::Context &info, int dlen)=0
virtual bool Data(Bridge::Context &info, const struct iovec *iovP, int iovN, int iovL, bool final)=0
virtual bool Error(Bridge::Context &info, int ecode, const char *etext)=0
virtual bool Done(Bridge::Context &info)=0
the result context
virtual bool Redir(Bridge::Context &info, int port, const char *hname)=0
virtual bool Wait(Bridge::Context &info, int wtime, const char *wtext)
virtual void Free(Bridge::Context &info, char *buffP, int buffL)
static const int uIPv4
ucap: Supports read redirects