From db736622a2aa5d9280c2e8e920502e30b2430c45 Mon Sep 17 00:00:00 2001 From: Gerardo Ganis Date: Wed, 31 May 2017 18:37:59 +0200 Subject: [PATCH] xrdsut: add pure getter in XrdSutCache Does not create the entry if not existing. Used by XrdCryptosslX509Crl. --- src/XrdSut/XrdSutCache.hh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/XrdSut/XrdSutCache.hh b/src/XrdSut/XrdSutCache.hh index 7237443148d..48643f60f12 100644 --- a/src/XrdSut/XrdSutCache.hh +++ b/src/XrdSut/XrdSutCache.hh @@ -51,6 +51,31 @@ public: XrdSutCache(int psize = 89, int size = 144, int load = 80) : table(psize, size, load) {} virtual ~XrdSutCache() {} + XrdSutCacheEntry *Get(const char *tag) { + // Get the entry with 'tag'. + // If found the entry is returned rd-locked. + // If rd-locking fails the status is set to kCE_inactive. + // Returns null if not found. + + XrdSutCacheEntry *cent = 0; + + // Exclusive access to the table + XrdSysMutexHelper raii(mtx); + + // Look for an entry + if (!(cent = table.Find(tag))) { + // none found + return cent; + } + + // We found an existing entry: + // lock until we get the ability to read (another thread may be valudating it) + if (cent->rwmtx.ReadLock()) { + // A problem occured: fail (set the entry invalid) + cent->status = kCE_inactive; + } + return cent; + } XrdSutCacheEntry *Get(const char *tag, bool &rdlock, XrdSutCacheGet_t condition = 0, void *arg = 0) { // Get or create the entry with 'tag'.