00001 #ifndef __CMS_CLIENTMSG__ 00002 #define __CMS_CLIENTMSG__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C m s C l i e n t M s g . h h */ 00006 /* */ 00007 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include "XProtocol/YProtocol.hh" 00034 00035 #include "XrdSys/XrdSysPthread.hh" 00036 00037 class XrdOucErrInfo; 00038 class XrdOucBuffer; 00039 00040 class XrdCmsClientMsg 00041 { 00042 public: 00043 00044 static XrdCmsClientMsg *Alloc(XrdOucErrInfo *erp); 00045 00046 inline int getResult() {return Result;} 00047 00048 inline int ID() {return id;} 00049 00050 static int Init(); 00051 00052 static int inQ() {return numinQ;} 00053 00054 void Lock() {Hold.Lock();} 00055 00056 void Recycle(); 00057 00058 static int Reply(const char *Man,XrdCms::CmsRRHdr &hdr,XrdOucBuffer *buff); 00059 00060 void UnLock() {Hold.UnLock();} 00061 00062 int Wait4Reply(int wtime) {return Hold.Wait(wtime);} 00063 00064 XrdCmsClientMsg() : Hold(0) {next = 0; inwaitq = 0; Resp = 0; Result = 0;} 00065 ~XrdCmsClientMsg() {} 00066 00067 private: 00068 static const int MidMask = 1023; 00069 static const int MaxMsgs = 1024; 00070 static const int MidIncr = 1024; 00071 static const int IncMask = 0x3ffffc00; 00072 static XrdCmsClientMsg *RemFromWaitQ(int msgid); 00073 00074 static int nextid; 00075 static int numinQ; 00076 00077 static XrdCmsClientMsg *msgTab; 00078 static XrdCmsClientMsg *nextfree; 00079 static XrdSysMutex FreeMsgQ; 00080 00081 XrdCmsClientMsg *next; 00082 XrdSysCondVar Hold; 00083 int inwaitq; 00084 int id; 00085 XrdOucErrInfo *Resp; 00086 int Result; 00087 }; 00088 #endif