-
Notifications
You must be signed in to change notification settings - Fork 149
/
XrdLinkXeq.hh
189 lines (141 loc) · 6.43 KB
/
XrdLinkXeq.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#ifndef __XRD_LINKXEQ_H__
#define __XRD_LINKXEQ_H__
/******************************************************************************/
/* */
/* X r d L i n k X e q . h h */
/* */
/* (c) 2018 by the Board of Trustees of the Leland Stanford, Jr., University */
/* Produced by Andrew Hanushevsky for Stanford University under contract */
/* DE-AC02-76-SFO0515 with the Department of Energy */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#include <sys/types.h>
#include <fcntl.h>
#include <time.h>
#include "Xrd/XrdLink.hh"
#include "Xrd/XrdPollInfo.hh"
#include "Xrd/XrdProtocol.hh"
#include "XrdNet/XrdNetAddr.hh"
#include "XrdTls/XrdTlsConnection.hh"
/******************************************************************************/
/* C l a s s D e f i n i t i o n */
/******************************************************************************/
class XrdSendQ;
class XrdLinkXeq : protected XrdLink
{
public:
inline
XrdNetAddrInfo *AddrInfo() {return (XrdNetAddrInfo *)&Addr;}
int Backlog();
int Client(char *buff, int blen);
int Close(bool defer=false);
void DoIt(); // Override
int getIOStats(long long &inbytes, long long &outbytes,
int &numstall, int &numtardy)
{ inbytes = BytesIn + BytesInTot;
outbytes = BytesOut+BytesOutTot;
numstall = stallCnt + stallCntTot;
numtardy = tardyCnt + tardyCntTot;
return InUse;
}
static int getName(int &curr, char *bname, int blen, XrdLinkMatch *who=0);
inline
XrdProtocol *getProtocol() {return Protocol;}
inline
const char *Name() const {return (const char *)Lname;}
inline const
XrdNetAddr *NetAddr() const {return &Addr;}
int Peek(char *buff, int blen, int timeout=-1);
int Recv(char *buff, int blen);
int Recv(char *buff, int blen, int timeout);
int RecvAll(char *buff, int blen, int timeout=-1);
int Send(const char *buff, int blen);
int Send(const struct iovec *iov, int iocnt, int bytes=0);
int Send(const sfVec *sdP, int sdn); // Iff sfOK > 0
void setID(const char *userid, int procid);
void setLocation(XrdNetAddrInfo::LocInfo &loc) {Addr.SetLocation(loc);}
bool setNB();
XrdProtocol *setProtocol(XrdProtocol *pp, bool push);
bool setTLS(bool enable);
void Shutdown(bool getLock);
static int Stats(char *buff, int blen, bool do_sync=false);
void syncStats(int *ctime=0);
int TLS_Peek(char *Buff, int Blen, int timeout);
int TLS_Recv(char *Buff, int Blen);
int TLS_Recv(char *Buff, int Blen, int timeout);
int TLS_RecvAll(char *Buff, int Blen, int timeout);
int TLS_Send(const char *Buff, int Blen);
int TLS_Send(const struct iovec *iov, int iocnt, int bytes);
int TLS_Send(const sfVec *sfP, int sfN);
const char *verTLS();
XrdLinkXeq();
~XrdLinkXeq() {} // Is never deleted!
XrdPollInfo PollInfo;
protected:
void Reset();
int sendData(const char *Buff, int Blen);
int SFError(int rc);
int TLS_Error(const char *act, int rc);
bool TLS_Write(const char *Buff, int Blen);
static const char *TraceID;
// Statistical area (global and local)
//
static long long LinkBytesIn;
static long long LinkBytesOut;
static long long LinkConTime;
static long long LinkCountTot;
static int LinkCount;
static int LinkCountMax;
static int LinkTimeOuts;
static int LinkStalls;
static int LinkSfIntr;
long long BytesIn;
long long BytesInTot;
long long BytesOut;
long long BytesOutTot;
int stallCnt;
int stallCntTot;
int tardyCnt;
int tardyCntTot;
int SfIntr;
static XrdSysMutex statsMutex;
// Protocol section
//
XrdProtocol *Protocol; // -> Protocol tied to the link
XrdProtocol *ProtoAlt; // -> Alternate/stacked protocol
// TLS section
//
XrdTlsConnection tlsIO;
// Identification section
//
XrdNetAddr Addr;
XrdSysMutex rdMutex;
XrdSysMutex wrMutex;
XrdSendQ *sendQ; // Protected by wrMutex && opMutex
int HNlen;
bool LockReads;
bool KeepFD;
char isIdle;
char Uname[24]; // Uname and Lname must be adjacent!
char Lname[256];
};
#endif