Logo ROOT  
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
52class XrdClientSid;
55class XrdClientThread;
56
57// Ugly prototype to avoid warnings under solaris
58//void * GarbageCollectorThread(void * arg, XrdClientThread *thr);
59
62
63private:
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);
98public:
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
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
UnsolRespProcResult
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
virtual ~XrdClientConnectionMgr()
XrdClientThread * fGarbageColl
XrdClientSid * fSidManager
XrdClientSid * SidManager()
XrdOucHash< XrdClientPhyConnection > fPhyHash
int Connect(XrdClientUrlInfo RemoteAddress)
friend int DisconnectElapsedPhyConn(const char *, XrdClientPhyConnection *, void *)
XrdClientMessage * ReadMsg(int LogConnectionID)
XrdClientVector< XrdClientPhyConnection * > fPhyTrash
XrdClientVector< XrdClientLogConnection * > fLogVec
int WriteRaw(int LogConnectionID, const void *buffer, int BufferLength, int substreamid)
XrdClientPhyConnection * GetPhyConnection(XrdClientUrlInfo server)
void Disconnect(int LogConnectionID, bool ForcePhysicalDisc)
UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *sender, XrdClientMessage *unsolmsg)
int ReadRaw(int LogConnectionID, void *buffer, int BufferLength)
friend void * GarbageCollectorThread(void *, XrdClientThread *thr)
XrdOucHash< CndVarInfo > fConnectingCondVars
XrdClientLogConnection * GetConnection(int LogConnectionID)
friend int DestroyPhyConn(const char *, XrdClientPhyConnection *, void *)