Backed out changeset b225a756abc2
authorJohn M. Schanck <jschanck@mozilla.com>
Fri, 09 Sep 2022 09:24:15 -0700
changeset 16330 e3b922f657f43c9722df2f61432964c418e0c359
parent 16325 97fec8885336bac6c3157e2825ce205955459999
child 16331 57af9485deec019c597408016fdc01a59890adc2
push id4201
push userjschanck@mozilla.com
push dateFri, 09 Sep 2022 16:28:15 +0000
backs outb225a756abc25d126418043191e7b18c6bbf38e1
Backed out changeset b225a756abc2
lib/softoken/pkcs11.c
--- a/lib/softoken/pkcs11.c
+++ b/lib/softoken/pkcs11.c
@@ -4213,30 +4213,26 @@ NSC_OpenSession(CK_SLOT_ID slotID, CK_FL
 
     do {
         PZLock *lock;
         do {
             sessionID = (PR_ATOMIC_INCREMENT(&slot->sessionIDCount) & 0xffffff) | (slot->index << 24);
         } while (sessionID == CK_INVALID_HANDLE);
         lock = SFTK_SESSION_LOCK(slot, sessionID);
         PZ_Lock(lock);
-        if (!slot->head) {
-            sessionID = CK_INVALID_HANDLE;
-            sftk_DestroySession(session);
-            PZ_Unlock(lock);
-            break;
-        }
         sameID = NULL;
-        sftkqueue_find(sameID, sessionID, slot->head, slot->sessHashSize);
-        if (sameID == NULL) {
-            session->handle = sessionID;
-            sftk_update_state(slot, session);
-            sftkqueue_add(session, sessionID, slot->head, slot->sessHashSize);
-        } else {
-            slot->sessionIDConflict++; /* for debugging */
+        if (slot->head) {
+            sftkqueue_find(sameID, sessionID, slot->head, slot->sessHashSize);
+            if (sameID == NULL) {
+                session->handle = sessionID;
+                sftk_update_state(slot, session);
+                sftkqueue_add(session, sessionID, slot->head, slot->sessHashSize);
+            } else {
+                slot->sessionIDConflict++; /* for debugging */
+            }
         }
         PZ_Unlock(lock);
     } while (sameID != NULL);
 
     *phSession = sessionID;
     return CKR_OK;
 }