xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
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 
57 
58 private:
59 
61 };
62 
63 /******************************************************************************/
64 /* X r d C m s R e s p */
65 /******************************************************************************/
66 
67 class XrdOucBuffer;
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  XrdOucBuffer *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 
93 
94 private:
95  void Recycle();
96  void ReplyXeq();
97 
99 static XrdSysMutex rdyMutex; // Protects the below
101 static XrdCmsResp *Last;
102 
103 static XrdSysMutex myMutex; // Protects above and below
105 static int numFree;
106 static const int maxFree = 300;
107 static int RepDelay;
108 
111 char theMan[128];
112 
115 int myID;
116 char UserID[64];
117 };
118 
119 /******************************************************************************/
120 /* X r d O d c R e s p Q */
121 /******************************************************************************/
122 
124 {
125 public:
126  void Add(XrdCmsResp *rp);
127 
128  void Purge();
129 
130  XrdCmsResp *Rem(int msgid);
131 
132  XrdCmsRespQ();
134 
135 private:
136 
137  XrdSysMutex myMutex; // Protects above and below
138 static const int mqSize = 512;
139 
141 };
142 #endif
static XrdSysMutex rdyMutex
Definition: XrdCmsResp.hh:99
static XrdCmsResp * Last
Definition: XrdCmsResp.hh:101
Definition: XrdCmsResp.hh:42
int ID()
Definition: XrdCmsResp.hh:79
XrdOucBuffer * myBuff
Definition: XrdCmsResp.hh:110
int CondWait()
Definition: XrdSysPthread.hh:497
Definition: YProtocol.hh:82
XrdCmsRespCB SyncCB
Definition: XrdCmsResp.hh:113
void Init()
Definition: XrdCmsResp.hh:49
void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
Definition: XrdCmsResp.hh:46
void Wait()
Definition: XrdSysPthread.hh:509
void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
Definition: XrdCmsResp.hh:76
~XrdCmsResp()
Definition: XrdCmsResp.hh:92
char UserID[64]
Definition: XrdCmsResp.hh:116
XrdCmsRespCB()
Definition: XrdCmsResp.hh:55
Definition: XrdSysPthread.hh:164
static XrdCmsResp * nextFree
Definition: XrdCmsResp.hh:104
static void Reply()
static int RepDelay
Definition: XrdCmsResp.hh:107
static const int maxFree
Definition: XrdCmsResp.hh:106
int myID
Definition: XrdCmsResp.hh:115
XrdCms::CmsRRHdr myRRHdr
Definition: XrdCmsResp.hh:109
void Post()
Definition: XrdSysPthread.hh:505
Definition: XrdCmsResp.hh:123
Definition: XrdOucErrInfo.hh:100
Definition: XrdSysPthread.hh:493
void Recycle()
int Same(unsigned long long arg1, unsigned long long arg2)
Definition: XrdCmsResp.hh:51
static XrdCmsResp * Alloc(XrdOucErrInfo *erp, int msgid)
static const int mqSize
Definition: XrdCmsResp.hh:138
static XrdCmsResp * First
Definition: XrdCmsResp.hh:100
XrdCmsResp * mqTab[mqSize]
Definition: XrdCmsResp.hh:140
XrdCmsResp * Rem(int msgid)
Definition: XrdOucBuffer.hh:140
void Add(XrdCmsResp *rp)
XrdCmsResp * next
Definition: XrdCmsResp.hh:114
XrdCmsResp()
Definition: XrdCmsResp.hh:91
Definition: XrdCmsResp.hh:69
XrdSysMutex myMutex
Definition: XrdCmsResp.hh:137
~XrdCmsRespQ()
Definition: XrdCmsResp.hh:133
XrdSysSemaphore respSync
Definition: XrdCmsResp.hh:60
int Same(unsigned long long arg1, unsigned long long arg2)
Definition: XrdCmsResp.hh:86
void Wait()
Definition: XrdCmsResp.hh:53
~XrdCmsRespCB()
Definition: XrdCmsResp.hh:56
char theMan[128]
Definition: XrdCmsResp.hh:111
Definition: XrdOucErrInfo.hh:484
void Purge()
static XrdSysMutex myMutex
Definition: XrdCmsResp.hh:103
void ReplyXeq()
static int numFree
Definition: XrdCmsResp.hh:105
static void setDelay(int repdly)
Definition: XrdCmsResp.hh:89
static XrdSysSemaphore isReady
Definition: XrdCmsResp.hh:98