XRootD
Loading...
Searching...
No Matches
XrdSutCache Class Reference

#include <XrdSutCache.hh>

+ Collaboration diagram for XrdSutCache:

Public Member Functions

 XrdSutCache (int psize=89, int size=144, int load=80)
 
virtual ~XrdSutCache ()
 
XrdSutCacheEntryGet (const char *tag)
 
XrdSutCacheEntryGet (const char *tag, bool &rdlock, XrdSutCacheGet_t condition=0, void *arg=0)
 
int Num ()
 
void Reset ()
 

Detailed Description

Definition at line 49 of file XrdSutCache.hh.

Constructor & Destructor Documentation

◆ XrdSutCache()

XrdSutCache::XrdSutCache ( int psize = 89,
int size = 144,
int load = 80 )
inline

Definition at line 51 of file XrdSutCache.hh.

51: table(psize, size, load) {}

◆ ~XrdSutCache()

virtual XrdSutCache::~XrdSutCache ( )
inlinevirtual

Definition at line 52 of file XrdSutCache.hh.

52{}

Member Function Documentation

◆ Get() [1/2]

XrdSutCacheEntry * XrdSutCache::Get ( const char * tag)
inline

Definition at line 54 of file XrdSutCache.hh.

54 {
55 // Get the entry with 'tag'.
56 // If found the entry is returned rd-locked.
57 // If rd-locking fails the status is set to kCE_inactive.
58 // Returns null if not found.
59
60 XrdSutCacheEntry *cent = 0;
61
62 // Exclusive access to the table
63 XrdSysMutexHelper raii(mtx);
64
65 // Look for an entry
66 if (!(cent = table.Find(tag))) {
67 // none found
68 return cent;
69 }
70
71 // We found an existing entry:
72 // lock until we get the ability to read (another thread may be valudating it)
73 int status = 0;
74 cent->rwmtx.ReadLock( status );
75 if ( status ) {
76 // A problem occurred: fail (set the entry invalid)
77 cent->status = kCE_inactive;
78 }
79 return cent;
80 }
@ kCE_inactive
T * Find(const char *KeyVal, time_t *KeyTime=0)

References XrdOucHash< T >::Find(), kCE_inactive, XrdSysRWLock::ReadLock(), XrdSutCacheEntry::rwmtx, and XrdSutCacheEntry::status.

Referenced by XrdSecProtocolgsi::Authenticate(), XrdCryptosslX509Crl::IsRevoked(), and XrdCryptosslX509Crl::IsRevoked().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Get() [2/2]

XrdSutCacheEntry * XrdSutCache::Get ( const char * tag,
bool & rdlock,
XrdSutCacheGet_t condition = 0,
void * arg = 0 )
inline

Definition at line 82 of file XrdSutCache.hh.

82 {
83 // Get or create the entry with 'tag'.
84 // New entries are always returned write-locked.
85 // The status of existing ones depends on condition: if condition is undefined or if applied
86 // to the entry with arguments 'arg' returns true, the entry is returned read-locked.
87 // Otherwise a write-lock is attempted on the entry: if unsuccessful (another thread is modifing
88 // the entry) the entry is read-locked.
89 // The status of the lock is returned in rdlock (true if read-locked).
90 rdlock = false;
91 XrdSutCacheEntry *cent = 0;
92
93 // Exclusive access to the table
94 XrdSysMutexHelper raii(mtx);
95
96 // Look for an entry
97 if (!(cent = table.Find(tag))) {
98 // If none, create a new one and write-lock for validation
99 cent = new XrdSutCacheEntry(tag);
100 int status = 0;
101 cent->rwmtx.WriteLock( status );
102 if (status) {
103 // A problem occurred: delete the entry and fail
104 delete cent;
105 return (XrdSutCacheEntry *)0;
106 }
107 // Register it in the table
108 table.Add(tag, cent);
109 return cent;
110 }
111
112 // We found an existing entry:
113 // lock until we get the ability to read (another thread may be valudating it)
114 int status = 0;
115 cent->rwmtx.ReadLock( status );
116 if (status) {
117 // A problem occurred: fail (set the entry invalid)
118 cent->status = kCE_inactive;
119 return cent;
120 }
121
122 // Check-it by apply the condition, if required
123 if (condition) {
124 if ((*condition)(cent, arg)) {
125 // Good and valid entry
126 rdlock = true;
127 } else {
128 // Invalid entry: unlock and write-lock to be able to validate it
129 cent->rwmtx.UnLock();
130 int status = 0;
131 cent->rwmtx.WriteLock( status );
132 if (status) {
133 // A problem occurred: fail (set the entry invalid)
134 cent->status = kCE_inactive;
135 return cent;
136 }
137 }
138 } else {
139 // Good and valid entry
140 rdlock = true;
141 }
142 // We are done: return read-locked so we can use it until we need it
143 return cent;
144 }
T * Add(const char *KeyVal, T *KeyData, const int LifeTime=0, XrdOucHash_Options opt=Hash_default)

References XrdOucHash< T >::Add(), XrdOucHash< T >::Find(), kCE_inactive, XrdSysRWLock::ReadLock(), XrdSutCacheEntry::rwmtx, XrdSutCacheEntry::status, XrdSysRWLock::UnLock(), and XrdSysRWLock::WriteLock().

+ Here is the call graph for this function:

◆ Num()

int XrdSutCache::Num ( )
inline

Definition at line 146 of file XrdSutCache.hh.

146{ return table.Num(); }

References XrdOucHash< T >::Num().

Referenced by XrdSecProtocolgsi::Init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Reset()

void XrdSutCache::Reset ( )
inline

Definition at line 147 of file XrdSutCache.hh.

147{ return table.Purge(); }

References XrdOucHash< T >::Purge().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: