summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexei.volkov.bugs%sun.com <devnull@localhost>2009-11-11 23:24:33 +0000
committeralexei.volkov.bugs%sun.com <devnull@localhost>2009-11-11 23:24:33 +0000
commitb892b212b8ef71b9279810fc001ec80d2380df45 (patch)
treeab68a44c30b8d42a9324c5c543f5540fd8b3e26c
parent2e8da27382722d3b63583ca02afe73ed5b38468a (diff)
downloadnss-hg-b892b212b8ef71b9279810fc001ec80d2380df45.tar.gz
back out patch for bug 517615: this patch requires a parallel fix to be made in softoken.nss_3_12_5_BETA2
-rw-r--r--security/nss/lib/util/secoid.c59
-rw-r--r--security/nss/lib/util/secoid.h2
2 files changed, 19 insertions, 42 deletions
diff --git a/security/nss/lib/util/secoid.c b/security/nss/lib/util/secoid.c
index 624e07a69..7e8c1b6e1 100644
--- a/security/nss/lib/util/secoid.c
+++ b/security/nss/lib/util/secoid.c
@@ -39,7 +39,6 @@
#include "pkcs11t.h"
#include "secitem.h"
#include "secerr.h"
-#include "pratom.h"
#include "prenv.h"
#include "plhash.h"
#include "nssrwlk.h"
@@ -1632,7 +1631,6 @@ static PLHashTable * dynOidHash;
static dynXOid ** dynOidTable; /* not in the pool */
static int dynOidEntriesAllocated;
static int dynOidEntriesUsed;
-static PRInt32 secoidInitCount;
/* Creates NSSRWLock and dynOidPool at initialization time.
*/
@@ -1859,18 +1857,13 @@ handleHashAlgSupport(char * envVal)
SECStatus
SECOID_Init(void)
{
+ PLHashEntry *entry;
+ const SECOidData *oid;
int i;
char * envVal;
- if (PR_AtomicIncrement(&secoidInitCount) > 1) {
- return SECSuccess;
- }
-
- if (oidhash || oidmechhash) {
- /* Should never happen. First call is done from thread safe env. */
- PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
- PORT_Assert(0);
- return SECFailure;
+ if (oidhash) {
+ return SECSuccess; /* already initialized */
}
if (!PR_GetEnv("NSS_ALLOW_WEAK_SIGNATURE_ALG")) {
@@ -1883,55 +1876,52 @@ SECOID_Init(void)
}
envVal = PR_GetEnv("NSS_HASH_ALG_SUPPORT");
- if (envVal) {
+ if (envVal)
handleHashAlgSupport(envVal);
- }
if (secoid_InitDynOidData() != SECSuccess) {
+ PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
PORT_Assert(0); /* this function should never fail */
- goto loser;
+ return SECFailure;
}
oidhash = PL_NewHashTable(0, SECITEM_Hash, SECITEM_HashCompare,
PL_CompareValues, NULL, NULL);
oidmechhash = PL_NewHashTable(0, secoid_HashNumber, PL_CompareValues,
PL_CompareValues, NULL, NULL);
- if (!oidhash || !oidmechhash) {
+
+ if ( !oidhash || !oidmechhash) {
+ PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
PORT_Assert(0); /*This function should never fail. */
- goto loser;
+ return(SECFailure);
}
for ( i = 0; i < SEC_OID_TOTAL; i++ ) {
- PLHashEntry *entry;
- const SECOidData *oid = &oids[i];
+ oid = &oids[i];
PORT_Assert ( oid->offset == i );
entry = PL_HashTableAdd( oidhash, &oid->oid, (void *)oid );
if ( entry == NULL ) {
+ PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
PORT_Assert(0); /*This function should never fail. */
- goto loser;
+ return(SECFailure);
}
if ( oid->mechanism != CKM_INVALID_MECHANISM ) {
entry = PL_HashTableAdd( oidmechhash,
(void *)oid->mechanism, (void *)oid );
if ( entry == NULL ) {
+ PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
PORT_Assert(0); /* This function should never fail. */
- goto loser;
+ return(SECFailure);
}
}
}
- PORT_Assert(i == SEC_OID_TOTAL);
- return SECSuccess;
-loser:
- /* Initial call of SECOID_Init is from thread safe env. At this point
- * secoidInitCount is equal to 1. SECOID_Shutdown will restore initial
- * value of globals and set secoidInitCount to 0. */
- SECOID_Shutdown();
- PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
- return SECFailure;
+ PORT_Assert (i == SEC_OID_TOTAL);
+
+ return(SECSuccess);
}
SECOidData *
@@ -2081,17 +2071,6 @@ static PRBool parentForkedAfterC_Initialize;
SECStatus
SECOID_Shutdown(void)
{
- PRInt32 initCount = PR_AtomicDecrement(&secoidInitCount);
- PORT_Assert(initCount >= 0);
- if (initCount < 0) {
- /* Should not happen.*/
- PR_AtomicIncrement(&secoidInitCount);
- PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
- return SECFailure;
- }
- if (initCount > 0) {
- return SECSuccess;
- }
if (oidhash) {
PL_HashTableDestroy(oidhash);
oidhash = NULL;
diff --git a/security/nss/lib/util/secoid.h b/security/nss/lib/util/secoid.h
index 355c606f9..e758f9614 100644
--- a/security/nss/lib/util/secoid.h
+++ b/security/nss/lib/util/secoid.h
@@ -123,8 +123,6 @@ extern SECOidTag SECOID_AddEntry(const SECOidData * src);
/*
* initialize the oid data structures.
- * Caller must ensure that initial call of the function is done from
- * thread safe environment.
*/
extern SECStatus SECOID_Init(void);