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 int Send(const char *buff, int blen); 00051 00052 int Send(const struct iovec *iov, int iovcnt, int iotot); 00053 00054 static void SetAQ(bool onoff) {qPerm = onoff;} 00055 00056 static void SetQM(unsigned int qmVal) {qMax = qmVal;} 00057 00058 static void SetQW(unsigned int qwVal) {qWarn = qwVal;} 00059 00060 void Terminate(XrdLink *lP=0); 00061 00062 XrdSendQ(XrdLink &lP, XrdSysMutex &mP); 00063 00064 private: 00065 00066 virtual ~XrdSendQ() {} 00067 00068 int SendNB(const char *Buff, int Blen); 00069 int SendNB(const struct iovec *iov, int iocnt, int bytes, int &iovX); 00070 00071 struct mBuff 00072 { 00073 mBuff *next; 00074 int mLen; 00075 char mData[4]; // Always made long enough 00076 }; 00077 00078 bool QMsg(mBuff *theMsg); 00079 void RelMsgs(mBuff *mP); 00080 void Scuttle(); 00081 00082 static unsigned int qWarn; 00083 static unsigned int qMax; 00084 static bool qPerm; 00085 XrdLink &mLink; 00086 XrdSysMutex &wMutex; 00087 00088 mBuff *fMsg; 00089 mBuff *lMsg; 00090 mBuff *delQ; 00091 int theFD; 00092 unsigned int inQ; 00093 unsigned int qWmsg; 00094 unsigned short discards; 00095 bool active; 00096 bool terminate; 00097 }; 00098 #endif