xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdOfs
XrdOfsEvr.hh
Go to the documentation of this file.
1
#ifndef __XRDOFSEVR_H__
2
#define __XRDOFSEVR_H__
3
/******************************************************************************/
4
/* */
5
/* X r d O f s E v r . h h */
6
/* */
7
/* (c) 2006 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 <strings.h>
34
#include "
XrdOuc/XrdOucHash.hh
"
35
#include "
XrdOuc/XrdOucErrInfo.hh
"
36
#include "
XrdSys/XrdSysPthread.hh
"
37
#include "
XrdOuc/XrdOucStream.hh
"
38
39
class
XrdSysError
;
40
class
XrdCmsClient
;
41
42
class
XrdOfsEvr
43
{
44
public
:
45
class
theClient
;
46
47
void
flushEvents
();
48
49
int
Init
(
XrdSysError
*eObj);
50
51
int
Init
(
XrdCmsClient
*trg=0);
52
53
void
recvEvents
();
54
55
void
Wait4Event
(
const
char
*path,
XrdOucErrInfo
*einfo);
56
57
void
Work4Event
(
theClient
*Client);
58
59
XrdOfsEvr
() :
mySem
(0),
eDest
(0),
Balancer
(0) {
runQ
= 0;
deferQ
= 0;}
60
~XrdOfsEvr
();
61
62
class
theClient
:
XrdOucEICB
63
{
64
public
:
65
66
void
Done
(
int
&Result,
XrdOucErrInfo
*eInfo,
const
char
*path=0)
67
{
EvrP
->
Work4Event
(
this
);}
68
69
int
Same
(
unsigned
long
long
arg1,
unsigned
long
long
arg2) {
return
0;}
70
71
theClient
*
Next
;
72
const
char
*
User
;
73
char
*
Path
;
74
XrdOfsEvr
*
EvrP
;
75
XrdOucEICB
*
evtCB
;
76
unsigned
long
long
evtCBarg
;
77
78
theClient
(
XrdOfsEvr
*evr,
XrdOucErrInfo
*einfo,
const
char
*path=0)
79
{
evtCB
= einfo->
getErrCB
(
evtCBarg
);
80
User
= einfo->
getErrUser
();
81
Path
= (path ? strdup(path) : 0);
82
EvrP
= evr;
83
Next
= 0;
84
}
85
~theClient
() {
if
(
Path
) free(
Path
);}
86
};
87
88
struct
theEvent
{
theClient
*
aClient
;
89
char
*
finalMsg
;
90
int
finalRC
;
91
char
Happened
;
92
93
theEvent
(
int
rc,
const
char
*
emsg
,
theClient
*cp=0)
94
{
aClient
= cp;
finalRC
= rc;
Happened
= 0;
95
finalMsg
= (emsg ? strdup(emsg) : 0);
96
}
97
~theEvent
()
98
{
if
(
finalMsg
) free(
finalMsg
);
99
if
(
aClient
)
delete
aClient
;
100
}
101
};
102
103
private
:
104
105
void
eventStage
();
106
void
sendEvent
(theEvent *ep);
107
108
static
const
int
maxLife
= (8*60*60);
// Eight hours
109
XrdSysMutex
myMutex
;
110
XrdSysSemaphore
mySem
;
111
XrdOucStream
eventFIFO
;
112
XrdSysError
*
eDest
;
113
XrdCmsClient
*
Balancer
;
114
theClient
*
deferQ
;
115
int
runQ
;
116
int
msgFD
;
117
118
XrdOucHash<theEvent>
Events
;
119
};
120
#endif
Generated by
1.8.3.1