00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef XRC_CONNMGR_H
00023 #define XRC_CONNMGR_H
00024
00025
00026 #include "XrdOuc/XrdOucHash.hh"
00027 #include "XrdSys/XrdSysPthread.hh"
00028 #include "XrdClient/XrdClientUnsolMsg.hh"
00029 #include "XrdClient/XrdClientPhyConnection.hh"
00030 #include "XrdClient/XrdClientVector.hh"
00031
00032 class XrdClientSid;
00033 class XrdClientLogConnection;
00034 class XrdClientMessage;
00035 class XrdClientThread;
00036
00037
00038
00039
00040 class XrdClientConnectionMgr: public XrdClientAbsUnsolMsgHandler,
00041 XrdClientUnsolMsgSender {
00042
00043 private:
00044 XrdClientSid *fSidManager;
00045
00046 XrdClientVector<XrdClientLogConnection*> fLogVec;
00047 XrdOucHash<XrdClientPhyConnection> fPhyHash;
00048
00049
00050 int fLastLogIdUsed;
00051
00052
00053 XrdClientVector<XrdClientPhyConnection *> fPhyTrash;
00054
00055
00056
00057
00058
00059 class CndVarInfo {
00060 public:
00061 XrdSysCondVar cv;
00062 int cnt;
00063 CndVarInfo(): cv(0), cnt(0) {};
00064 };
00065
00066 XrdOucHash<CndVarInfo> fConnectingCondVars;
00067
00068 XrdSysRecMutex fMutex;
00069
00070
00071
00072 XrdClientThread *fGarbageColl;
00073
00074 friend void * GarbageCollectorThread(void *, XrdClientThread *thr);
00075 UnsolRespProcResult
00076 ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *sender,
00077 XrdClientMessage *unsolmsg);
00078 public:
00079 XrdClientConnectionMgr();
00080
00081 virtual ~XrdClientConnectionMgr();
00082
00083 int Connect(XrdClientUrlInfo RemoteAddress);
00084 void Disconnect(int LogConnectionID, bool ForcePhysicalDisc);
00085
00086 void GarbageCollect();
00087
00088 XrdClientLogConnection
00089 *GetConnection(int LogConnectionID);
00090 XrdClientPhyConnection *GetPhyConnection(XrdClientUrlInfo server);
00091
00092 XrdClientMessage*
00093 ReadMsg(int LogConnectionID);
00094
00095 int ReadRaw(int LogConnectionID, void *buffer, int BufferLength);
00096 int WriteRaw(int LogConnectionID, const void *buffer,
00097 int BufferLength, int substreamid);
00098
00099 XrdClientSid *SidManager() { return fSidManager; }
00100
00101 friend int DisconnectElapsedPhyConn(const char *,
00102 XrdClientPhyConnection *, void *);
00103 friend int DestroyPhyConn(const char *,
00104 XrdClientPhyConnection *, void *);
00105 };
00106
00107
00108 #endif