diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-13 20:33:45 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-13 20:33:45 +0000 |
commit | ac3d597ebe7b6d9c83a8922e927be7980fbed399 (patch) | |
tree | a7551ecf2be1ebf4f8cca8377dada7ea979d298d /base/nss_util.cc | |
parent | 93983a938f6b5f31ba792f5fa28a62822015eddf (diff) | |
download | chromium_src-ac3d597ebe7b6d9c83a8922e927be7980fbed399.zip chromium_src-ac3d597ebe7b6d9c83a8922e927be7980fbed399.tar.gz chromium_src-ac3d597ebe7b6d9c83a8922e927be7980fbed399.tar.bz2 |
NSS: don't set environment variables when multi-threaded.
We can't alter the envionment once we have gone multithreaded because
glibc's getenv doesn't take the environment lock. Thus we add an
EarlyNSSInit() function which can do so, early in startup.
BUG=66835
TEST=ThreadSanitizer
http://codereview.chromium.org/6185005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/nss_util.cc')
-rw-r--r-- | base/nss_util.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/base/nss_util.cc b/base/nss_util.cc index 8fdede3..da678f0 100644 --- a/base/nss_util.cc +++ b/base/nss_util.cc @@ -99,6 +99,9 @@ char* PK11PasswordFunc(PK11SlotInfo* slot, PRBool retry, void* arg) { // // TODO(wtc): port this function to other USE_NSS platforms. It is defined // only for OS_LINUX simply because the statfs structure is OS-specific. +// +// Because this function sets an environment variable it must be run before we +// go multi-threaded. void UseLocalCacheOfNSSDatabaseIfNFS(const FilePath& database_dir) { #if defined(OS_LINUX) struct statfs buf; @@ -240,6 +243,9 @@ class NSSInitSingleton { #else FilePath database_dir = GetInitialConfigDirectory(); if (!database_dir.empty()) { + // This duplicates the work which should have been done in + // EarlySetupForNSSInit. However, this function is idempotent so there's + // no harm done. UseLocalCacheOfNSSDatabaseIfNFS(database_dir); // Initialize with a persistent database (likely, ~/.pki/nssdb). @@ -344,6 +350,14 @@ LazyInstance<NSSInitSingleton, LeakyLazyInstanceTraits<NSSInitSingleton> > } // namespace +#if defined(USE_NSS) +void EarlySetupForNSSInit() { + FilePath database_dir = GetInitialConfigDirectory(); + if (!database_dir.empty()) + UseLocalCacheOfNSSDatabaseIfNFS(database_dir); +} +#endif + void EnsureNSPRInit() { g_nspr_singleton.Get(); } |