xrootd
Loading...
Searching...
No Matches
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
35#include "Xrd/XrdBuffer.hh"
38
39class XrdXrootdFile;
40
42{
43public:
44
45static const int crcSZ = sizeof(kXR_unt32);
46static const int maxBSize = 1048576; // 1MB maximum buffer size
48
51
52bool Advance();
53
54struct iovec *FrameInfo(int &iovn, int &rdlen)
55 {rdlen = iovLen;
56 return ((iovn = iovNum) ? ioVec : 0);
57 }
58
59kXR_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
68char *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
80const char *Setup(XrdBuffer *buffP, kXR_int64 fOffs, int totlen);
81
82
85
86private:
87
88static
89const char *TraceID;
90char *dataBuff; // Pointer to data buffer
91int dataBLen; // Actual length of buffer
92int iovNum; // Number of elements in use
93int lenLeft; // Number of bytes left to read
94
95int iovRem; // Number of elements remaining to do
96int iovLen; // Length of data read by the ioVec
97int endLen; // Length of last segment if it is short
98int fixSRD; // ioVec[fixSRD] has short read
99kXR_unt32 csVec[maxIOVN/2]; // Checksums received
100struct 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
Definition XrdBuffer.hh:42
int bsize
Definition XrdBuffer.hh:46
char * buff
Definition XrdBuffer.hh:45
Definition XrdXrootdFile.hh:101
Definition XrdXrootdPgwBadCS.hh:37
Definition XrdXrootdPgwCtl.hh:42
int iovLen
Definition XrdXrootdPgwCtl.hh:96
int iovRem
Definition XrdXrootdPgwCtl.hh:95
ServerResponseStatus resp
Definition XrdXrootdPgwCtl.hh:49
static const int crcSZ
Definition XrdXrootdPgwCtl.hh:45
struct iovec * FrameInfo(int &iovn, int &rdlen)
Definition XrdXrootdPgwCtl.hh:54
int lenLeft
Definition XrdXrootdPgwCtl.hh:93
int dataBLen
Definition XrdXrootdPgwCtl.hh:91
~XrdXrootdPgwCtl()
Definition XrdXrootdPgwCtl.hh:84
char * dataBuff
Definition XrdXrootdPgwCtl.hh:90
int fixSRD
Definition XrdXrootdPgwCtl.hh:98
struct iovec ioVec[maxIOVN]
Definition XrdXrootdPgwCtl.hh:100
static const int maxIOVN
Definition XrdXrootdPgwCtl.hh:47
XrdXrootdPgwCtl(int pid)
int endLen
Definition XrdXrootdPgwCtl.hh:97
static const int maxBSize
Definition XrdXrootdPgwCtl.hh:46
kXR_unt32 csVec[maxIOVN/2]
Definition XrdXrootdPgwCtl.hh:99
const char * Setup(XrdBuffer *buffP, kXR_int64 fOffs, int totlen)
char * FrameLeft(int k, int &dlen)
Definition XrdXrootdPgwCtl.hh:68
kXR_unt32 * FrameInfo(int &csNum, char *&buff, int &datalen, XrdBuffer *bP)
Definition XrdXrootdPgwCtl.hh:59
static const char * TraceID
Definition XrdXrootdPgwCtl.hh:89
int iovNum
Definition XrdXrootdPgwCtl.hh:92
ServerResponseBody_pgWrite info
Definition XrdXrootdPgwCtl.hh:50
static const int kXR_pgPageSZ
Definition XProtocol.hh:494
Definition XProtocol.hh:1064
Definition XProtocol.hh:1255