1 diff --git a/ssl/ssl3con.c b/ssl/ssl3con.c
2 index 0ac85da..f5afab7 100644
5 @@ -5261,7 +5261,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
6 * the lock across the calls to ssl3_CallHelloExtensionSenders.
8 if (sid->u.ssl3.lock) {
9 - PR_RWLock_Rlock(sid->u.ssl3.lock);
10 + NSSRWLock_LockRead(sid->u.ssl3.lock);
13 if (isTLS || (ss->firstHsDone && ss->peerRequestedProtection)) {
14 @@ -5270,7 +5270,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
16 extLen = ssl3_CallHelloExtensionSenders(ss, PR_FALSE, maxBytes, NULL);
18 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
19 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
22 total_exten_len += extLen;
23 @@ -5297,7 +5297,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
24 /* how many suites are permitted by policy and user preference? */
25 num_suites = count_cipher_suites(ss, ss->ssl3.policy, PR_TRUE);
27 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
28 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
29 return SECFailure; /* count_cipher_suites has set error code. */
32 @@ -5342,7 +5342,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
34 rv = ssl3_AppendHandshakeHeader(ss, client_hello, length);
35 if (rv != SECSuccess) {
36 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
37 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
38 return rv; /* err set by ssl3_AppendHandshake* */
41 @@ -5361,21 +5361,21 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
42 rv = ssl3_AppendHandshakeNumber(ss, ss->clientHelloVersion, 2);
44 if (rv != SECSuccess) {
45 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
46 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
47 return rv; /* err set by ssl3_AppendHandshake* */
50 if (!resending) { /* Don't re-generate if we are in DTLS re-sending mode */
51 rv = ssl3_GetNewRandom(&ss->ssl3.hs.client_random);
52 if (rv != SECSuccess) {
53 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
54 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
55 return rv; /* err set by GetNewRandom. */
58 rv = ssl3_AppendHandshake(ss, &ss->ssl3.hs.client_random,
60 if (rv != SECSuccess) {
61 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
62 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
63 return rv; /* err set by ssl3_AppendHandshake* */
66 @@ -5385,7 +5385,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
68 rv = ssl3_AppendHandshakeNumber(ss, 0, 1);
69 if (rv != SECSuccess) {
70 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
71 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
72 return rv; /* err set by ssl3_AppendHandshake* */
75 @@ -5393,14 +5393,14 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
76 rv = ssl3_AppendHandshakeVariable(
77 ss, ss->ssl3.hs.cookie, ss->ssl3.hs.cookieLen, 1);
78 if (rv != SECSuccess) {
79 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
80 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
81 return rv; /* err set by ssl3_AppendHandshake* */
85 rv = ssl3_AppendHandshakeNumber(ss, num_suites*sizeof(ssl3CipherSuite), 2);
86 if (rv != SECSuccess) {
87 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
88 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
89 return rv; /* err set by ssl3_AppendHandshake* */
92 @@ -5409,7 +5409,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
93 rv = ssl3_AppendHandshakeNumber(ss, TLS_EMPTY_RENEGOTIATION_INFO_SCSV,
94 sizeof(ssl3CipherSuite));
95 if (rv != SECSuccess) {
96 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
97 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
98 return rv; /* err set by ssl3_AppendHandshake* */
101 @@ -5418,7 +5418,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
102 rv = ssl3_AppendHandshakeNumber(ss, TLS_FALLBACK_SCSV,
103 sizeof(ssl3CipherSuite));
104 if (rv != SECSuccess) {
105 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
106 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
107 return rv; /* err set by ssl3_AppendHandshake* */
110 @@ -5428,7 +5428,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
111 if (config_match(suite, ss->ssl3.policy, PR_TRUE, &ss->vrange)) {
113 if (actual_count > num_suites) {
114 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
115 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
116 /* set error card removal/insertion error */
117 PORT_SetError(SSL_ERROR_TOKEN_INSERTION_REMOVAL);
119 @@ -5436,7 +5436,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
120 rv = ssl3_AppendHandshakeNumber(ss, suite->cipher_suite,
121 sizeof(ssl3CipherSuite));
122 if (rv != SECSuccess) {
123 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
124 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
125 return rv; /* err set by ssl3_AppendHandshake* */
128 @@ -5447,14 +5447,14 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
130 if (actual_count != num_suites) {
131 /* Card removal/insertion error */
132 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
133 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
134 PORT_SetError(SSL_ERROR_TOKEN_INSERTION_REMOVAL);
138 rv = ssl3_AppendHandshakeNumber(ss, numCompressionMethods, 1);
139 if (rv != SECSuccess) {
140 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
141 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
142 return rv; /* err set by ssl3_AppendHandshake* */
144 for (i = 0; i < compressionMethodsCount; i++) {
145 @@ -5462,7 +5462,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
147 rv = ssl3_AppendHandshakeNumber(ss, compressions[i], 1);
148 if (rv != SECSuccess) {
149 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
150 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
151 return rv; /* err set by ssl3_AppendHandshake* */
154 @@ -5473,20 +5473,20 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
156 rv = ssl3_AppendHandshakeNumber(ss, maxBytes, 2);
157 if (rv != SECSuccess) {
158 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
159 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
160 return rv; /* err set by AppendHandshake. */
163 extLen = ssl3_CallHelloExtensionSenders(ss, PR_TRUE, maxBytes, NULL);
165 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
166 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
171 extLen = ssl3_AppendPaddingExtension(ss, paddingExtensionLen, maxBytes);
173 - if (sid->u.ssl3.lock) { PR_RWLock_Unlock(sid->u.ssl3.lock); }
174 + if (sid->u.ssl3.lock) { NSSRWLock_UnlockRead(sid->u.ssl3.lock); }
178 @@ -5495,7 +5495,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBool resending)
181 if (sid->u.ssl3.lock) {
182 - PR_RWLock_Unlock(sid->u.ssl3.lock);
183 + NSSRWLock_UnlockRead(sid->u.ssl3.lock);
186 if (ss->xtnData.sentSessionTicketInClientHello) {
187 diff --git a/ssl/sslimpl.h b/ssl/sslimpl.h
188 index d12228e..efcbf9f 100644
191 @@ -731,7 +731,7 @@ struct sslSessionIDStr {
192 * cached. Before then, there is no need to lock anything because
193 * the sid isn't being shared by anything.
198 /* The lock must be held while reading or writing these members
199 * because they change while the sid is cached.
200 diff --git a/ssl/sslnonce.c b/ssl/sslnonce.c
201 index cefdda6..28ad364 100644
204 @@ -136,7 +136,7 @@ ssl_DestroySID(sslSessionID *sid)
207 if (sid->u.ssl3.lock) {
208 - PR_DestroyRWLock(sid->u.ssl3.lock);
209 + NSSRWLock_Destroy(sid->u.ssl3.lock);
213 @@ -308,7 +308,7 @@ CacheSID(sslSessionID *sid)
214 PRINT_BUF(8, (0, "sessionID:",
215 sid->u.ssl3.sessionID, sid->u.ssl3.sessionIDLength));
217 - sid->u.ssl3.lock = PR_NewRWLock(PR_RWLOCK_RANK_NONE, NULL);
218 + sid->u.ssl3.lock = NSSRWLock_New(NSS_RWLOCK_RANK_NONE, NULL);
219 if (!sid->u.ssl3.lock) {
222 @@ -450,7 +450,7 @@ ssl3_SetSIDSessionTicket(sslSessionID *sid,
223 * yet, so no locking is needed.
225 if (sid->u.ssl3.lock) {
226 - PR_RWLock_Wlock(sid->u.ssl3.lock);
227 + NSSRWLock_LockWrite(sid->u.ssl3.lock);
228 if (sid->u.ssl3.locked.sessionTicket.ticket.data) {
229 SECITEM_FreeItem(&sid->u.ssl3.locked.sessionTicket.ticket,
231 @@ -465,6 +465,6 @@ ssl3_SetSIDSessionTicket(sslSessionID *sid,
232 newSessionTicket->ticket.len = 0;
234 if (sid->u.ssl3.lock) {
235 - PR_RWLock_Unlock(sid->u.ssl3.lock);
236 + NSSRWLock_UnlockWrite(sid->u.ssl3.lock);