OLD | NEW |
1 diff --git a/nss/lib/ssl/ssl3con.c b/nss/lib/ssl/ssl3con.c | 1 diff -pu a/nss/lib/ssl/ssl3con.c b/nss/lib/ssl/ssl3con.c |
2 index 53c29f0..bc54c99 100644 | 2 --- a/nss/lib/ssl/ssl3con.c» 2014-01-03 19:02:30.135754914 -0800 |
3 --- a/nss/lib/ssl/ssl3con.c | 3 +++ b/nss/lib/ssl/ssl3con.c» 2014-01-03 19:03:07.266361523 -0800 |
4 +++ b/nss/lib/ssl/ssl3con.c | 4 @@ -5655,7 +5655,6 @@ SSL3_ShutdownServerCache(void) |
5 @@ -5593,7 +5593,6 @@ SSL3_ShutdownServerCache(void) | |
6 } | 5 } |
7 | 6 |
8 PZ_Unlock(symWrapKeysLock); | 7 PZ_Unlock(symWrapKeysLock); |
9 - ssl_FreeSessionCacheLocks(); | 8 - ssl_FreeSessionCacheLocks(); |
10 return SECSuccess; | 9 return SECSuccess; |
11 } | 10 } |
12 | 11 |
13 @@ -5645,7 +5644,7 @@ getWrappingKey( sslSocket * ss, | 12 @@ -5707,7 +5706,7 @@ getWrappingKey( sslSocket * ss, |
14 | 13 |
15 pSymWrapKey = &symWrapKeys[symWrapMechIndex].symWrapKey[exchKeyType]; | 14 pSymWrapKey = &symWrapKeys[symWrapMechIndex].symWrapKey[exchKeyType]; |
16 | 15 |
17 - ssl_InitSessionCacheLocks(PR_TRUE); | 16 - ssl_InitSessionCacheLocks(PR_TRUE); |
18 + ssl_InitSessionCacheLocks(); | 17 + ssl_InitSessionCacheLocks(); |
19 | 18 |
20 PZ_Lock(symWrapKeysLock); | 19 PZ_Lock(symWrapKeysLock); |
21 | 20 |
22 diff --git a/nss/lib/ssl/sslimpl.h b/nss/lib/ssl/sslimpl.h | 21 diff -pu a/nss/lib/ssl/sslimpl.h b/nss/lib/ssl/sslimpl.h |
23 index e3ae9ce..59140f8 100644 | 22 --- a/nss/lib/ssl/sslimpl.h» 2014-01-03 19:02:30.135754914 -0800 |
24 --- a/nss/lib/ssl/sslimpl.h | 23 +++ b/nss/lib/ssl/sslimpl.h» 2014-01-03 19:03:07.266361523 -0800 |
25 +++ b/nss/lib/ssl/sslimpl.h | 24 @@ -1904,9 +1904,7 @@ extern SECStatus ssl_InitSymWrapKeysLock |
26 @@ -1845,9 +1845,7 @@ extern SECStatus ssl_InitSymWrapKeysLock(void); | |
27 | 25 |
28 extern SECStatus ssl_FreeSymWrapKeysLock(void); | 26 extern SECStatus ssl_FreeSymWrapKeysLock(void); |
29 | 27 |
30 -extern SECStatus ssl_InitSessionCacheLocks(PRBool lazyInit); | 28 -extern SECStatus ssl_InitSessionCacheLocks(PRBool lazyInit); |
31 - | 29 - |
32 -extern SECStatus ssl_FreeSessionCacheLocks(void); | 30 -extern SECStatus ssl_FreeSessionCacheLocks(void); |
33 +extern SECStatus ssl_InitSessionCacheLocks(void); | 31 +extern SECStatus ssl_InitSessionCacheLocks(void); |
34 | 32 |
35 /***************** platform client auth ****************/ | 33 /***************** platform client auth ****************/ |
36 | 34 |
37 diff --git a/nss/lib/ssl/sslnonce.c b/nss/lib/ssl/sslnonce.c | 35 diff -pu a/nss/lib/ssl/sslnonce.c b/nss/lib/ssl/sslnonce.c |
38 index 5d8a954..a6f7349 100644 | 36 --- a/nss/lib/ssl/sslnonce.c» 2014-01-03 18:54:48.638219358 -0800 |
39 --- a/nss/lib/ssl/sslnonce.c | 37 +++ b/nss/lib/ssl/sslnonce.c» 2014-01-03 19:03:07.276361687 -0800 |
40 +++ b/nss/lib/ssl/sslnonce.c | |
41 @@ -35,91 +35,55 @@ static PZLock * cacheLock = NULL; | 38 @@ -35,91 +35,55 @@ static PZLock * cacheLock = NULL; |
42 #define LOCK_CACHE lock_cache() | 39 #define LOCK_CACHE lock_cache() |
43 #define UNLOCK_CACHE PZ_Unlock(cacheLock) | 40 #define UNLOCK_CACHE PZ_Unlock(cacheLock) |
44 | 41 |
45 +static PRCallOnceType lockOnce; | 42 -static SECStatus |
46 + | |
47 +/* FreeSessionCacheLocks is a callback from NSS_RegisterShutdown which destroys | |
48 + * the session cache locks on shutdown and resets them to their initial | |
49 + * state. */ | |
50 static SECStatus | |
51 -ssl_InitClientSessionCacheLock(void) | 43 -ssl_InitClientSessionCacheLock(void) |
52 +FreeSessionCacheLocks(void* appData, void* nssData) | 44 -{ |
53 { | 45 - cacheLock = PZ_NewLock(nssILockCache); |
54 + static const PRCallOnceType pristineCallOnce; | |
55 + SECStatus rv; | |
56 + | |
57 + if (!cacheLock) { | |
58 + PORT_SetError(SEC_ERROR_NOT_INITIALIZED); | |
59 + return SECFailure; | |
60 + } | |
61 + | |
62 + PZ_DestroyLock(cacheLock); | |
63 + cacheLock = NULL; | |
64 + | |
65 + rv = ssl_FreeSymWrapKeysLock(); | |
66 + if (rv != SECSuccess) { | |
67 + return rv; | |
68 + } | |
69 + | |
70 + lockOnce = pristineCallOnce; | |
71 + return SECSuccess; | |
72 +} | |
73 + | |
74 +/* InitSessionCacheLocks is called, protected by lockOnce, to create the | |
75 + * session cache locks. */ | |
76 +static PRStatus | |
77 +InitSessionCacheLocks(void) | |
78 +{ | |
79 + SECStatus rv; | |
80 + | |
81 cacheLock = PZ_NewLock(nssILockCache); | |
82 - return cacheLock ? SECSuccess : SECFailure; | 46 - return cacheLock ? SECSuccess : SECFailure; |
83 -} | 47 -} |
84 - | 48 - |
85 -static SECStatus | 49 -static SECStatus |
86 -ssl_FreeClientSessionCacheLock(void) | 50 -ssl_FreeClientSessionCacheLock(void) |
87 -{ | 51 -{ |
88 - if (cacheLock) { | 52 - if (cacheLock) { |
89 + if (cacheLock == NULL) { | 53 - PZ_DestroyLock(cacheLock); |
90 + return PR_FAILURE; | 54 - cacheLock = NULL; |
91 + } | |
92 + rv = ssl_InitSymWrapKeysLock(); | |
93 + if (rv != SECSuccess) { | |
94 + PRErrorCode error = PORT_GetError(); | |
95 PZ_DestroyLock(cacheLock); | |
96 cacheLock = NULL; | |
97 - return SECSuccess; | 55 - return SECSuccess; |
98 - } | 56 - } |
99 - PORT_SetError(SEC_ERROR_NOT_INITIALIZED); | 57 - PORT_SetError(SEC_ERROR_NOT_INITIALIZED); |
100 - return SECFailure; | 58 - return SECFailure; |
101 -} | 59 -} |
102 - | 60 - |
103 -static PRBool LocksInitializedEarly = PR_FALSE; | 61 -static PRBool LocksInitializedEarly = PR_FALSE; |
104 - | 62 - |
105 -static SECStatus | 63 -static SECStatus |
106 -FreeSessionCacheLocks() | 64 -FreeSessionCacheLocks() |
107 -{ | 65 -{ |
108 - SECStatus rv1, rv2; | 66 - SECStatus rv1, rv2; |
109 - rv1 = ssl_FreeSymWrapKeysLock(); | 67 - rv1 = ssl_FreeSymWrapKeysLock(); |
110 - rv2 = ssl_FreeClientSessionCacheLock(); | 68 - rv2 = ssl_FreeClientSessionCacheLock(); |
111 - if ( (SECSuccess == rv1) && (SECSuccess == rv2) ) { | 69 - if ( (SECSuccess == rv1) && (SECSuccess == rv2) ) { |
112 - return SECSuccess; | 70 - return SECSuccess; |
113 - } | 71 - } |
114 - return SECFailure; | 72 - return SECFailure; |
115 -} | 73 -} |
116 - | 74 +static PRCallOnceType lockOnce; |
117 -static SECStatus | 75 |
| 76 +/* FreeSessionCacheLocks is a callback from NSS_RegisterShutdown which destroys |
| 77 + * the session cache locks on shutdown and resets them to their initial |
| 78 + * state. */ |
| 79 static SECStatus |
118 -InitSessionCacheLocks(void) | 80 -InitSessionCacheLocks(void) |
119 -{ | 81 +FreeSessionCacheLocks(void* appData, void* nssData) |
| 82 { |
120 - SECStatus rv1, rv2; | 83 - SECStatus rv1, rv2; |
121 - PRErrorCode rc; | 84 - PRErrorCode rc; |
122 - rv1 = ssl_InitSymWrapKeysLock(); | 85 - rv1 = ssl_InitSymWrapKeysLock(); |
123 - rv2 = ssl_InitClientSessionCacheLock(); | 86 - rv2 = ssl_InitClientSessionCacheLock(); |
124 - if ( (SECSuccess == rv1) && (SECSuccess == rv2) ) { | 87 - if ( (SECSuccess == rv1) && (SECSuccess == rv2) ) { |
125 - return SECSuccess; | 88 - return SECSuccess; |
126 - } | 89 - } |
127 - rc = PORT_GetError(); | 90 - rc = PORT_GetError(); |
128 - FreeSessionCacheLocks(); | 91 - FreeSessionCacheLocks(); |
129 - PORT_SetError(rc); | 92 - PORT_SetError(rc); |
130 - return SECFailure; | 93 - return SECFailure; |
131 -} | 94 -} |
132 - | 95 + static const PRCallOnceType pristineCallOnce; |
| 96 + SECStatus rv; |
| 97 |
133 -/* free the session cache locks if they were initialized early */ | 98 -/* free the session cache locks if they were initialized early */ |
134 -SECStatus | 99 -SECStatus |
135 -ssl_FreeSessionCacheLocks() | 100 -ssl_FreeSessionCacheLocks() |
136 -{ | 101 -{ |
137 - PORT_Assert(PR_TRUE == LocksInitializedEarly); | 102 - PORT_Assert(PR_TRUE == LocksInitializedEarly); |
138 - if (!LocksInitializedEarly) { | 103 - if (!LocksInitializedEarly) { |
139 - PORT_SetError(SEC_ERROR_NOT_INITIALIZED); | 104 + if (!cacheLock) { |
140 - return SECFailure; | 105 PORT_SetError(SEC_ERROR_NOT_INITIALIZED); |
141 - } | 106 return SECFailure; |
| 107 } |
142 - FreeSessionCacheLocks(); | 108 - FreeSessionCacheLocks(); |
143 - LocksInitializedEarly = PR_FALSE; | 109 - LocksInitializedEarly = PR_FALSE; |
144 - return SECSuccess; | 110 - return SECSuccess; |
145 -} | 111 -} |
146 - | 112 |
147 -static PRCallOnceType lockOnce; | 113 -static PRCallOnceType lockOnce; |
148 - | 114 + PZ_DestroyLock(cacheLock); |
| 115 + cacheLock = NULL; |
| 116 |
149 -/* free the session cache locks if they were initialized lazily */ | 117 -/* free the session cache locks if they were initialized lazily */ |
150 -static SECStatus ssl_ShutdownLocks(void* appData, void* nssData) | 118 -static SECStatus ssl_ShutdownLocks(void* appData, void* nssData) |
151 -{ | 119 -{ |
152 - PORT_Assert(PR_FALSE == LocksInitializedEarly); | 120 - PORT_Assert(PR_FALSE == LocksInitializedEarly); |
153 - if (LocksInitializedEarly) { | 121 - if (LocksInitializedEarly) { |
154 - PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); | 122 - PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); |
155 - return SECFailure; | 123 - return SECFailure; |
156 - } | 124 + rv = ssl_FreeSymWrapKeysLock(); |
| 125 + if (rv != SECSuccess) { |
| 126 + return rv; |
| 127 } |
157 - FreeSessionCacheLocks(); | 128 - FreeSessionCacheLocks(); |
158 - memset(&lockOnce, 0, sizeof(lockOnce)); | 129 - memset(&lockOnce, 0, sizeof(lockOnce)); |
159 - return SECSuccess; | 130 + |
160 -} | 131 + lockOnce = pristineCallOnce; |
161 - | 132 return SECSuccess; |
| 133 } |
| 134 |
162 -static PRStatus initSessionCacheLocksLazily(void) | 135 -static PRStatus initSessionCacheLocksLazily(void) |
163 -{ | 136 +/* InitSessionCacheLocks is called, protected by lockOnce, to create the |
| 137 + * session cache locks. */ |
| 138 +static PRStatus |
| 139 +InitSessionCacheLocks(void) |
| 140 { |
164 - SECStatus rv = InitSessionCacheLocks(); | 141 - SECStatus rv = InitSessionCacheLocks(); |
165 - if (SECSuccess != rv) { | 142 - if (SECSuccess != rv) { |
166 + PORT_SetError(error); | 143 + SECStatus rv; |
| 144 + |
| 145 + cacheLock = PZ_NewLock(nssILockCache); |
| 146 + if (cacheLock == NULL) { |
167 return PR_FAILURE; | 147 return PR_FAILURE; |
168 } | 148 } |
169 - rv = NSS_RegisterShutdown(ssl_ShutdownLocks, NULL); | 149 - rv = NSS_RegisterShutdown(ssl_ShutdownLocks, NULL); |
| 150 + rv = ssl_InitSymWrapKeysLock(); |
| 151 + if (rv != SECSuccess) { |
| 152 + PRErrorCode error = PORT_GetError(); |
| 153 + PZ_DestroyLock(cacheLock); |
| 154 + cacheLock = NULL; |
| 155 + PORT_SetError(error); |
| 156 + return PR_FAILURE; |
| 157 + } |
170 + | 158 + |
171 + rv = NSS_RegisterShutdown(FreeSessionCacheLocks, NULL); | 159 + rv = NSS_RegisterShutdown(FreeSessionCacheLocks, NULL); |
172 PORT_Assert(SECSuccess == rv); | 160 PORT_Assert(SECSuccess == rv); |
173 if (SECSuccess != rv) { | 161 if (SECSuccess != rv) { |
174 return PR_FAILURE; | 162 return PR_FAILURE; |
175 @@ -127,34 +91,18 @@ static PRStatus initSessionCacheLocksLazily(void) | 163 @@ -127,34 +91,18 @@ static PRStatus initSessionCacheLocksLaz |
176 return PR_SUCCESS; | 164 return PR_SUCCESS; |
177 } | 165 } |
178 | 166 |
179 -/* lazyInit means that the call is not happening during a 1-time | 167 -/* lazyInit means that the call is not happening during a 1-time |
180 - * initialization function, but rather during dynamic, lazy initialization | 168 - * initialization function, but rather during dynamic, lazy initialization |
181 - */ | 169 - */ |
182 SECStatus | 170 SECStatus |
183 -ssl_InitSessionCacheLocks(PRBool lazyInit) | 171 -ssl_InitSessionCacheLocks(PRBool lazyInit) |
184 +ssl_InitSessionCacheLocks(void) | 172 +ssl_InitSessionCacheLocks(void) |
185 { | 173 { |
(...skipping 20 matching lines...) Expand all Loading... |
206 | 194 |
207 -static void | 195 -static void |
208 +static void | 196 +static void |
209 lock_cache(void) | 197 lock_cache(void) |
210 { | 198 { |
211 - ssl_InitSessionCacheLocks(PR_TRUE); | 199 - ssl_InitSessionCacheLocks(PR_TRUE); |
212 + ssl_InitSessionCacheLocks(); | 200 + ssl_InitSessionCacheLocks(); |
213 PZ_Lock(cacheLock); | 201 PZ_Lock(cacheLock); |
214 } | 202 } |
215 | 203 |
216 diff --git a/nss/lib/ssl/sslsnce.c b/nss/lib/ssl/sslsnce.c | 204 diff -pu a/nss/lib/ssl/sslsnce.c b/nss/lib/ssl/sslsnce.c |
217 index b0446ad..34e07b0 100644 | 205 --- a/nss/lib/ssl/sslsnce.c» 2014-01-03 18:38:48.402575652 -0800 |
218 --- a/nss/lib/ssl/sslsnce.c | 206 +++ b/nss/lib/ssl/sslsnce.c» 2014-01-03 19:03:07.276361687 -0800 |
219 +++ b/nss/lib/ssl/sslsnce.c | 207 @@ -1353,7 +1353,7 @@ SSL_ConfigServerSessionIDCache(» int |
220 @@ -1353,7 +1353,7 @@ SSL_ConfigServerSessionIDCache(» int maxCacheEntries
, | |
221 PRUint32 ssl3_timeout, | 208 PRUint32 ssl3_timeout, |
222 const char * directory) | 209 const char * directory) |
223 { | 210 { |
224 - ssl_InitSessionCacheLocks(PR_FALSE); | 211 - ssl_InitSessionCacheLocks(PR_FALSE); |
225 + ssl_InitSessionCacheLocks(); | 212 + ssl_InitSessionCacheLocks(); |
226 return SSL_ConfigServerSessionIDCacheInstance(&globalCache, | 213 return SSL_ConfigServerSessionIDCacheInstance(&globalCache, |
227 maxCacheEntries, ssl2_timeout, ssl3_timeout, directory, PR_FALSE
); | 214 maxCacheEntries, ssl2_timeout, ssl3_timeout, directory, PR_FALSE
); |
228 } | 215 } |
229 @@ -1467,7 +1467,7 @@ SSL_ConfigServerSessionIDCacheWithOpt( | 216 @@ -1467,7 +1467,7 @@ SSL_ConfigServerSessionIDCacheWithOpt( |
230 PRBool enableMPCache) | 217 PRBool enableMPCache) |
231 { | 218 { |
232 if (!enableMPCache) { | 219 if (!enableMPCache) { |
233 - ssl_InitSessionCacheLocks(PR_FALSE); | 220 - ssl_InitSessionCacheLocks(PR_FALSE); |
234 + ssl_InitSessionCacheLocks(); | 221 + ssl_InitSessionCacheLocks(); |
235 return ssl_ConfigServerSessionIDCacheInstanceWithOpt(&globalCache, | 222 return ssl_ConfigServerSessionIDCacheInstanceWithOpt(&globalCache, |
236 ssl2_timeout, ssl3_timeout, directory, PR_FALSE, | 223 ssl2_timeout, ssl3_timeout, directory, PR_FALSE, |
237 maxCacheEntries, maxCertCacheEntries, maxSrvNameCacheEntries); | 224 maxCacheEntries, maxCertCacheEntries, maxSrvNameCacheEntries); |
238 @@ -1512,7 +1512,7 @@ SSL_InheritMPServerSIDCacheInstance(cacheDesc *cache, cons
t char * envString) | 225 @@ -1512,7 +1512,7 @@ SSL_InheritMPServerSIDCacheInstance(cach |
239 return SECSuccess; /* already done. */ | 226 return SECSuccess; /* already done. */ |
240 } | 227 } |
241 | 228 |
242 - ssl_InitSessionCacheLocks(PR_FALSE); | 229 - ssl_InitSessionCacheLocks(PR_FALSE); |
243 + ssl_InitSessionCacheLocks(); | 230 + ssl_InitSessionCacheLocks(); |
244 | 231 |
245 ssl_sid_lookup = ServerSessionIDLookup; | 232 ssl_sid_lookup = ServerSessionIDLookup; |
246 ssl_sid_cache = ServerSessionIDCache; | 233 ssl_sid_cache = ServerSessionIDCache; |
OLD | NEW |