xrootd
XrdSendQ.hh
Go to the documentation of this file.
1 #ifndef __XRDSENDQ__H
2 #define __XRDSENDQ__H
3 /******************************************************************************/
4 /* */
5 /* X r d S e n d Q . h h */
6 /* */
7 /* (c) 2016 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 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <string.h>
34 #include <unistd.h>
35 #include <sys/uio.h>
36 
37 #include "Xrd/XrdJob.hh"
38 
39 class XrdLink;
40 class XrdSysMutex;
41 
42 class XrdSendQ : public XrdJob
43 {
44 public:
45 
46 unsigned int Backlog() {return inQ;}
47 
48 virtual void DoIt();
49 
50  int Send(const char *buff, int blen);
51 
52  int Send(const struct iovec *iov, int iovcnt, int iotot);
53 
54 static void SetAQ(bool onoff) {qPerm = onoff;}
55 
56 static void SetQM(unsigned int qmVal) {qMax = qmVal;}
57 
58 static void SetQW(unsigned int qwVal) {qWarn = qwVal;}
59 
60  void Terminate(XrdLink *lP=0);
61 
62  XrdSendQ(XrdLink &lP, XrdSysMutex &mP);
63 
64 private:
65 
66 virtual ~XrdSendQ() {}
67 
68 int SendNB(const char *Buff, int Blen);
69 int SendNB(const struct iovec *iov, int iocnt, int bytes, int &iovX);
70 
71 struct mBuff
72 {
74 int mLen;
75 char mData[4]; // Always made long enough
76 };
77 
78 bool QMsg(mBuff *theMsg);
79 void RelMsgs(mBuff *mP);
80 void Scuttle();
81 
82 static unsigned int qWarn;
83 static unsigned int qMax;
84 static bool qPerm;
87 
91 int theFD;
92 unsigned int inQ;
93 unsigned int qWmsg;
94 unsigned short discards;
95 bool active;
96 bool terminate;
97 };
98 #endif
unsigned short discards
Definition: XrdSendQ.hh:94
int mLen
Definition: XrdSendQ.hh:74
static unsigned int qWarn
Definition: XrdSendQ.hh:82
bool QMsg(mBuff *theMsg)
virtual void DoIt()
XrdSysMutex & wMutex
Definition: XrdSendQ.hh:86
static bool qPerm
Definition: XrdSendQ.hh:84
void Terminate(XrdLink *lP=0)
mBuff * next
Definition: XrdSendQ.hh:73
virtual ~XrdSendQ()
Definition: XrdSendQ.hh:66
void RelMsgs(mBuff *mP)
Definition: XrdSendQ.hh:71
int SendNB(const char *Buff, int Blen)
Definition: XrdSysPthread.hh:165
static unsigned int qMax
Definition: XrdSendQ.hh:83
Definition: XrdOucIOVec.hh:65
static void SetQW(unsigned int qwVal)
Definition: XrdSendQ.hh:58
char mData[4]
Definition: XrdSendQ.hh:75
XrdSendQ(XrdLink &lP, XrdSysMutex &mP)
int theFD
Definition: XrdSendQ.hh:91
Definition: XrdSendQ.hh:42
mBuff * fMsg
Definition: XrdSendQ.hh:88
mBuff * lMsg
Definition: XrdSendQ.hh:89
unsigned int inQ
Definition: XrdSendQ.hh:92
int Send(const char *buff, int blen)
bool active
Definition: XrdSendQ.hh:95
mBuff * delQ
Definition: XrdSendQ.hh:90
unsigned int qWmsg
Definition: XrdSendQ.hh:93
bool terminate
Definition: XrdSendQ.hh:96
XrdLink & mLink
Definition: XrdSendQ.hh:85
static void SetAQ(bool onoff)
Definition: XrdSendQ.hh:54
unsigned int Backlog()
Definition: XrdSendQ.hh:46
static void SetQM(unsigned int qmVal)
Definition: XrdSendQ.hh:56
void Scuttle()
Definition: XrdJob.hh:42