Skip to content

Commit

Permalink
secgsi: remove definition and use of GSIStack
Browse files Browse the repository at this point in the history
This is not needed anymore with the new XrdSutCache because entry content can be
deleted when found invalid
  • Loading branch information
gganis committed Jul 6, 2017
1 parent ee34569 commit 3f0f086
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 50 deletions.
29 changes: 8 additions & 21 deletions src/XrdSecgsi/XrdSecProtocolgsi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ XrdSutCache XrdSecProtocolgsi::cacheGMAP; // Grid map entries (default size 144
XrdSutCache XrdSecProtocolgsi::cacheGMAPFun; // Entries mapped by GMAPFun (default size 144)
XrdSutCache XrdSecProtocolgsi::cacheAuthzFun; // Entities filled by AuthzFun (default size 144)
//
// CA and CRL stacks
GSIStack<XrdCryptoX509Chain> XrdSecProtocolgsi::stackCA; // Stack of CA in use
GSIStack<XrdCryptoX509Crl> XrdSecProtocolgsi::stackCRL; // Stack of CRL in use
//
// GMAP control vars
time_t XrdSecProtocolgsi::lastGMAPCheck = -1; // Time of last check
XrdSysMutex XrdSecProtocolgsi::mutexGMAP; // Mutex to control GMAP reloads
Expand Down Expand Up @@ -4285,8 +4281,8 @@ int XrdSecProtocolgsi::GetCA(const char *cahash,
// If invalid we fail
if (cent->status == kCE_inactive) {
// Cleanup and remove existing invalid entries
if (chain) stackCA.Del(chain);
if (crl) stackCRL.Del(crl);
if (chain) delete chain;
if (crl) delete crl;
PRINT("unable to get a valid entry from cache for " << tag);
return -1;
}
Expand All @@ -4296,25 +4292,18 @@ int XrdSecProtocolgsi::GetCA(const char *cahash,
// Save chain
chain = (X509Chain *)(cent->buf1.buf);
if (hs) hs->Chain = chain;
stackCA.Add(chain);
// Save crl
bool goodcrl = (crl) ? 1 : 0;
if (goodcrl && CRLCheck >= 3 && crl->IsExpired()) goodcrl = 0;
if (goodcrl && CRLRefresh > 0 && ((timestamp - cent->mtime) > CRLRefresh)) goodcrl = 0;
// If the CA is not good, we reload the CRL in any case
if (goodcrl) {
if (hs) hs->Crl = crl;
// Add to the stack for proper cleaning of invalidated CRLs
stackCRL.Add(crl);
}
if (crl && hs) hs->Crl = crl;
// Done
return 0;
}

// Cleanup and remove existing invalid entries
if (chain) stackCA.Del(chain);
if (crl) stackCRL.Del(crl);
if (chain) delete chain;
if (crl) delete crl;

chain = 0;
crl = 0;
cent->buf1.buf = 0;
cent->buf2.buf = 0;

Expand Down Expand Up @@ -4361,11 +4350,9 @@ int XrdSecProtocolgsi::GetCA(const char *cahash,
// Add to the cache
cent->buf1.buf = (char *)(chain);
cent->buf1.len = 0; // Just a flag
stackCA.Add(chain);
if (crl) {
cent->buf2.buf = (char *)(crl);
cent->buf2.len = 0; // Just a flag
stackCRL.Add(crl);
}
cent->mtime = timestamp;
cent->status = kCE_ok;
Expand Down Expand Up @@ -4842,7 +4829,7 @@ int XrdSecProtocolgsi::LoadGMAP(int now)
return 0;

// Reset the cache
if (cacheGMAP.Size() > 0) cacheGMAP.Reset();
if (cacheGMAP.Num() > 0) cacheGMAP.Reset();

// Open the file
FILE *fm = fopen(GMAPFile.c_str(),"r");
Expand Down
30 changes: 1 addition & 29 deletions src/XrdSecgsi/XrdSecProtocolgsi.hh
Original file line number Diff line number Diff line change
Expand Up @@ -227,27 +227,6 @@ typedef struct {
int bits;
} ProxyIn_t;

template<class T>
class GSIStack {
public:
void Add(T *t) {
char k[40]; snprintf(k, 40, "%p", t);
mtx.Lock();
if (!stack.Find(k)) stack.Add(k, t, 0, Hash_count); // We need an additional count
stack.Add(k, t, 0, Hash_count);
mtx.UnLock();
}
void Del(T *t) {
char k[40]; snprintf(k, 40, "%p", t);
mtx.Lock();
if (stack.Find(k)) stack.Del(k, Hash_count);
mtx.UnLock();
}
private:
XrdSysMutex mtx;
XrdOucHash<T> stack;
};

/******************************************************************************/
/* X r d S e c P r o t o c o l g s i C l a s s */
/******************************************************************************/
Expand Down Expand Up @@ -352,10 +331,6 @@ private:
static XrdSutCache cacheGMAPFun; // Cache for entries mapped by GMAPFun
static XrdSutCache cacheAuthzFun; // Cache for entities filled by AuthzFun
//
// CA and CRL stacks
static GSIStack<XrdCryptoX509Chain> stackCA; // Stack of CA in use
static GSIStack<XrdCryptoX509Crl> stackCRL; // Stack of CRL in use
//
// GMAP control vars
static time_t lastGMAPCheck; // time of last check on GMAP
static XrdSysMutex mutexGMAP; // mutex to control GMAP reloads
Expand Down Expand Up @@ -504,10 +479,7 @@ public:
SafeDelete(Chain);
}
if (Crl) {
// This decreases the counter and actually deletes the object only
// when no instance is using it
XrdSecProtocolgsi::stackCRL.Del(Crl);
Crl = 0;
SafeDelete(Crl);
}
// The proxy chain is owned by the proxy cache; invalid proxies are
// detected (and eventually removed) by QueryProxy
Expand Down

0 comments on commit 3f0f086

Please sign in to comment.