bug 203049, move operations outside of slot->slotLock

r=relyea


git-svn-id: svn://10.0.0.236/branches/NSS_3_3_BRANCH@142359 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ian.mcgreer%sun.com
2003-05-12 23:24:25 +00:00
parent 44a0662542
commit 61aaa8d82f
2 changed files with 18 additions and 19 deletions

View File

@@ -2916,16 +2916,16 @@ CK_RV NSC_OpenSession(CK_SLOT_ID slotID, CK_FLAGS flags,
flags | CKF_SERIAL_SESSION);
if (session == NULL) return CKR_HOST_MEMORY;
PK11_USE_THREADS(PZ_Lock(slot->slotLock);)
if (slotID == NETSCAPE_SLOT_ID && (flags & CKF_RW_SESSION)) {
/* NETSCAPE_SLOT_ID is Read ONLY */
session->info.flags &= ~CKF_RW_SESSION;
}
slot->sessionCount++;
if (session->info.flags & CKF_RW_SESSION) {
slot->rwSessionCount++;
}
PK11_USE_THREADS(PZ_Lock(slot->slotLock);)
++slot->sessionCount;
PK11_USE_THREADS(PZ_Unlock(slot->slotLock);)
if (session->info.flags & CKF_RW_SESSION) {
PR_AtomicIncrement(&slot->rwSessionCount);
}
do {
do {
@@ -2975,19 +2975,18 @@ CK_RV NSC_CloseSession(CK_SESSION_HANDLE hSession)
}
PK11_USE_THREADS(PZ_Unlock(PK11_SESSION_LOCK(slot,hSession));)
PK11_USE_THREADS(PZ_Lock(slot->slotLock);)
if (sessionFound) {
slot->sessionCount--;
PK11_USE_THREADS(PZ_Lock(slot->slotLock);)
if (--slot->sessionCount == 0) {
pw = slot->password;
slot->isLoggedIn = PR_FALSE;
slot->password = NULL;
}
PK11_USE_THREADS(PZ_Unlock(slot->slotLock);)
if (session->info.flags & CKF_RW_SESSION) {
slot->rwSessionCount--;
PR_AtomicDecrement(&slot->rwSessionCount);
}
}
if (slot->sessionCount == 0) {
pw = slot->password;
slot->isLoggedIn = PR_FALSE;
slot->password = NULL;
}
PK11_USE_THREADS(PZ_Unlock(slot->slotLock);)
pk11_FreeSession(session);
if (pw) SECITEM_ZfreeItem(pw, PR_TRUE);
@@ -3033,11 +3032,11 @@ CK_RV NSC_CloseAllSessions (CK_SLOT_ID slotID)
session->next = session->prev = NULL;
PK11_USE_THREADS(PZ_Unlock(PK11_SESSION_LOCK(slot,i));)
PK11_USE_THREADS(PZ_Lock(slot->slotLock);)
slot->sessionCount--;
if (session->info.flags & CKF_RW_SESSION) {
slot->rwSessionCount--;
}
--slot->sessionCount;
PK11_USE_THREADS(PZ_Unlock(slot->slotLock);)
if (session->info.flags & CKF_RW_SESSION) {
PR_AtomicDecrement(&slot->rwSessionCount);
}
} else {
PK11_USE_THREADS(PZ_Unlock(PK11_SESSION_LOCK(slot,i));)
}

View File

@@ -291,7 +291,7 @@ struct PK11SlotStr {
int sessionIDCount;
int sessionIDConflict;
int sessionCount;
int rwSessionCount;
PRInt32 rwSessionCount;
int tokenIDCount;
PK11Object *tokObjects[TOKEN_OBJECT_HASH_SIZE];
PK11Session *head[SESSION_HASH_SIZE];