xrootd
Loading...
Searching...
No Matches
XrdLinkXeq.hh
Go to the documentation of this file.
1#ifndef __XRD_LINKXEQ_H__
2#define __XRD_LINKXEQ_H__
3/******************************************************************************/
4/* */
5/* X r d L i n k X e q . 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#include <fcntl.h>
34#include <ctime>
35
36#include "Xrd/XrdLink.hh"
37#include "Xrd/XrdLinkInfo.hh"
38#include "Xrd/XrdPollInfo.hh"
39#include "Xrd/XrdProtocol.hh"
40
41#include "XrdNet/XrdNetAddr.hh"
42
43#include "XrdTls/XrdTls.hh"
45
46/******************************************************************************/
47/* C l a s s D e f i n i t i o n */
48/******************************************************************************/
49
50class XrdSendQ;
51
52class XrdLinkXeq : protected XrdLink
53{
54public:
55
56inline
58
59int Backlog();
60
61int Client(char *buff, int blen);
62
63int Close(bool defer=false);
64
65void DoIt(); // Override
66
67
68 int getIOStats(long long &inbytes, long long &outbytes,
69 int &numstall, int &numtardy)
70 { inbytes = BytesIn + BytesInTot;
71 outbytes = BytesOut+BytesOutTot;
72 numstall = stallCnt + stallCntTot;
73 numtardy = tardyCnt + tardyCntTot;
74 return LinkInfo.InUse;
75 }
76
78
79static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0);
80
81inline
83
84inline
85const char *Name() const {return (const char *)Lname;}
86
87inline const
88XrdNetAddr *NetAddr() const {return &Addr;}
89
90int Peek(char *buff, int blen, int timeout=-1);
91
92int Recv(char *buff, int blen);
93int Recv(char *buff, int blen, int timeout);
94int Recv(const struct iovec *iov, int iocnt, int timeout);
95
96int RecvAll(char *buff, int blen, int timeout=-1);
97
98bool Register(const char *hName);
99
100int Send(const char *buff, int blen);
101int Send(const struct iovec *iov, int iocnt, int bytes=0);
102
103int Send(const sfVec *sdP, int sdn); // Iff sfOK > 0
104
105void setID(const char *userid, int procid);
106
108
109bool setNB();
110
112
113void setProtName(const char *name);
114
115bool setTLS(bool enable, XrdTlsContext *ctx=0);
116
117 void Shutdown(bool getLock);
118
119static int Stats(char *buff, int blen, bool do_sync=false);
120
121 void syncStats(int *ctime=0);
122
123int TLS_Peek(char *Buff, int Blen, int timeout);
124
125int TLS_Recv(char *Buff, int Blen);
126
127int TLS_Recv(char *Buff, int Blen, int timeout, bool havelock=false);
128
129int TLS_Recv(const struct iovec *iov, int iocnt, int timeout);
130
131int TLS_RecvAll(char *Buff, int Blen, int timeout);
132
133int TLS_Send(const char *Buff, int Blen);
134
135int TLS_Send(const struct iovec *iov, int iocnt, int bytes);
136
137int TLS_Send(const sfVec *sfP, int sfN);
138
139const char *verTLS();
140
142 ~XrdLinkXeq() {} // Is never deleted!
143
146
147protected:
148
149int RecvIOV(const struct iovec *iov, int iocnt);
150void Reset();
151int sendData(const char *Buff, int Blen);
152int SendIOV(const struct iovec *iov, int iocnt, int bytes);
153int SFError(int rc);
154int TLS_Error(const char *act, XrdTls::RC rc);
155bool TLS_Write(const char *Buff, int Blen);
156
157static const char *TraceID;
158
159// Statistical area (global and local)
160//
161static long long LinkBytesIn;
162static long long LinkBytesOut;
163static long long LinkConTime;
164static long long LinkCountTot;
165static int LinkCount;
166static int LinkCountMax;
167static int LinkTimeOuts;
168static int LinkStalls;
169static int LinkSfIntr;
170 long long BytesIn;
171 long long BytesInTot;
172 long long BytesOut;
173 long long BytesOutTot;
180
181// Protocol section
182//
183XrdProtocol *Protocol; // -> Protocol tied to the link
184XrdProtocol *ProtoAlt; // -> Alternate/stacked protocol
185
186// TLS section
187//
189
190// Identification section
191//
195XrdSendQ *sendQ; // Protected by wrMutex && opMutex
200char Uname[24]; // Uname and Lname must be adjacent!
201char Lname[256];
202};
203#endif
Definition XrdLinkInfo.hh:39
int InUse
Definition XrdLinkInfo.hh:47
Definition XrdLinkMatch.hh:35
Definition XrdLinkXeq.hh:53
int TLS_Send(const char *Buff, int Blen)
long long BytesOut
Definition XrdLinkXeq.hh:172
int TLS_Error(const char *act, XrdTls::RC rc)
int TLS_Peek(char *Buff, int Blen, int timeout)
int stallCntTot
Definition XrdLinkXeq.hh:175
int Client(char *buff, int blen)
char Uname[24]
Definition XrdLinkXeq.hh:200
XrdTlsPeerCerts * getPeerCerts()
XrdNetAddrInfo * AddrInfo()
Definition XrdLinkXeq.hh:57
static int LinkCountMax
Definition XrdLinkXeq.hh:166
XrdLinkInfo LinkInfo
Definition XrdLinkXeq.hh:144
const char * Name() const
Definition XrdLinkXeq.hh:85
XrdProtocol * ProtoAlt
Definition XrdLinkXeq.hh:184
int Close(bool defer=false)
int TLS_Send(const sfVec *sfP, int sfN)
XrdNetAddr Addr
Definition XrdLinkXeq.hh:192
int TLS_Recv(char *Buff, int Blen)
int sendData(const char *Buff, int Blen)
long long BytesInTot
Definition XrdLinkXeq.hh:171
bool TLS_Write(const char *Buff, int Blen)
int SendIOV(const struct iovec *iov, int iocnt, int bytes)
XrdProtocol * setProtocol(XrdProtocol *pp, bool push)
static long long LinkCountTot
Definition XrdLinkXeq.hh:164
int TLS_Send(const struct iovec *iov, int iocnt, int bytes)
long long BytesOutTot
Definition XrdLinkXeq.hh:173
void Shutdown(bool getLock)
int Peek(char *buff, int blen, int timeout=-1)
static int LinkCount
Definition XrdLinkXeq.hh:165
void Reset()
int Backlog()
static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0)
XrdSysMutex wrMutex
Definition XrdLinkXeq.hh:194
XrdSendQ * sendQ
Definition XrdLinkXeq.hh:195
XrdPollInfo PollInfo
Definition XrdLinkXeq.hh:145
void setID(const char *userid, int procid)
static const char * TraceID
Definition XrdLinkXeq.hh:157
bool LockReads
Definition XrdLinkXeq.hh:197
int stallCnt
Definition XrdLinkXeq.hh:174
int TLS_Recv(char *Buff, int Blen, int timeout, bool havelock=false)
int Recv(char *buff, int blen)
static long long LinkBytesIn
Definition XrdLinkXeq.hh:161
int SfIntr
Definition XrdLinkXeq.hh:178
int TLS_RecvAll(char *Buff, int Blen, int timeout)
int SFError(int rc)
int Recv(const struct iovec *iov, int iocnt, int timeout)
long long BytesIn
Definition XrdLinkXeq.hh:170
static int Stats(char *buff, int blen, bool do_sync=false)
int tardyCntTot
Definition XrdLinkXeq.hh:177
int Send(const char *buff, int blen)
XrdSysMutex rdMutex
Definition XrdLinkXeq.hh:193
bool KeepFD
Definition XrdLinkXeq.hh:198
const char * verTLS()
bool setNB()
int RecvIOV(const struct iovec *iov, int iocnt)
int tardyCnt
Definition XrdLinkXeq.hh:176
int TLS_Recv(const struct iovec *iov, int iocnt, int timeout)
int Send(const sfVec *sdP, int sdn)
char Lname[256]
Definition XrdLinkXeq.hh:201
int Send(const struct iovec *iov, int iocnt, int bytes=0)
static long long LinkConTime
Definition XrdLinkXeq.hh:163
static int LinkSfIntr
Definition XrdLinkXeq.hh:169
XrdTlsSocket tlsIO
Definition XrdLinkXeq.hh:188
void DoIt()
void setLocation(XrdNetAddrInfo::LocInfo &loc)
Definition XrdLinkXeq.hh:107
XrdProtocol * getProtocol()
Definition XrdLinkXeq.hh:82
int HNlen
Definition XrdLinkXeq.hh:196
int RecvAll(char *buff, int blen, int timeout=-1)
XrdProtocol * Protocol
Definition XrdLinkXeq.hh:183
bool Register(const char *hName)
static XrdSysMutex statsMutex
Definition XrdLinkXeq.hh:179
~XrdLinkXeq()
Definition XrdLinkXeq.hh:142
void setProtName(const char *name)
static int LinkStalls
Definition XrdLinkXeq.hh:168
const XrdNetAddr * NetAddr() const
Definition XrdLinkXeq.hh:88
static long long LinkBytesOut
Definition XrdLinkXeq.hh:162
void syncStats(int *ctime=0)
char isIdle
Definition XrdLinkXeq.hh:199
bool setTLS(bool enable, XrdTlsContext *ctx=0)
int Recv(char *buff, int blen, int timeout)
int getIOStats(long long &inbytes, long long &outbytes, int &numstall, int &numtardy)
Definition XrdLinkXeq.hh:68
static int LinkTimeOuts
Definition XrdLinkXeq.hh:167
Definition XrdNetAddrInfo.hh:54
Definition XrdNetAddr.hh:42
void SetLocation(XrdNetAddrInfo::LocInfo &loc)
Definition XrdPollInfo.hh:37
Definition XrdProtocol.hh:125
Definition XrdSendQ.hh:43
Definition XrdSysPthread.hh:165
Definition XrdTlsContext.hh:37
Definition XrdTlsPeerCerts.hh:35
Socket wrapper for TLS I/O.
Definition XrdTlsSocket.hh:40
RC
Definition XrdTls.hh:40
Definition XrdNetAddrInfo.hh:195
Definition XrdOucSFVec.hh:43
Definition XrdOucIOVec.hh:65