xrootd
XrdClientConnMgr.hh
Go to the documentation of this file.
1 
2 // //
3 // XrdClientConnMgr //
4 // Author: Fabrizio Furano (INFN Padova, 2004) //
5 // Adapted from TXNetFile (root.cern.ch) originally done by //
6 // Alvise Dorigo, Fabrizio Furano //
7 // INFN Padova, 2003 //
8 // //
9 // The connection manager maps multiple logical connections on a single //
10 // physical connection. //
11 // There is one and only one logical connection per client //
12 // and one and only one physical connection per server:port. //
13 // Thus multiple objects withing a given application share //
14 // the same physical TCP channel to communicate with a server. //
15 // This reduces the time overhead for socket creation and reduces also //
16 // the server load due to handling many sockets. //
17 // //
19 
20 // $Id$
21 
22 #ifndef XRC_CONNMGR_H
23 #define XRC_CONNMGR_H
24 
25 
26 #include "XrdOuc/XrdOucHash.hh"
27 #include "XrdSys/XrdSysPthread.hh"
31 
32 class XrdClientSid;
34 class XrdClientMessage;
35 class XrdClientThread;
36 
37 // Ugly prototype to avoid warnings under solaris
38 //void * GarbageCollectorThread(void * arg, XrdClientThread *thr);
39 
42 
43 private:
45 
48 
49  // To try not to reuse too much the same array ids
51  // Phyconns are inserted here when they have to be destroyed later
52  // All the phyconns here are disconnected.
54 
55  // To arbitrate between multiple threads trying to connect to the same server.
56  // The first has to connect, all the others have to wait for the completion
57  // The meaning of this is: if there is a condvar associated to the hostname key,
58  // then wait for it to be signalled before deciding what to do
59  class CndVarInfo {
60  public:
62  int cnt;
63  CndVarInfo(): cv(0), cnt(0) {};
64  };
65 
67 
68  XrdSysRecMutex fMutex; // mutex used to protect local variables
69  // of this and TXLogConnection, TXPhyConnection
70  // classes; not used to protect i/o streams
71 
73 
74  friend void * GarbageCollectorThread(void *, XrdClientThread *thr);
77  XrdClientMessage *unsolmsg);
78 public:
80 
81  virtual ~XrdClientConnectionMgr();
82 
83  bool BootUp();
84  bool ShutDown();
85 
86 
87  int Connect(XrdClientUrlInfo RemoteAddress);
88  void Disconnect(int LogConnectionID, bool ForcePhysicalDisc);
89 
90  void GarbageCollect();
91 
93  *GetConnection(int LogConnectionID);
95 
97  ReadMsg(int LogConnectionID);
98 
99  int ReadRaw(int LogConnectionID, void *buffer, int BufferLength);
100  int WriteRaw(int LogConnectionID, const void *buffer,
101  int BufferLength, int substreamid);
102 
104 
105  friend int DisconnectElapsedPhyConn(const char *,
106  XrdClientPhyConnection *, void *);
107  friend int DestroyPhyConn(const char *,
108  XrdClientPhyConnection *, void *);
109 };
110 
111 
112 #endif