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
35
#include "
XProtocol/XProtocol.hh
"
36
#include "
XrdSys/XrdSysPthread.hh
"
37
38
class
XrdOucString
;
39
class
XrdXrootdFile
;
40
41
class
XrdXrootdPgwFob
42
{
43
public
:
44
45
46
bool
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
55
bool
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
63
bool
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
70
int
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
77
XrdXrootdPgwFob
(
XrdXrootdFile
*fP)
78
: fileP(fP), numErrs(0), numFixd(0) {}
79
80
~XrdXrootdPgwFob
();
81
82
private
:
83
84
XrdXrootdFile
*fileP;
85
XrdSysMutex
fobMutex;
86
std::set<kXR_int64> badOffs;
// Uncorrected offsets
87
int
numErrs;
88
int
numFixd;
89
};
90
#endif
XProtocol.hh
kXR_int64
long long kXR_int64
Definition
XPtypes.hh:98
XrdSysPthread.hh
XrdOucString
Definition
XrdOucString.hh:252
XrdSysMutexHelper
Definition
XrdSysPthread.hh:263
XrdSysMutex
Definition
XrdSysPthread.hh:165
XrdXrootdFile
Definition
XrdXrootdFile.hh:101
XrdXrootdPgwFob
Definition
XrdXrootdPgwFob.hh:42
XrdXrootdPgwFob::hasOffs
bool hasOffs(kXR_int64 foffs, int dlen)
Definition
XrdXrootdPgwFob.hh:63
XrdXrootdPgwFob::XrdXrootdPgwFob
XrdXrootdPgwFob(XrdXrootdFile *fP)
Definition
XrdXrootdPgwFob.hh:77
XrdXrootdPgwFob::delOffs
bool delOffs(kXR_int64 foffs, int dlen)
Definition
XrdXrootdPgwFob.hh:55
XrdXrootdPgwFob::numOffs
int numOffs(int *errs=0, int *fixs=0)
Definition
XrdXrootdPgwFob.hh:70
XrdXrootdPgwFob::addOffs
bool addOffs(kXR_int64 foffs, int dlen)
Definition
XrdXrootdPgwFob.hh:46
XrdXrootd
XrdXrootdPgwFob.hh
Generated by
1.18.0