1 #ifndef _XrdClientPhyConnection
2 #define _XrdClientPhyConnection
45 #include "XrdSys/XrdSysPthread.hh"
46 #include "XrdSys/XrdSysSemWait.hh"
56 enum ERemoteServerType {
66 class XrdClientThread;
69 class XrdClientPhyConnection:
public XrdClientUnsolMsgSender {
72 time_t fLastUseTimestamp;
73 enum ELoginState fLogged;
74 XrdSecProtocol *fSecProtocol;
81 XrdSysRecMutex fRwMutex;
84 XrdSysRecMutex fMutex;
85 XrdSysRecMutex fMultireadMutex;
88 XrdClientThread *fReaderthreadhandler[64];
91 int fReaderthreadrunning;
93 XrdClientUrlInfo fServer;
95 XrdClientSock *fSocket;
97 UnsolRespProcResult HandleUnsolicited(XrdClientMessage *m);
99 XrdSysSemWait fReaderCV;
103 XrdClientSid *fSidManager;
107 ERemoteServerType fServerType;
110 XrdClientPhyConnection(XrdClientAbsUnsolMsgHandler *h, XrdClientSid *sid);
111 ~XrdClientPhyConnection();
113 XrdClientMessage *BuildMessage(
bool IgnoreTimeouts,
bool Enqueue);
114 bool CheckAutoTerm();
116 bool Connect(XrdClientUrlInfo RemoteHost,
bool isUnix = 0);
127 bool Connect( XrdClientUrlInfo RemoteHost,
bool isUnix ,
int fd );
129 void CountLogConn(
int d = 1);
133 DoHandShake(ServerInitHandShake &xbody,
134 int substreamid = 0);
137 short GetLogConnCnt()
const {
return fLogConnCnt; }
138 int GetReaderThreadsCnt() { XrdSysMutexHelper l(fMutex);
return fReaderthreadrunning; }
140 long GetTTL() {
return fTTLsec; }
142 XrdSecProtocol *GetSecProtocol()
const {
return fSecProtocol; }
143 int GetSocket() {
return fSocket ? fSocket->fSocket : -1; }
146 void ReinitFDTable() {
if (fSocket) fSocket->ReinitFDTable(); }
148 int SaveSocket() { fTTLsec = 0;
return fSocket ? (fSocket->SaveSocket()) : -1; }
149 void SetInterrupt() {
if (fSocket) fSocket->SetInterrupt(); }
150 void SetSecProtocol(XrdSecProtocol *sp) { fSecProtocol = sp; }
152 void StartedReader();
154 bool IsAddress(
const XrdOucString &addr) {
155 return ( (fServer.Host == addr) ||
156 (fServer.HostAddr == addr) );
159 ELoginState IsLogged();
161 bool IsPort(
int port) {
return (fServer.Port == port); };
162 bool IsUser(
const XrdOucString &usr) {
return (fServer.User == usr); };
169 int ReadRaw(
void *buffer,
int BufferLength,
int substreamid = -1,
170 int *usedsubstreamid = 0);
172 XrdClientMessage *ReadMessage(
int streamid);
173 bool ReConnect(XrdClientUrlInfo RemoteHost);
174 void SetLogged(ELoginState status) { fLogged = status; }
175 inline void SetTTL(
long ttl) { fTTLsec = ttl; }
178 void UnlockChannel();
179 int WriteRaw(
const void *buffer,
int BufferLength,
int substreamid = 0);
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); }
186 bool TestAndSetMStreamsGoing();
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); }
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); }
197 void ReadLock() { fMultireadMutex.Lock(); }
198 void ReadUnLock() { fMultireadMutex.UnLock(); }
200 int WipeStreamid(
int streamid) {
return fMsgQ.WipeStreamid(streamid); }
209 class XrdClientPhyConnLocker {
211 XrdClientPhyConnection *phyconn;
214 XrdClientPhyConnLocker(XrdClientPhyConnection *phyc) {
217 phyconn->LockChannel();
220 ~XrdClientPhyConnLocker(){
222 phyconn->UnlockChannel();