xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdLink.hh
Go to the documentation of this file.
1 #ifndef __XRD_LINK_H__
2 #define __XRD_LINK_H__
3 /******************************************************************************/
4 /* */
5 /* X r d L i n k . h h */
6 /* */
7 /* (c) 2018 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <sys/types.h>
33 
34 #include "XrdNet/XrdNetAddr.hh"
35 #include "XrdOuc/XrdOucSFVec.hh"
36 #include "XrdSys/XrdSysPthread.hh"
37 
38 #include "Xrd/XrdJob.hh"
39 
40 /******************************************************************************/
41 /* C l a s s D e f i n i t i o n */
42 /******************************************************************************/
43 
44 class XrdLinkMatch;
45 class XrdLinkXeq;
46 class XrdPollInfo;
47 class XrdProtocol;
48 class XrdTlsPeerCerts;
49 class XrdTlsContext;
50 
51 class XrdLink : public XrdJob
52 {
53 public:
54 
55 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
60 
61 bool Activate();
62 
63 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
69 
71 
72 //-----------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
77 
78 int Backlog();
79 
80 //-----------------------------------------------------------------------------
88 //-----------------------------------------------------------------------------
89 
90 int Client(char *buff, int blen);
91 
92 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
101 
102 int Close(bool defer=false);
103 
104 //-----------------------------------------------------------------------------
106 //-----------------------------------------------------------------------------
107 
108 void Enable();
109 
110 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
115 
116 int FDnum();
117 
118 //-----------------------------------------------------------------------------
132 //-----------------------------------------------------------------------------
133 
134 static XrdLink *Find(int &curr, XrdLinkMatch *who=0);
135 
136 //-----------------------------------------------------------------------------
148 //-----------------------------------------------------------------------------
149 
150  int getIOStats(long long &inbytes, long long &outbytes,
151  int &numstall, int &numtardy);
152 
153 //-----------------------------------------------------------------------------
167 //-----------------------------------------------------------------------------
168 
169 static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0);
170 
171 //-----------------------------------------------------------------------------
178 //-----------------------------------------------------------------------------
179 
181 
182 //-----------------------------------------------------------------------------
184 //-----------------------------------------------------------------------------
185 
187 
188 //-----------------------------------------------------------------------------
193 //-----------------------------------------------------------------------------
194 
195 void Hold(bool lk);
196 
197 //-----------------------------------------------------------------------------
202 //-----------------------------------------------------------------------------
203 
204 const char *Host() const {return (const char *)HostName;}
205 
206 //-----------------------------------------------------------------------------
208 //-----------------------------------------------------------------------------
209 
210 char *ID; // This is referenced a lot (should have been const).
211 
212 //-----------------------------------------------------------------------------
216 //-----------------------------------------------------------------------------
217 
218 unsigned int Inst() const {return Instance;}
219 
220 //-----------------------------------------------------------------------------
225 //-----------------------------------------------------------------------------
226 
227 bool isFlawed() const;
228 
229 //-----------------------------------------------------------------------------
237 //-----------------------------------------------------------------------------
238 
239 bool isInstance(unsigned int inst) const;
240 
241 //-----------------------------------------------------------------------------
246 //-----------------------------------------------------------------------------
247 
248 const char *Name() const;
249 
250 //-----------------------------------------------------------------------------
255 //-----------------------------------------------------------------------------
256 const
257 XrdNetAddr *NetAddr() const;
258 
259 //-----------------------------------------------------------------------------
269 //-----------------------------------------------------------------------------
270 
271 int Peek(char *buff, int blen, int timeout=-1);
272 
273 //-----------------------------------------------------------------------------
282 //-----------------------------------------------------------------------------
283 
284 int Recv(char *buff, int blen);
285 
286 //-----------------------------------------------------------------------------
299 //-----------------------------------------------------------------------------
300 
301 int Recv(char *buff, int blen, int timeout);
302 
303 //-----------------------------------------------------------------------------
315 //-----------------------------------------------------------------------------
316 
317 int Recv(const struct iovec *iov, int iocnt, int timeout);
318 
319 //-----------------------------------------------------------------------------
332 //-----------------------------------------------------------------------------
333 
334 int RecvAll(char *buff, int blen, int timeout=-1);
335 
336 //------------------------------------------------------------------------------
345 //------------------------------------------------------------------------------
346 
347 bool Register(const char *hName);
348 
349 //-----------------------------------------------------------------------------
358 //-----------------------------------------------------------------------------
359 
360 int Send(const char *buff, int blen);
361 
362 //-----------------------------------------------------------------------------
372 //-----------------------------------------------------------------------------
373 
374 int Send(const struct iovec *iov, int iocnt, int bytes=0);
375 
376 //-----------------------------------------------------------------------------
385 //-----------------------------------------------------------------------------
386 
387 static bool sfOK; // True if Send(sfVec) enabled
388 
390 
391 int Send(const sfVec *sdP, int sdn); // Iff sfOK is true
392 
393 //-----------------------------------------------------------------------------
395 //-----------------------------------------------------------------------------
396 
397 void Serialize();
398 
399 //-----------------------------------------------------------------------------
406 //-----------------------------------------------------------------------------
407 
408 int setEtext(const char *text);
409 
410 //-----------------------------------------------------------------------------
415 //-----------------------------------------------------------------------------
416 
417 void setID(const char *userid, int procid);
418 
419 //-----------------------------------------------------------------------------
423 //-----------------------------------------------------------------------------
424 
426 
427 //-----------------------------------------------------------------------------
432 //-----------------------------------------------------------------------------
433 
434 bool setNB();
435 
436 //-----------------------------------------------------------------------------
444 //-----------------------------------------------------------------------------
445 
446 XrdProtocol *setProtocol(XrdProtocol *pp, bool runit=false, bool push=false);
447 
448 //-----------------------------------------------------------------------------
453 //-----------------------------------------------------------------------------
454 
455 void setProtName(const char *name);
456 
457 //-----------------------------------------------------------------------------
461 //-----------------------------------------------------------------------------
462 
463 void setRef(int cnt);
464 
465 //-----------------------------------------------------------------------------
467 //
475 //-----------------------------------------------------------------------------
476 
477 bool setTLS(bool enable, XrdTlsContext *ctx=0);
478 
479 //-----------------------------------------------------------------------------
483 //-----------------------------------------------------------------------------
484 
485 void Shutdown(bool getLock);
486 
487 //-----------------------------------------------------------------------------
496 //-----------------------------------------------------------------------------
497 
498 static int Stats(char *buff, int blen, bool do_sync=0);
499 
500 //-----------------------------------------------------------------------------
504 //-----------------------------------------------------------------------------
505 
506 void syncStats(int *ctime=0);
507 
508 //-----------------------------------------------------------------------------
524 //-----------------------------------------------------------------------------
525 
526 int Terminate(const char *owner, int fdnum, unsigned int inst);
527 
528 //-----------------------------------------------------------------------------
530 //-----------------------------------------------------------------------------
531 
532 time_t timeCon() const;
533 
534 //-----------------------------------------------------------------------------
536 //-----------------------------------------------------------------------------
537 
538 int UseCnt() const;
539 
540 //-----------------------------------------------------------------------------
542 //-----------------------------------------------------------------------------
543 
544 void armBridge();
545 
546 //-----------------------------------------------------------------------------
551 //-----------------------------------------------------------------------------
552 
553 bool hasBridge() const {return isBridged;}
554 
555 //-----------------------------------------------------------------------------
563 //-----------------------------------------------------------------------------
564 
565 bool hasTLS() const {return isTLS;}
566 
567 //-----------------------------------------------------------------------------
572 //-----------------------------------------------------------------------------
573 
574 const char *verTLS();
575 
576 //-----------------------------------------------------------------------------
580 //-----------------------------------------------------------------------------
581 
582  XrdLink(XrdLinkXeq &lxq);
583 
584 protected:
585  ~XrdLink() {} // Is never deleted!
586 
587 void DoIt(); // This is an override of XrdJob::DoIt.
588 void ResetLink();
589 int Wait4Data(int timeout);
590 
591 void *rsvd1[3]; // Reserved for future use
592 XrdLinkXeq &linkXQ; // The implementation
593 char *HostName; // Pointer to the hostname
594 unsigned int Instance; // Instance number of this object
595 bool isBridged; // If true, this link is an in-memory bridge
596 bool isTLS; // If true, this link uses TLS for all I/O
597 char rsvd2[2];
598 };
599 #endif
Definition: XrdOucSFVec.hh:43
Definition: XrdProtocol.hh:124
Definition: XrdPollInfo.hh:36
Definition: XrdNetAddr.hh:41
Definition: XrdOucIOVec.hh:65
Definition: XrdNetAddrInfo.hh:194
Definition: XrdLinkXeq.hh:52
Definition: XrdNetAddrInfo.hh:53
Definition: XrdTlsContext.hh:36
Definition: XrdLinkMatch.hh:35
Definition: XrdTlsPeerCerts.hh:34
Definition: XrdJob.hh:42