Logo ROOT   6.14/05
Reference Guide
XrdClientConnMgr.hh
Go to the documentation of this file.
1 #ifndef XRC_CONNMGR_H
2 #define XRC_CONNMGR_H
3 /******************************************************************************/
4 /* */
5 /* X r d C l i e n t C o n n M g r . 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 // The connection manager maps multiple logical connections on a single //
36 // physical connection. //
37 // There is one and only one logical connection per client //
38 // and one and only one physical connection per server:port. //
39 // Thus multiple objects withing a given application share //
40 // the same physical TCP channel to communicate with a server. //
41 // This reduces the time overhead for socket creation and reduces also //
42 // the server load due to handling many sockets. //
43 // //
44 //////////////////////////////////////////////////////////////////////////
45 
46 #include "XrdOuc/XrdOucHash.hh"
47 #include "XrdSys/XrdSysPthread.hh"
51 
52 class XrdClientSid;
54 class XrdClientMessage;
55 class XrdClientThread;
56 
57 // Ugly prototype to avoid warnings under solaris
58 //void * GarbageCollectorThread(void * arg, XrdClientThread *thr);
59 
62 
63 private:
64  XrdClientSid *fSidManager;
65 
67  XrdOucHash<XrdClientPhyConnection> fPhyHash;
68 
69  // To try not to reuse too much the same array ids
71  // Phyconns are inserted here when they have to be destroyed later
72  // All the phyconns here are disconnected.
74 
75  // To arbitrate between multiple threads trying to connect to the same server.
76  // The first has to connect, all the others have to wait for the completion
77  // The meaning of this is: if there is a condvar associated to the hostname key,
78  // then wait for it to be signalled before deciding what to do
79  class CndVarInfo {
80  public:
81  XrdSysCondVar cv;
82  int cnt;
83  CndVarInfo(): cv(0), cnt(0) {};
84  };
85 
86  XrdOucHash<CndVarInfo> fConnectingCondVars;
87 
88  XrdSysRecMutex fMutex; // mutex used to protect local variables
89  // of this and TXLogConnection, TXPhyConnection
90  // classes; not used to protect i/o streams
91 
92  XrdClientThread *fGarbageColl;
93 
94  friend void * GarbageCollectorThread(void *, XrdClientThread *thr);
97  XrdClientMessage *unsolmsg);
98 public:
100 
101  virtual ~XrdClientConnectionMgr();
102 
103  bool BootUp();
104  bool ShutDown();
105 
106 
107  int Connect(XrdClientUrlInfo RemoteAddress);
108  void Disconnect(int LogConnectionID, bool ForcePhysicalDisc);
109 
110  void GarbageCollect();
111 
113  *GetConnection(int LogConnectionID);
115 
117  ReadMsg(int LogConnectionID);
118 
119  int ReadRaw(int LogConnectionID, void *buffer, int BufferLength);
120  int WriteRaw(int LogConnectionID, const void *buffer,
121  int BufferLength, int substreamid);
122 
123  XrdClientSid *SidManager() { return fSidManager; }
124 
125  friend int DisconnectElapsedPhyConn(const char *,
126  XrdClientPhyConnection *, void *);
127  friend int DestroyPhyConn(const char *,
128  XrdClientPhyConnection *, void *);
129 };
130 #endif
friend void * GarbageCollectorThread(void *, XrdClientThread *thr)
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
XrdClientSid * SidManager()
XrdOucHash< XrdClientPhyConnection > fPhyHash
friend int DisconnectElapsedPhyConn(const char *, XrdClientPhyConnection *, void *)
XrdClientVector< XrdClientPhyConnection * > fPhyTrash
virtual ~XrdClientConnectionMgr()
XrdClientPhyConnection * GetPhyConnection(XrdClientUrlInfo server)
friend int DestroyPhyConn(const char *, XrdClientPhyConnection *, void *)
UnsolRespProcResult
XrdOucHash< CndVarInfo > fConnectingCondVars
int WriteRaw(int LogConnectionID, const void *buffer, int BufferLength, int substreamid)
UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *sender, XrdClientMessage *unsolmsg)
XrdClientThread * fGarbageColl
XrdClientMessage * ReadMsg(int LogConnectionID)
int ReadRaw(int LogConnectionID, void *buffer, int BufferLength)
XrdClientVector< XrdClientLogConnection * > fLogVec
int Connect(XrdClientUrlInfo RemoteAddress)
XrdClientLogConnection * GetConnection(int LogConnectionID)
void Disconnect(int LogConnectionID, bool ForcePhysicalDisc)
XrdClientSid * fSidManager