Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 10:33:30

0001 #ifndef __XRDSENDQ__H
0002 #define __XRDSENDQ__H
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                           X r d S e n d Q . h h                            */
0006 /*                                                                            */
0007 /* (c) 2016 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include <cstring>
0034 #include <unistd.h>
0035 #include <sys/uio.h>
0036   
0037 #include "Xrd/XrdJob.hh"
0038 
0039 class XrdLink;
0040 class XrdSysMutex;
0041 
0042 class XrdSendQ : public XrdJob
0043 {
0044 public:
0045 
0046 unsigned int  Backlog() {return inQ;}
0047 
0048 virtual  void DoIt();
0049 
0050          int  Send(const char *buff, int blen);
0051 
0052          int  Send(const struct iovec *iov, int iovcnt, int iotot);
0053 
0054 static   void SetAQ(bool onoff)         {qPerm = onoff;}
0055 
0056 static   void SetQM(unsigned int qmVal) {qMax  = qmVal;}
0057 
0058 static   void SetQW(unsigned int qwVal) {qWarn = qwVal;}
0059 
0060          void Terminate(XrdLink *lP=0);
0061 
0062          XrdSendQ(XrdLink &lP, XrdSysMutex &mP);
0063 
0064 private:
0065 
0066 virtual ~XrdSendQ() {}
0067 
0068 int      SendNB(const char *Buff, int Blen);
0069 int      SendNB(const struct iovec *iov, int iocnt, int bytes, int &iovX);
0070 
0071 struct mBuff
0072 {
0073 mBuff *next;
0074 int    mLen;
0075 char   mData[4]; // Always made long enough
0076 };
0077 
0078 bool     QMsg(mBuff *theMsg);
0079 void     RelMsgs(mBuff *mP);
0080 void     Scuttle();
0081 
0082 static unsigned int  qWarn;
0083 static unsigned int  qMax;
0084 static bool          qPerm;
0085 XrdLink             &mLink;
0086 XrdSysMutex         &wMutex;
0087 
0088 mBuff               *fMsg;
0089 mBuff               *lMsg;
0090 mBuff               *delQ;
0091 int                  theFD;
0092 unsigned int         inQ;
0093 unsigned int         qWmsg;
0094 unsigned short       discards;
0095 bool                 active;
0096 bool                 terminate;
0097 };
0098 #endif