diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-21 21:52:41 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-21 21:52:41 +0000 |
commit | 59a3b36577ed3d3adb70f119033fd82223ddd3bb (patch) | |
tree | 761b0e32a59dcbd6896431d1397fa5d08e586f6e /net/ocsp | |
parent | 6f515a97557655ca48dd0d0064cdc0c122601335 (diff) | |
download | chromium_src-59a3b36577ed3d3adb70f119033fd82223ddd3bb.zip chromium_src-59a3b36577ed3d3adb70f119033fd82223ddd3bb.tar.gz chromium_src-59a3b36577ed3d3adb70f119033fd82223ddd3bb.tar.bz2 |
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
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(); |