XRootD
XrdXrootdPgwCtl.hh
Go to the documentation of this file.
1 #ifndef __XRDXROOTDPGWCTL_HH_
2 #define __XRDXROOTDPGWCTL_HH_
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d P g w C t l . h h */
6 /* */
7 /* (c) 2021 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <sys/uio.h>
33 
34 #include "XProtocol/XProtocol.hh"
35 #include "Xrd/XrdBuffer.hh"
36 #include "XrdSys/XrdSysPageSize.hh"
38 
39 class XrdXrootdFile;
40 
42 {
43 public:
44 
45 static const int crcSZ = sizeof(kXR_unt32);
46 static const int maxBSize = 1048576; // 1MB maximum buffer size
48 
51 
52 bool Advance();
53 
54 struct iovec *FrameInfo(int &iovn, int &rdlen)
55  {rdlen = iovLen;
56  return ((iovn = iovNum) ? ioVec : 0);
57  }
58 
59 kXR_unt32 *FrameInfo(int &csNum, char *&buff, int &datalen, XrdBuffer *bP)
60  {if (bP->buff != dataBuff || bP->bsize != dataBLen
61  || !iovNum) return 0;
62  csNum = iovNum>>1;
63  buff = (char *)ioVec[1].iov_base;
64  datalen = iovLen - (crcSZ * csNum);
65  return csVec;
66  }
67 
68 char *FrameLeft(int k, int &dlen)
69  {k *= 2;
70  if (k >= iovNum) {dlen = 0; return 0;}
71  char *buff = (char *)ioVec[k+1].iov_base;
72  if (!k) dlen = iovLen - (iovNum/2*crcSZ);
73  else {int n = (iovNum - k)/2;
74  dlen = ((n-1)*XrdProto::kXR_pgPageSZ)
75  + ioVec[k+1].iov_len;
76  }
77  return buff;
78  }
79 
80 const char *Setup(XrdBuffer *buffP, kXR_int64 fOffs, int totlen);
81 
82 
83  XrdXrootdPgwCtl(int pid);
85 
86 private:
87 
88 static
89 const char *TraceID;
90 char *dataBuff; // Pointer to data buffer
91 int dataBLen; // Actual length of buffer
92 int iovNum; // Number of elements in use
93 int lenLeft; // Number of bytes left to read
94 
95 int iovRem; // Number of elements remaining to do
96 int iovLen; // Length of data read by the ioVec
97 int endLen; // Length of last segment if it is short
98 int fixSRD; // ioVec[fixSRD] has short read
99 kXR_unt32 csVec[maxIOVN/2]; // Checksums received
100 struct iovec ioVec[maxIOVN]; // Read vector
101 };
102 
103 #endif
long long kXR_int64
Definition: XPtypes.hh:98
unsigned int kXR_unt32
Definition: XPtypes.hh:90
int bsize
Definition: XrdBuffer.hh:46
char * buff
Definition: XrdBuffer.hh:45
char * FrameLeft(int k, int &dlen)
kXR_unt32 * FrameInfo(int &csNum, char *&buff, int &datalen, XrdBuffer *bP)
ServerResponseStatus resp
static const int crcSZ
static const int maxIOVN
XrdXrootdPgwCtl(int pid)
static const int maxBSize
struct iovec * FrameInfo(int &iovn, int &rdlen)
const char * Setup(XrdBuffer *buffP, kXR_int64 fOffs, int totlen)
ServerResponseBody_pgWrite info
static const int kXR_pgPageSZ
Definition: XProtocol.hh:494