diff options
Diffstat (limited to 'net/ocsp')
-rw-r--r-- | net/ocsp/nss_ocsp.cc | 14 | ||||
-rw-r--r-- | net/ocsp/nss_ocsp.h | 6 |
2 files changed, 15 insertions, 5 deletions
diff --git a/net/ocsp/nss_ocsp.cc b/net/ocsp/nss_ocsp.cc index fbb734f..b7fcb65 100644 --- a/net/ocsp/nss_ocsp.cc +++ b/net/ocsp/nss_ocsp.cc @@ -43,13 +43,15 @@ static URLRequestContext* g_request_context = NULL; class OCSPIOLoop : public MessageLoop::DestructionObserver { public: // MessageLoop::DestructionObserver: - virtual void WillDestroyCurrentMessageLoop(); + virtual void WillDestroyCurrentMessageLoop() { Shutdown(); } void StartUsing() { AutoLock autolock(lock_); used_ = true; } + void Shutdown(); + bool used() const { AutoLock autolock(lock_); return used_; @@ -95,7 +97,9 @@ OCSPIOLoop::~OCSPIOLoop() { pthread_mutex_unlock(&g_request_context_lock); } -void OCSPIOLoop::WillDestroyCurrentMessageLoop() { +void OCSPIOLoop::Shutdown() { + MessageLoopForIO::current()->RemoveDestructionObserver(this); + // Prevent the worker thread from trying to access |io_loop_|. { AutoLock autolock(lock_); @@ -855,14 +859,16 @@ void EnsureOCSPInit() { g_ocsp_nss_initialization.Get(); } +void ShutdownOCSP() { + g_ocsp_io_loop.Get().Shutdown(); +} + // This function would be called before NSS initialization. void SetURLRequestContextForOCSP(URLRequestContext* request_context) { pthread_mutex_lock(&g_request_context_lock); if (request_context) { DCHECK(request_context->is_main()); DCHECK(!g_request_context); - } else { - DCHECK(g_request_context); } g_request_context = request_context; pthread_mutex_unlock(&g_request_context_lock); diff --git a/net/ocsp/nss_ocsp.h b/net/ocsp/nss_ocsp.h index 97d69b9..cf2e66e 100644 --- a/net/ocsp/nss_ocsp.h +++ b/net/ocsp/nss_ocsp.h @@ -17,9 +17,13 @@ void SetMessageLoopForOCSP(); // Initializes OCSP handlers for NSS. This must be called before any // certificate verification functions. This function is thread-safe, and OCSP -// handlers will only ever be initialized once. +// handlers will only ever be initialized once. ShutdownOCSP() must be called +// on shutdown. void EnsureOCSPInit(); +// This should be called once on shutdown to stop issuing URLRequests for OCSP. +void ShutdownOCSP(); + // Set URLRequestContext for OCSP handlers. void SetURLRequestContextForOCSP(URLRequestContext* request_context); URLRequestContext* GetURLRequestContextForOCSP(); |