00001 #ifndef __XRDSENDQ__H 00002 #define __XRDSENDQ__H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S e n d Q . h h */ 00006 /* */ 00007 /* (c) 2016 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 <string.h> 00034 #include <unistd.h> 00035 #include <sys/uio.h> 00036 00037 #include "Xrd/XrdJob.hh" 00038 00039 class XrdLink; 00040 class XrdSysMutex; 00041 00042 class XrdSendQ : public XrdJob 00043 { 00044 public: 00045 00046 unsigned int Backlog() {return inQ;} 00047 00048 virtual void DoIt(); 00049 00050 static void Init(XrdSysError *eP, XrdScheduler *sP) {Say = eP; Sched = sP;} 00051 00052 int Send(const char *buff, int blen); 00053 00054 int Send(const struct iovec *iov, int iovcnt, int iotot); 00055 00056 static void SetAQ(bool onoff) {qPerm = onoff;} 00057 00058 static void SetQM(unsigned int qmVal) {qMax = qmVal;} 00059 00060 static void SetQW(unsigned int qwVal) {qWarn = qwVal;} 00061 00062 void Terminate(XrdLink *lP=0); 00063 00064 XrdSendQ(XrdLink &lP, XrdSysMutex &mP); 00065 00066 private: 00067 00068 virtual ~XrdSendQ() {} 00069 00070 int SendNB(const char *Buff, int Blen); 00071 int SendNB(const struct iovec *iov, int iocnt, int bytes, int &iovX); 00072 00073 struct mBuff 00074 { 00075 mBuff *next; 00076 int mLen; 00077 char mData[4]; // Always made long enough 00078 }; 00079 00080 bool QMsg(mBuff *theMsg); 00081 void RelMsgs(mBuff *mP); 00082 void Scuttle(); 00083 00084 static XrdScheduler *Sched; 00085 static XrdSysError *Say; 00086 static unsigned int qWarn; 00087 static unsigned int qMax; 00088 static bool qPerm; 00089 XrdLink &mLink; 00090 XrdSysMutex &wMutex; 00091 00092 mBuff *fMsg; 00093 mBuff *lMsg; 00094 mBuff *delQ; 00095 int theFD; 00096 unsigned int inQ; 00097 unsigned int qWmsg; 00098 unsigned short discards; 00099 bool active; 00100 bool terminate; 00101 }; 00102 #endif