File indexing completed on 2026-01-08 10:33:33
0001 #ifndef __XRDOFSEVR_H__
0002 #define __XRDOFSEVR_H__
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
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);
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