| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file implements the CLIENT Session ID cache. | 2 * This file implements the CLIENT Session ID cache. |
| 3 * | 3 * |
| 4 * This Source Code Form is subject to the terms of the Mozilla Public | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
| 5 * License, v. 2.0. If a copy of the MPL was not distributed with this | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 7 | 7 |
| 8 #include "cert.h" | 8 #include "cert.h" |
| 9 #include "pk11pub.h" | 9 #include "pk11pub.h" |
| 10 #include "secitem.h" | 10 #include "secitem.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 /* BEWARE: This function gets called for both client and server SIDs !! | 109 /* BEWARE: This function gets called for both client and server SIDs !! |
| 110 * If the unreferenced sid is not in the cache, Free sid and its contents. | 110 * If the unreferenced sid is not in the cache, Free sid and its contents. |
| 111 */ | 111 */ |
| 112 static void | 112 static void |
| 113 ssl_DestroySID(sslSessionID *sid) | 113 ssl_DestroySID(sslSessionID *sid) |
| 114 { | 114 { |
| 115 int i; | 115 int i; |
| 116 SSL_TRC(8, ("SSL: destroy sid: sid=0x%x cached=%d", sid, sid->cached)); | 116 SSL_TRC(8, ("SSL: destroy sid: sid=0x%x cached=%d", sid, sid->cached)); |
| 117 PORT_Assert((sid->references == 0)); | 117 PORT_Assert(sid->references == 0); |
| 118 | 118 PORT_Assert(sid->cached != in_client_cache); |
| 119 if (sid->cached == in_client_cache) | |
| 120 » return;»/* it will get taken care of next time cache is traversed. */ | |
| 121 | 119 |
| 122 if (sid->version < SSL_LIBRARY_VERSION_3_0) { | 120 if (sid->version < SSL_LIBRARY_VERSION_3_0) { |
| 123 SECITEM_ZfreeItem(&sid->u.ssl2.masterKey, PR_FALSE); | 121 SECITEM_ZfreeItem(&sid->u.ssl2.masterKey, PR_FALSE); |
| 124 SECITEM_ZfreeItem(&sid->u.ssl2.cipherArg, PR_FALSE); | 122 SECITEM_ZfreeItem(&sid->u.ssl2.cipherArg, PR_FALSE); |
| 125 } else { | 123 } else { |
| 126 if (sid->u.ssl3.locked.sessionTicket.ticket.data) { | 124 if (sid->u.ssl3.locked.sessionTicket.ticket.data) { |
| 127 SECITEM_FreeItem(&sid->u.ssl3.locked.sessionTicket.ticket, | 125 SECITEM_FreeItem(&sid->u.ssl3.locked.sessionTicket.ticket, |
| 128 PR_FALSE); | 126 PR_FALSE); |
| 129 } | 127 } |
| 130 if (sid->u.ssl3.srvName.data) { | 128 if (sid->u.ssl3.srvName.data) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 return NULL; | 213 return NULL; |
| 216 now = ssl_Time(); | 214 now = ssl_Time(); |
| 217 LOCK_CACHE; | 215 LOCK_CACHE; |
| 218 sidp = &cache; | 216 sidp = &cache; |
| 219 while ((sid = *sidp) != 0) { | 217 while ((sid = *sidp) != 0) { |
| 220 PORT_Assert(sid->cached == in_client_cache); | 218 PORT_Assert(sid->cached == in_client_cache); |
| 221 PORT_Assert(sid->references >= 1); | 219 PORT_Assert(sid->references >= 1); |
| 222 | 220 |
| 223 SSL_TRC(8, ("SSL: Lookup1: sid=0x%x", sid)); | 221 SSL_TRC(8, ("SSL: Lookup1: sid=0x%x", sid)); |
| 224 | 222 |
| 225 » if (sid->expirationTime < now || !sid->references) { | 223 » if (sid->expirationTime < now) { |
| 226 /* | 224 /* |
| 227 » ** This session-id timed out, or was orphaned. | 225 » ** This session-id timed out. |
| 228 ** Don't even care who it belongs to, blow it out of our cache. | 226 ** Don't even care who it belongs to, blow it out of our cache. |
| 229 */ | 227 */ |
| 230 SSL_TRC(7, ("SSL: lookup1, throwing sid out, age=%d refs=%d", | 228 SSL_TRC(7, ("SSL: lookup1, throwing sid out, age=%d refs=%d", |
| 231 now - sid->creationTime, sid->references)); | 229 now - sid->creationTime, sid->references)); |
| 232 | 230 |
| 233 *sidp = sid->next; /* delink it from the list. */ | 231 *sidp = sid->next; /* delink it from the list. */ |
| 234 sid->cached = invalid_cache; /* mark not on list. */ | 232 sid->cached = invalid_cache; /* mark not on list. */ |
| 235 » if (!sid->references) | 233 » ssl_FreeLockedSID(sid);» » /* drop ref count, free. */ |
| 236 » » ssl_DestroySID(sid); | |
| 237 » else | |
| 238 » » ssl_FreeLockedSID(sid);»» /* drop ref count, free. */ | |
| 239 | |
| 240 } else if (!memcmp(&sid->addr, addr, sizeof(PRIPv6Addr)) && /* server IP
addr matches */ | 234 } else if (!memcmp(&sid->addr, addr, sizeof(PRIPv6Addr)) && /* server IP
addr matches */ |
| 241 (sid->port == port) && /* server port matches */ | 235 (sid->port == port) && /* server port matches */ |
| 242 /* proxy (peerID) matches */ | 236 /* proxy (peerID) matches */ |
| 243 (((peerID == NULL) && (sid->peerID == NULL)) || | 237 (((peerID == NULL) && (sid->peerID == NULL)) || |
| 244 ((peerID != NULL) && (sid->peerID != NULL) && | 238 ((peerID != NULL) && (sid->peerID != NULL) && |
| 245 PORT_Strcmp(sid->peerID, peerID) == 0)) && | 239 PORT_Strcmp(sid->peerID, peerID) == 0)) && |
| 246 /* is cacheable */ | 240 /* is cacheable */ |
| 247 (sid->version < SSL_LIBRARY_VERSION_3_0 || | 241 (sid->version < SSL_LIBRARY_VERSION_3_0 || |
| 248 sid->u.ssl3.keys.resumable) && | 242 sid->u.ssl3.keys.resumable) && |
| 249 /* server hostname matches. */ | 243 /* server hostname matches. */ |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 | 463 |
| 470 /* Do a shallow copy, moving the ticket data. */ | 464 /* Do a shallow copy, moving the ticket data. */ |
| 471 sid->u.ssl3.locked.sessionTicket = *newSessionTicket; | 465 sid->u.ssl3.locked.sessionTicket = *newSessionTicket; |
| 472 newSessionTicket->ticket.data = NULL; | 466 newSessionTicket->ticket.data = NULL; |
| 473 newSessionTicket->ticket.len = 0; | 467 newSessionTicket->ticket.len = 0; |
| 474 | 468 |
| 475 if (sid->u.ssl3.lock) { | 469 if (sid->u.ssl3.lock) { |
| 476 NSSRWLock_UnlockWrite(sid->u.ssl3.lock); | 470 NSSRWLock_UnlockWrite(sid->u.ssl3.lock); |
| 477 } | 471 } |
| 478 } | 472 } |
| OLD | NEW |