Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
XrdClientPhyConnection.hh
Go to the documentation of this file.
1#ifndef _XrdClientPhyConnection
2#define _XrdClientPhyConnection
3/******************************************************************************/
4/* */
5/* X r d C l i e n t P h y C o n n e c t i o n . h h */
6/* */
7/* Author: Fabrizio Furano (INFN Padova, 2004) */
8/* Adapted from TXNetFile (root.cern.ch) originally done by */
9/* Alvise Dorigo, Fabrizio Furano */
10/* INFN Padova, 2003 */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
33//////////////////////////////////////////////////////////////////////////
34// //
35// Class handling physical connections to xrootd servers //
36// //
37//////////////////////////////////////////////////////////////////////////
38
39
45#include "XrdSys/XrdSysPthread.hh"
46#include "XrdSys/XrdSysSemWait.hh"
47
48#include <time.h> // for time_t data type
49
51 kNo = 0,
52 kYes = 1,
53 kPending = 2
54};
55
57 kSTError = -1, // Some error occurred: server type undetermined
58 kSTNone = 0, // Remote server type un-recognized
59 kSTRootd = 1, // Remote server type: old rootd server
60 kSTBaseXrootd = 2, // Remote server type: xrootd dynamic load balancer
61 kSTDataXrootd = 3, // Remote server type: xrootd data server
62 kSTMetaXrootd = 4 // Remote server type: xrootd meta manager
63};
64
65class XrdClientSid;
66class XrdClientThread;
67class XrdSecProtocol;
68
70
71private:
73 enum ELoginState fLogged; // only 1 login/auth is needed for physical
74 XrdSecProtocol *fSecProtocol; // authentication protocol
75
77 fMsgQ; // The queue used to hold incoming messages
78
81 XrdSysRecMutex fRwMutex; // Lock before using the physical channel
82 // (for reading and/or writing)
83
85 XrdSysRecMutex fMultireadMutex; // Used to arbitrate between multiple
86 // threads reading msgs from the same conn
87
88 XrdClientThread *fReaderthreadhandler[64]; // The thread which is going to pump
89 // out the data from the socket
90
92
94
96
98
100
101 short fLogConnCnt; // Number of logical connections using this phyconn
102
103 XrdClientSid *fSidManager;
104
105public:
106 long fServerProto; // The server protocol
109
112
113 XrdClientMessage *BuildMessage(bool IgnoreTimeouts, bool Enqueue);
115
116 bool Connect(XrdClientUrlInfo RemoteHost, bool isUnix = 0);
117
118 //--------------------------------------------------------------------------
119 //! Connect to a remote location
120 //!
121 //! @param RemoteHost address descriptor
122 //! @param isUnix true if the address points to a Unix socket
123 //! @param fd a descriptor pointing to a connected socket
124 //! if the subroutine is supposed to reuse an existing
125 //! connection, -1 otherwise
126 //--------------------------------------------------------------------------
127 bool Connect( XrdClientUrlInfo RemoteHost, bool isUnix , int fd );
128
129 void CountLogConn(int d = 1);
131
133 DoHandShake(ServerInitHandShake &xbody,
134 int substreamid = 0);
135
137 short GetLogConnCnt() const { return fLogConnCnt; }
139
140 long GetTTL() { return fTTLsec; }
141
142 XrdSecProtocol *GetSecProtocol() const { return fSecProtocol; }
143 int GetSocket() { return fSocket ? fSocket->fSocket : -1; }
144
145 // Tells to the sock to rebuild the list of interesting selectors
147
148 int SaveSocket() { fTTLsec = 0; return fSocket ? (fSocket->SaveSocket()) : -1; }
150 void SetSecProtocol(XrdSecProtocol *sp) { fSecProtocol = sp; }
151
153
154 bool IsAddress(const XrdOucString &addr) {
155 return ( (fServer.Host == addr) ||
156 (fServer.HostAddr == addr) );
157 }
158
160
161 bool IsPort(int port) { return (fServer.Port == port); };
162 bool IsUser(const XrdOucString &usr) { return (fServer.User == usr); };
163 bool IsValid();
164
165
167
168 // see XrdClientSock for the meaning of the parameters
169 int ReadRaw(void *buffer, int BufferLength, int substreamid = -1,
170 int *usedsubstreamid = 0);
171
173 bool ReConnect(XrdClientUrlInfo RemoteHost);
174 void SetLogged(ELoginState status) { fLogged = status; }
175 inline void SetTTL(long ttl) { fTTLsec = ttl; }
177 void Touch();
179 int WriteRaw(const void *buffer, int BufferLength, int substreamid = 0);
180
181 int TryConnectParallelStream(int port, int windowsz, int sockid) { return ( fSocket ? fSocket->TryConnectParallelSock(port, windowsz, sockid) : -1); }
182 int EstablishPendingParallelStream(int tmpid, int newid) { return ( fSocket ? fSocket->EstablishParallelSock(tmpid, newid) : -1); }
183 void RemoveParallelStream(int substreamid) { if (fSocket) fSocket->RemoveParallelSock(substreamid); }
184 // Tells if the attempt to establish the parallel streams is ongoing or was done
185 // and mark it as ongoing or done
187
188 int GetSockIdHint(int reqsperstream) { return ( fSocket ? fSocket->GetSockIdHint(reqsperstream) : 0); }
189 int GetSockIdCount() {return ( fSocket ? fSocket->GetSockIdCount() : 0); }
190 void PauseSelectOnSubstream(int substreamid) { if (fSocket) fSocket->PauseSelectOnSubstream(substreamid); }
191 void RestartSelectOnSubstream(int substreamid) { if (fSocket) fSocket->RestartSelectOnSubstream(substreamid); }
192
193 // To prohibit/re-enable a socket descriptor from being looked at by the reader threads
194 virtual void BanSockDescr(int sockdescr, int sockid) { if (fSocket) fSocket->BanSockDescr(sockdescr, sockid); }
195 virtual void UnBanSockDescr(int sockdescr) { if (fSocket) fSocket->UnBanSockDescr(sockdescr); }
196
197 void ReadLock() { fMultireadMutex.Lock(); }
198 void ReadUnLock() { fMultireadMutex.UnLock(); }
199
200 int WipeStreamid(int streamid) { return fMsgQ.WipeStreamid(streamid); }
201};
202
203
204
205
206//
207// Class implementing a trick to automatically unlock an XrdClientPhyConnection
208//
210private:
212
213public:
215 // Constructor
216 phyconn = phyc;
218 }
219
221 // Destructor.
223 }
224
225};
226#endif
#define d(i)
Definition RSha256.hxx:102
#define h(i)
Definition RSha256.hxx:106
#define XrdSysSemWait
UnsolRespProcResult
#define XrdSysMutexHelper
Definition XrdSysToOuc.h:17
#define XrdSysRecMutex
Definition XrdSysToOuc.h:18
int WipeStreamid(int streamid)
XrdClientPhyConnection * phyconn
XrdClientPhyConnLocker(XrdClientPhyConnection *phyc)
UnsolRespProcResult HandleUnsolicited(XrdClientMessage *m)
bool ReConnect(XrdClientUrlInfo RemoteHost)
int GetSockIdHint(int reqsperstream)
ERemoteServerType DoHandShake(ServerInitHandShake &xbody, int substreamid=0)
int ReadRaw(void *buffer, int BufferLength, int substreamid=-1, int *usedsubstreamid=0)
XrdClientMessage * BuildMessage(bool IgnoreTimeouts, bool Enqueue)
virtual void BanSockDescr(int sockdescr, int sockid)
int WriteRaw(const void *buffer, int BufferLength, int substreamid=0)
ELoginState IsLogged()
XrdClientPhyConnection(XrdClientAbsUnsolMsgHandler *h, XrdClientSid *sid)
void SetLogged(ELoginState status)
bool IsAddress(const XrdOucString &addr)
void CountLogConn(int d=1)
virtual void UnBanSockDescr(int sockdescr)
void RemoveParallelStream(int substreamid)
bool Connect(XrdClientUrlInfo RemoteHost, bool isUnix, int fd)
Connect to a remote location.
void RestartSelectOnSubstream(int substreamid)
XrdClientThread * fReaderthreadhandler[64]
XrdSecProtocol * GetSecProtocol() const
void SetSecProtocol(XrdSecProtocol *sp)
XrdClientMessage * ReadMessage(int streamid)
int EstablishPendingParallelStream(int tmpid, int newid)
bool IsUser(const XrdOucString &usr)
int TryConnectParallelStream(int port, int windowsz, int sockid)
void PauseSelectOnSubstream(int substreamid)
bool Connect(XrdClientUrlInfo RemoteHost, bool isUnix=0)
void SetInterrupt(int which=0)
virtual Sockdescr TryConnectParallelSock(int, int, Sockid &)
virtual void PauseSelectOnSubstream(Sockid)
virtual int GetSockIdCount()
virtual void BanSockDescr(Sockdescr, Sockid)
virtual Sockid GetSockIdHint(int)
virtual int EstablishParallelSock(Sockid, Sockid)
virtual int RemoveParallelSock(Sockid)
virtual void RestartSelectOnSubstream(Sockid)
virtual int SaveSocket()
virtual void UnBanSockDescr(Sockdescr)
XrdOucString HostAddr
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4