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 182 of file XrdTlsContext.cc.

183{
184 EPNAME("Flusher");
185 time_t tStart, tWaited;
186 int flushT, waitT, hits, miss, sesn, tmos;
187 long tNow;
188
189// Get the implementation details
190//
191 XrdTlsContextImpl *ctxImpl = static_cast<XrdTlsContextImpl*>(parg);
192
193// Get the interval as it may change as we are running
194//
195 ctxImpl->crlMutex.ReadLock();
196 waitT = flushT = ctxImpl->flushT;
197 ctxImpl->crlMutex.UnLock();
198
199// Indicate we have started in the trace record
200//
201 DBG_CTX("Cache flusher started; interval="<<flushT<<" seconds.");
202
203// Do this forever
204//
205do{tStart = time(0);
206 ctxImpl->flsCVar->Wait(waitT);
207 tWaited= time(0) - tStart;
208
209// Check if this context is still alive. Generally, it never gets deleted.
210//
211 ctxImpl->crlMutex.ReadLock();
212 if (!ctxImpl->owner) break;
213
214// If the interval changed, see if we should wait a bit longer
215//
216 if (flushT != ctxImpl->flushT && tWaited < ctxImpl->flushT-1)
217 {waitT = ctxImpl->flushT - tWaited;
218 ctxImpl->crlMutex.UnLock();
219 continue;
220 }
221
222// Get the new values and drop the lock
223//
224 waitT = flushT = ctxImpl->flushT;
225 ctxImpl->crlMutex.UnLock();
226
227// Get some relevant statistics
228//
229 sesn = SSL_CTX_sess_number(ctxImpl->ctx);
230 hits = SSL_CTX_sess_hits(ctxImpl->ctx);
231 miss = SSL_CTX_sess_misses(ctxImpl->ctx);
232 tmos = SSL_CTX_sess_timeouts(ctxImpl->ctx);
233
234// Flush the cache
235//
236 tNow = time(0);
237 SSL_CTX_flush_sessions(ctxImpl->ctx, tNow);
238
239// Print some stuff should debugging be on
240//
242 {char mBuff[512];
243 snprintf(mBuff, sizeof(mBuff), "sess=%d hits=%d miss=%d timeouts=%d",
244 sesn, hits, miss, tmos);
245 DBG_CTX("Cache flushed; " <<mBuff);
246 }
247 } while(true);
248
249// If we are here the context that started us has gone away and we are done
250//
251 bool keepctx = ctxImpl->crlRunning;
252 ctxImpl->flsRunning = false;
253 ctxImpl->crlMutex.UnLock();
254 if (!keepctx) delete ctxImpl;
255 return (void *)0;
256}
#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 262 of file XrdTlsContext.cc.

263{
264 pthread_t tid;
265 int rc;
266
267// Set the new flush interval
268//
269 pImpl->crlMutex.WriteLock();
270 pImpl->flushT = flushT;
271 pImpl->crlMutex.UnLock();
272
273// If the flush thread is already running, then wake it up to get the new value
274//
275 if (pImpl->flsRunning)
276 {pImpl->flsCVar->Signal();
277 return true;
278 }
279
280// Start the flusher thread
281//
282 pImpl->flsCVar = new XrdSysCondVar();
283 if ((rc = XrdSysThread::Run(&tid, XrdTlsFlush::Flusher, (void *)pImpl,
284 0, "Cache Flusher")))
285 {char eBuff[512];
286 snprintf(eBuff, sizeof(eBuff),
287 "Unable to start cache flusher thread; rc=%d", rc);
288 XrdTls::Emsg("SessCache:", eBuff, false);
289 return false;
290 }
291
292// Finish up
293//
294 pImpl->flsRunning = true;
295 SSL_CTX_set_session_cache_mode(pImpl->ctx, SSL_SESS_CACHE_NO_AUTO_CLEAR);
296 return true;
297}
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: