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 if (runStatus)
469 }
470 } while((rc == 0) && !runError && !runWait);
471 }
473
474
475
476 if (rc >= 0 && runWait) return;
477 runWTot = 0;
478
479
480
481 if (runStatus)
485 }
486
487
488
489
492}
493
494
495
496
497
498#define KXR_INDEX(x) x-kXR_auth
499
501{
503
504
505
506 memset(rTab, 0, sizeof(rTab));
527
528
529
530 return rTab;
531}
532
533
534
535
536
537bool XrdXrootdTransit::ReqWrite(char *xdataP, int xdataL)
538{
539
540
541
543
544
545
547 {
Resume = 0; wBuff = xdataP; wBLen = xdataL;
548 return true;
549 }
550
551
552
553
557 return true;
558}
559
560
561
562
563
565{
566 int movLen, rc;
567
568
569
570
574 if (rc)
575 {
TRACEP(REQ,
"Bridge request failed due to re-entry");
576 return false;
577 }
578
579
580
582
583
584
589 {
TRACEP(REQ,
"Unsupported bridge request");
591 }
592
593
594
597 {
TRACEP(REQ,
"Invalid request data length");
599 }
600
601
602
606
607
608
610
611
612
613
614
617 if (!RunCopy(xdataP, movLen)) return true;
618 if (!runArgs || movLen > runABsz)
619 {if (runArgs) free(runArgs);
620 if (!(runArgs = (char *)malloc(movLen)))
621 {
TRACEP(REQ,
"Failed to allocate memory");
623 }
624 runABsz = movLen;
625 }
626 memcpy(runArgs, xdataP, movLen); runALen = movLen;
630 return true;
631 }
632 } else runALen = 0;
633
634
635
636 runError = 0;
638 return true;
639}
640
641
642
643
644
645bool XrdXrootdTransit::RunCopy(char *buffP, int buffL)
646{
647
648
649
653 {Fail(
kXR_ArgTooLong,
"Request argument too long");
return false;}
655 }
656
657
658
661 return true;
662}
663
664
665
666
667
669{
673 int rc;
674 bool aOK;
675
676
677
678 runDone = true;
679 switch(rcode)
682 eMsg = (ioN < 2 ?
"" : (
const char *)ioV[1].iov_base);
683 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
685 break;
687 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
688 aOK = (ioN ? respObj->
Data(rInfo, ioV, ioN, ioL,
true)
689 : respObj->
Done(rInfo));
690 break;
692 aOK = respObj->
Data(rInfo, ioV, ioN, ioL,
false);
693 runDone = false;
694 break;
696 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
698 aOK = respObj->
Redir(rInfo,rc,(
const char *)ioV[1].iov_base);
699 break;
701 return Wait(rInfo, ioV, ioN, ioL);
702 break;
704 runDone = false;
705 return WaitResp(rInfo, ioV, ioN, ioL);
706 break;
707 default:
if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
709 "internal logic error");
710 break;
711 };
712
713
714
715 return (aOK ? 0 : -1);
716}
717
718
719
721{
724 offset, dlen, fdnum);
725
726
727
728 runDone = true;
729 return (respObj->
File(sfInfo, dlen) ? 0 : -1);
730}
731
732
733
735{
738 sfvec, sfvnum, dlen);
739
740
741
742 runDone = true;
743 return (respObj->
File(sfInfo, dlen) ? 0 : -1);
744}
745
746
747
748
749
751 const struct iovec *ioV, int ioN, int ioL)
752{
754
755
756
758 eMsg = (ioN < 2 ?
"reason unknown" : (
const char *)ioV[1].iov_base);
759
760
761
762 if (runWMax <= 0)
763 {int wtime = runWait;
764 runWait = 0;
765 return (respObj->
Wait(rInfo, wtime,
eMsg) ? 0 : -1);
766 }
767
768
769
770 if (runWTot >= runWMax)
771 {runDone = true;
772 runWait = 0;
774 }
775
776
777
778 if (runWait > runWMax) runWait = runWMax;
779
780
781
782 if (runWCall && !(respObj->
Wait(rInfo, runWait,
eMsg)))
return -1;
783
784
785
786 TRACEP(REQ,
"Bridge delaying request " <<runWait <<
" sec (" <<
eMsg <<
")");
788 return 0;
789}
790
791
792
793
794
796 const struct iovec *ioV, int ioN, int ioL)
797{
800 int wTime;
801
802
803
805 eMsg = (ioN < 2 ?
"reason unknown" : (
const char *)ioV[1].iov_base);
806 TRACEP(REQ,
"Bridge waiting for resp; sid=" <<rInfo.
sID.num
807 <<
" wt=" <<wTime <<
" (" <<
eMsg <<
")");
808
809
810
811
812
813
814
815
818
819
820
821 runWait = -1;
822 return 0;
823}
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)
union XrdXrootdTransPend::@190 Pend
XrdXrootdTransit * bridge
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::@163 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