xrootd
XrdXrootdPrepare.hh
Go to the documentation of this file.
1 #ifndef __XROOTD_PREPARE__H
2 #define __XROOTD_PREPARE__H
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d P r e p a r e . h h */
6 /* */
7 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <dirent.h>
34 #include <sys/types.h>
35 
36 #include "Xrd/XrdJob.hh"
37 #include "Xrd/XrdScheduler.hh"
38 #include "XrdSys/XrdSysError.hh"
39 #include "XrdOuc/XrdOucTList.hh"
40 
41 /******************************************************************************/
42 /* X r d O l b P r e p A r g s */
43 /******************************************************************************/
44 
46 {
47 public:
48 friend class XrdXrootdPrepare;
49 
50 char *reqid;
51 char *user;
52 char *notify;
53 int prty;
54 char mode[4];
56 
57  XrdXrootdPrepArgs(int sfree=1, int pfree=1)
58  {reqid = user = notify = 0; paths = 0; *mode = '\0';
59  dirP = 0; prty = reqlen = usrlen = 0;
60  freestore = sfree; freepaths = pfree;
61  }
63  {XrdOucTList *tp;
64  if (freestore)
65  {if (reqid) free(reqid);
66  if (notify) free(notify);
67  }
68  if (freepaths) while((tp=paths)) {paths=paths->next; delete tp;}
69  if (dirP) closedir(dirP);
70  }
71 private:
72 DIR *dirP;
73 int reqlen;
74 int usrlen;
77 };
78 
79 /******************************************************************************/
80 /* C l a s s X r d O l b P r e p a r e */
81 /******************************************************************************/
82 
83 class XrdXrootdPrepare : public XrdJob
84 {
85 public:
86 
87 static int Close(int fd) {return close(fd);}
88 
89  void DoIt() {Scrub();
90  SchedP->Schedule((XrdJob *)this, scrubtime+time(0));
91  }
92 
93 static int List(XrdXrootdPrepArgs &pargs, char *resp, int resplen);
94 
95 static void Log(XrdXrootdPrepArgs &pargs);
96 
97 static void Logdel(char *reqid);
98 
99 static int Open(const char *reqid, int &fsz);
100 
101 static void Scrub();
102 
103 static int setParms(int stime, int skeep);
104 
105 static int setParms(char *ldir);
106 
107  XrdXrootdPrepare(XrdSysError *lp, XrdScheduler *sp, bool nomsg);
108  ~XrdXrootdPrepare() {} // Never gets deleted
109 
110 private:
111 
112 static const char *TraceID;
113 static XrdScheduler *SchedP; // System scheduler
114 static XrdSysError *eDest; // Error message handler
115 
116 static int scrubtime;
117 static int scrubkeep;
118 static char *LogDir;
119 static int LogDirLen;
120 };
121 #endif
static int Open(const char *reqid, int &fsz)
static int scrubtime
Definition: XrdXrootdPrepare.hh:116
~XrdXrootdPrepArgs()
Definition: XrdXrootdPrepare.hh:62
static int Close(int fd)
Definition: XrdXrootdPrepare.hh:87
static XrdScheduler * SchedP
Definition: XrdXrootdPrepare.hh:113
int freepaths
Definition: XrdXrootdPrepare.hh:76
Definition: XrdXrootdPrepare.hh:83
static int setParms(int stime, int skeep)
char mode[4]
Definition: XrdXrootdPrepare.hh:54
char * reqid
Definition: XrdXrootdPrepare.hh:50
static int scrubkeep
Definition: XrdXrootdPrepare.hh:117
Definition: XrdSysError.hh:89
DIR * dirP
Definition: XrdXrootdPrepare.hh:72
Definition: XrdScheduler.hh:44
char * user
Definition: XrdXrootdPrepare.hh:51
XrdXrootdPrepare(XrdSysError *lp, XrdScheduler *sp, bool nomsg)
static void Log(XrdXrootdPrepArgs &pargs)
char * notify
Definition: XrdXrootdPrepare.hh:52
XrdOucTList * paths
Definition: XrdXrootdPrepare.hh:55
static int LogDirLen
Definition: XrdXrootdPrepare.hh:119
static void Scrub()
int usrlen
Definition: XrdXrootdPrepare.hh:74
int freestore
Definition: XrdXrootdPrepare.hh:75
static void Logdel(char *reqid)
int reqlen
Definition: XrdXrootdPrepare.hh:73
Definition: XrdXrootdPrepare.hh:45
int prty
Definition: XrdXrootdPrepare.hh:53
XrdXrootdPrepArgs(int sfree=1, int pfree=1)
Definition: XrdXrootdPrepare.hh:57
Definition: XrdOucTList.hh:41
static XrdSysError * eDest
Definition: XrdXrootdPrepare.hh:114
#define closedir(a)
Definition: XrdPosix.hh:45
XrdOucTList * next
Definition: XrdOucTList.hh:45
#define close(a)
Definition: XrdPosix.hh:43
static char * LogDir
Definition: XrdXrootdPrepare.hh:118
static int List(XrdXrootdPrepArgs &pargs, char *resp, int resplen)
~XrdXrootdPrepare()
Definition: XrdXrootdPrepare.hh:108
static const char * TraceID
Definition: XrdXrootdPrepare.hh:112
void Schedule(XrdJob *jp)
Definition: XrdJob.hh:42
void DoIt()
Definition: XrdXrootdPrepare.hh:89