xrootd
Loading...
Searching...
No Matches
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 <cstring>
34
37
38class XrdOucString;
39class XrdXrootdFile;
40
42{
43public:
44
45
46bool addOffs(kXR_int64 foffs, int dlen)
48 foffs = foffs << XrdProto::kXR_pgPageBL;
49 if (dlen < XrdProto::kXR_pgPageSZ) foffs |= dlen;
50 badOffs.insert(foffs);
51 numErrs++;
52 return badOffs.size() <= XrdProto::kXR_pgMaxEos;
53 }
54
55bool delOffs(kXR_int64 foffs, int dlen)
57 foffs = foffs << XrdProto::kXR_pgPageBL;
58 if (dlen < XrdProto::kXR_pgPageSZ) foffs |= dlen;
59 numFixd++;
60 return badOffs.erase(foffs) != 0;
61 }
62
63bool hasOffs(kXR_int64 foffs, int dlen)
65 foffs = foffs << XrdProto::kXR_pgPageBL;
66 if (dlen < XrdProto::kXR_pgPageSZ) foffs |= dlen;
67 return badOffs.find(foffs) != badOffs.end();
68 }
69
70int numOffs(int *errs=0, int *fixs=0)
72 if (errs) *errs = numErrs;
73 if (fixs) *fixs = numFixd;
74 return badOffs.size();
75 }
76
79
81
82private:
83
86std::set<kXR_int64> badOffs; // Uncorrected offsets
89};
90#endif
long long kXR_int64
Definition XPtypes.hh:98
Definition XrdOucString.hh:254
Definition XrdSysPthread.hh:263
Definition XrdSysPthread.hh:165
Definition XrdXrootdFile.hh:101
Definition XrdXrootdPgwFob.hh:42
bool hasOffs(kXR_int64 foffs, int dlen)
Definition XrdXrootdPgwFob.hh:63
XrdXrootdPgwFob(XrdXrootdFile *fP)
Definition XrdXrootdPgwFob.hh:77
int numFixd
Definition XrdXrootdPgwFob.hh:88
int numErrs
Definition XrdXrootdPgwFob.hh:87
std::set< kXR_int64 > badOffs
Definition XrdXrootdPgwFob.hh:86
bool delOffs(kXR_int64 foffs, int dlen)
Definition XrdXrootdPgwFob.hh:55
int numOffs(int *errs=0, int *fixs=0)
Definition XrdXrootdPgwFob.hh:70
XrdSysMutex fobMutex
Definition XrdXrootdPgwFob.hh:85
XrdXrootdFile * fileP
Definition XrdXrootdPgwFob.hh:84
bool addOffs(kXR_int64 foffs, int dlen)
Definition XrdXrootdPgwFob.hh:46
static const int kXR_pgPageSZ
Definition XProtocol.hh:494
static const int kXR_pgPageBL
Definition XProtocol.hh:495
static const int kXR_pgMaxEos
Definition XProtocol.hh:498