xrootd
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 
13 #include "XrdOuc/XrdOucErrInfo.hh"
14 #include "XrdSys/XrdSysPthread.hh"
15 
16 #include "XProtocol/YProtocol.hh"
17 
18 /******************************************************************************/
19 /* X r d C m s R e s p C B */
20 /******************************************************************************/
21 
23 {
24 public:
25 
26 void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
27  {respSync.Post();}
28 
29 void Init() {while(respSync.CondWait()) {}}
30 
31 int Same(unsigned long long arg1, unsigned long long arg2) {return 0;}
32 
33 void Wait() {respSync.Wait();}
34 
37 
38 private:
39 
41 };
42 
43 /******************************************************************************/
44 /* X r d C m s R e s p */
45 /******************************************************************************/
46 
47 class XrdNetBuffer;
48 
49 class XrdCmsResp : public XrdOucEICB, public XrdOucErrInfo
50 {
51 public:
52 friend class XrdCmsRespQ;
53 
54 static XrdCmsResp *Alloc(XrdOucErrInfo *erp, int msgid);
55 
56  void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
57  {Recycle();}
58 
59 inline int ID() {return myID;}
60 
61  void Reply(const char *Man, XrdCms::CmsRRHdr &rrhdr,
62  XrdNetBuffer *netbuff);
63 
64 static void Reply();
65 
66  int Same(unsigned long long arg1, unsigned long long arg2)
67  {return 0;}
68 
69 static void setDelay(int repdly) {RepDelay = repdly;}
70 
73 
74 private:
75  void Recycle();
76  void ReplyXeq();
77 
79 static XrdSysMutex rdyMutex; // Protects the below
80 static XrdCmsResp *First;
81 static XrdCmsResp *Last;
82 
83 static XrdSysMutex myMutex; // Protects above and below
85 static int numFree;
86 static const int maxFree = 300;
87 static int RepDelay;
88 
91 char theMan[128];
92 
95 int myID;
96 char UserID[64];
97 };
98 
99 /******************************************************************************/
100 /* X r d O d c R e s p Q */
101 /******************************************************************************/
102 
104 {
105 public:
106  void Add(XrdCmsResp *rp);
107 
108  void Purge();
109 
110  XrdCmsResp *Rem(int msgid);
111 
112  XrdCmsRespQ();
114 
115 private:
116 
117  XrdSysMutex myMutex; // Protects above and below
118 static const int mqSize = 512;
119 
121 };
122 #endif