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

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

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