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

Side by Side Diff: net/third_party/nss/ssl/ssl3con.c

Issue 10539144: Always initialize session cache locks lazily. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/third_party/nss/ssl/sslimpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* 2 /*
3 * SSL3 Protocol 3 * SSL3 Protocol
4 * 4 *
5 * ***** BEGIN LICENSE BLOCK ***** 5 * ***** BEGIN LICENSE BLOCK *****
6 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 6 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * 7 *
8 * The contents of this file are subject to the Mozilla Public License Version 8 * The contents of this file are subject to the Mozilla Public License Version
9 * 1.1 (the "License"); you may not use this file except in compliance with 9 * 1.1 (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at 10 * the License. You may obtain a copy of the License at
(...skipping 4506 matching lines...) Expand 10 before | Expand all | Expand 10 after
4517 PORT_SetError(SEC_ERROR_NOT_INITIALIZED); 4517 PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
4518 return SECFailure; 4518 return SECFailure;
4519 } 4519 }
4520 4520
4521 SECStatus 4521 SECStatus
4522 SSL3_ShutdownServerCache(void) 4522 SSL3_ShutdownServerCache(void)
4523 { 4523 {
4524 int i, j; 4524 int i, j;
4525 4525
4526 if (!symWrapKeysLock) 4526 if (!symWrapKeysLock)
4527 return SECSuccess; /* lock was never initialized */ 4527 return SECSuccess; /* lock was never initialized */
wtc 2012/06/13 23:08:21 Note that SSL3_ShutdownServerCache does a null che
4528 PZ_Lock(symWrapKeysLock); 4528 PZ_Lock(symWrapKeysLock);
4529 /* get rid of all symWrapKeys */ 4529 /* get rid of all symWrapKeys */
4530 for (i = 0; i < SSL_NUM_WRAP_MECHS; ++i) { 4530 for (i = 0; i < SSL_NUM_WRAP_MECHS; ++i) {
4531 for (j = 0; j < kt_kea_size; ++j) { 4531 for (j = 0; j < kt_kea_size; ++j) {
4532 PK11SymKey ** pSymWrapKey; 4532 PK11SymKey ** pSymWrapKey;
4533 pSymWrapKey = &symWrapKeys[i].symWrapKey[j]; 4533 pSymWrapKey = &symWrapKeys[i].symWrapKey[j];
4534 if (*pSymWrapKey) { 4534 if (*pSymWrapKey) {
4535 PK11_FreeSymKey(*pSymWrapKey); 4535 PK11_FreeSymKey(*pSymWrapKey);
4536 *pSymWrapKey = NULL; 4536 *pSymWrapKey = NULL;
4537 } 4537 }
4538 } 4538 }
4539 } 4539 }
4540 4540
4541 PZ_Unlock(symWrapKeysLock); 4541 PZ_Unlock(symWrapKeysLock);
4542 ssl_FreeSessionCacheLocks();
wtc 2012/06/13 23:08:21 The ssl_FreeSessionCacheLocks function is used whe
4543 return SECSuccess; 4542 return SECSuccess;
4544 } 4543 }
4545 4544
4546 SECStatus ssl_InitSymWrapKeysLock(void) 4545 SECStatus ssl_InitSymWrapKeysLock(void)
4547 { 4546 {
4548 symWrapKeysLock = PZ_NewLock(nssILockOther); 4547 symWrapKeysLock = PZ_NewLock(nssILockOther);
4549 return symWrapKeysLock ? SECSuccess : SECFailure; 4548 return symWrapKeysLock ? SECSuccess : SECFailure;
4550 } 4549 }
4551 4550
4552 /* Try to get wrapping key for mechanism from in-memory array. 4551 /* Try to get wrapping key for mechanism from in-memory array.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4584 return NULL; /* why are we here?!? */ 4583 return NULL; /* why are we here?!? */
4585 } 4584 }
4586 4585
4587 symWrapMechIndex = ssl_FindIndexByWrapMechanism(masterWrapMech); 4586 symWrapMechIndex = ssl_FindIndexByWrapMechanism(masterWrapMech);
4588 PORT_Assert(symWrapMechIndex >= 0); 4587 PORT_Assert(symWrapMechIndex >= 0);
4589 if (symWrapMechIndex < 0) 4588 if (symWrapMechIndex < 0)
4590 return NULL; /* invalid masterWrapMech. */ 4589 return NULL; /* invalid masterWrapMech. */
4591 4590
4592 pSymWrapKey = &symWrapKeys[symWrapMechIndex].symWrapKey[exchKeyType]; 4591 pSymWrapKey = &symWrapKeys[symWrapMechIndex].symWrapKey[exchKeyType];
4593 4592
4594 ssl_InitSessionCacheLocks(PR_TRUE);
4595
4596 PZ_Lock(symWrapKeysLock); 4593 PZ_Lock(symWrapKeysLock);
4597 4594
4598 unwrappedWrappingKey = *pSymWrapKey; 4595 unwrappedWrappingKey = *pSymWrapKey;
4599 if (unwrappedWrappingKey != NULL) { 4596 if (unwrappedWrappingKey != NULL) {
4600 if (PK11_VerifyKeyOK(unwrappedWrappingKey)) { 4597 if (PK11_VerifyKeyOK(unwrappedWrappingKey)) {
4601 unwrappedWrappingKey = PK11_ReferenceSymKey(unwrappedWrappingKey); 4598 unwrappedWrappingKey = PK11_ReferenceSymKey(unwrappedWrappingKey);
4602 goto done; 4599 goto done;
4603 } 4600 }
4604 /* slot series has changed, so this key is no good any more. */ 4601 /* slot series has changed, so this key is no good any more. */
4605 PK11_FreeSymKey(unwrappedWrappingKey); 4602 PK11_FreeSymKey(unwrappedWrappingKey);
(...skipping 6087 matching lines...) Expand 10 before | Expand all | Expand 10 after
10693 PORT_Free(ss->ssl3.hs.recvdFragments.buf); 10690 PORT_Free(ss->ssl3.hs.recvdFragments.buf);
10694 } 10691 }
10695 } 10692 }
10696 10693
10697 ss->ssl3.initialized = PR_FALSE; 10694 ss->ssl3.initialized = PR_FALSE;
10698 10695
10699 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE); 10696 SECITEM_FreeItem(&ss->ssl3.nextProto, PR_FALSE);
10700 } 10697 }
10701 10698
10702 /* End of ssl3con.c */ 10699 /* End of ssl3con.c */
OLDNEW
« no previous file with comments | « no previous file | net/third_party/nss/ssl/sslimpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698