Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / net / third_party / nss / patches / nssrwlock.patch
blob2f10a4fbd378e3af9bd5e6afe5d0de62254f8926
1 diff -pu a/nss/lib/ssl/ssl3con.c b/nss/lib/ssl/ssl3con.c
2 --- a/nss/lib/ssl/ssl3con.c 2014-01-17 19:01:58.104487211 -0800
3 +++ b/nss/lib/ssl/ssl3con.c 2014-01-17 19:02:38.965159506 -0800
4 @@ -5211,7 +5211,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
5 * the lock across the calls to ssl3_CallHelloExtensionSenders.
6 */
7 if (sid->u.ssl3.lock) {
8 - PR_RWLock_Rlock(sid->u.ssl3.lock);
9 + NSSRWLock_LockRead(sid->u.ssl3.lock);
12 if (isTLS || (ss->firstHsDone && ss->peerRequestedProtection)) {
13 @@ -5220,7 +5220,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
15 extLen = ssl3_CallHelloExtensionSenders(ss, PR_FALSE, maxBytes, NULL);
16 if (extLen < 0) {
17 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
18 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
19 return SECFailure;
21 maxBytes -= extLen;
22 @@ -5248,7 +5248,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
23 /* how many suites are permitted by policy and user preference? */
24 num_suites = count_cipher_suites(ss, ss->ssl3.policy, PR_TRUE);
25 if (!num_suites) {
26 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
27 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
28 return SECFailure; /* count_cipher_suites has set error code. */
31 @@ -5293,7 +5293,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
33 rv = ssl3_AppendHandshakeHeader(ss, client_hello, length);
34 if (rv != SECSuccess) {
35 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
36 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
37 return rv; /* err set by ssl3_AppendHandshake* */
40 @@ -5312,21 +5312,21 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
41 rv = ssl3_AppendHandshakeNumber(ss, ss->clientHelloVersion, 2);
43 if (rv != SECSuccess) {
44 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
45 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
46 return rv; /* err set by ssl3_AppendHandshake* */
49 if (!resending) { /* Don't re-generate if we are in DTLS re-sending mode */
50 rv = ssl3_GetNewRandom(&ss->ssl3.hs.client_random);
51 if (rv != SECSuccess) {
52 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
53 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
54 return rv; /* err set by GetNewRandom. */
57 rv = ssl3_AppendHandshake(ss, &ss->ssl3.hs.client_random,
58 SSL3_RANDOM_LENGTH);
59 if (rv != SECSuccess) {
60 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
61 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
62 return rv; /* err set by ssl3_AppendHandshake* */
65 @@ -5336,7 +5336,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
66 else
67 rv = ssl3_AppendHandshakeVariable(ss, NULL, 0, 1);
68 if (rv != SECSuccess) {
69 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
70 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
71 return rv; /* err set by ssl3_AppendHandshake* */
74 @@ -5344,14 +5344,14 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
75 rv = ssl3_AppendHandshakeVariable(
76 ss, ss->ssl3.hs.cookie, ss->ssl3.hs.cookieLen, 1);
77 if (rv != SECSuccess) {
78 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
79 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
80 return rv; /* err set by ssl3_AppendHandshake* */
84 rv = ssl3_AppendHandshakeNumber(ss, num_suites*sizeof(ssl3CipherSuite), 2);
85 if (rv != SECSuccess) {
86 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
87 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
88 return rv; /* err set by ssl3_AppendHandshake* */
91 @@ -5360,7 +5360,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
92 rv = ssl3_AppendHandshakeNumber(ss, TLS_EMPTY_RENEGOTIATION_INFO_SCSV,
93 sizeof(ssl3CipherSuite));
94 if (rv != SECSuccess) {
95 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
96 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
97 return rv; /* err set by ssl3_AppendHandshake* */
99 actual_count++;
100 @@ -5369,7 +5369,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
101 rv = ssl3_AppendHandshakeNumber(ss, TLS_FALLBACK_SCSV,
102 sizeof(ssl3CipherSuite));
103 if (rv != SECSuccess) {
104 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
105 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
106 return rv; /* err set by ssl3_AppendHandshake* */
108 actual_count++;
109 @@ -5379,7 +5379,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
110 if (config_match(suite, ss->ssl3.policy, PR_TRUE, &ss->vrange)) {
111 actual_count++;
112 if (actual_count > num_suites) {
113 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
114 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
115 /* set error card removal/insertion error */
116 PORT_SetError(SSL_ERROR_TOKEN_INSERTION_REMOVAL);
117 return SECFailure;
118 @@ -5387,7 +5387,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
119 rv = ssl3_AppendHandshakeNumber(ss, suite->cipher_suite,
120 sizeof(ssl3CipherSuite));
121 if (rv != SECSuccess) {
122 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
123 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
124 return rv; /* err set by ssl3_AppendHandshake* */
127 @@ -5398,14 +5398,14 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
128 * the server.. */
129 if (actual_count != num_suites) {
130 /* Card removal/insertion error */
131 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
132 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
133 PORT_SetError(SSL_ERROR_TOKEN_INSERTION_REMOVAL);
134 return SECFailure;
137 rv = ssl3_AppendHandshakeNumber(ss, numCompressionMethods, 1);
138 if (rv != SECSuccess) {
139 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
140 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
141 return rv; /* err set by ssl3_AppendHandshake* */
143 for (i = 0; i < compressionMethodsCount; i++) {
144 @@ -5413,7 +5413,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
145 continue;
146 rv = ssl3_AppendHandshakeNumber(ss, compressions[i], 1);
147 if (rv != SECSuccess) {
148 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
149 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
150 return rv; /* err set by ssl3_AppendHandshake* */
153 @@ -5424,20 +5424,20 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
155 rv = ssl3_AppendHandshakeNumber(ss, maxBytes, 2);
156 if (rv != SECSuccess) {
157 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
158 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
159 return rv; /* err set by AppendHandshake. */
162 extLen = ssl3_CallHelloExtensionSenders(ss, PR_TRUE, maxBytes, NULL);
163 if (extLen < 0) {
164 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
165 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
166 return SECFailure;
168 maxBytes -= extLen;
170 extLen = ssl3_AppendPaddingExtension(ss, paddingExtensionLen, maxBytes);
171 if (extLen < 0) {
172 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
173 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
174 return SECFailure;
176 maxBytes -= extLen;
177 @@ -5446,7 +5446,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo
180 if (sid->u.ssl3.lock) {
181 - PR_RWLock_Unlock(sid->u.ssl3.lock);
182 + NSSRWLock_UnlockRead(sid->u.ssl3.lock);
185 if (ss->xtnData.sentSessionTicketInClientHello) {
186 diff -pu a/nss/lib/ssl/sslimpl.h b/nss/lib/ssl/sslimpl.h
187 --- a/nss/lib/ssl/sslimpl.h 2014-01-17 19:00:52.843413560 -0800
188 +++ b/nss/lib/ssl/sslimpl.h 2014-01-17 19:02:38.965159506 -0800
189 @@ -730,7 +730,7 @@ struct sslSessionIDStr {
190 * cached. Before then, there is no need to lock anything because
191 * the sid isn't being shared by anything.
193 - PRRWLock *lock;
194 + NSSRWLock *lock;
196 /* The lock must be held while reading or writing these members
197 * because they change while the sid is cached.
198 diff -pu a/nss/lib/ssl/sslnonce.c b/nss/lib/ssl/sslnonce.c
199 --- a/nss/lib/ssl/sslnonce.c 2014-01-17 19:02:25.844943628 -0800
200 +++ b/nss/lib/ssl/sslnonce.c 2014-01-17 19:02:38.965159506 -0800
201 @@ -136,7 +136,7 @@ ssl_DestroySID(sslSessionID *sid)
204 if (sid->u.ssl3.lock) {
205 - PR_DestroyRWLock(sid->u.ssl3.lock);
206 + NSSRWLock_Destroy(sid->u.ssl3.lock);
210 @@ -308,7 +308,7 @@ CacheSID(sslSessionID *sid)
211 PRINT_BUF(8, (0, "sessionID:",
212 sid->u.ssl3.sessionID, sid->u.ssl3.sessionIDLength));
214 - sid->u.ssl3.lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, NULL);
215 + sid->u.ssl3.lock = NSSRWLock_New(NSS_RWLOCK_RANK_NONE, NULL);
216 if (!sid->u.ssl3.lock) {
217 return;
219 @@ -448,7 +448,7 @@ ssl3_SetSIDSessionTicket(sslSessionID *s
220 * yet, so no locking is needed.
222 if (sid->u.ssl3.lock) {
223 - PR_RWLock_Wlock(sid->u.ssl3.lock);
224 + NSSRWLock_LockWrite(sid->u.ssl3.lock);
226 /* A server might have sent us an empty ticket, which has the
227 * effect of clearing the previously known ticket.
228 @@ -467,6 +467,6 @@ ssl3_SetSIDSessionTicket(sslSessionID *s
229 newSessionTicket->ticket.len = 0;
231 if (sid->u.ssl3.lock) {
232 - PR_RWLock_Unlock(sid->u.ssl3.lock);
233 + NSSRWLock_UnlockWrite(sid->u.ssl3.lock);