XrdProofdProtocol.h

Go to the documentation of this file.
00001 // @(#)root/proofd:$Id: XrdProofdProtocol.h 30920 2009-10-29 18:17:44Z ganis $
00002 // Author: G. Ganis  June 2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_XrdProofdProtocol
00013 #define ROOT_XrdProofdProtocol
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // XrdProofdProtocol                                                    //
00018 //                                                                      //
00019 // Authors: G. Ganis, CERN, 2005                                        //
00020 //                                                                      //
00021 // XrdProtocol implementation to coordinate 'proofserv' applications.   //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #include <vector>
00026 
00027 // Version index: start from 1001 (0x3E9) to distinguish from 'proofd'
00028 // To be increment when non-backward compatible changes are introduced
00029 //  1001 (0x3E9) -> 1002 (0x3EA) : support for flexible env setting
00030 //  1002 (0x3EA) -> 1003 (0x3EB) : many new features
00031 //  1003 (0x3EB) -> 1004 (0x3EC) : restructuring
00032 //  1004 (0x3EC) -> 1005 (0x3ED) : deeper restructuring
00033 //  1005 (0x3EC) -> 1006 (0x3EE) : support for ls,rm,stat,md5sum, getfile, ...
00034 #define XPROOFD_VERSBIN 0x000003EE
00035 #define XPROOFD_VERSION "0.6"
00036 
00037 #ifdef OLDXRDOUC
00038 #  include "XrdSysToOuc.h"
00039 #  include "XrdOuc/XrdOucPthread.hh"
00040 #else
00041 #  include "XrdSys/XrdSysPthread.hh"
00042 #endif
00043 #include "Xrd/XrdLink.hh"
00044 #include "Xrd/XrdObject.hh"
00045 #include "Xrd/XrdProtocol.hh"
00046 #include "XrdOuc/XrdOucString.hh"
00047 #include "XrdSec/XrdSecInterface.hh"
00048 #include "XProofProtocol.h"
00049 
00050 class XrdBuffer;
00051 class XrdProofdClient;
00052 class XrdProofdManager;
00053 class XrdProofdResponse;
00054 class XrdProofdProofServ;
00055 class XrdSrvBuffer;
00056 
00057 class XrdProofdProtocol : XrdProtocol {
00058 
00059 public:
00060    XrdProofdProtocol();
00061    virtual ~XrdProofdProtocol() {} // Never gets destroyed
00062 
00063    void          DoIt() {}
00064    XrdProtocol  *Match(XrdLink *lp);
00065    int           Process(XrdLink *lp);
00066    void          Recycle(XrdLink *lp, int x, const char *y);
00067    int           Stats(char *buff, int blen, int do_sync);
00068 
00069    static int    Configure(char *parms, XrdProtocol_Config *pi);
00070 
00071    // Buffer / Data handlers
00072    int           GetData(const char *dtype, char *buff, int blen);
00073    static XrdBuffer *GetBuff(int quantum, XrdBuffer *argp = 0);
00074    static void   ReleaseBuff(XrdBuffer *argp);
00075    static int    MaxBuffsz() { return fgMaxBuffsz; }    // Maximum buffer size we can have
00076 
00077    // Getters
00078    inline kXR_int32 CID() const { return fCID; }
00079    inline XrdProofdClient *Client() const { return fPClient; }
00080    inline int    ConnType() const { return fConnType; }
00081    inline const char *TraceID() const { return fTraceID.c_str(); }
00082    inline bool   Internal() { return (fConnType == kXPD_Internal) ? 1 : 0; }
00083    inline bool   IsCtrlC() { XrdSysMutexHelper mhp(fCtrlcMutex);
00084                              bool rc = fIsCtrlC; fIsCtrlC = 0; return rc; }
00085    inline int    Pid() const { return fPid; }
00086    inline void   ResetCtrlC() { XrdSysMutexHelper mhp(fCtrlcMutex); fIsCtrlC = 0; }
00087    inline char   Status() const { return fStatus; }
00088    inline short int ProofProtocol() const { return fProofProtocol; }
00089    inline bool   SuperUser() const { return fSuperUser; }
00090 
00091    XrdProofdResponse *Response(kXR_unt16 rid);
00092    inline XPClientRequest *Request() const { return (XPClientRequest *)&fRequest; }
00093    inline XrdBuffer *Argp() const { return fArgp; }
00094    inline XrdLink *Link() const { return fLink; }
00095    inline XrdSecProtocol *AuthProt() const { return fAuthProt; }
00096 
00097    // Setters
00098    inline void   SetAdminPath(const char *p) { XrdSysMutexHelper mhp(fMutex); fAdminPath = p; }
00099    inline void   SetAuthEntity(XrdSecEntity *se = 0) { fSecEntity.tident = fLink->ID;
00100                                                        fSecClient = (se) ? se : &fSecEntity; }
00101    inline void   SetAuthProt(XrdSecProtocol *p) { fAuthProt = p; }
00102    inline void   SetClient(XrdProofdClient *c) { fPClient = c; }
00103    inline void   SetClntCapVer(unsigned char c) { fClntCapVer = c; }
00104    inline void   SetCID(kXR_int32 cid) { fCID = cid; }
00105    inline void   SetConnType(int ct) { fConnType = ct; }
00106    inline void   SetTraceID() { if (fLink) XPDFORM(fTraceID, "%s: ", fLink->ID); }
00107    inline void   SetPid(int pid) { fPid = pid; }
00108    inline void   SetProofProtocol(short int pp) { fProofProtocol = pp; }
00109    inline void   SetStatus(char s) { fStatus = s; }
00110    inline void   SetSuperUser(bool su = 1) { fSuperUser = su; }
00111 
00112    static XrdProofdManager *Mgr() { return fgMgr; }
00113    static int    EUidAtStartup() { return fgEUidAtStartup; }
00114 
00115  private:
00116 
00117    XrdProofdResponse *GetNewResponse(kXR_unt16 rid);
00118    int           Interrupt();
00119    int           Ping();
00120    int           Process2();
00121    void          Reset();
00122    int           SendData(XrdProofdProofServ *xps, kXR_int32 sid = -1, XrdSrvBuffer **buf = 0, bool sb = 0);
00123    int           SendDataN(XrdProofdProofServ *xps, XrdSrvBuffer **buf = 0, bool sb = 0);
00124    int           SendMsg();
00125    int           CtrlC();
00126    void          TouchAdminPath();
00127    int           Urgent();
00128 
00129    //
00130    // Protocol variables
00131 
00132    XrdObject<XrdProofdProtocol>  fProtLink;
00133    XrdBuffer                    *fArgp;
00134 
00135    XrdLink                      *fLink;
00136    int                           fPid;             // Remote ID of the connected process
00137 
00138    char                          fStatus;
00139 
00140    unsigned char                 fClntCapVer;
00141    short int                     fProofProtocol;   // PROOF protocol version run by client
00142 
00143    bool                          fSuperUser;       // TRUE for privileged clients (admins)
00144 
00145    XrdProofdClient              *fPClient;         // Our reference XrdProofdClient
00146    XrdOucString                  fAdminPath;       // Admin path for this client
00147 
00148    XrdOucString                  fTraceID;          // Tracing ID
00149 
00150    XrdSecEntity                 *fSecClient;
00151    XrdSecProtocol               *fAuthProt;
00152    XrdSecEntity                  fSecEntity;
00153 
00154    kXR_int32                     fConnType;        // Type of connection: Clnt-Mst, Mst-Mst, Mst-Wrk
00155 
00156    kXR_int32                     fCID;             // Reference ID of this client
00157 
00158    XrdSysRecMutex                fMutex;           // Local mutex
00159    XrdSysRecMutex                fCtrlcMutex;      // CtrlC mutex
00160 
00161    bool                          fIsCtrlC;         // True is CtrlC was raised;
00162 
00163    //
00164    // These depend on the logical connection
00165    XPClientRequest               fRequest;  // handle client requests
00166    std::vector<XrdProofdResponse *> fResponses; // One per each logical connection
00167 
00168    //
00169    // Static area: general protocol managing section
00170    //
00171    static bool                   fgConfigDone;
00172    static int                    fgCount;
00173    static XrdObjectQ<XrdProofdProtocol> fgProtStack;
00174    static XrdBuffManager        *fgBPool;        // Buffer manager
00175    static int                    fgMaxBuffsz;    // Maximum buffer size we can have
00176    static XrdSysRecMutex         fgBMutex;       // Buffer management mutex
00177 
00178    static XrdSysError            fgEDest;     // Error message handler
00179    static XrdSysLogger          *fgLogger;    // Error logger
00180 
00181    static int                    fgEUidAtStartup; // Effective uid at startup
00182 
00183    //
00184    // Static area: protocol configuration section
00185    static int                    fgReadWait;
00186    static XrdProofdManager      *fgMgr;       // Cluster manager
00187 
00188    static void                   PostSession(int on, const char *u, const char *g,
00189                                              XrdProofdProofServ *xps);
00190 };
00191 
00192 #define XPD_SETRESP(p, x) \
00193    kXR_unt16 rid; \
00194    memcpy((void *)&rid, (const void *)&(p->Request()->header.streamid[0]), 2); \
00195    XrdProofdResponse *response = p->Response(rid); \
00196    if (!response) { \
00197       TRACEP(p, XERR, x << ": could not get Response instance for requid:"<< rid); \
00198       return rc; \
00199    }
00200 
00201 #define XPD_SETRESPV(p, x) \
00202    kXR_unt16 rid; \
00203    memcpy((void *)&rid, (const void *)&(p->Request()->header.streamid[0]), 2); \
00204    XrdProofdResponse *response = p->Response(rid); \
00205    if (!response) { \
00206       TRACEP(p, XERR, x << ": could not get Response instance for requid:"<< rid); \
00207       return; \
00208    }
00209 
00210 #define XPD_CLNT_VERSION_OK(p,v) (v < 0 || (p && p->ProofProtocol() >= v))
00211 
00212 #endif

Generated on Tue Jul 5 14:51:49 2011 for ROOT_528-00b_version by  doxygen 1.5.1