Avoid call to sdb_measureAccess if NSS_SDB_USE_CACHE is set
authorPeter (Stig) Edwards <thatsafunnyname@gmail.com>
Thu, 23 Jan 2014 20:54:46 +0100
changeset 11012 9934c8faef29
parent 11011 204e4d573b9d
child 11013 3c3b381c4865
push id284
push userkaie@kuix.de
push date2014-01-23 19:54 +0000
Avoid call to sdb_measureAccess if NSS_SDB_USE_CACHE is set
lib/softoken/sdb.c
--- a/lib/softoken/sdb.c
+++ b/lib/softoken/sdb.c
@@ -2007,17 +2007,27 @@ s_open(const char *directory, const char
 	    error = CKR_HOST_MEMORY;
 	    goto loser;
 	}
     }
 #endif
 
     /* how long does it take to test for a non-existant file in our working
      * directory? Allows us to test if we may be on a network file system */
-    accessOps = sdb_measureAccess(directory);
+    accessOps = 1;
+    {
+        char *env;
+        env = PR_GetEnv("NSS_SDB_USE_CACHE");
+        /* If the environment variable is set to yes or no, sdb_init() will
+         * ignore the value of accessOps, and we can skip the measuring. */
+        if (!env || ((PORT_Strcasecmp(env, "no") != 0) &&
+                     (PORT_Strcasecmp(env, "yes") != 0))){
+           accessOps = sdb_measureAccess(directory);
+        }
+    }
 
     /*
      * open the cert data base
      */
     if (certdb) {
 	/* initialize Certificate database */
 	error = sdb_init(cert, "nssPublic", SDB_CERT, &inUpdate,
 			 newInit, flags, accessOps, certdb);