XRootD
Loading...
Searching...
No Matches
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
35
37
38/******************************************************************************/
39/* X r d C m s R e s p C B */
40/******************************************************************************/
41
43{
44public:
45
46void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
47 {respSync.Post();}
48
49void Init() {while(respSync.CondWait()) {}}
50
51int Same(unsigned long long arg1, unsigned long long arg2) {return 0;}
52
53void Wait() {respSync.Wait();}
54
55 XrdCmsRespCB() : respSync(0) {}
57
58private:
59
60XrdSysSemaphore respSync;
61};
62
63/******************************************************************************/
64/* X r d C m s R e s p */
65/******************************************************************************/
66
67class XrdOucBuffer;
68
69class XrdCmsResp : public XrdOucEICB, public XrdOucErrInfo
70{
71public:
72friend class XrdCmsRespQ;
73
74static XrdCmsResp *Alloc(XrdOucErrInfo *erp, int msgid);
75
76 void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
77 {Recycle();}
78
79inline int ID() {return myID;}
80
81 void Reply(const char *Man, XrdCms::CmsRRHdr &rrhdr,
82 XrdOucBuffer *netbuff);
83
84static void Reply();
85
86 int Same(unsigned long long arg1, unsigned long long arg2)
87 {return 0;}
88
89static void setDelay(int repdly) {RepDelay = repdly;}
90
91 XrdCmsResp() : XrdOucErrInfo(UserID) {next = 0; myBuff = 0;}
93
94private:
95 void Recycle();
96 void ReplyXeq();
97
98static XrdSysSemaphore isReady;
99static XrdSysMutex rdyMutex; // Protects the below
100static XrdCmsResp *First;
101static XrdCmsResp *Last;
102
103static XrdSysMutex myMutex; // Protects above and below
104static XrdCmsResp *nextFree;
105static int numFree;
106static const int maxFree = 300;
107static int RepDelay;
108
109XrdCms::CmsRRHdr myRRHdr;
110XrdOucBuffer *myBuff;
111char theMan[128];
112
113XrdCmsRespCB SyncCB;
114XrdCmsResp *next;
115int myID;
116char UserID[64];
117};
118
119/******************************************************************************/
120/* X r d O d c R e s p Q */
121/******************************************************************************/
122
124{
125public:
126 void Add(XrdCmsResp *rp);
127
128 void Purge();
129
130 XrdCmsResp *Rem(int msgid);
131
132 XrdCmsRespQ();
134
135private:
136
137 XrdSysMutex myMutex; // Protects above and below
138static const int mqSize = 512;
139
140XrdCmsResp *mqTab[mqSize];
141};
142#endif
XrdOucString Path
void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
Definition XrdCmsResp.hh:46
int Same(unsigned long long arg1, unsigned long long arg2)
Definition XrdCmsResp.hh:51
XrdCmsResp * Rem(int msgid)
void Add(XrdCmsResp *rp)
static void setDelay(int repdly)
Definition XrdCmsResp.hh:89
void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
Definition XrdCmsResp.hh:76
friend class XrdCmsRespQ
Definition XrdCmsResp.hh:72
int Same(unsigned long long arg1, unsigned long long arg2)
Definition XrdCmsResp.hh:86
static void Reply()
static XrdCmsResp * Alloc(XrdOucErrInfo *erp, int msgid)
Definition XrdCmsResp.cc:64
XrdOucEICB()
Constructor and destructor.
XrdOucErrInfo(const char *user=0, XrdOucEICB *cb=0, unsigned long long ca=0, int mid=0, int uc=0)