Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5513)

Unified Diff: base/nss_util.cc

Issue 6185005: NSS: don't set environment variables when multi-threaded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/nss_util.h ('k') | chrome/app/chrome_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/nss_util.cc
diff --git a/base/nss_util.cc b/base/nss_util.cc
index 8fdede3cb3fb176da1d75da7b3df2dd5045501b9..da678f0518a04a62f66fe2767985afd320b83f0e 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();
}
« no previous file with comments | « base/nss_util.h ('k') | chrome/app/chrome_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698