Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Unified Diff: net/third_party/nss/ssl/sslnonce.c

Issue 10539144: Always initialize session cache locks lazily. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove unrelated cleanup Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/third_party/nss/ssl/sslnonce.c
===================================================================
--- net/third_party/nss/ssl/sslnonce.c (revision 142005)
+++ net/third_party/nss/ssl/sslnonce.c (working copy)
@@ -65,7 +65,7 @@
* invalid_cache has been removed from the cache.
*/
-#define LOCK_CACHE lock_cache()
+#define LOCK_CACHE PZ_Lock(cacheLock)
#define UNLOCK_CACHE PZ_Unlock(cacheLock)
static SECStatus
@@ -87,8 +87,6 @@
return SECFailure;
}
-static PRBool LocksInitializedEarly = PR_FALSE;
-
static SECStatus
FreeSessionCacheLocks()
{
@@ -117,30 +115,11 @@
return SECFailure;
}
-/* free the session cache locks if they were initialized early */
-SECStatus
-ssl_FreeSessionCacheLocks()
-{
- PORT_Assert(PR_TRUE == LocksInitializedEarly);
- if (!LocksInitializedEarly) {
- PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
- return SECFailure;
- }
- FreeSessionCacheLocks();
- LocksInitializedEarly = PR_FALSE;
- return SECSuccess;
-}
-
static PRCallOnceType lockOnce;
/* free the session cache locks if they were initialized lazily */
static SECStatus ssl_ShutdownLocks(void* appData, void* nssData)
{
- PORT_Assert(PR_FALSE == LocksInitializedEarly);
- if (LocksInitializedEarly) {
- PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
- return SECFailure;
- }
FreeSessionCacheLocks();
memset(&lockOnce, 0, sizeof(lockOnce));
return SECSuccess;
@@ -160,37 +139,15 @@
return PR_SUCCESS;
}
-/* lazyInit means that the call is not happening during a 1-time
- * initialization function, but rather during dynamic, lazy initialization
- */
+/* the call is happening during dynamic, lazy initialization */
SECStatus
-ssl_InitSessionCacheLocks(PRBool lazyInit)
+ssl_InitSessionCacheLocks()
{
- if (LocksInitializedEarly) {
- return SECSuccess;
- }
-
- if (lazyInit) {
- return (PR_SUCCESS ==
- PR_CallOnce(&lockOnce, initSessionCacheLocksLazily)) ?
- SECSuccess : SECFailure;
- }
-
- if (SECSuccess == InitSessionCacheLocks()) {
- LocksInitializedEarly = PR_TRUE;
- return SECSuccess;
- }
-
- return SECFailure;
+ return (PR_SUCCESS ==
+ PR_CallOnce(&lockOnce, initSessionCacheLocksLazily)) ?
+ SECSuccess : SECFailure;
}
-static void
-lock_cache(void)
-{
- ssl_InitSessionCacheLocks(PR_TRUE);
- PZ_Lock(cacheLock);
-}
-
/* BEWARE: This function gets called for both client and server SIDs !!
* If the unreferenced sid is not in the cache, Free sid and its contents.
*/
@@ -477,6 +434,8 @@
void
SSL_ClearSessionCache(void)
{
+ if (!cacheLock)
+ return; /* lock was never initialized */
LOCK_CACHE;
while(cache != NULL)
UncacheSID(cache);

Powered by Google App Engine
This is Rietveld 408576698