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

Side by Side Diff: net/third_party/nss/patches/cachelocks.patch

Issue 1844813002: Uprev NSS to 3.23 on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more GN fix Created 4 years, 8 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
OLDNEW
1 diff --git a/lib/ssl/ssl3con.c b/lib/ssl/ssl3con.c 1 diff --git a/lib/ssl/ssl3con.c b/lib/ssl/ssl3con.c
2 index 2533679..ba3d012 100644 2 index 1394542..d7d186a 100644
3 --- a/lib/ssl/ssl3con.c 3 --- a/lib/ssl/ssl3con.c
4 +++ b/lib/ssl/ssl3con.c 4 +++ b/lib/ssl/ssl3con.c
5 @@ -5921,7 +5921,6 @@ SSL3_ShutdownServerCache(void) 5 @@ -6049,7 +6049,6 @@ SSL3_ShutdownServerCache(void)
6 } 6 }
7 7
8 PZ_Unlock(symWrapKeysLock); 8 PZ_Unlock(symWrapKeysLock);
9 - ssl_FreeSessionCacheLocks(); 9 - ssl_FreeSessionCacheLocks();
10 return SECSuccess; 10 return SECSuccess;
11 } 11 }
12 12
13 @@ -5973,7 +5972,7 @@ getWrappingKey( sslSocket * ss, 13 @@ -6102,7 +6101,7 @@ getWrappingKey(sslSocket *ss,
14 14
15 pSymWrapKey = &symWrapKeys[symWrapMechIndex].symWrapKey[exchKeyType]; 15 pSymWrapKey = &symWrapKeys[symWrapMechIndex].symWrapKey[exchKeyType];
16 16
17 - ssl_InitSessionCacheLocks(PR_TRUE); 17 - ssl_InitSessionCacheLocks(PR_TRUE);
18 + ssl_InitSessionCacheLocks(); 18 + ssl_InitSessionCacheLocks();
19 19
20 PZ_Lock(symWrapKeysLock); 20 PZ_Lock(symWrapKeysLock);
21 21
22 diff --git a/lib/ssl/sslimpl.h b/lib/ssl/sslimpl.h 22 diff --git a/lib/ssl/sslimpl.h b/lib/ssl/sslimpl.h
23 index d5f326f..d53c446 100644 23 index d47eb28..c0e3a0b 100644
24 --- a/lib/ssl/sslimpl.h 24 --- a/lib/ssl/sslimpl.h
25 +++ b/lib/ssl/sslimpl.h 25 +++ b/lib/ssl/sslimpl.h
26 @@ -1957,9 +1957,7 @@ extern SECStatus ssl_InitSymWrapKeysLock(void); 26 @@ -2029,9 +2029,7 @@ extern SECStatus ssl_InitSymWrapKeysLock(void);
27 27
28 extern SECStatus ssl_FreeSymWrapKeysLock(void); 28 extern SECStatus ssl_FreeSymWrapKeysLock(void);
29 29
30 -extern SECStatus ssl_InitSessionCacheLocks(PRBool lazyInit); 30 -extern SECStatus ssl_InitSessionCacheLocks(PRBool lazyInit);
31 - 31 -
32 -extern SECStatus ssl_FreeSessionCacheLocks(void); 32 -extern SECStatus ssl_FreeSessionCacheLocks(void);
33 +extern SECStatus ssl_InitSessionCacheLocks(void); 33 +extern SECStatus ssl_InitSessionCacheLocks(void);
34 34
35 /***************** platform client auth ****************/ 35 /**************** DTLS-specific functions **************/
36 36 extern void dtls_FreeQueuedMessage(DTLSQueuedMessage *msg);
37 diff --git a/lib/ssl/sslnonce.c b/lib/ssl/sslnonce.c 37 diff --git a/lib/ssl/sslnonce.c b/lib/ssl/sslnonce.c
38 index 1326a8b..c45849d 100644 38 index 4804cb8..99591cc 100644
39 --- a/lib/ssl/sslnonce.c 39 --- a/lib/ssl/sslnonce.c
40 +++ b/lib/ssl/sslnonce.c 40 +++ b/lib/ssl/sslnonce.c
41 @@ -35,91 +35,55 @@ static PZLock * cacheLock = NULL; 41 @@ -35,93 +35,55 @@ static PZLock *cacheLock = NULL;
42 #define LOCK_CACHE » lock_cache() 42 #define LOCK_CACHE lock_cache()
43 #define UNLOCK_CACHE» PZ_Unlock(cacheLock) 43 #define UNLOCK_CACHE PZ_Unlock(cacheLock)
44 44
45 -static SECStatus 45 -static SECStatus
46 -ssl_InitClientSessionCacheLock(void) 46 -ssl_InitClientSessionCacheLock(void)
47 -{ 47 -{
48 - cacheLock = PZ_NewLock(nssILockCache); 48 - cacheLock = PZ_NewLock(nssILockCache);
49 - return cacheLock ? SECSuccess : SECFailure; 49 - return cacheLock ? SECSuccess : SECFailure;
50 -} 50 -}
51 - 51 -
52 -static SECStatus 52 -static SECStatus
53 -ssl_FreeClientSessionCacheLock(void) 53 -ssl_FreeClientSessionCacheLock(void)
54 -{ 54 -{
55 - if (cacheLock) { 55 - if (cacheLock) {
56 - PZ_DestroyLock(cacheLock); 56 - PZ_DestroyLock(cacheLock);
57 - cacheLock = NULL; 57 - cacheLock = NULL;
58 - return SECSuccess; 58 - return SECSuccess;
59 - } 59 - }
60 - PORT_SetError(SEC_ERROR_NOT_INITIALIZED); 60 - PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
61 - return SECFailure; 61 - return SECFailure;
62 -} 62 -}
63 - 63 -
64 -static PRBool LocksInitializedEarly = PR_FALSE; 64 -static PRBool LocksInitializedEarly = PR_FALSE;
65 +static PRCallOnceType lockOnce; 65 +static PRCallOnceType lockOnce;
66 66
67 +/* FreeSessionCacheLocks is a callback from NSS_RegisterShutdown which destroys 67 +/* FreeSessionCacheLocks is a callback from NSS_RegisterShutdown which destroys
68 + * the session cache locks on shutdown and resets them to their initial 68 + * the session cache locks on shutdown and resets them to their initial
69 + * state. */ 69 + * state. */
70 static SECStatus 70 static SECStatus
71 -FreeSessionCacheLocks() 71 -FreeSessionCacheLocks()
72 +FreeSessionCacheLocks(void* appData, void* nssData) 72 +FreeSessionCacheLocks(void *appData, void *nssData)
73 { 73 {
74 - SECStatus rv1, rv2; 74 - SECStatus rv1, rv2;
75 - rv1 = ssl_FreeSymWrapKeysLock(); 75 - rv1 = ssl_FreeSymWrapKeysLock();
76 - rv2 = ssl_FreeClientSessionCacheLock(); 76 - rv2 = ssl_FreeClientSessionCacheLock();
77 - if ( (SECSuccess == rv1) && (SECSuccess == rv2) ) { 77 - if ((SECSuccess == rv1) && (SECSuccess == rv2)) {
78 - return SECSuccess; 78 - return SECSuccess;
79 - } 79 - }
80 - return SECFailure; 80 - return SECFailure;
81 -} 81 -}
82 + static const PRCallOnceType pristineCallOnce; 82 + static const PRCallOnceType pristineCallOnce;
83 + SECStatus rv; 83 + SECStatus rv;
84 84
85 -static SECStatus 85 -static SECStatus
86 -InitSessionCacheLocks(void) 86 -InitSessionCacheLocks(void)
87 -{ 87 -{
88 - SECStatus rv1, rv2; 88 - SECStatus rv1, rv2;
89 - PRErrorCode rc; 89 - PRErrorCode rc;
90 - rv1 = ssl_InitSymWrapKeysLock(); 90 - rv1 = ssl_InitSymWrapKeysLock();
91 - rv2 = ssl_InitClientSessionCacheLock(); 91 - rv2 = ssl_InitClientSessionCacheLock();
92 - if ( (SECSuccess == rv1) && (SECSuccess == rv2) ) { 92 - if ((SECSuccess == rv1) && (SECSuccess == rv2)) {
93 - return SECSuccess; 93 - return SECSuccess;
94 - } 94 - }
95 - rc = PORT_GetError(); 95 - rc = PORT_GetError();
96 - FreeSessionCacheLocks(); 96 - FreeSessionCacheLocks();
97 - PORT_SetError(rc); 97 - PORT_SetError(rc);
98 - return SECFailure; 98 - return SECFailure;
99 -} 99 -}
100 - 100 -
101 -/* free the session cache locks if they were initialized early */ 101 -/* free the session cache locks if they were initialized early */
102 -SECStatus 102 -SECStatus
103 -ssl_FreeSessionCacheLocks() 103 -ssl_FreeSessionCacheLocks()
104 -{ 104 -{
105 - PORT_Assert(PR_TRUE == LocksInitializedEarly); 105 - PORT_Assert(PR_TRUE == LocksInitializedEarly);
106 - if (!LocksInitializedEarly) { 106 - if (!LocksInitializedEarly) {
107 + if (!cacheLock) { 107 + if (!cacheLock) {
108 PORT_SetError(SEC_ERROR_NOT_INITIALIZED); 108 PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
109 return SECFailure; 109 return SECFailure;
110 } 110 }
111 - FreeSessionCacheLocks(); 111 - FreeSessionCacheLocks();
112 - LocksInitializedEarly = PR_FALSE; 112 - LocksInitializedEarly = PR_FALSE;
113 - return SECSuccess; 113 - return SECSuccess;
114 -} 114 -}
115 115
116 -static PRCallOnceType lockOnce; 116 -static PRCallOnceType lockOnce;
117 + PZ_DestroyLock(cacheLock); 117 + PZ_DestroyLock(cacheLock);
118 + cacheLock = NULL; 118 + cacheLock = NULL;
119 119
120 -/* free the session cache locks if they were initialized lazily */ 120 -/* free the session cache locks if they were initialized lazily */
121 -static SECStatus ssl_ShutdownLocks(void* appData, void* nssData) 121 -static SECStatus
122 -ssl_ShutdownLocks(void *appData, void *nssData)
122 -{ 123 -{
123 - PORT_Assert(PR_FALSE == LocksInitializedEarly); 124 - PORT_Assert(PR_FALSE == LocksInitializedEarly);
124 - if (LocksInitializedEarly) { 125 - if (LocksInitializedEarly) {
125 - PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); 126 - PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
126 - return SECFailure; 127 - return SECFailure;
127 + rv = ssl_FreeSymWrapKeysLock(); 128 + rv = ssl_FreeSymWrapKeysLock();
128 + if (rv != SECSuccess) { 129 + if (rv != SECSuccess) {
129 + return rv; 130 + return rv;
130 } 131 }
131 - FreeSessionCacheLocks(); 132 - FreeSessionCacheLocks();
132 - memset(&lockOnce, 0, sizeof(lockOnce)); 133 - memset(&lockOnce, 0, sizeof(lockOnce));
133 + 134 +
134 + lockOnce = pristineCallOnce; 135 + lockOnce = pristineCallOnce;
135 return SECSuccess; 136 return SECSuccess;
136 } 137 }
137 138
138 -static PRStatus initSessionCacheLocksLazily(void)
139 +/* InitSessionCacheLocks is called, protected by lockOnce, to create the 139 +/* InitSessionCacheLocks is called, protected by lockOnce, to create the
140 + * session cache locks. */ 140 + * session cache locks. */
141 +static PRStatus 141 static PRStatus
142 -initSessionCacheLocksLazily(void)
142 +InitSessionCacheLocks(void) 143 +InitSessionCacheLocks(void)
143 { 144 {
144 - SECStatus rv = InitSessionCacheLocks(); 145 - SECStatus rv = InitSessionCacheLocks();
145 - if (SECSuccess != rv) { 146 - if (SECSuccess != rv) {
146 + SECStatus rv; 147 + SECStatus rv;
147 + 148 +
148 + cacheLock = PZ_NewLock(nssILockCache); 149 + cacheLock = PZ_NewLock(nssILockCache);
149 + if (cacheLock == NULL) { 150 + if (cacheLock == NULL) {
150 return PR_FAILURE; 151 return PR_FAILURE;
151 } 152 }
152 - rv = NSS_RegisterShutdown(ssl_ShutdownLocks, NULL); 153 - rv = NSS_RegisterShutdown(ssl_ShutdownLocks, NULL);
153 + rv = ssl_InitSymWrapKeysLock(); 154 + rv = ssl_InitSymWrapKeysLock();
154 + if (rv != SECSuccess) { 155 + if (rv != SECSuccess) {
155 + PRErrorCode error = PORT_GetError(); 156 + PRErrorCode error = PORT_GetError();
156 + PZ_DestroyLock(cacheLock); 157 + PZ_DestroyLock(cacheLock);
157 + cacheLock = NULL; 158 + cacheLock = NULL;
158 + PORT_SetError(error); 159 + PORT_SetError(error);
159 + return PR_FAILURE; 160 + return PR_FAILURE;
160 + } 161 + }
161 + 162 +
162 + rv = NSS_RegisterShutdown(FreeSessionCacheLocks, NULL); 163 + rv = NSS_RegisterShutdown(FreeSessionCacheLocks, NULL);
163 PORT_Assert(SECSuccess == rv); 164 PORT_Assert(SECSuccess == rv);
164 if (SECSuccess != rv) { 165 if (SECSuccess != rv) {
165 return PR_FAILURE; 166 return PR_FAILURE;
166 @@ -127,34 +91,18 @@ static PRStatus initSessionCacheLocksLazily(void) 167 @@ -129,35 +91,19 @@ initSessionCacheLocksLazily(void)
167 return PR_SUCCESS; 168 return PR_SUCCESS;
168 } 169 }
169 170
170 -/* lazyInit means that the call is not happening during a 1-time 171 -/* lazyInit means that the call is not happening during a 1-time
171 - * initialization function, but rather during dynamic, lazy initialization 172 - * initialization function, but rather during dynamic, lazy initialization
172 - */ 173 - */
173 SECStatus 174 SECStatus
174 -ssl_InitSessionCacheLocks(PRBool lazyInit) 175 -ssl_InitSessionCacheLocks(PRBool lazyInit)
175 +ssl_InitSessionCacheLocks(void) 176 +ssl_InitSessionCacheLocks()
176 { 177 {
177 - if (LocksInitializedEarly) { 178 - if (LocksInitializedEarly) {
178 - return SECSuccess; 179 - return SECSuccess;
179 - } 180 - }
180 - 181 -
181 - if (lazyInit) { 182 - if (lazyInit) {
182 - return (PR_SUCCESS == 183 - return (PR_SUCCESS ==
183 - PR_CallOnce(&lockOnce, initSessionCacheLocksLazily)) ? 184 - PR_CallOnce(&lockOnce, initSessionCacheLocksLazily))
184 - SECSuccess : SECFailure; 185 - ? SECSuccess
186 - : SECFailure;
185 - } 187 - }
186 - 188 -
187 - if (SECSuccess == InitSessionCacheLocks()) { 189 - if (SECSuccess == InitSessionCacheLocks()) {
188 - LocksInitializedEarly = PR_TRUE; 190 - LocksInitializedEarly = PR_TRUE;
189 - return SECSuccess; 191 - return SECSuccess;
190 - } 192 - }
191 - 193 -
192 - return SECFailure; 194 - return SECFailure;
193 + return (PR_SUCCESS == 195 + return (PR_SUCCESS ==
194 + PR_CallOnce(&lockOnce, InitSessionCacheLocks)) ? 196 + PR_CallOnce(&lockOnce, InitSessionCacheLocks))
195 + SECSuccess : SECFailure; 197 + ? SECSuccess
198 + : SECFailure;
196 } 199 }
197 200
198 -static void 201 static void
199 +static void
200 lock_cache(void) 202 lock_cache(void)
201 { 203 {
202 - ssl_InitSessionCacheLocks(PR_TRUE); 204 - ssl_InitSessionCacheLocks(PR_TRUE);
203 + ssl_InitSessionCacheLocks(); 205 + ssl_InitSessionCacheLocks();
204 PZ_Lock(cacheLock); 206 PZ_Lock(cacheLock);
205 } 207 }
206 208
207 diff --git a/lib/ssl/sslsnce.c b/lib/ssl/sslsnce.c 209 diff --git a/lib/ssl/sslsnce.c b/lib/ssl/sslsnce.c
208 index f31b2e9..3856c13 100644 210 index da1f93f..e3f749e 100644
209 --- a/lib/ssl/sslsnce.c 211 --- a/lib/ssl/sslsnce.c
210 +++ b/lib/ssl/sslsnce.c 212 +++ b/lib/ssl/sslsnce.c
211 @@ -1363,7 +1363,7 @@ SSL_ConfigServerSessionIDCache(» int maxCacheEntries , 213 @@ -1344,7 +1344,7 @@ SSL_ConfigServerSessionIDCache(int maxCacheEntries,
212 » » » »PRUint32 ssl3_timeout, 214 PRUint32 ssl3_timeout,
213 » » » const char * directory) 215 const char *directory)
214 { 216 {
215 - ssl_InitSessionCacheLocks(PR_FALSE); 217 - ssl_InitSessionCacheLocks(PR_FALSE);
216 + ssl_InitSessionCacheLocks(); 218 + ssl_InitSessionCacheLocks();
217 return SSL_ConfigServerSessionIDCacheInstance(&globalCache, 219 return SSL_ConfigServerSessionIDCacheInstance(&globalCache,
218 » » maxCacheEntries, ssl2_timeout, ssl3_timeout, directory, PR_FALSE ); 220 maxCacheEntries, ssl2_timeout , ssl3_timeout, directory, PR_FALSE);
219 } 221 }
220 @@ -1477,7 +1477,7 @@ SSL_ConfigServerSessionIDCacheWithOpt( 222 @@ -1458,7 +1458,7 @@ SSL_ConfigServerSessionIDCacheWithOpt(
221 PRBool enableMPCache) 223 PRBool enableMPCache)
222 { 224 {
223 if (!enableMPCache) { 225 if (!enableMPCache) {
224 - ssl_InitSessionCacheLocks(PR_FALSE); 226 - ssl_InitSessionCacheLocks(PR_FALSE);
225 + ssl_InitSessionCacheLocks(); 227 + ssl_InitSessionCacheLocks();
226 return ssl_ConfigServerSessionIDCacheInstanceWithOpt(&globalCache, 228 return ssl_ConfigServerSessionIDCacheInstanceWithOpt(&globalCache,
227 ssl2_timeout, ssl3_timeout, directory, PR_FALSE, 229 ssl2_timeout, ssl3 _timeout, directory, PR_FALSE,
228 maxCacheEntries, maxCertCacheEntries, maxSrvNameCacheEntries); 230 maxCacheEntries, m axCertCacheEntries, maxSrvNameCacheEntries);
229 @@ -1521,7 +1521,7 @@ SSL_InheritMPServerSIDCacheInstance(cacheDesc *cache, cons t char * envString) 231 @@ -1502,7 +1502,7 @@ SSL_InheritMPServerSIDCacheInstance(cacheDesc *cache, cons t char *envString)
230 » return SECSuccess;» /* already done. */ 232 return SECSuccess; /* already done. */
231 } 233 }
232 234
233 - ssl_InitSessionCacheLocks(PR_FALSE); 235 - ssl_InitSessionCacheLocks(PR_FALSE);
234 + ssl_InitSessionCacheLocks(); 236 + ssl_InitSessionCacheLocks();
235 237
236 ssl_sid_lookup = ServerSessionIDLookup; 238 ssl_sid_lookup = ServerSessionIDLookup;
237 ssl_sid_cache = ServerSessionIDCache; 239 ssl_sid_cache = ServerSessionIDCache;
OLDNEW
« no previous file with comments | « net/third_party/nss/patches/cachecerts.patch ('k') | net/third_party/nss/patches/chacha20poly1305.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698