Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 10:33:33

0001 #ifndef __XRDOFSEVR_H__
0002 #define __XRDOFSEVR_H__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                          X r d O f s E v r . h h                           */
0006 /*                                                                            */
0007 /* (c) 2006 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include <strings.h>
0034 #include "XrdOuc/XrdOucHash.hh"
0035 #include "XrdOuc/XrdOucErrInfo.hh"
0036 #include "XrdSys/XrdSysPthread.hh"
0037 #include "XrdOuc/XrdOucStream.hh"
0038 
0039 class XrdSysError;
0040 class XrdCmsClient;
0041 
0042 class XrdOfsEvr
0043 {
0044 public:
0045 class theClient;
0046 
0047 void flushEvents();
0048 
0049 int  Init(XrdSysError *eObj);
0050 
0051 int  Init(XrdCmsClient *trg=0);
0052 
0053 void recvEvents();
0054 
0055 void Wait4Event(const char *path, XrdOucErrInfo *einfo);
0056 
0057 void Work4Event(theClient *Client);
0058 
0059       XrdOfsEvr() : mySem(0), eDest(0), Balancer(0) {runQ = 0; deferQ = 0;}
0060      ~XrdOfsEvr();
0061 
0062 class theClient : XrdOucEICB
0063 {
0064 public:
0065 
0066 void Done(int &Result, XrdOucErrInfo *eInfo, const char *path=0)
0067          { (void)Result; (void)eInfo; (void)path; EvrP->Work4Event(this);}
0068 
0069 int  Same(unsigned long long arg1, unsigned long long arg2)
0070 { (void)arg1; (void)arg2; return 0;}
0071 
0072 theClient         *Next;
0073 const char        *User;
0074 char              *Path;
0075 XrdOfsEvr         *EvrP;
0076 XrdOucEICB        *evtCB;
0077 unsigned long long evtCBarg;
0078 
0079          theClient(XrdOfsEvr *evr, XrdOucErrInfo *einfo, const char *path=0)
0080                            {evtCB = einfo->getErrCB(evtCBarg);
0081                             User  = einfo->getErrUser();
0082                             Path  = (path ? strdup(path) : 0);
0083                             EvrP  = evr;
0084                             Next  = 0;
0085                            }
0086         ~theClient() {if (Path) free(Path);}
0087         };
0088 
0089 struct theEvent  {theClient  *aClient;
0090                   char       *finalMsg;
0091                   int         finalRC;
0092                   char        Happened;
0093 
0094                   theEvent(int rc, const char *emsg, theClient *cp=0)
0095                           {aClient = cp; finalRC = rc; Happened = 0;
0096                            finalMsg = (emsg ? strdup(emsg) : 0);
0097                           }
0098                  ~theEvent() 
0099                           {if (finalMsg) free(finalMsg);
0100                            if (aClient) delete aClient;
0101                           }
0102                   };
0103 
0104 private:
0105 
0106 void eventStage();
0107 void sendEvent(theEvent *ep);
0108 
0109 static const int     maxLife = (8*60*60); // Eight hours
0110 XrdSysMutex          myMutex;
0111 XrdSysSemaphore      mySem;
0112 XrdOucStream         eventFIFO;
0113 XrdSysError         *eDest;
0114 XrdCmsClient        *Balancer;
0115 theClient           *deferQ;
0116 int                  runQ;
0117 int                  msgFD;
0118 
0119 XrdOucHash<theEvent> Events;
0120 };
0121 #endif