xrootd
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 
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 // //
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:
65 
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:
82  int cnt;
83  CndVarInfo(): cv(0), cnt(0) {};
84  };
85 
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 
93 
94  friend void * GarbageCollectorThread(void *, XrdClientThread *thr);
97  XrdClientMessage *unsolmsg);
98 public:
100 
102 
103  bool BootUp();
104  bool ShutDown();
105 
106 
107  int Connect(XrdClientUrlInfo RemoteAddress);
108  void Disconnect(int LogConnectionID, bool ForcePhysicalDisc);
109 
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 
124 
125  friend int DisconnectElapsedPhyConn(const char *,
126  XrdClientPhyConnection *, void *);
127  friend int DestroyPhyConn(const char *,
128  XrdClientPhyConnection *, void *);
129 };
130 #endif
XrdClientConnectionMgr::fPhyHash
XrdOucHash< XrdClientPhyConnection > fPhyHash
Definition: XrdClientConnMgr.hh:67
XrdClientConnectionMgr::DisconnectElapsedPhyConn
friend int DisconnectElapsedPhyConn(const char *, XrdClientPhyConnection *, void *)
XrdClientConnectionMgr::GetConnection
XrdClientLogConnection * GetConnection(int LogConnectionID)
UnsolRespProcResult
UnsolRespProcResult
Definition: XrdClientUnsolMsg.hh:43
XrdSysPthread.hh
XrdClientConnectionMgr::fPhyTrash
XrdClientVector< XrdClientPhyConnection * > fPhyTrash
Definition: XrdClientConnMgr.hh:73
XrdClientThread
Definition: XrdClientThread.hh:40
XrdClientConnectionMgr::fLogVec
XrdClientVector< XrdClientLogConnection * > fLogVec
Definition: XrdClientConnMgr.hh:66
XrdClientConnectionMgr::ShutDown
bool ShutDown()
XrdClientConnectionMgr::BootUp
bool BootUp()
XrdOucHash< XrdClientPhyConnection >
XrdClientConnectionMgr::DestroyPhyConn
friend int DestroyPhyConn(const char *, XrdClientPhyConnection *, void *)
XrdClientConnectionMgr::Connect
int Connect(XrdClientUrlInfo RemoteAddress)
XrdClientConnectionMgr::GetPhyConnection
XrdClientPhyConnection * GetPhyConnection(XrdClientUrlInfo server)
XrdClientConnectionMgr::fConnectingCondVars
XrdOucHash< CndVarInfo > fConnectingCondVars
Definition: XrdClientConnMgr.hh:86
XrdOucHash.hh
XrdClientLogConnection
Definition: XrdClientLogConnection.hh:46
XrdClientConnectionMgr::WriteRaw
int WriteRaw(int LogConnectionID, const void *buffer, int BufferLength, int substreamid)
XrdClientConnectionMgr::ReadMsg
XrdClientMessage * ReadMsg(int LogConnectionID)
XrdClientConnectionMgr::ReadRaw
int ReadRaw(int LogConnectionID, void *buffer, int BufferLength)
XrdSysCondVar
Definition: XrdSysPthread.hh:79
XrdClientUnsolMsg.hh
XrdClientConnectionMgr::CndVarInfo::cv
XrdSysCondVar cv
Definition: XrdClientConnMgr.hh:81
XrdClientConnectionMgr::ProcessUnsolicitedMsg
UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *sender, XrdClientMessage *unsolmsg)
XrdClientConnectionMgr
Definition: XrdClientConnMgr.hh:61
XrdClientMessage
Definition: XrdClientMessage.hh:49
XrdClientVector< XrdClientLogConnection * >
XrdSysRecMutex
Definition: XrdSysPthread.hh:240
XrdClientConnectionMgr::fSidManager
XrdClientSid * fSidManager
Definition: XrdClientConnMgr.hh:64
XrdClientConnectionMgr::XrdClientConnectionMgr
XrdClientConnectionMgr()
XrdClientPhyConnection.hh
XrdClientConnectionMgr::CndVarInfo::cnt
int cnt
Definition: XrdClientConnMgr.hh:82
XrdClientAbsUnsolMsgHandler
Definition: XrdClientUnsolMsg.hh:51
XrdClientConnectionMgr::Disconnect
void Disconnect(int LogConnectionID, bool ForcePhysicalDisc)
XrdClientConnectionMgr::CndVarInfo::CndVarInfo
CndVarInfo()
Definition: XrdClientConnMgr.hh:83
XrdClientUnsolMsgSender
Definition: XrdClientUnsolMsg.hh:63
XrdClientConnectionMgr::SidManager
XrdClientSid * SidManager()
Definition: XrdClientConnMgr.hh:123
XrdClientUrlInfo
Definition: XrdClientUrlInfo.hh:50
XrdClientConnectionMgr::GarbageCollect
void GarbageCollect()
XrdClientVector.hh
XrdClientPhyConnection
Definition: XrdClientPhyConnection.hh:69
XrdClientConnectionMgr::fGarbageColl
XrdClientThread * fGarbageColl
Definition: XrdClientConnMgr.hh:92
XrdClientConnectionMgr::fLastLogIdUsed
int fLastLogIdUsed
Definition: XrdClientConnMgr.hh:70
XrdClientConnectionMgr::fMutex
XrdSysRecMutex fMutex
Definition: XrdClientConnMgr.hh:88
XrdClientConnectionMgr::~XrdClientConnectionMgr
virtual ~XrdClientConnectionMgr()
XrdClientConnectionMgr::CndVarInfo
Definition: XrdClientConnMgr.hh:79
XrdClientConnectionMgr::GarbageCollectorThread
friend void * GarbageCollectorThread(void *, XrdClientThread *thr)
XrdClientSid
Definition: XrdClientSid.hh:57