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); 10 } 11 12 if (isTLS || (ss->firstHsDone && ss->peerRequestedProtection)) { 13 @@ -5220,7 +5220,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo 14 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; 20 } 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. */ 29 } 30 31 @@ -5293,7 +5293,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo 32 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* */ 38 } 39 40 @@ -5312,21 +5312,21 @@ ssl3_SendClientHello(sslSocket *ss, PRBo 41 rv = ssl3_AppendHandshakeNumber(ss, ss->clientHelloVersion, 2); 42 } 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* */ 47 } 48 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. */ 55 } 56 } 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* */ 63 } 64 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* */ 72 } 73 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* */ 81 } 82 } 83 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* */ 89 } 90 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* */ 98 } 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* */ 107 } 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* */ 125 } 126 } 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; 135 } 136 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* */ 142 } 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* */ 151 } 152 } 153 @@ -5424,20 +5424,20 @@ ssl3_SendClientHello(sslSocket *ss, PRBo 154 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. */ 160 } 161 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; 167 } 168 maxBytes -= extLen; 169 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; 175 } 176 maxBytes -= extLen; 177 @@ -5446,7 +5446,7 @@ ssl3_SendClientHello(sslSocket *ss, PRBo 178 } 179 180 if (sid->u.ssl3.lock) { 181 - PR_RWLock_Unlock(sid->u.ssl3.lock); 182 + NSSRWLock_UnlockRead(sid->u.ssl3.lock); 183 } 184 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. 192 */ 193 - PRRWLock *lock; 194 + NSSRWLock *lock; 195 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) 202 } 203 204 if (sid->u.ssl3.lock) { 205 - PR_DestroyRWLock(sid->u.ssl3.lock); 206 + NSSRWLock_Destroy(sid->u.ssl3.lock); 207 } 208 } 209 210 @@ -308,7 +308,7 @@ CacheSID(sslSessionID *sid) 211 PRINT_BUF(8, (0, "sessionID:", 212 sid->u.ssl3.sessionID, sid->u.ssl3.sessionIDLength)); 213 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; 218 } 219 @@ -448,7 +448,7 @@ ssl3_SetSIDSessionTicket(sslSessionID *s 220 * yet, so no locking is needed. 221 */ 222 if (sid->u.ssl3.lock) { 223 - PR_RWLock_Wlock(sid->u.ssl3.lock); 224 + NSSRWLock_LockWrite(sid->u.ssl3.lock); 225 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; 230 231 if (sid->u.ssl3.lock) { 232 - PR_RWLock_Unlock(sid->u.ssl3.lock); 233 + NSSRWLock_UnlockWrite(sid->u.ssl3.lock); 234 } 235 } 236