00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef XRC_PSOCK_H
00014 #define XRC_PSOCK_H
00015
00016 #include "XrdClient/XrdClientSock.hh"
00017 #include "XrdClient/XrdClientVector.hh"
00018 #include "XrdOuc/XrdOucRash.hh"
00019 #include "XrdSys/XrdSysPthread.hh"
00020
00021
00022
00023 struct fdinfo {
00024 fd_set fdset;
00025 int maxfd;
00026 };
00027
00028
00029
00030 class XrdClientPSock: public XrdClientSock {
00031
00032 friend class XrdClientPhyConnection;
00033
00034 private:
00035
00036
00037 XrdSysRecMutex fMutex;
00038
00039
00040 fdinfo globalfdinfo;
00041
00042 Sockid lastsidhint;
00043
00044
00045
00046 XrdClientVector<Sockid> fSocketIdRepo;
00047
00048
00049 XrdOucRash<Sockid, Sockdescr> fSocketPool;
00050
00051
00052
00053
00054 XrdOucRash<Sockdescr, Sockid> fSocketNYHandshakedIdPool;
00055
00056 Sockdescr GetSock(Sockid id) {
00057 XrdSysMutexHelper mtx(fMutex);
00058
00059 Sockdescr *fd = fSocketPool.Find(id);
00060 if (fd) return *fd;
00061 else return -1;
00062 }
00063
00064 Sockdescr GetMainSock() {
00065 return GetSock(0);
00066 }
00067
00068
00069 XrdOucRash<Sockdescr, Sockid> fSocketIdPool;
00070
00071
00072 Sockid GetSockId(Sockdescr sock) {
00073 XrdSysMutexHelper mtx(fMutex);
00074
00075 Sockid *id = fSocketIdPool.Find(sock);
00076 if (id) return *id;
00077 else return -1;
00078 }
00079
00080 protected:
00081
00082 virtual int SaveSocket() {
00083 XrdSysMutexHelper mtx(fMutex);
00084
00085
00086 Sockdescr *fd = fSocketPool.Find(0);
00087
00088 fSocketIdPool.Del(*fd);
00089 fSocketPool.Del(0);
00090
00091 fConnected = 0;
00092 fRDInterrupt = 0;
00093 fWRInterrupt = 0;
00094
00095 if (fd) return *fd;
00096 else return 0;
00097 }
00098
00099 public:
00100 XrdClientPSock(XrdClientUrlInfo host, int windowsize = 0);
00101 virtual ~XrdClientPSock();
00102
00103 void BanSockDescr(Sockdescr s, Sockid newid) { XrdSysMutexHelper mtx(fMutex); fSocketNYHandshakedIdPool.Rep(s, newid); }
00104 void UnBanSockDescr(Sockdescr s) { XrdSysMutexHelper mtx(fMutex); fSocketNYHandshakedIdPool.Del(s); }
00105
00106
00107
00108
00109
00110 virtual int RecvRaw(void* buffer, int length, Sockid substreamid = -1,
00111 Sockid *usedsubstreamid = 0);
00112
00113
00114
00115 virtual int SendRaw(const void* buffer, int length, Sockid substreamid = 0);
00116
00117 virtual void TryConnect(bool isUnix = 0);
00118
00119 virtual Sockdescr TryConnectParallelSock(int port, int windowsz, Sockid &tmpid);
00120
00121 virtual int EstablishParallelSock(Sockid tmpsockid, Sockid newsockid);
00122
00123 virtual void Disconnect();
00124
00125 virtual int RemoveParallelSock(Sockid sockid);
00126
00127
00128 virtual Sockid GetSockIdHint(int reqsperstream);
00129
00130
00131 virtual int GetSockIdCount() {
00132 XrdSysMutexHelper mtx(fMutex);
00133
00134 return fSocketPool.Num();
00135 }
00136
00137 virtual void PauseSelectOnSubstream(Sockid substreamid);
00138 virtual void RestartSelectOnSubstream(Sockid substreamid);
00139
00140 };
00141
00142 #endif