XRootD
Loading...
Searching...
No Matches
XrdTlsCrl Namespace Reference

Functions

void * Refresh (void *parg)
 

Function Documentation

◆ Refresh()

void * XrdTlsCrl::Refresh ( void * parg)

Definition at line 198 of file XrdTlsContext.cc.

199{
200 EPNAME("Refresh");
201 int sleepTime;
202 bool doreplace;
203
204// Get the implementation details
205//
206 XrdTlsContextImpl *ctxImpl = static_cast<XrdTlsContextImpl*>(parg);
207
208// Indicate we have started in the trace record
209//
210 DBG_CTX("CRL refresh started.")
211
212// Do this forever but first get the sleep time
213//
214do{ctxImpl->crlMutex.ReadLock();
215 sleepTime = ctxImpl->Parm.crlRT;
216 ctxImpl->crlMutex.UnLock();
217
218// We may have been cancelled, in which case we just exit
219//
220 if (!sleepTime)
221 {ctxImpl->crlMutex.WriteLock();
222 ctxImpl->crlRunning = false;
223 ctxImpl->crlMutex.UnLock();
224 DBG_CTX("CRL refresh ending by request!");
225 return (void *)0;
226 }
227
228// Indicate we how long before a refresh
229//
230 DBG_CTX("CRL refresh will happen in " <<sleepTime <<" seconds.");
231
232// Now sleep the request amount of time
233//
234 XrdSysTimer::Snooze(sleepTime);
235
236 if (ctxImpl->owner->x509Verify() || ctxImpl->owner->newHostCertificateDetected()) {
237 // Check if this context is still alive. Generally, it never gets deleted.
238 //
239 ctxImpl->crlMutex.WriteLock();
240 if (!ctxImpl->owner) break;
241
242 // We clone the original, this will give us the latest crls (i.e. refreshed).
243 // We drop the lock while doing so as this may take a long time. This is
244 // completely safe to do because we implicitly own the implementation.
245 //
246 ctxImpl->crlMutex.UnLock();
247 XrdTlsContext *newctx = ctxImpl->owner->Clone();
248
249 // Verify that the context was properly built
250 //
251 if (!newctx || !newctx->isOK())
252 {XrdTls::Emsg("CrlRefresh:","Refresh of context failed!!!",false);
253 continue;
254 }
255
256 // OK, set the new context to be used next time Session() is called.
257 //
258 ctxImpl->crlMutex.WriteLock();
259 doreplace = (ctxImpl->ctxnew != 0);
260 if (doreplace) delete ctxImpl->ctxnew;
261 ctxImpl->ctxnew = newctx;
262 ctxImpl->crlMutex.UnLock();
263
264 // Do some debugging
265 //
266 if (doreplace) {DBG_CTX("CRL refresh created replacement x509 store.");}
267 else {DBG_CTX("CRL refresh created new x509 store.");}
268 }
269 } while(true);
270
271// If we are here the context that started us has gone away and we are done
272//
273 bool keepctx = ctxImpl->flsRunning;
274 ctxImpl->crlRunning = false;
275 ctxImpl->crlMutex.UnLock();
276 if (!keepctx) delete ctxImpl;
277 return (void *)0;
278}
#define EPNAME(x)
#define DBG_CTX(y)
static void Snooze(int seconds)
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 XrdTlsContext::SetCrlRefresh().

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