summaryrefslogtreecommitdiffstats
path: root/base/nss_util.h
diff options
context:
space:
mode:
authordavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 22:44:48 +0000
committerdavidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 22:44:48 +0000
commit6913847c616758791214954dc3adc1492bdc688d (patch)
tree55bd2e7d5ab09a1f5c7d37e270c1c7bcb3392013 /base/nss_util.h
parent8c94d63f7a6e071bdc90648d614f1825cea195d0 (diff)
downloadchromium_src-6913847c616758791214954dc3adc1492bdc688d.zip
chromium_src-6913847c616758791214954dc3adc1492bdc688d.tar.gz
chromium_src-6913847c616758791214954dc3adc1492bdc688d.tar.bz2
Add a unit test to check KeygenHandler's thread-safety
We'll want some semblance of thread-safety when we make keygen asynchronous. R=wtc,mattm BUG=148 TEST=unit test Review URL: http://codereview.chromium.org/2838010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/nss_util.h')
-rw-r--r--base/nss_util.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/base/nss_util.h b/base/nss_util.h
index 94a81cb..8de3537 100644
--- a/base/nss_util.h
+++ b/base/nss_util.h
@@ -7,6 +7,10 @@
#include "base/basictypes.h"
+#if defined(USE_NSS)
+class Lock;
+#endif // defined(USE_NSS)
+
// This file specifically doesn't depend on any NSS or NSPR headers because it
// is included by various (non-crypto) parts of chrome to call the
// initialization functions.
@@ -33,6 +37,30 @@ void OpenPersistentNSSDB();
// We use a int64 instead of PRTime here to avoid depending on NSPR headers.
Time PRTimeToBaseTime(int64 prtime);
+#if defined(USE_NSS)
+// NSS has a bug which can cause a deadlock or stall in some cases when writing
+// to the certDB and keyDB. It also has a bug which causes concurrent key pair
+// generations to scribble over each other. To work around this, we synchronize
+// writes to the NSS databases with a global lock. The lock is hidden beneath a
+// function for easy disabling when the bug is fixed. Callers should allow for
+// it to return NULL in the future.
+//
+// See https://bugzilla.mozilla.org/show_bug.cgi?id=564011
+Lock* GetNSSWriteLock();
+
+// A helper class that acquires the NSS write Lock while the AutoNSSWriteLock
+// is in scope.
+class AutoNSSWriteLock {
+ public:
+ AutoNSSWriteLock();
+ ~AutoNSSWriteLock();
+ private:
+ Lock *lock_;
+ DISALLOW_COPY_AND_ASSIGN(AutoNSSWriteLock);
+};
+
+#endif // defined(USE_NSS)
+
} // namespace base
#endif // BASE_NSS_UTIL_H_