xrootd
Loading...
Searching...
No Matches
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"
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
44class XrdLinkMatch;
45class XrdLinkXeq;
46class XrdPollInfo;
47class XrdProtocol;
48class XrdTlsPeerCerts;
49class XrdTlsContext;
50
51class XrdLink : public XrdJob
52{
53public:
54
55//-----------------------------------------------------------------------------
59//-----------------------------------------------------------------------------
60
61bool Activate();
62
63//-----------------------------------------------------------------------------
68//-----------------------------------------------------------------------------
69
71
72//-----------------------------------------------------------------------------
76//-----------------------------------------------------------------------------
77
78int Backlog();
79
80//-----------------------------------------------------------------------------
88//-----------------------------------------------------------------------------
89
90int Client(char *buff, int blen);
91
92//-----------------------------------------------------------------------------
100//-----------------------------------------------------------------------------
101
102int Close(bool defer=false);
103
104//-----------------------------------------------------------------------------
106//-----------------------------------------------------------------------------
107
108void Enable();
109
110//-----------------------------------------------------------------------------
114//-----------------------------------------------------------------------------
115
116int FDnum();
117
118//-----------------------------------------------------------------------------
132//-----------------------------------------------------------------------------
133
134static 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
169static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0);
170
171//-----------------------------------------------------------------------------
178//-----------------------------------------------------------------------------
179
181
182//-----------------------------------------------------------------------------
184//-----------------------------------------------------------------------------
185
187
188//-----------------------------------------------------------------------------
193//-----------------------------------------------------------------------------
194
195void Hold(bool lk);
196
197//-----------------------------------------------------------------------------
202//-----------------------------------------------------------------------------
203
204const char *Host() const {return (const char *)HostName;}
205
206//-----------------------------------------------------------------------------
208//-----------------------------------------------------------------------------
209
210char *ID; // This is referenced a lot (should have been const).
211
212//-----------------------------------------------------------------------------
216//-----------------------------------------------------------------------------
217
218unsigned int Inst() const {return Instance;}
219
220//-----------------------------------------------------------------------------
225//-----------------------------------------------------------------------------
226
227bool isFlawed() const;
228
229//-----------------------------------------------------------------------------
237//-----------------------------------------------------------------------------
238
239bool isInstance(unsigned int inst) const;
240
241//-----------------------------------------------------------------------------
246//-----------------------------------------------------------------------------
247
248const char *Name() const;
249
250//-----------------------------------------------------------------------------
255//-----------------------------------------------------------------------------
256const
258
259//-----------------------------------------------------------------------------
269//-----------------------------------------------------------------------------
270
271int Peek(char *buff, int blen, int timeout=-1);
272
273//-----------------------------------------------------------------------------
282//-----------------------------------------------------------------------------
283
284int Recv(char *buff, int blen);
285
286//-----------------------------------------------------------------------------
299//-----------------------------------------------------------------------------
300
301int Recv(char *buff, int blen, int timeout);
302
303//-----------------------------------------------------------------------------
316//-----------------------------------------------------------------------------
317
318int Recv(const struct iovec *iov, int iocnt, int timeout);
319
320//-----------------------------------------------------------------------------
333//-----------------------------------------------------------------------------
334
335int RecvAll(char *buff, int blen, int timeout=-1);
336
337//------------------------------------------------------------------------------
346//------------------------------------------------------------------------------
347
348bool Register(const char *hName);
349
350//-----------------------------------------------------------------------------
359//-----------------------------------------------------------------------------
360
361int Send(const char *buff, int blen);
362
363//-----------------------------------------------------------------------------
373//-----------------------------------------------------------------------------
374
375int Send(const struct iovec *iov, int iocnt, int bytes=0);
376
377//-----------------------------------------------------------------------------
386//-----------------------------------------------------------------------------
387
388static bool sfOK; // True if Send(sfVec) enabled
389
391
392int Send(const sfVec *sdP, int sdn); // Iff sfOK is true
393
394//-----------------------------------------------------------------------------
396//-----------------------------------------------------------------------------
397
399
400//-----------------------------------------------------------------------------
407//-----------------------------------------------------------------------------
408
409int setEtext(const char *text);
410
411//-----------------------------------------------------------------------------
416//-----------------------------------------------------------------------------
417
418void setID(const char *userid, int procid);
419
420//-----------------------------------------------------------------------------
424//-----------------------------------------------------------------------------
425
427
428//-----------------------------------------------------------------------------
433//-----------------------------------------------------------------------------
434
435bool setNB();
436
437//-----------------------------------------------------------------------------
445//-----------------------------------------------------------------------------
446
447XrdProtocol *setProtocol(XrdProtocol *pp, bool runit=false, bool push=false);
448
449//-----------------------------------------------------------------------------
454//-----------------------------------------------------------------------------
455
456void setProtName(const char *name);
457
458//-----------------------------------------------------------------------------
462//-----------------------------------------------------------------------------
463
464void setRef(int cnt);
465
466//-----------------------------------------------------------------------------
468//
476//-----------------------------------------------------------------------------
477
478bool setTLS(bool enable, XrdTlsContext *ctx=0);
479
480//-----------------------------------------------------------------------------
484//-----------------------------------------------------------------------------
485
486void Shutdown(bool getLock);
487
488//-----------------------------------------------------------------------------
497//-----------------------------------------------------------------------------
498
499static int Stats(char *buff, int blen, bool do_sync=0);
500
501//-----------------------------------------------------------------------------
505//-----------------------------------------------------------------------------
506
507void syncStats(int *ctime=0);
508
509//-----------------------------------------------------------------------------
525//-----------------------------------------------------------------------------
526
527int Terminate(const char *owner, int fdnum, unsigned int inst);
528
529//-----------------------------------------------------------------------------
531//-----------------------------------------------------------------------------
532
533time_t timeCon() const;
534
535//-----------------------------------------------------------------------------
537//-----------------------------------------------------------------------------
538
539int UseCnt() const;
540
541//-----------------------------------------------------------------------------
543//-----------------------------------------------------------------------------
544
546
547//-----------------------------------------------------------------------------
552//-----------------------------------------------------------------------------
553
554bool hasBridge() const {return isBridged;}
555
556//-----------------------------------------------------------------------------
561//-----------------------------------------------------------------------------
562
563bool hasTLS() const {return isTLS;}
564
565//-----------------------------------------------------------------------------
570//-----------------------------------------------------------------------------
571
572const char *verTLS();
573
574//-----------------------------------------------------------------------------
578//-----------------------------------------------------------------------------
579
581
582protected:
583 ~XrdLink() {} // Is never deleted!
584
585void DoIt(); // This is an override of XrdJob::DoIt.
587int Wait4Data(int timeout);
588
589void *rsvd1[3]; // Reserved for future use
590XrdLinkXeq &linkXQ; // The implementation
591char *HostName; // Pointer to the hostname
592unsigned int Instance; // Instance number of this object
593bool isBridged; // If true, this link is an in-memory bridge
594bool isTLS; // If true, this link uses TLS for all I/O
595char rsvd2[2];
596};
597#endif
Definition XrdJob.hh:43
Definition XrdLinkMatch.hh:35
Definition XrdLinkXeq.hh:53
Definition XrdNetAddrInfo.hh:54
Definition XrdNetAddr.hh:42
Definition XrdPollInfo.hh:37
Definition XrdProtocol.hh:125
Definition XrdTlsContext.hh:37
Definition XrdTlsPeerCerts.hh:35
Definition XrdNetAddrInfo.hh:195
Definition XrdOucSFVec.hh:43
Definition XrdOucIOVec.hh:65