xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdClient
XrdClientSid.hh
Go to the documentation of this file.
1
#ifndef XRC_SID_H
2
#define XRC_SID_H
3
/******************************************************************************/
4
/* */
5
/* X r d C l i e n t S i d . h h */
6
/* */
7
/* Author: Fabrizio Furano (INFN Padova, 2005) */
8
/* */
9
/* This file is part of the XRootD software suite. */
10
/* */
11
/* XRootD is free software: you can redistribute it and/or modify it under */
12
/* the terms of the GNU Lesser General Public License as published by the */
13
/* Free Software Foundation, either version 3 of the License, or (at your */
14
/* option) any later version. */
15
/* */
16
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
17
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
18
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
19
/* License for more details. */
20
/* */
21
/* You should have received a copy of the GNU Lesser General Public License */
22
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
23
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
24
/* */
25
/* The copyright holder's institutional names and contributor's names may not */
26
/* be used to endorse or promote products derived from this software without */
27
/* specific prior written permission of the institution or contributor. */
28
/******************************************************************************/
29
31
// //
32
// Utility classes to handle the mapping between xrootd streamids. //
33
// A single streamid can have multiple "parallel" streamids. //
34
// Their use is typically to support the client to submit multiple //
35
// parallel requests (belonging to the same LogConnectionID), //
36
// whose answers are to be processed asynchronously when they arrive. //
37
// //
39
40
#include "
XrdOuc/XrdOucRash.hh
"
41
#include "
XProtocol/XProtocol.hh
"
42
#include "
XrdClient/XrdClientProtocol.hh
"
43
#include "
XrdClient/XrdClientVector.hh
"
44
#include "
XrdSys/XrdSysPthread.hh
"
45
46
struct
SidInfo
{
47
kXR_unt16
fathersid
;
48
ClientRequest
outstandingreq
;
49
long
long
reqbyteprogress
;
50
time_t
sendtime
;
51
52
kXR_unt16
rspstatuscode
;
53
kXR_unt32
rsperrno
;
54
char
*
rsperrmsg
;
55
};
56
57
class
XrdClientSid
{
58
59
private
:
60
// Used to quickly get info about a sid being used
61
// as a child of another sid. A child sid is used to parallely
62
// interact with a server for the same logical connection using its father sid
63
// Only child sids are inserted here. If a sid is not here but is not free,
64
// then it's a father sid, i.e. normally a sid used for the non async xrootd traffic
65
// Remember: for any child sid, it's mandatory to keep the request
66
// which is outstanding for that stream. This struct can be used to
67
// read data, but also for preparing many files in advance.
68
XrdOucRash<kXR_unt16, struct SidInfo>
childsidnfo
;
69
70
// To quickly get a sid which is not being used
71
// This one has constant time operations if the ops
72
// are performed at the back of the vector
73
// Remember: 0 is NOT a valid sid
74
XrdClientVector<kXR_unt16>
freesids
;
75
76
XrdSysMutex
fMutex
;
77
78
public
:
79
XrdClientSid
();
80
virtual
~XrdClientSid
();
81
82
// Gets an available sid
83
// From now on it will be no more available.
84
// A retval of 0 means that there are no more available sids
85
kXR_unt16
GetNewSid
();
86
87
// Gets an available sid for a request which is to be outstanding
88
// This means that this sid will be inserted into the Rash
89
// The request gets inserted the new sid in the right place
90
// Also the one passed as parameter gets the new sid, as should be expected
91
kXR_unt16
GetNewSid
(
kXR_unt16
sid,
ClientRequest
*req);
92
93
94
// Releases a sid.
95
// It is re-inserted into the available set
96
// Its info is rmeoved from the tree
97
void
ReleaseSid
(
kXR_unt16
sid);
98
99
// Releases a sid and all its childs
100
void
ReleaseSidTree
(
kXR_unt16
fathersid);
101
102
// Report the response for an outstanding request
103
// Typically this is used to keep track of the received errors, expecially
104
// for async writes
105
void
ReportSidResp
(
kXR_unt16
sid,
kXR_unt16
statuscode,
kXR_unt32
errcode,
char
*errmsg);
106
107
int
GetFailedOutstandingWriteRequests
(
kXR_unt16
fathersid,
XrdClientVector<ClientRequest>
&reqvect);
108
int
GetAllOutstandingWriteRequests
(
kXR_unt16
fathersid,
XrdClientVector<ClientRequest>
&reqvect);
109
int
GetOutstandingWriteRequestCnt
(
kXR_unt16
fathersid);
110
111
// 0 if non existent as a child sid
112
inline
struct
SidInfo
*
GetSidInfo
(
kXR_unt16
sid) {
113
XrdSysMutexHelper
l(
fMutex
);
114
return
(
childsidnfo
.
Find
(sid));
115
};
116
117
inline
bool
JoinedSids
(
kXR_unt16
father,
kXR_unt16
child
) {
118
XrdSysMutexHelper
l(
fMutex
);
119
120
struct
SidInfo
*si =
childsidnfo
.
Find
(child);
121
122
if
(!si)
return
false
;
123
return
(si->
fathersid
== father);
124
}
125
126
127
// Useful for debugging
128
void
PrintoutOutstandingRequests
();
129
};
130
#endif
Generated by
1.8.3.1