xrootd
XrdClientSid.hh
Go to the documentation of this file.
1 
2 // //
3 // XrdClientMessage //
4 // //
5 // Author: Fabrizio Furano (INFN Padova, 2005) //
6 // //
7 // Utility classes to handle the mapping between xrootd streamids. //
8 // A single streamid can have multiple "parallel" streamids. //
9 // Their use is typically to support the client to submit multiple //
10 // parallel requests (belonging to the same LogConnectionID), //
11 // whose answers are to be processed asynchronously when they arrive. //
12 // //
14 
15 
16 // $Id$
17 
18 
19 
20 #ifndef XRC_SID_H
21 #define XRC_SID_H
22 
23 #include "XrdOuc/XrdOucRash.hh"
24 #include "XProtocol/XProtocol.hh"
27 #include "XrdSys/XrdSysPthread.hh"
28 
29 struct SidInfo {
32  long long reqbyteprogress;
33  time_t sendtime;
34 
37  char *rsperrmsg;
38 };
39 
40 class XrdClientSid {
41 
42  private:
43  // Used to quickly get info about a sid being used
44  // as a child of another sid. A child sid is used to parallely
45  // interact with a server for the same logical connection using its father sid
46  // Only child sids are inserted here. If a sid is not here but is not free,
47  // then it's a father sid, i.e. normally a sid used for the non async xrootd traffic
48  // Remember: for any child sid, it's mandatory to keep the request
49  // which is outstanding for that stream. This struct can be used to
50  // read data, but also for preparing many files in advance.
52 
53  // To quickly get a sid which is not being used
54  // This one has constant time operations if the ops
55  // are performed at the back of the vector
56  // Remember: 0 is NOT a valid sid
58 
60 
61  public:
62  XrdClientSid();
63  virtual ~XrdClientSid();
64 
65  // Gets an available sid
66  // From now on it will be no more available.
67  // A retval of 0 means that there are no more available sids
69 
70  // Gets an available sid for a request which is to be outstanding
71  // This means that this sid will be inserted into the Rash
72  // The request gets inserted the new sid in the right place
73  // Also the one passed as parameter gets the new sid, as should be expected
75 
76 
77  // Releases a sid.
78  // It is re-inserted into the available set
79  // Its info is rmeoved from the tree
80  void ReleaseSid(kXR_unt16 sid);
81 
82  // Releases a sid and all its childs
83  void ReleaseSidTree(kXR_unt16 fathersid);
84 
85  // Report the response for an outstanding request
86  // Typically this is used to keep track of the received errors, expecially
87  // for async writes
88  void ReportSidResp(kXR_unt16 sid, kXR_unt16 statuscode, kXR_unt32 errcode, char *errmsg);
89 
93 
94  // 0 if non existent as a child sid
95  inline struct SidInfo *GetSidInfo(kXR_unt16 sid) {
97  return (childsidnfo.Find(sid));
98  };
99 
100  inline bool JoinedSids(kXR_unt16 father, kXR_unt16 child) {
102 
103  struct SidInfo *si = childsidnfo.Find(child);
104 
105  if (!si) return false;
106  return (si->fathersid == father);
107  }
108 
109 
110  // Useful for debugging
112 };
113 
114 
115 
116 
117 
118 
119 
120 
121 #endif