summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2002-05-22 21:47:23 +0000
committerrelyea%netscape.com <devnull@localhost>2002-05-22 21:47:23 +0000
commitf66105f32067d52042cf81a102df581f7dc251b8 (patch)
tree19b743b26c5bcbe76d1e34ef097316f672920f94
parent55c51d1b890b70d543fd2b8a5bdc57e383431efe (diff)
downloadnss-hg-f66105f32067d52042cf81a102df581f7dc251b8.tar.gz
Close our peer database handles because some platforms (Mac) do bad things
if you hold two berkelydb handles open to the same database in the same process. (actually a lot of platforms could cause problems, the Mac version of dbm (1.85) just does the bad things right away).
-rw-r--r--security/nss/lib/softoken/pkcs11.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/security/nss/lib/softoken/pkcs11.c b/security/nss/lib/softoken/pkcs11.c
index b869f7f15..f7b2813ef 100644
--- a/security/nss/lib/softoken/pkcs11.c
+++ b/security/nss/lib/softoken/pkcs11.c
@@ -2413,6 +2413,25 @@ static void nscFreeAllSlots(int moduleIndex)
}
}
+static void
+pk11_closePeer(PRBool isFIPS)
+{
+ CK_SLOT_ID slotID = isFIPS ? PRIVATE_KEY_SLOT_ID: FIPS_SLOT_ID;
+ PK11Slot *slot;
+ int moduleIndex = isFIPS? NSC_NON_FIPS_MODULE : NSC_FIPS_MODULE;
+ PLHashTable *tmpSlotHashTable = nscSlotHashTable[moduleIndex];
+
+ slot = (PK11Slot *) PL_HashTableLookup(tmpSlotHashTable, (void *)slotID);
+ if (slot == NULL) {
+ return;
+ }
+ pk11_DBShutdown(slot->certDB,slot->keyDB);
+ slot->certDB = NULL;
+ slot->keyDB = NULL;
+ return;
+}
+
+static PRBool nsc_init = PR_FALSE;
/* NSC_Initialize initializes the Cryptoki library. */
CK_RV nsc_CommonInitialize(CK_VOID_PTR pReserved, PRBool isFIPS)
@@ -2454,6 +2473,12 @@ CK_RV nsc_CommonInitialize(CK_VOID_PTR pReserved, PRBool isFIPS)
goto loser;
}
+ /* if we have a peer already open, have him close his DB's so we
+ * don't clobber each other. */
+ if ((isFIPS && nsc_init) || (!isFIPS && nsf_init)) {
+ pk11_closePeer(isFIPS);
+ }
+
for (i=0; i < paramStrings.token_count; i++) {
crv =
PK11_SlotInit(paramStrings.configdir, &paramStrings.tokens[i],
@@ -2470,7 +2495,6 @@ loser:
return crv;
}
-static PRBool nsc_init = PR_FALSE;
CK_RV NSC_Initialize(CK_VOID_PTR pReserved)
{
CK_RV crv;