xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdCms
XrdCmsResp.hh
Go to the documentation of this file.
1
#ifndef __CMS_RESP__
2
#define __CMS_RESP__
3
/******************************************************************************/
4
/* */
5
/* X r d C m s r e s p . h h */
6
/* */
7
/* (c) 2007 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 "
XrdOuc/XrdOucErrInfo.hh
"
34
#include "
XrdSys/XrdSysPthread.hh
"
35
36
#include "
XProtocol/YProtocol.hh
"
37
38
/******************************************************************************/
39
/* X r d C m s R e s p C B */
40
/******************************************************************************/
41
42
class
XrdCmsRespCB
:
XrdOucEICB
43
{
44
public
:
45
46
void
Done
(
int
&Result,
XrdOucErrInfo
*eInfo,
const
char
*
Path
=0)
47
{
respSync
.
Post
();}
48
49
void
Init
() {
while
(
respSync
.
CondWait
()) {}}
50
51
int
Same
(
unsigned
long
long
arg1,
unsigned
long
long
arg2) {
return
0;}
52
53
void
Wait
() {
respSync
.
Wait
();}
54
55
XrdCmsRespCB
() :
respSync
(0) {}
56
~XrdCmsRespCB
() {}
57
58
private
:
59
60
XrdSysSemaphore
respSync
;
61
};
62
63
/******************************************************************************/
64
/* X r d C m s R e s p */
65
/******************************************************************************/
66
67
class
XrdNetBuffer
;
68
69
class
XrdCmsResp
:
public
XrdOucEICB
,
public
XrdOucErrInfo
70
{
71
public
:
72
friend
class
XrdCmsRespQ
;
73
74
static
XrdCmsResp
*
Alloc
(
XrdOucErrInfo
*erp,
int
msgid);
75
76
void
Done
(
int
&Result,
XrdOucErrInfo
*eInfo,
const
char
*
Path
=0)
77
{
Recycle
();}
78
79
inline
int
ID
() {
return
myID
;}
80
81
void
Reply
(
const
char
*Man,
XrdCms::CmsRRHdr
&rrhdr,
82
XrdNetBuffer
*netbuff);
83
84
static
void
Reply
();
85
86
int
Same
(
unsigned
long
long
arg1,
unsigned
long
long
arg2)
87
{
return
0;}
88
89
static
void
setDelay
(
int
repdly) {
RepDelay
= repdly;}
90
91
XrdCmsResp
() :
XrdOucErrInfo
(
UserID
) {
next
= 0;
myBuff
= 0;}
92
~XrdCmsResp
() {}
93
94
private
:
95
void
Recycle
();
96
void
ReplyXeq
();
97
98
static
XrdSysSemaphore
isReady
;
99
static
XrdSysMutex
rdyMutex
;
// Protects the below
100
static
XrdCmsResp
*
First
;
101
static
XrdCmsResp
*
Last
;
102
103
static
XrdSysMutex
myMutex
;
// Protects above and below
104
static
XrdCmsResp
*
nextFree
;
105
static
int
numFree
;
106
static
const
int
maxFree
= 300;
107
static
int
RepDelay
;
108
109
XrdCms::CmsRRHdr
myRRHdr
;
110
XrdNetBuffer
*
myBuff
;
111
char
theMan
[128];
112
113
XrdCmsRespCB
SyncCB
;
114
XrdCmsResp
*
next
;
115
int
myID
;
116
char
UserID
[64];
117
};
118
119
/******************************************************************************/
120
/* X r d O d c R e s p Q */
121
/******************************************************************************/
122
123
class
XrdCmsRespQ
124
{
125
public
:
126
void
Add
(
XrdCmsResp
*rp);
127
128
void
Purge
();
129
130
XrdCmsResp
*
Rem
(
int
msgid);
131
132
XrdCmsRespQ
();
133
~XrdCmsRespQ
() {
Purge
();}
134
135
private
:
136
137
XrdSysMutex
myMutex
;
// Protects above and below
138
static
const
int
mqSize
= 512;
139
140
XrdCmsResp
*
mqTab
[
mqSize
];
141
};
142
#endif
Generated by
1.8.3.1