XRootD
XrdTlsCrl Namespace Reference

Functions

void * Refresh (void *parg)
 

Function Documentation

◆ Refresh()

void* XrdTlsCrl::Refresh ( void *  parg)

Definition at line 88 of file XrdTlsContext.cc.

89 {
90  EPNAME("Refresh");
91  int sleepTime;
92  bool doreplace;
93 
94 // Get the implementation details
95 //
96  XrdTlsContextImpl *ctxImpl = static_cast<XrdTlsContextImpl*>(parg);
97 
98 // Indicate we have started in the trace record
99 //
100  DBG_CTX("CRL refresh started.")
101 
102 // Do this forever but first get the sleep time
103 //
104 do{ctxImpl->crlMutex.ReadLock();
105  sleepTime = ctxImpl->Parm.crlRT;
106  ctxImpl->crlMutex.UnLock();
107 
108 // We may have been cancelled, in which case we just exit
109 //
110  if (!sleepTime)
111  {ctxImpl->crlMutex.WriteLock();
112  ctxImpl->crlRunning = false;
113  ctxImpl->crlMutex.UnLock();
114  DBG_CTX("CRL refresh ending by request!");
115  return (void *)0;
116  }
117 
118 // Indicate we how long before a refresh
119 //
120  DBG_CTX("CRL refresh will happen in " <<sleepTime <<" seconds.");
121 
122 // Now sleep the request amount of time
123 //
124  XrdSysTimer::Snooze(sleepTime);
125 
126  if (ctxImpl->owner->x509Verify() || ctxImpl->owner->newHostCertificateDetected()) {
127  // Check if this context is still alive. Generally, it never gets deleted.
128  //
129  ctxImpl->crlMutex.WriteLock();
130  if (!ctxImpl->owner) break;
131 
132  // We clone the original, this will give us the latest crls (i.e. refreshed).
133  // We drop the lock while doing so as this may take a long time. This is
134  // completely safe to do because we implicitly own the implementation.
135  //
136  ctxImpl->crlMutex.UnLock();
137  XrdTlsContext *newctx = ctxImpl->owner->Clone();
138 
139  // Verify that the context was properly built
140  //
141  if (!newctx || !newctx->isOK())
142  {XrdTls::Emsg("CrlRefresh:","Refresh of context failed!!!",false);
143  continue;
144  }
145 
146  // OK, set the new context to be used next time Session() is called.
147  //
148  ctxImpl->crlMutex.WriteLock();
149  doreplace = (ctxImpl->ctxnew != 0);
150  if (doreplace) delete ctxImpl->ctxnew;
151  ctxImpl->ctxnew = newctx;
152  ctxImpl->crlMutex.UnLock();
153 
154  // Do some debugging
155  //
156  if (doreplace) {DBG_CTX("CRL refresh created replacement x509 store.");}
157  else {DBG_CTX("CRL refresh created new x509 store.");}
158  }
159  } while(true);
160 
161 // If we are here the context that started us has gone away and we are done
162 //
163  bool keepctx = ctxImpl->flsRunning;
164  ctxImpl->crlRunning = false;
165  ctxImpl->crlMutex.UnLock();
166  if (!keepctx) delete ctxImpl;
167  return (void *)0;
168 }
#define EPNAME(x)
Definition: XrdBwmTrace.hh:56
#define DBG_CTX(y)
Definition: XrdTlsTrace.hh:39
static void Snooze(int seconds)
Definition: XrdSysTimer.cc:168
XrdTlsContext * Clone(bool full=true, bool startCRLRefresh=false)
bool newHostCertificateDetected()
static void Emsg(const char *tid, const char *msg=0, bool flush=true)
Definition: XrdTls.cc:104
XrdTlsContext * owner
XrdTlsContext::CTX_Params Parm
XrdTlsContext * ctxnew
XrdSysRWLock crlMutex
int crlRT
crl refresh interval time in seconds

References XrdTlsContext::Clone(), XrdTlsContextImpl::crlMutex, XrdTlsContext::CTX_Params::crlRT, XrdTlsContextImpl::crlRunning, XrdTlsContextImpl::ctxnew, DBG_CTX, XrdTls::Emsg(), EPNAME, XrdTlsContextImpl::flsRunning, XrdTlsContext::isOK(), XrdTlsContext::newHostCertificateDetected(), XrdTlsContextImpl::owner, XrdTlsContextImpl::Parm, XrdSysRWLock::ReadLock(), XrdSysTimer::Snooze(), XrdSysRWLock::UnLock(), XrdSysRWLock::WriteLock(), and XrdTlsContext::x509Verify().

Referenced by XrdDigAuth::Authorize(), and XrdTlsContext::SetCrlRefresh().

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