XrdCmsResp.hh

Go to the documentation of this file.
00001 #ifndef __CMS_RESP__
00002 #define __CMS_RESP__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                         X r d C m s r e s p . h h                          */
00006 /*                                                                            */
00007 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012   
00013 //          $Id: XrdCmsResp.hh 32231 2010-02-05 18:24:46Z ganis $
00014 
00015 // Based on: XrdCmsResp.hh,v 1.1 2006/09/26 07:49:15 abh
00016 
00017 #include "XrdOuc/XrdOucErrInfo.hh"
00018 #include "XrdSys/XrdSysPthread.hh"
00019 
00020 #include "XProtocol/YProtocol.hh"
00021 
00022 /******************************************************************************/
00023 /*                          X r d C m s R e s p C B                           */
00024 /******************************************************************************/
00025 
00026 class XrdCmsRespCB : XrdOucEICB
00027 {
00028 public:
00029 
00030 void Done(int &Result, XrdOucErrInfo *eInfo) {respSync.Post();}
00031 
00032 void Init() {while(respSync.CondWait()) {}}
00033 
00034 int  Same(unsigned long long arg1, unsigned long long arg2) {return 0;}
00035 
00036 void Wait() {respSync.Wait();}
00037 
00038      XrdCmsRespCB() : respSync(0) {}
00039     ~XrdCmsRespCB() {}
00040 
00041 private:
00042 
00043 XrdSysSemaphore     respSync;
00044 };
00045 
00046 /******************************************************************************/
00047 /*                            X r d C m s R e s p                             */
00048 /******************************************************************************/
00049 
00050 class XrdNetBuffer;
00051   
00052 class XrdCmsResp : public XrdOucEICB, public XrdOucErrInfo
00053 {
00054 public:
00055 friend class XrdCmsRespQ;
00056 
00057 static XrdCmsResp *Alloc(XrdOucErrInfo *erp, int msgid);
00058 
00059        void        Done(int &Result, XrdOucErrInfo *eInfo) {Recycle();}
00060 
00061 inline int         ID() {return myID;}
00062 
00063        void        Reply(const char   *Man, XrdCms::CmsRRHdr &rrhdr,
00064                          XrdNetBuffer *netbuff);
00065 
00066 static void        Reply();
00067 
00068        int         Same(unsigned long long arg1, unsigned long long arg2)
00069                        {return 0;}
00070 
00071 static void        setDelay(int repdly) {RepDelay = repdly;}
00072 
00073        XrdCmsResp() : XrdOucErrInfo(UserID) {next = 0; myBuff = 0;}
00074       ~XrdCmsResp() {}
00075 
00076 private:
00077        void Recycle();
00078        void ReplyXeq();
00079 
00080 static XrdSysSemaphore        isReady;
00081 static XrdSysMutex            rdyMutex;  // Protects the below
00082 static XrdCmsResp            *First;
00083 static XrdCmsResp            *Last;
00084 
00085 static XrdSysMutex            myMutex;  // Protects above and below
00086 static XrdCmsResp            *nextFree;
00087 static int                    numFree;
00088 static const int              maxFree = 300;
00089 static int                    RepDelay;
00090 
00091 XrdCms::CmsRRHdr    myRRHdr;
00092 XrdNetBuffer       *myBuff;
00093 char                theMan[64];
00094 
00095 XrdCmsRespCB        SyncCB;
00096 XrdCmsResp         *next;
00097 int                 myID;
00098 char                UserID[64];
00099 };
00100   
00101 /******************************************************************************/
00102 /*                           X r d O d c R e s p Q                            */
00103 /******************************************************************************/
00104   
00105 class XrdCmsRespQ
00106 {
00107 public:
00108        void        Add(XrdCmsResp *rp);
00109 
00110        void        Purge();
00111 
00112        XrdCmsResp *Rem(int msgid);
00113 
00114        XrdCmsRespQ();
00115       ~XrdCmsRespQ() {Purge();}
00116 
00117 private:
00118 
00119        XrdSysMutex  myMutex;  // Protects above and below
00120 static const int    mqSize = 512;
00121 
00122 XrdCmsResp         *mqTab[mqSize];
00123 };
00124 #endif

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