Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/proofd:$Id$
2// Author: G. Ganis June 2005
5 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
12#ifndef ROOT_XrdProofConn
13#define ROOT_XrdProofConn
16// //
17// XrdProofConn //
18// //
19// Authors: G. Ganis, CERN, 2005 //
20// //
21// Low level handler of connections to xproofd. //
22// //
27#include "XrdSysToOuc.h"
28#include "XProofProtocol.h"
29#include "XProofProtUtils.h"
32#ifndef __OUC_STRING_H__
33#include "XrdOuc/XrdOucString.hh"
36#include <list>
41class XrdSysRecMutex;
42class XrdSecProtocol;
43class XrdSysPlugin;
45// Generic sender
46typedef int (*XrdProofConnSender_t)(const char *, int, void *);
50friend class TXSocket;
51friend class TXUnixSocket;
52friend class XrdProofPhyConn;
60 char fMode; // Type of client
62 int fLogConnID; // Logical connection ID of current object
63 kXR_unt16 fStreamid; // Streamid used for normal communications
64 int fRemoteProtocol; // Protocol of remote daemon
65 int fServerProto; // The server protocol
66 ESrvType fServerType; // Server type as returned by DoHandShake()
67 // (see enum ServerType)
68 short fSessionID; // proofsrv: remote ID of connected session
69 XrdOucString fUser; // Username used for login
70 XrdOucString fHost; // Remote host
71 int fPort; // Remote port
72 XrdOucString fLastErrMsg; // Msg describing last error
73 XErrorCode fLastErr; // Last error code
74 char fCapVer; // a version number (e.g. a protocol num)
76 XrdOucString fLoginBuffer; // Buffer to be sent over at login
78 XrdSysRecMutex *fMutex; // Lock SendRecv actions
80 XrdSysRecMutex *fConnectInterruptMtx; // Protect access to fConnectInterrupt
83 XrdClientPhyConnection *fPhyConn; // underlying physical connection
85 int fOpenSockFD; // Underlying socket descriptor
87 XrdClientAbsUnsolMsgHandler *fUnsolMsgHandler; // Handler of unsolicited responses
89 XrdProofConnSender_t fSender; // Generic message forwarder
90 void *fSenderArg; // Optional rgument for the message forwarder
92 XrdClientUrlInfo fUrl; // Connection URL info object with
94 static XrdClientConnectionMgr *fgConnMgr; //Connection Manager
96 static int fgMaxTry; //max number of connection attempts
97 static int fgTimeWait; //Wait time between an attempt and the other
99 static XrdSysPlugin *fgSecPlugin; // Sec library plugin
100 static void *fgSecGetProtocol; // Sec protocol getter
102 XrdSecProtocol *Authenticate(char *plist, int lsiz);
103 bool CheckErrorStatus(XrdClientMessage *, int &, const char *, bool);
104 bool CheckResp(struct ServerResponseHeader *resp,
105 const char *met, bool);
106 virtual void Connect(int = -1);
107 void ReConnect();
108 virtual int TryConnect(int = -1);
111 virtual bool GetAccessToSrv(XrdClientPhyConnection *p = 0);
112 virtual bool Init(const char *url = 0, int = -1);
113 bool Login();
114 bool MatchStreamID(struct ServerResponseHeader *resp);
116 const void *reqData, char **answData);
118 void SetInterrupt();
120 void SetConnectInterrupt();
121 bool ConnectInterrupt();
124 XrdProofConn(const char *url, char mode = 'M', int psid = -1, char ver = -1,
125 XrdClientAbsUnsolMsgHandler * uh = 0, const char *logbuf = 0);
126 virtual ~XrdProofConn();
128 virtual void Close(const char *opt = "");
130 int GetLogConnID() const { return fLogConnID; }
131 int GetLowSocket();
132 int GetOpenError() const { return (int)fLastErr; }
133 int GetServType() const { return (int)fServerType; }
134 short GetSessionID() const { return fSessionID; }
135 const char *GetUrl() { return (const char *) fUrl.GetUrl().c_str(); }
136 const char *GetLastErr() { return fLastErrMsg.c_str(); }
138 bool IsValid() const;
140 XReqErrorType LowWrite(XPClientRequest *, const void *, int);
142 // Send, Recv interfaces
143 virtual int ReadRaw(void *buf, int len, XrdClientPhyConnection *p = 0);
144 virtual XrdClientMessage *ReadMsg();
145 XrdClientMessage *SendReq(XPClientRequest *req, const void *reqData,
146 char **answData, const char *CmdName,
147 bool notifyerr = 1);
148 virtual void SetAsync(XrdClientAbsUnsolMsgHandler *uh, XrdProofConnSender_t = 0, void * = 0);
149 void SetSID(kXR_char *sid);
150 virtual int WriteRaw(const void *buf, int len, XrdClientPhyConnection *p = 0);
152 static void GetRetryParam(int &maxtry, int &timewait);
153 static void SetRetryParam(int maxtry = 5, int timewait = 2);
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
#define XrdSysPlugin
Definition: XpdSysPlugin.h:8
int(* XrdProofConnSender_t)(const char *, int, void *)
Definition: XrdProofConn.h:46
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
High level handler of connections to XProofD.
Definition: TXSocket.h:59
Implementation of TXSocket using PF_UNIX sockets.
Definition: TXUnixSocket.h:29
XrdOucString GetUrl()
ESrvType DoHandShake(XrdClientPhyConnection *p=0)
Performs initial hand-shake with the server in order to understand which kind of server is there at t...
virtual int TryConnect(int=-1)
Connect to remote server.
static void GetRetryParam(int &maxtry, int &timewait)
Retrieve current values of the retry control parameters, numer of retries and wait time between attem...
static int fgTimeWait
Definition: XrdProofConn.h:97
XrdClientPhyConnection * fPhyConn
Definition: XrdProofConn.h:83
XrdClientMessage * SendReq(XPClientRequest *req, const void *reqData, char **answData, const char *CmdName, bool notifyerr=1)
SendReq tries to send a single command for a number of times.
ESrvType fServerType
Definition: XrdProofConn.h:66
static void * fgSecGetProtocol
Definition: XrdProofConn.h:100
virtual bool Init(const char *url=0, int=-1)
int fRemoteProtocol
Definition: XrdProofConn.h:64
static int fgMaxTry
Definition: XrdProofConn.h:96
XrdSecProtocol * Authenticate(char *plist, int lsiz)
Negotiate authentication with the remote server.
bool ConnectInterrupt()
Check if interrupted during connect.
bool CheckErrorStatus(XrdClientMessage *, int &, const char *, bool)
Check error status.
virtual void SetAsync(XrdClientAbsUnsolMsgHandler *uh, XrdProofConnSender_t=0, void *=0)
Set handler of unsolicited responses.
XrdProofConnSender_t fSender
Definition: XrdProofConn.h:89
virtual bool GetAccessToSrv(XrdClientPhyConnection *p=0)
Gets access to the connected server.
bool MatchStreamID(struct ServerResponseHeader *resp)
Check stream ID matching.
int GetLogConnID() const
Definition: XrdProofConn.h:130
short fSessionID
Definition: XrdProofConn.h:68
XrdOucRecMutex * fConnectInterruptMtx
Definition: XrdProofConn.h:80
XrdClientAbsUnsolMsgHandler * fUnsolMsgHandler
Definition: XrdProofConn.h:87
XErrorCode fLastErr
Definition: XrdProofConn.h:73
virtual UnsolRespProcResult ProcessUnsolicitedMsg(XrdClientUnsolMsgSender *s, XrdClientMessage *m)
We are here if an unsolicited response comes from a logical conn The response comes in the form of an...
bool IsValid() const
Test validity of this connection.
virtual int WriteRaw(const void *buf, int len, XrdClientPhyConnection *p=0)
Low level write call.
bool CheckResp(struct ServerResponseHeader *resp, const char *met, bool)
Checks if the server's response is ours.
virtual void Close(const char *opt="")
Close connection.
XrdClientMessage * SendRecv(XPClientRequest *req, const void *reqData, char **answData)
SendRecv sends a command to the server and to get a response.
static XrdClientConnectionMgr * fgConnMgr
Definition: XrdProofConn.h:94
XrdClientUrlInfo fUrl
Definition: XrdProofConn.h:92
kXR_unt16 fStreamid
Definition: XrdProofConn.h:63
virtual ~XrdProofConn()
short GetSessionID() const
Definition: XrdProofConn.h:134
virtual XrdClientMessage * ReadMsg()
Pickup message from the queue.
void SetSID(kXR_char *sid)
Set our stream id, to match against that one in the server's response.
XrdOucString fUser
Definition: XrdProofConn.h:69
XrdOucString fLastErrMsg
Definition: XrdProofConn.h:72
XrdOucRecMutex * fMutex
Definition: XrdProofConn.h:78
XReqErrorType LowWrite(XPClientRequest *, const void *, int)
Send request to server (NB: req is marshalled at this point, so we need also the plain reqDataLen)
const char * GetLastErr()
Definition: XrdProofConn.h:136
void * fSenderArg
Definition: XrdProofConn.h:90
virtual void Connect(int=-1)
Run the connection attempts: the result is stored in fConnected.
XrdOucString fLoginBuffer
Definition: XrdProofConn.h:76
static XrdOucPlugin * fgSecPlugin
Definition: XrdProofConn.h:99
int GetLowSocket()
Return the socket descriptor of the underlying connection.
XrdProofConn(const char *url, char mode='M', int psid=-1, char ver=-1, XrdClientAbsUnsolMsgHandler *uh=0, const char *logbuf=0)
bool Login()
This method perform the loggin-in into the server just after the hand-shake.
void ReConnect()
Perform a reconnection attempt when a connection is not valid any more.
int GetOpenError() const
Definition: XrdProofConn.h:132
static void SetRetryParam(int maxtry=5, int timewait=2)
Change values of the retry control parameters, numer of retries and wait time between attempts (in se...
const char * GetUrl()
Definition: XrdProofConn.h:135
virtual int ReadRaw(void *buf, int len, XrdClientPhyConnection *p=0)
Low level receive call.
int GetServType() const
Definition: XrdProofConn.h:133
bool fConnectInterrupt
Definition: XrdProofConn.h:81
XrdOucString fHost
Definition: XrdProofConn.h:70
void SetInterrupt()
Interrupt the underlying socket.
void SetConnectInterrupt()
Interrupt connection attempts.
static constexpr double s
TMarker m
Definition: textangle.C:8