OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived | 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived |
6 // from AuthCertificateCallback() in | 6 // from AuthCertificateCallback() in |
7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. | 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. |
8 | 8 |
9 /* ***** BEGIN LICENSE BLOCK ***** | 9 /* ***** BEGIN LICENSE BLOCK ***** |
10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1181 LeaveFunction(""); | 1181 LeaveFunction(""); |
1182 return; | 1182 return; |
1183 } | 1183 } |
1184 | 1184 |
1185 // OnSendComplete may need to call DoPayloadRead while the renegotiation | 1185 // OnSendComplete may need to call DoPayloadRead while the renegotiation |
1186 // handshake is in progress. | 1186 // handshake is in progress. |
1187 int rv_read = ERR_IO_PENDING; | 1187 int rv_read = ERR_IO_PENDING; |
1188 int rv_write = ERR_IO_PENDING; | 1188 int rv_write = ERR_IO_PENDING; |
1189 bool network_moved; | 1189 bool network_moved; |
1190 do { | 1190 do { |
1191 if (user_read_buf_) | 1191 if (user_read_buf_ && rv_read == ERR_IO_PENDING) |
1192 rv_read = DoPayloadRead(); | 1192 rv_read = DoPayloadRead(); |
1193 if (user_write_buf_) | 1193 if (user_write_buf_ && rv_write == ERR_IO_PENDING) |
1194 rv_write = DoPayloadWrite(); | 1194 rv_write = DoPayloadWrite(); |
1195 network_moved = DoTransportIO(); | 1195 network_moved = DoTransportIO(); |
1196 } while (rv_read == ERR_IO_PENDING && | 1196 } while (network_moved); |
Wez
2011/07/18 21:53:33
This loop used to exit on error, or if one or othe
Sergey Ulanov
2011/07/19 19:26:56
Actually the code below may crash even when only D
wtc
2011/07/21 00:42:30
Wez, you are right on. I recently noticed this pr
| |
1197 rv_write == ERR_IO_PENDING && | |
1198 network_moved); | |
1199 | 1197 |
1200 if (user_read_buf_ && rv_read != ERR_IO_PENDING) | 1198 if (user_read_buf_ && rv_read != ERR_IO_PENDING) |
1201 DoReadCallback(rv_read); | 1199 DoReadCallback(rv_read); |
1202 if (user_write_buf_ && rv_write != ERR_IO_PENDING) | 1200 if (user_write_buf_ && rv_write != ERR_IO_PENDING) |
1203 DoWriteCallback(rv_write); | 1201 DoWriteCallback(rv_write); |
1204 | 1202 |
1205 LeaveFunction(""); | 1203 LeaveFunction(""); |
1206 } | 1204 } |
1207 | 1205 |
1208 void SSLClientSocketNSS::OnRecvComplete(int result) { | 1206 void SSLClientSocketNSS::OnRecvComplete(int result) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1310 | 1308 |
1311 if (!nss_bufs_) { | 1309 if (!nss_bufs_) { |
1312 LOG(DFATAL) << "!nss_bufs_"; | 1310 LOG(DFATAL) << "!nss_bufs_"; |
1313 int rv = ERR_UNEXPECTED; | 1311 int rv = ERR_UNEXPECTED; |
1314 net_log_.AddEvent(NetLog::TYPE_SSL_WRITE_ERROR, | 1312 net_log_.AddEvent(NetLog::TYPE_SSL_WRITE_ERROR, |
1315 make_scoped_refptr(new SSLErrorParams(rv, 0))); | 1313 make_scoped_refptr(new SSLErrorParams(rv, 0))); |
1316 return rv; | 1314 return rv; |
1317 } | 1315 } |
1318 | 1316 |
1319 bool network_moved; | 1317 bool network_moved; |
1320 int rv; | 1318 int rv = ERR_IO_PENDING; |
1321 do { | 1319 do { |
1322 rv = DoPayloadWrite(); | 1320 if (rv == ERR_IO_PENDING) |
1321 rv = DoPayloadWrite(); | |
1323 network_moved = DoTransportIO(); | 1322 network_moved = DoTransportIO(); |
1324 } while (rv == ERR_IO_PENDING && network_moved); | 1323 } while (network_moved); |
Wez
2011/07/18 21:53:33
This will continue to loop on PR_Write() errors.
Sergey Ulanov
2011/07/19 19:26:56
Why can't we continue pushing data to the transpor
| |
1325 | 1324 |
1326 LeaveFunction(""); | 1325 LeaveFunction(""); |
1327 return rv; | 1326 return rv; |
1328 } | 1327 } |
1329 | 1328 |
1330 bool SSLClientSocketNSS::LoadSSLHostInfo() { | 1329 bool SSLClientSocketNSS::LoadSSLHostInfo() { |
1331 const SSLHostInfo::State& state(ssl_host_info_->state()); | 1330 const SSLHostInfo::State& state(ssl_host_info_->state()); |
1332 | 1331 |
1333 if (state.certs.empty()) | 1332 if (state.certs.empty()) |
1334 return false; | 1333 return false; |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1735 } | 1734 } |
1736 | 1735 |
1737 // Do network I/O between the given buffer and the given socket. | 1736 // Do network I/O between the given buffer and the given socket. |
1738 // Return true if some I/O performed, false otherwise (error or ERR_IO_PENDING) | 1737 // Return true if some I/O performed, false otherwise (error or ERR_IO_PENDING) |
1739 bool SSLClientSocketNSS::DoTransportIO() { | 1738 bool SSLClientSocketNSS::DoTransportIO() { |
1740 EnterFunction(""); | 1739 EnterFunction(""); |
1741 bool network_moved = false; | 1740 bool network_moved = false; |
1742 if (nss_bufs_ != NULL) { | 1741 if (nss_bufs_ != NULL) { |
1743 int nsent = BufferSend(); | 1742 int nsent = BufferSend(); |
1744 int nreceived = BufferRecv(); | 1743 int nreceived = BufferRecv(); |
1745 network_moved = (nsent > 0 || nreceived >= 0); | 1744 network_moved = (nsent > 0 || nreceived > 0); |
Wez
2011/07/18 21:53:33
A zero return value from the underlying net::Socke
Sergey Ulanov
2011/07/19 19:26:56
The previous behavior may be counter-intuitive dep
| |
1746 } | 1745 } |
1747 LeaveFunction(network_moved); | 1746 LeaveFunction(network_moved); |
1748 return network_moved; | 1747 return network_moved; |
1749 } | 1748 } |
1750 | 1749 |
1751 // Return 0 for EOF, | 1750 // Return 0 for EOF, |
1752 // > 0 for bytes transferred immediately, | 1751 // > 0 for bytes transferred immediately, |
1753 // < 0 for error (or the non-error ERR_IO_PENDING). | 1752 // < 0 for error (or the non-error ERR_IO_PENDING). |
1754 int SSLClientSocketNSS::BufferSend(void) { | 1753 int SSLClientSocketNSS::BufferSend(void) { |
1755 if (transport_send_busy_) | 1754 if (transport_send_busy_) |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2269 valid_thread_id_ = base::PlatformThread::CurrentId(); | 2268 valid_thread_id_ = base::PlatformThread::CurrentId(); |
2270 } | 2269 } |
2271 | 2270 |
2272 bool SSLClientSocketNSS::CalledOnValidThread() const { | 2271 bool SSLClientSocketNSS::CalledOnValidThread() const { |
2273 EnsureThreadIdAssigned(); | 2272 EnsureThreadIdAssigned(); |
2274 base::AutoLock auto_lock(lock_); | 2273 base::AutoLock auto_lock(lock_); |
2275 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 2274 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
2276 } | 2275 } |
2277 | 2276 |
2278 } // namespace net | 2277 } // namespace net |
OLD | NEW |