XrdOfsEvr.hh

Go to the documentation of this file.
00001 #ifndef __XRDOFSEVR_H__
00002 #define __XRDOFSEVR_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                          X r d O f s E v r . h h                           */
00006 /*                                                                            */
00007 /* (c) 2006 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: XrdOfsEvr.hh 24468 2008-06-22 16:47:03Z ganis $
00014 
00015 #include <strings.h>
00016 #include "XrdOuc/XrdOucHash.hh"
00017 #include "XrdOuc/XrdOucErrInfo.hh"
00018 #include "XrdSys/XrdSysPthread.hh"
00019 #include "XrdOuc/XrdOucStream.hh"
00020 
00021 class XrdSysError;
00022 class XrdCmsClient;
00023 
00024 class XrdOfsEvr
00025 {
00026 public:
00027 class theClient;
00028 
00029 void flushEvents();
00030 
00031 int  Init(XrdSysError *eObj, XrdCmsClient *trg=0);
00032 
00033 void recvEvents();
00034 
00035 void Wait4Event(const char *path, XrdOucErrInfo *einfo);
00036 
00037 void Work4Event(theClient *Client);
00038 
00039       XrdOfsEvr() : mySem(0) {runQ = 0; deferQ = 0;}
00040      ~XrdOfsEvr();
00041 
00042 class theClient : XrdOucEICB
00043 {
00044 public:
00045 
00046 void Done(int &Result, XrdOucErrInfo *eInfo) {EvrP->Work4Event(this);}
00047 
00048 int  Same(unsigned long long arg1, unsigned long long arg2) {return 0;}
00049 
00050 theClient         *Next;
00051 const char        *User;
00052 char              *Path;
00053 XrdOfsEvr         *EvrP;
00054 XrdOucEICB        *evtCB;
00055 unsigned long long evtCBarg;
00056 
00057          theClient(XrdOfsEvr *evr, XrdOucErrInfo *einfo, const char *path=0)
00058                            {evtCB = einfo->getErrCB(evtCBarg);
00059                             User  = einfo->getErrUser();
00060                             Path  = (path ? strdup(path) : 0);
00061                             EvrP  = evr;
00062                             Next  = 0;
00063                            }
00064         ~theClient() {if (Path) free(Path);}
00065         };
00066 
00067 struct theEvent  {theClient  *aClient;
00068                   char       *finalMsg;
00069                   int         finalRC;
00070                   char        Happened;
00071 
00072                   theEvent(int rc, const char *emsg, theClient *cp=0)
00073                           {aClient = cp; finalRC = rc; Happened = 0;
00074                            finalMsg = (emsg ? strdup(emsg) : 0);
00075                           }
00076                  ~theEvent() 
00077                           {if (finalMsg) free(finalMsg);
00078                            if (aClient) delete aClient;
00079                           }
00080                   };
00081 
00082 private:
00083 
00084 void eventStage();
00085 void sendEvent(theEvent *ep);
00086 
00087 static const int     maxLife = (8*60*60); // Eight hours
00088 XrdSysMutex          myMutex;
00089 XrdSysSemaphore      mySem;
00090 XrdOucStream         eventFIFO;
00091 XrdSysError         *eDest;
00092 XrdCmsClient        *Balancer;
00093 theClient           *deferQ;
00094 int                  runQ;
00095 int                  msgFD;
00096 
00097 XrdOucHash<theEvent> Events;
00098 };
00099 #endif

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