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

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

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