summaryrefslogtreecommitdiffstats
path: root/security/nss/lib/softoken/pkcs11u.c
diff options
context:
space:
mode:
authorJ.C. Jones <jjones@mozilla.com>2019-12-06 15:36:44 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-12-06 15:36:44 +0100
commit836e72e96caf47add72a13a715722fad030f196c (patch)
tree7a9a2aeb77ea0e04ac1fc2779dd3cea591a0623e /security/nss/lib/softoken/pkcs11u.c
parentd558cf6647406bdbb87c852772ad211670eff223 (diff)
downloadUXP-836e72e96caf47add72a13a715722fad030f196c.tar
UXP-836e72e96caf47add72a13a715722fad030f196c.tar.gz
UXP-836e72e96caf47add72a13a715722fad030f196c.tar.lz
UXP-836e72e96caf47add72a13a715722fad030f196c.tar.xz
UXP-836e72e96caf47add72a13a715722fad030f196c.zip
[NSS] Bug 1508776 - Remove unneeded refcounting from SFTKSession
SFTKSession objects are only ever actually destroyed at PK11 session closure, as the session is always the final holder -- and asserting refCount == 1 shows that to be true. Because of that, NSC_CloseSession can just call `sftk_DestroySession` directly and leave `sftk_FreeSession` as a no-op to be removed in the future.
Diffstat (limited to 'security/nss/lib/softoken/pkcs11u.c')
-rw-r--r--security/nss/lib/softoken/pkcs11u.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/security/nss/lib/softoken/pkcs11u.c b/security/nss/lib/softoken/pkcs11u.c
index 7b5fe732f..8cb5d2e70 100644
--- a/security/nss/lib/softoken/pkcs11u.c
+++ b/security/nss/lib/softoken/pkcs11u.c
@@ -1772,7 +1772,6 @@ sftk_NewSession(CK_SLOT_ID slotID, CK_NOTIFY notify, CK_VOID_PTR pApplication,
return NULL;
session->next = session->prev = NULL;
- session->refCount = 1;
session->enc_context = NULL;
session->hash_context = NULL;
session->sign_context = NULL;
@@ -1796,11 +1795,10 @@ sftk_NewSession(CK_SLOT_ID slotID, CK_NOTIFY notify, CK_VOID_PTR pApplication,
}
/* free all the data associated with a session. */
-static void
+void
sftk_DestroySession(SFTKSession *session)
{
SFTKObjectList *op, *next;
- PORT_Assert(session->refCount == 0);
/* clean out the attributes */
/* since no one is referencing us, it's safe to walk the chain
@@ -1844,31 +1842,20 @@ sftk_SessionFromHandle(CK_SESSION_HANDLE handle)
PZ_Lock(lock);
sftkqueue_find(session, handle, slot->head, slot->sessHashSize);
- if (session)
- session->refCount++;
PZ_Unlock(lock);
return (session);
}
/*
- * release a reference to a session handle
+ * release a reference to a session handle. This method of using SFTKSessions
+ * is deprecated, but the pattern should be retained until a future effort
+ * to refactor all SFTKSession users at once is completed.
*/
void
sftk_FreeSession(SFTKSession *session)
{
- PRBool destroy = PR_FALSE;
- SFTKSlot *slot = sftk_SlotFromSession(session);
- PZLock *lock = SFTK_SESSION_LOCK(slot, session->handle);
-
- PZ_Lock(lock);
- if (session->refCount == 1)
- destroy = PR_TRUE;
- session->refCount--;
- PZ_Unlock(lock);
-
- if (destroy)
- sftk_DestroySession(session);
+ return;
}
void