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

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
Index: base/nss_util.cc
diff --git a/base/nss_util.cc b/base/nss_util.cc
index b411422bf142761298cc60e32b3f00066c4dbad7..6b07e87b5cb22812c8eb0d972a299b1d9add5a31 100644
--- a/base/nss_util.cc
+++ b/base/nss_util.cc
@@ -78,6 +78,9 @@ FilePath GetInitialConfigDirectory() {
//
// 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;
@@ -219,6 +222,8 @@ class NSSInitSingleton {
#else
FilePath database_dir = GetInitialConfigDirectory();
if (!database_dir.empty()) {
+ // This duplicates the work which should have been done in EarlyNSSInit.
+ // However, this function is idempotent so there's no harm done.
UseLocalCacheOfNSSDatabaseIfNFS(database_dir);
// Initialize with a persistent database (likely, ~/.pki/nssdb).
@@ -321,6 +326,14 @@ LazyInstance<NSSInitSingleton, LeakyLazyInstanceTraits<NSSInitSingleton> >
} // namespace
+void EarlyNSSInit() {
+#if defined(OS_LINUX)
wtc 2011/01/13 00:07:02 This ifdef should be #if defined(USE_NSS) to m
+ FilePath database_dir = GetInitialConfigDirectory();
+ if (!database_dir.empty())
+ UseLocalCacheOfNSSDatabaseIfNFS(database_dir);
+#endif
+}
+
void EnsureNSPRInit() {
g_nspr_singleton.Get();
}

Powered by Google App Engine
This is Rietveld 408576698