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

Functions

void * Flusher (void *parg)
 
bool Setup_Flusher (XrdTlsContextImpl *pImpl, int flushT)
 

Function Documentation

◆ Flusher()

void * XrdTlsFlush::Flusher ( void * parg)

Definition at line 292 of file XrdTlsContext.cc.

293{
294 EPNAME("Flusher");
295 time_t tStart, tWaited;
296 int flushT, waitT, hits, miss, sesn, tmos;
297 long tNow;
298
299// Get the implementation details
300//
301 XrdTlsContextImpl *ctxImpl = static_cast<XrdTlsContextImpl*>(parg);
302
303// Get the interval as it may change as we are running
304//
305 ctxImpl->crlMutex.ReadLock();
306 waitT = flushT = ctxImpl->flushT;
307 ctxImpl->crlMutex.UnLock();
308
309// Indicate we have started in the trace record
310//
311 DBG_CTX("Cache flusher started; interval="<<flushT<<" seconds.");
312
313// Do this forever
314//
315do{tStart = time(0);
316 ctxImpl->flsCVar->Wait(waitT);
317 tWaited= time(0) - tStart;
318
319// Check if this context is still alive. Generally, it never gets deleted.
320//
321 ctxImpl->crlMutex.ReadLock();
322 if (!ctxImpl->owner) break;
323
324// If the interval changed, see if we should wait a bit longer
325//
326 if (flushT != ctxImpl->flushT && tWaited < ctxImpl->flushT-1)
327 {waitT = ctxImpl->flushT - tWaited;
328 ctxImpl->crlMutex.UnLock();
329 continue;
330 }
331
332// Get the new values and drop the lock
333//
334 waitT = flushT = ctxImpl->flushT;
335 ctxImpl->crlMutex.UnLock();
336
337// Get some relevant statistics
338//
339 sesn = SSL_CTX_sess_number(ctxImpl->ctx);
340 hits = SSL_CTX_sess_hits(ctxImpl->ctx);
341 miss = SSL_CTX_sess_misses(ctxImpl->ctx);
342 tmos = SSL_CTX_sess_timeouts(ctxImpl->ctx);
343
344// Flush the cache
345//
346 tNow = time(0);
347 SSL_CTX_flush_sessions(ctxImpl->ctx, tNow);
348
349// Print some stuff should debugging be on
350//
352 {char mBuff[512];
353 snprintf(mBuff, sizeof(mBuff), "sess=%d hits=%d miss=%d timeouts=%d",
354 sesn, hits, miss, tmos);
355 DBG_CTX("Cache flushed; " <<mBuff);
356 }
357 } while(true);
358
359// If we are here the context that started us has gone away and we are done
360//
361 bool keepctx = ctxImpl->crlRunning;
362 ctxImpl->flsRunning = false;
363 ctxImpl->crlMutex.UnLock();
364 if (!keepctx) delete ctxImpl;
365 return (void *)0;
366}
#define EPNAME(x)
#define DBG_CTX(y)
#define TRACING(x)
Definition XrdTrace.hh:70
static const int dbgCTX
Turn debugging in for context operations.
Definition XrdTls.hh:100
XrdTlsContext * owner
XrdSysCondVar * flsCVar
XrdSysRWLock crlMutex

References XrdTlsContextImpl::crlMutex, XrdTlsContextImpl::crlRunning, XrdTlsContextImpl::ctx, DBG_CTX, XrdTls::dbgCTX, EPNAME, XrdTlsContextImpl::flsCVar, XrdTlsContextImpl::flsRunning, XrdTlsContextImpl::flushT, XrdTlsContextImpl::owner, XrdSysRWLock::ReadLock(), TRACING, XrdSysRWLock::UnLock(), and XrdSysCondVar::Wait().

Referenced by Setup_Flusher().

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

◆ Setup_Flusher()

bool XrdTlsFlush::Setup_Flusher ( XrdTlsContextImpl * pImpl,
int flushT )

Definition at line 372 of file XrdTlsContext.cc.

373{
374 pthread_t tid;
375 int rc;
376
377// Set the new flush interval
378//
379 pImpl->crlMutex.WriteLock();
380 pImpl->flushT = flushT;
381 pImpl->crlMutex.UnLock();
382
383// If the flush thread is already running, then wake it up to get the new value
384//
385 if (pImpl->flsRunning)
386 {pImpl->flsCVar->Signal();
387 return true;
388 }
389
390// Start the flusher thread
391//
392 pImpl->flsCVar = new XrdSysCondVar();
393 if ((rc = XrdSysThread::Run(&tid, XrdTlsFlush::Flusher, (void *)pImpl,
394 0, "Cache Flusher")))
395 {char eBuff[512];
396 snprintf(eBuff, sizeof(eBuff),
397 "Unable to start cache flusher thread; rc=%d", rc);
398 XrdTls::Emsg("SessCache:", eBuff, false);
399 return false;
400 }
401
402// Finish up
403//
404 pImpl->flsRunning = true;
405 SSL_CTX_set_session_cache_mode(pImpl->ctx, SSL_SESS_CACHE_NO_AUTO_CLEAR);
406 return true;
407}
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
static void Emsg(const char *tid, const char *msg=0, bool flush=true)
Definition XrdTls.cc:104
void * Flusher(void *parg)

References XrdTlsContextImpl::crlMutex, XrdTlsContextImpl::ctx, XrdTls::Emsg(), XrdTlsContextImpl::flsCVar, XrdTlsContextImpl::flsRunning, Flusher(), XrdTlsContextImpl::flushT, XrdSysThread::Run(), XrdSysCondVar::Signal(), XrdSysRWLock::UnLock(), and XrdSysRWLock::WriteLock().

Referenced by XrdTlsContext::SessionCache().

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