From 59a3b36577ed3d3adb70f119033fd82223ddd3bb Mon Sep 17 00:00:00 2001 From: "willchan@chromium.org" Date: Thu, 21 Oct 2010 21:52:41 +0000 Subject: Explicitly shutdown OCSP. BUG=59630 TEST=existing Review URL: http://codereview.chromium.org/3822011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63428 0039d316-1c4b-4281-b951-d872f2087c98 --- net/ocsp/nss_ocsp.cc | 14 ++++++++++---- net/ocsp/nss_ocsp.h | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'net/ocsp') 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(); -- cgit v1.1