Loading...
Searching...
No Matches
XrdSutPFCache Class Reference

`#include <XrdSutPFCache.hh>`

Collaboration diagram for XrdSutPFCache:

## Public Member Functions

| XrdSutPFCache ()
virtual | ~XrdSutPFCache ()
XrdSutPFEntry * | Add (XrdSutPFCacheRef &urRef, const char *ID, bool force=0)
void | Dump (const char *msg=0)
bool | Empty () const
int | Entries () const
int | Flush (const char *pfname=0)
XrdSutPFEntry * | Get (int i) const
XrdSutPFEntry * | Get (XrdSutPFCacheRef &urRef, const char *ID, bool *wild=0)
int | Init (int capacity=100, bool lock=1)
int | Load (const char *pfname)
int | Refresh ()
int | Rehash (bool force=0, bool lock=1)
bool | Remove (const char *ID, int opt=1)
int | Reset (int newsz=-1, bool lock=1)
void | SetLifetime (int lifet=300)
int | Trim (int lifet=0)

## Detailed Description

Definition at line 71 of file XrdSutPFCache.hh.

## Constructor & Destructor Documentation

## XrdSutPFCache()

XrdSutPFCache::XrdSutPFCache | ( |  | ) |

inline

Definition at line 92 of file XrdSutPFCache.hh.

{ cachemx = -1; cachesz = 0; cachent = 0; lifetime = 300;
utime = -1; htmtime = -1; pfile = ""; isinit = 0; }

## ~XrdSutPFCache()

XrdSutPFCache::~XrdSutPFCache | ( |  | ) |

virtual

Definition at line 49 of file XrdSutPFCache.cc.

{
// Destructor
// We are destroying the cache
rwlock.WriteLock();
// Cleanup content
while (cachemx > -1) {
if (cachent[cachemx]) {
delete cachent[cachemx];
cachent[cachemx] = 0;
}
cachemx--;
}
// Cleanup table
if (cachent)
delete[] cachent;
// Done
rwlock.UnLock();
}

## Member Function Documentation

## Add()

XrdSutPFEntry * XrdSutPFCache::Add | ( | XrdSutPFCacheRef & | urRef,
|  | const char * | ID,
|  | bool | force = 0 )

Definition at line 207 of file XrdSutPFCache.cc.

{
// Add an entry with ID in cache
// Cache buffer is re-allocated with double size, if needed
// Hash is updated
EPNAME("Cache::Add");
//
// IF ID is undefined, do nothing
if (!ID || !strlen(ID)) {
DEBUG("empty ID !");
return (XrdSutPFEntry *)0 ;
}
//
// If an entry already exists, return it
XrdSutPFEntry *ent = Get(urRef, ID);
if (ent)
return ent;
// Lock for writing
XrdSysRWLockHelper isg(rwlock, 0);
//
// Make sure there enough space for a new entry
if (cachemx == cachesz - 1) {
//
// Duplicate buffer
XrdSutPFEntry **newcache = new XrdSutPFEntry *[2*cachesz];
if (!newcache) {
DEBUG("could not extend cache to size: "<<(2*cachesz));
return (XrdSutPFEntry *)0 ;
}
// Update info
cachesz *= 2;
//
// Copy existing valid entries, calculating real size
int i = 0, nmx = 0;
for (; i <= cachemx; i++) {
if (cachent[i]) {
newcache[nmx] = cachent[i];
nmx++;
}
}
// update size
cachemx = nmx - 1;
//
// Reset new entries
for (i = cachemx + 1; i <= cachemx; i++) {
newcache[i] = 0;
}
//
// Cleanup and reassign
delete[] cachent;
cachent = newcache;
//
// Force rehash in this case
force = 1;
}
//
// The next free
int pos = cachemx + 1;
//
// Add new entry
cachent[pos] = new XrdSutPFEntry(ID);
if (cachent[pos]) {
cachemx = pos;
} else {
DEBUG("could not allocate space for new cache entry");
return (XrdSutPFEntry *)0 ;
}
// Update time stamp
utime = (kXR_int32)time(0);
// Rebuild hash table
if (Rehash(force, 0) != 0) {
DEBUG("problems re-hashing");
return (XrdSutPFEntry *)0 ;
}
// We are done (we can lock the entry without a wait)
urRef.Lock(&(cachent[pos]->pfeMutex));
return cachent[pos];
}
kXR_int32
int kXR_int32
Definition XPtypes.hh:89
DEBUG
#define DEBUG(x)
Definition XrdBwmTrace.hh:54
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56
ID
#define ID
Definition XrdXrootdAioBuff.cc:38
XrdSutPFCacheRef::Lock
void Lock(XrdSysMutex *Mutex)
Definition XrdSutPFCache.hh:47
XrdSutPFCache::Rehash
int Rehash(bool force=0, bool lock=1)
Definition XrdSutPFCache.cc:659

References DEBUG, EPNAME, ID, XrdSutPFCacheRef::Lock(), and Rehash().

Here is the call graph for this function:

## Dump()

void XrdSutPFCache::Dump | ( | const char * | msg = 0 | ) |

Definition at line 487 of file XrdSutPFCache.cc.

{
// Dump content of the cache
EPNAME("Cache::Dump");
PRINT("//-----------------------------------------------------");
PRINT("//");
if (msg && strlen(msg) > 0) {
PRINT("// "<<msg);
PRINT("//");
}
PRINT("// Capacity: "<<cachesz);
PRINT("// Max index filled: "<<cachemx);
PRINT("//");
// Lock for reading
XrdSysRWLockHelper isg(rwlock, 1);
if (cachesz > 0) {
XrdSutPFEntry *ent = 0;
int i = 0, nn = 0;
for (; i <= cachemx; i++) {
// get entry
if ((ent = cachent[i])) {
char smt[20] = {0};
XrdSutTimeString(ent->mtime,smt);
nn++;
PRINT("// #:"<<nn<<" st:"<<ent->status<<" cn:"<<ent->cnt
<<" buf:"<<ent->buf1.len<<","<<ent->buf2.len<<","
<<ent->buf3.len<<","<<ent->buf4.len<<" mod:"<<smt
<<" name:"<<ent->name);
}
}
PRINT("//");
}
PRINT("//-----------------------------------------------------");
}
PRINT
#define PRINT(y)
Definition XrdCryptosslTrace.hh:39
XrdSutTimeString
int XrdSutTimeString(int t, char *st, int opt)
Definition XrdSutAux.cc:305
XrdSutPFBuf::len
kXR_int32 len
Definition XrdSutPFEntry.hh:58
XrdSutPFEntry::mtime
kXR_int32 mtime
Definition XrdSutPFEntry.hh:83
XrdSutPFEntry::buf3
XrdSutPFBuf buf3
Definition XrdSutPFEntry.hh:86
XrdSutPFEntry::buf1
XrdSutPFBuf buf1
Definition XrdSutPFEntry.hh:84
XrdSutPFEntry::status
short status
Definition XrdSutPFEntry.hh:81
XrdSutPFEntry::buf2
XrdSutPFBuf buf2
Definition XrdSutPFEntry.hh:85
XrdSutPFEntry::buf4
XrdSutPFBuf buf4
Definition XrdSutPFEntry.hh:87
XrdSutPFEntry::cnt
short cnt
Definition XrdSutPFEntry.hh:82
XrdSutPFEntry::name
char * name
Definition XrdSutPFEntry.hh:80

References XrdSutPFEntry::buf1, XrdSutPFEntry::buf2, XrdSutPFEntry::buf3, XrdSutPFEntry::buf4, XrdSutPFEntry::cnt, EPNAME, XrdSutPFBuf::len, XrdSutPFEntry::mtime, XrdSutPFEntry::name, PRINT, XrdSutPFEntry::status, and XrdSutTimeString().

Referenced by Get(), and Rehash().

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

## Empty()

bool XrdSutPFCache::Empty | ( |  | ) | const

inline

Definition at line 98 of file XrdSutPFCache.hh.

{ return (cachemx == -1); }

## Entries()

int XrdSutPFCache::Entries | ( |  | ) | const

inline

Definition at line 97 of file XrdSutPFCache.hh.

{ return (cachemx+1); }

## Flush()

int XrdSutPFCache::Flush | ( | const char * | pfname = 0 | ) |

Definition at line 701 of file XrdSutPFCache.cc.

{
// Flush cache content to file pfn.
// If pfn == 0 and the cache was initialized from a file, flush
// to initializing file.
// If pfn does not exist, create it.
// Return 0 if ok, -1 otherwise
EPNAME("Cache::Flush");
// Make sure we have all the info
if (!pfn && pfile.length() <= 0) {
DEBUG("invalid input");
return -1;
}
if (!pfn)
pfn = pfile.c_str();
// Attach to file and open it; create if not ther
XrdSutPFile ff(pfn, (kPFEopen | kPFEcreate));
if (!ff.IsValid()) {
DEBUG("cannot attach-to or create file "<<pfn<<" ("<<ff.LastErrStr()<<")");
return -1;
}
// Lock for writing
XrdSysRWLockHelper isg(rwlock, 0);
//
// Loop over cache entries
int i = 0, nr = 0, nfs = 0;
for (; i <= cachemx; i++ ) {
if (cachent[i]) {
//
// Retrieve related from file, if any
// Read entry out
XrdSutPFEntry ent;
if ((nr = ff.ReadEntry(cachent[i]->name, ent)) < 0) {
ff.Close();
return -1;
}
//
// Write (update) only if older that cache or not found
if (nr == 0 || cachent[i]->mtime > ent.mtime) {
if (ff.WriteEntry(*cachent[i]) < 0) {
ff.Close();
return -1;
}
nfs++;
}
}
}
// Close the file
ff.Close();
// Update the time stamp (to avoid fake loads later on)
utime = (kXR_int32)time(0);
// Save file name
if (pfile.length() <= 0)
pfile = pfn;
DEBUG("Cache flushed to file "<<pfn<<" ("<<nfs<<" entries updated / written)");
return 0;
}
kPFEopen
#define kPFEopen
Definition XrdSutPFile.hh:60
kPFEcreate
#define kPFEcreate
Definition XrdSutPFile.hh:59

References XrdSutPFile::Close(), DEBUG, EPNAME, XrdSutPFile::IsValid(), kPFEcreate, kPFEopen, XrdSutPFile::LastErrStr(), XrdSutPFEntry::mtime, XrdSutPFile::ReadEntry(), and XrdSutPFile::WriteEntry().

Here is the call graph for this function:

## Get() [1/2]

XrdSutPFEntry * XrdSutPFCache::Get | ( | int | i | ) | const

inline

Definition at line 110 of file XrdSutPFCache.hh.

{ return (i<=cachemx) ? cachent[i] :
(XrdSutPFEntry *)0; }

## Get() [2/2]

XrdSutPFEntry * XrdSutPFCache::Get | ( | XrdSutPFCacheRef & | urRef,
|  | const char * | ID,
|  | bool * | wild = 0 )

Definition at line 122 of file XrdSutPFCache.cc.

{
// Retrieve an entry with ID, if any
// If wild is defined, search also best matching regular expression
// with wildcard '*'; *wild = 0 will indicate exact match,
// *wild = 1 wild card compatibility match
EPNAME("Cache::Get");
XrdSutPFEntry *pfEnt;
int i;
TRACE(Dump,"locating entry for ID: "<<ID);
//
// If ID is undefined, do nothing
if (!ID || !strlen(ID)) {
DEBUG("empty ID !");
return (XrdSutPFEntry *)0 ;
}
if (wild) *wild = 0;
if (Rehash() != 0) {
DEBUG("problems rehashing");
return (XrdSutPFEntry *)0 ;
}
// Lock for reading
XrdSysRWLockHelper isg(rwlock, 1);
// Find the entry and lock it. Repeat if we can get a lock.
//
for (i = 0; i < maxTries; i++)
{if ((pfEnt = Get(ID, wild)))
{if (pfEnt->pfeMutex.CondLock())
{urRef.Set(&(pfEnt->pfeMutex));
return pfEnt;
}
} else return pfEnt;
isg.UnLock();
XrdSysTimer::Wait(retryMSW);
if (Rehash() != 0)
{DEBUG("problems rehashing");
return (XrdSutPFEntry *)0 ;
}
isg.Lock(&rwlock, 1);
}
// Nothing found
return (XrdSutPFEntry *)0 ;
}
TRACE
#define TRACE(act, x)
Definition XrdTrace.hh:63
XrdSutPFCacheRef::Set
void Set(XrdSysMutex *Mutex)
Definition XrdSutPFCache.hh:55
XrdSutPFCache::Dump
void Dump(const char *msg=0)
Definition XrdSutPFCache.cc:487
XrdSutPFEntry::pfeMutex
XrdSysMutex pfeMutex
Definition XrdSutPFEntry.hh:88
XrdSysMutex::CondLock
int CondLock()
Definition XrdSysPthread.hh:169
XrdSysTimer::Wait
static void Wait(int milliseconds)
Definition XrdSysTimer.cc:227

References XrdSysMutex::CondLock(), DEBUG, Dump(), EPNAME, ID, XrdSysRWLockHelper::Lock(), XrdSutPFEntry::pfeMutex, Rehash(), XrdSutPFCacheRef::Set(), TRACE, XrdSysRWLockHelper::UnLock(), and XrdSysTimer::Wait().

Here is the call graph for this function:

## Init()

int XrdSutPFCache::Init | ( | int | capacity = 100,
|  | bool | lock = 1 )

Definition at line 73 of file XrdSutPFCache.cc.

{
// Initialize the cache to hold up to capacity entries.
// Later on, capacity is double each time more space is needed.
// Return 0 if ok, -1 otherwise
EPNAME("Cache::Init");
// Lock for writing
if (lock) rwlock.WriteLock();
// Nothing to do if already done
if (isinit) {
if (lock) rwlock.UnLock();
return 0;
}
// Make sure capacity makes sense; use a default, if not
capacity = (capacity > 0) ? capacity : 100;
// Allocate
cachent = new XrdSutPFEntry *[capacity];
if (cachent) {
for (int i = 0; i < capacity; i++) { cachent[i] = 0; }
cachesz = capacity;
DEBUG("cache allocated for "<<cachesz<<" entries");
// Update time stamp
utime = (kXR_int32)time(0);
// Init hash table
if (Rehash(0, 0) != 0) {
DEBUG("problems initialising hash table");
}
// UnLock
if (lock) rwlock.UnLock();
return 0;
} else
DEBUG("could not allocate cache - out-of-resources ");
// Flag has initialized
isinit = 1;
// UnLock
if (lock) rwlock.UnLock();
return -1;
}

References DEBUG, EPNAME, and Rehash().

Referenced by Load(), and Reset().

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

## Load()

int XrdSutPFCache::Load | ( | const char * | pfname | ) |

Definition at line 531 of file XrdSutPFCache.cc.

{
// Initialize the cache from the content of a file of PF entries
// Return 0 if ok, -1 otherwise
EPNAME("Cache::Load");
// Make sure file name is defined
if (!pfn) {
DEBUG("invalid input file name");
return -1;
}
// Check if file exists and if it has been modified since last load
struct stat st;
if (stat(pfn,&st) == -1) {
DEBUG("cannot stat file (errno: "<<errno<<")");
return -1;
}
if (utime > -1 && utime > st.st_mtime) {
DEBUG("cached information for file "<<pfn<<" is up-to-date");
return 0;
}
// Lock for writing
XrdSysRWLockHelper isg(rwlock, 0);
// Attach to file and open it
XrdSutPFile ff(pfn, kPFEopen);
if (!ff.IsValid()) {
DEBUG("file is not a valid PFEntry file ("<<ff.LastErrStr()<<")");
return -1;
}
// Read the header
XrdSutPFHeader header;
if (ff.ReadHeader(header) < 0) {
ff.Close();
return -1;
}
// If the file has no entries there is nothing to do
if (header.entries <= 0) {
DEBUG("PFEntry file is empty - default init and return");
// Save file name
pfile = pfn;
Init(-1, 0);
return 0;
}
// Allocate cache, if not done already or if too small
if (Reset(header.entries, 0) == -1) {
DEBUG("problems allocating / resizing cache ");
ff.Close();
return -1;
}
// Read entries
kXR_int32 ne = 0;
XrdSutPFEntInd ind;
kXR_int32 nxtofs = header.indofs;
while (nxtofs > 0 && ne < header.entries) {
//
// read index entry
if (ff.ReadInd(nxtofs, ind) < 0) {
DEBUG("problems reading index entry ");
ff.Close();
return -1;
}
// If active ...
if (ind.entofs > 0) {
// Read entry out
XrdSutPFEntry ent;
if (ff.ReadEnt(ind.entofs, ent) < 0) {
ff.Close();
return -1;
}
// Copy for the cache
XrdSutPFEntry *cent = new XrdSutPFEntry(ent);
if (cent) {
// Set the id
cent->SetName(ind.name);
// Fill the array
cachent[ne] = cent;
// Count
ne++;
} else {
DEBUG("problems duplicating entry for cache");
ff.Close();
return -1;
}
}
// Go to next
nxtofs = ind.nxtofs;
}
cachemx = ne-1;
if (nxtofs > 0)
DEBUG("WARNING: inconsistent number of entries: possible file corruption");
// Update the time stamp
utime = (kXR_int32)time(0);
// Save file name
pfile = pfn;
// Close the file
ff.Close();
DEBUG("PF file "<<pfn<<" loaded in cache (found "<<ne<<" entries)");
// Force update hash table
if (Rehash(1, 0) != 0) {
DEBUG("problems creating hash table");
return -1;
}
return 0;
}
stat
#define stat(a, b)
Definition XrdPosix.hh:101
XrdSutPFCache::Reset
int Reset(int newsz=-1, bool lock=1)
Definition XrdSutPFCache.cc:448
XrdSutPFCache::Init
int Init(int capacity=100, bool lock=1)
Definition XrdSutPFCache.cc:73
XrdSutPFEntInd::entofs
kXR_int32 entofs
Definition XrdSutPFile.hh:88
XrdSutPFEntInd::nxtofs
kXR_int32 nxtofs
Definition XrdSutPFile.hh:87
XrdSutPFEntInd::name
char * name
Definition XrdSutPFile.hh:86
XrdSutPFEntry::SetName
void SetName(const char *n=0)
Definition XrdSutPFEntry.cc:136
XrdSutPFHeader::entries
kXR_int32 entries
Definition XrdSutPFile.hh:108
XrdSutPFHeader::indofs
kXR_int32 indofs
Definition XrdSutPFile.hh:109

References XrdSutPFile::Close(), DEBUG, XrdSutPFEntInd::entofs, XrdSutPFHeader::entries, EPNAME, XrdSutPFHeader::indofs, Init(), XrdSutPFile::IsValid(), kPFEopen, XrdSutPFile::LastErrStr(), XrdSutPFEntInd::name, XrdSutPFEntInd::nxtofs, Rehash(), Reset(), XrdSutPFEntry::SetName(), and stat.

Referenced by Refresh().

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

## Refresh()

int XrdSutPFCache::Refresh | ( |  | ) |

Definition at line 769 of file XrdSutPFCache.cc.

{
// Refresh content of a cache created from file.
// Return 0 if ok, -1 otherwise
EPNAME("Cache::Refresh");
// Make sure we have all the info
if (pfile.length() <= 0) {
DEBUG("cache was not initialized from file - do nothing");
return -1;
}
// Check if file exists and if it has been modified since last load
struct stat st;
if (stat(pfile.c_str(),&st) == -1) {
DEBUG("cannot stat file (errno: "<<errno<<")");
return -1;
}
if (utime > -1 && utime > st.st_mtime) {
DEBUG("cached information for file "<<pfile<<" is up-to-date");
return 0;
}
// Lock for writing
XrdSysRWLockHelper isg(rwlock, 0);
if (Load(pfile.c_str()) != 0) {
DEBUG("problems loading passwd information from file: "<<pfile);
return -1;
}
// Update the time stamp (to avoid fake loads or refreshs later on)
utime = (kXR_int32)time(0);
DEBUG("Cache refreshed from file: "<<pfile);
return 0;
}
XrdSutPFCache::Load
int Load(const char *pfname)
Definition XrdSutPFCache.cc:531

References DEBUG, EPNAME, Load(), and stat.

Here is the call graph for this function:

## Rehash()

int XrdSutPFCache::Rehash | ( | bool | force = 0,
|  | bool | lock = 1 )

Definition at line 659 of file XrdSutPFCache.cc.

{
// Update or create hahs table corresponding to the present content of the
// cache
// Return 0 if ok, -1 otherwise
EPNAME("Cache::Rehash");
// Lock for writing
if (lock) rwlock.WriteLock();
if (htmtime >= utime && !force) {
TRACE(Dump, "hash table is up-to-date");
if (lock) rwlock.UnLock();
return 0;
}
// Clean up the hash table
hashtable.Purge();
kXR_int32 i = 0, nht = 0;
for (; i <= cachemx; i++) {
if (cachent[i]) {
// Fill the hash table
kXR_int32 *key = new kXR_int32(i);
if (key) {
TRACE(Dump, "Adding ID: "<<cachent[i]->name<<"; key: "<<*key);
hashtable.Add(cachent[i]->name,key);
nht++;
}
}
}
// Update modification time
htmtime = (kXR_int32)time(0);
// Unlock
if (lock) rwlock.UnLock();
DEBUG("Hash table updated (found "<<nht<<" active entries)");
return 0;
}

References DEBUG, Dump(), EPNAME, and TRACE.

Referenced by Add(), Get(), Init(), Load(), and Remove().

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

## Remove()

bool XrdSutPFCache::Remove | ( | const char * | ID,
|  | int | opt = 1 )

Definition at line 294 of file XrdSutPFCache.cc.

{
// If opt==1 remove entry with name matching exactly ID from cache
// If opt==0 all entries with names starting with ID are removed
// Return 1 if ok, 0 otherwise
EPNAME("Cache::Remove");
//
// IF ID is undefined, do nothing
if (!ID || !strlen(ID)) {
DEBUG("empty ID !");
return 0 ;
}
// Lock for writing
XrdSysRWLockHelper isg(rwlock, 0);
if (Rehash(0, 0) != 0) {
DEBUG("problems rehashing");
return 0 ;
}
bool found = 0;
if (opt == 1) {
int pos = -1;
// Look in the hash first
kXR_int32 *ie = hashtable.Find(ID);
if (*ie >= 0 && *ie < cachesz) {
// Return the associated entry
pos = *ie;
}
//
// Check if pos makes sense
if (cachent[pos] && !strcmp(cachent[pos]->name,ID)) {
if (!Delete(cachent[pos])) DEBUG("Delete deferred for " <<ID);
cachent[pos] = 0;
// We are done, if not the one at highest index
if (pos < cachemx)
return 1;
// We update the highest index
found = 1;
}
} else {
// Loop over entries
int i = cachemx;
for (; i >= 0; i--) {
if (cachent[i]) {
if (!strncmp(cachent[i]->name,ID,strlen(ID))) {
if (!Delete(cachent[i])) DEBUG("Delete deferred for " <<ID);
cachent[i] = 0;
found = 1;
}
}
}
}
if (found) {
// Update time stamp
utime = (kXR_int32)time(0);
// Rebuild hash table
if (Rehash(0, 0) != 0) {
DEBUG("problems re-hashing");
return 0 ;
}
}
// We are done
return found;
}

References DEBUG, EPNAME, ID, and Rehash().

Here is the call graph for this function:

## Reset()

int XrdSutPFCache::Reset | ( | int | newsz = -1,
|  | bool | lock = 1 )

Definition at line 448 of file XrdSutPFCache.cc.

{
// Remove all existing entries.
// If newsz > -1, set new capacity to newsz, reallocating if needed
// Return 0 if ok, -1 if problems reallocating.
EPNAME("Cache::Reset");
// Lock for writing
if (lock) rwlock.WriteLock();
// Loop over entries
int i = cachemx;
for (; i >= 0; i--) {
if (cachent[i]) {
if (!Delete(cachent[i]))
DEBUG("Delete deferred for " <<cachent[i]->name);
cachent[i] = 0;
}
}
int rc = 0;
// Reallocate, if requested
if (newsz > -1 && newsz != cachesz) {
delete[] cachent;
cachent = 0;
cachesz = 0;
cachemx = -1;
isinit = 0;
rc = Init(newsz, 0);
}
// Unlock
if (lock) rwlock.UnLock();
// We are done
return rc;
}

References DEBUG, EPNAME, and Init().

Referenced by Load().

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

## SetLifetime()

void XrdSutPFCache::SetLifetime | ( | int | lifet = 300 | ) |

inline

Definition at line 107 of file XrdSutPFCache.hh.

{ lifetime = lifet; }

## Trim()

int XrdSutPFCache::Trim | ( | int | lifet = 0 | ) |

Definition at line 410 of file XrdSutPFCache.cc.

{
// Remove entries older then lifet seconds. If lifet <=0, compare
// to lifetime, which can be set with SetValidity().
// Return number of entries removed
// Lock for writing
EPNAME("Cache::Trim");
XrdSysRWLockHelper isg(rwlock, 0);
//
// Make sure lifet makes sense; if not, use internal default
lifet = (lifet > 0) ? lifet : lifetime;
//
// Reference time
int reftime = time(0) - lifet;
// Loop over entries
int i = cachemx, nrm = 0;
for (; i >= 0; i--) {
if (cachent[i] && cachent[i]->mtime < reftime) {
if (!Delete(cachent[i]))
DEBUG("Delete deferred for " <<cachent[i]->name);
cachent[i] = 0;
nrm++;
}
if (i == cachemx) {
if (!cachent[i])
cachemx--;
}
}
// We are done
return nrm;
}

References DEBUG, and EPNAME.

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

- XrdSutPFCache.hh
- XrdSutPFCache.cc