From 166fac0d1cb9d3d2c8aae8e9a040c90a57eed5b4 Mon Sep 17 00:00:00 2001 From: "rsleevi@chromium.org" Date: Sat, 29 Jun 2013 21:18:16 +0000 Subject: Actually close the test NSS DB when ScopedTestNSSDB is destroyed NSS 3.15.1 fixes all known errors with SECMOD_CloseUserDB, so it can now be safely used again while testing BUG=156433 R=mattm Review URL: https://chromiumcodereview.appspot.com/18238002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209351 0039d316-1c4b-4281-b951-d872f2087c98 --- crypto/nss_util.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'crypto') diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc index bbbaa70..850d47d 100644 --- a/crypto/nss_util.cc +++ b/crypto/nss_util.cc @@ -318,14 +318,14 @@ class NSSInitSingleton { } void CloseTestNSSDB() { - if (test_slot_) { - SECStatus status = SECMOD_CloseUserDB(test_slot_); - if (status != SECSuccess) - PLOG(ERROR) << "SECMOD_CloseUserDB failed: " << PORT_GetError(); - PK11_FreeSlot(test_slot_); - test_slot_ = NULL; - ignore_result(g_test_nss_db_dir.Get().Delete()); - } + if (!test_slot_) + return; + SECStatus status = SECMOD_CloseUserDB(test_slot_); + if (status != SECSuccess) + PLOG(ERROR) << "SECMOD_CloseUserDB failed: " << PORT_GetError(); + PK11_FreeSlot(test_slot_); + test_slot_ = NULL; + ignore_result(g_test_nss_db_dir.Get().Delete()); } PK11SlotInfo* GetPublicNSSKeySlot() { @@ -698,9 +698,12 @@ ScopedTestNSSDB::ScopedTestNSSDB() } ScopedTestNSSDB::~ScopedTestNSSDB() { - // TODO(mattm): Close the dababase once NSS 3.14 is required, - // which fixes https://bugzilla.mozilla.org/show_bug.cgi?id=588269 - // Resource leaks are suppressed. http://crbug.com/156433 . + // Don't close when NSS is < 3.15.1, because it would require an additional + // sleep for 1 second after closing the database, due to + // http://bugzil.la/875601. + if (NSS_VersionCheck("3.15.1")) { + g_nss_singleton.Get().CloseTestNSSDB(); + } } base::Lock* GetNSSWriteLock() { -- cgit v1.1