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)
47 {XrdSysMutexHelper mHelp(fobMutex);
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)
56 {XrdSysMutexHelper mHelp(fobMutex);
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)
64 {XrdSysMutexHelper mHelp(fobMutex);
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)
71 {XrdSysMutexHelper mHelp(fobMutex);
72 if (errs) *errs = numErrs;
73 if (fixs) *fixs = numFixd;
74 return badOffs.size();
75 }
76
78 : fileP(fP), numErrs(0), numFixd(0) {}
79
81
82private:
83
84XrdXrootdFile *fileP;
85XrdSysMutex fobMutex;
86std::set<kXR_int64> badOffs; // Uncorrected offsets
87int numErrs;
88int numFixd;
89};
90#endif
long long kXR_int64
Definition XPtypes.hh:98
bool hasOffs(kXR_int64 foffs, int dlen)
XrdXrootdPgwFob(XrdXrootdFile *fP)
bool delOffs(kXR_int64 foffs, int dlen)
int numOffs(int *errs=0, int *fixs=0)
bool addOffs(kXR_int64 foffs, int dlen)
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