xrootd
XrdXrootdPgwFob.hh
Go to the documentation of this file.
1 #ifndef __XRDXROOTDPGWFOB_HH_
2 #define __XRDXROOTDPGWFOB_HH_
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d P g w F o b . 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 <set>
33 #include <string.h>
34 
35 #include "XProtocol/XProtocol.hh"
36 #include "XrdSys/XrdSysPthread.hh"
39 
40 class XrdOucString;
41 class XrdXrootdFile;
42 
44 {
45 public:
46 
48 
49 bool addOffs(kXR_int64 foffs, int dlen)
51  foffs = foffs << XrdProto::kXR_pgPageBL;
52  if (dlen < XrdProto::kXR_pgPageSZ) foffs |= dlen;
53  badOffs.insert(foffs);
54  numErrs++;
55  return badOffs.size() <= XrdProto::kXR_pgMaxEos;
56  }
57 
58 bool delOffs(kXR_int64 foffs, int dlen)
60  foffs = foffs << XrdProto::kXR_pgPageBL;
61  if (dlen < XrdProto::kXR_pgPageSZ) foffs |= dlen;
62  numFixd++;
63  return badOffs.erase(foffs) != 0;
64  }
65 
66 bool hasOffs(kXR_int64 foffs, int dlen)
68  foffs = foffs << XrdProto::kXR_pgPageBL;
69  if (dlen < XrdProto::kXR_pgPageSZ) foffs |= dlen;
70  return badOffs.find(foffs) != badOffs.end();
71  }
72 
73 int numOffs(int *errs=0, int *fixs=0)
75  if (errs) *errs = numErrs;
76  if (fixs) *fixs = numFixd;
77  return badOffs.size();
78  }
79 
81  : fileP(fP), numErrs(0), numFixd(0)
82  {memset(ctlVec, 0, sizeof(ctlVec));}
83 
85 
86 private:
87 
90 std::set<kXR_int64> badOffs; // Uncorrected offsets
91 int numErrs;
92 int numFixd;
93 };
94 #endif
XrdXrootdPgwCtl * ctlVec[XrdXrootdProtocol::maxStreams]
Definition: XrdXrootdPgwFob.hh:47
int numOffs(int *errs=0, int *fixs=0)
Definition: XrdXrootdPgwFob.hh:73
XrdXrootdFile * fileP
Definition: XrdXrootdPgwFob.hh:88
int numErrs
Definition: XrdXrootdPgwFob.hh:91
Definition: XrdXrootdPgwCtl.hh:40
bool hasOffs(kXR_int64 foffs, int dlen)
Definition: XrdXrootdPgwFob.hh:66
XrdXrootdPgwFob(XrdXrootdFile *fP)
Definition: XrdXrootdPgwFob.hh:80
Definition: XrdXrootdPgwFob.hh:43
Definition: XrdXrootdFile.hh:99
Definition: XrdSysPthread.hh:165
static const int kXR_pgPageBL
Definition: XProtocol.hh:489
bool addOffs(kXR_int64 foffs, int dlen)
Definition: XrdXrootdPgwFob.hh:49
XrdSysMutex fobMutex
Definition: XrdXrootdPgwFob.hh:89
bool delOffs(kXR_int64 foffs, int dlen)
Definition: XrdXrootdPgwFob.hh:58
static const int kXR_pgMaxEos
Definition: XProtocol.hh:492
static const int kXR_pgPageSZ
Definition: XProtocol.hh:488
std::set< kXR_int64 > badOffs
Definition: XrdXrootdPgwFob.hh:90
int numFixd
Definition: XrdXrootdPgwFob.hh:92
static const int maxStreams
Definition: XrdXrootdProtocol.hh:138
long long kXR_int64
Definition: XPtypes.hh:98
Definition: XrdOucString.hh:254
Definition: XrdSysPthread.hh:262