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

Side by Side Diff: net/socket/ssl_client_socket_nss.cc

Issue 7399025: Fix instability in SSL client/server sockets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/socket/ssl_server_socket_nss.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 return rv; 1289 return rv;
1290 } 1290 }
1291 1291
1292 bool network_moved; 1292 bool network_moved;
1293 int rv; 1293 int rv;
1294 do { 1294 do {
1295 rv = DoPayloadRead(); 1295 rv = DoPayloadRead();
1296 network_moved = DoTransportIO(); 1296 network_moved = DoTransportIO();
1297 } while (rv == ERR_IO_PENDING && network_moved); 1297 } while (rv == ERR_IO_PENDING && network_moved);
1298 1298
1299 do {
1300 network_moved = DoTransportIO();
1301 } while (network_moved);
1302
1299 LeaveFunction(""); 1303 LeaveFunction("");
1300 return rv; 1304 return rv;
1301 } 1305 }
1302 1306
1303 int SSLClientSocketNSS::DoWriteLoop(int result) { 1307 int SSLClientSocketNSS::DoWriteLoop(int result) {
1304 EnterFunction(""); 1308 EnterFunction("");
1305 DCHECK(completed_handshake_); 1309 DCHECK(completed_handshake_);
1306 DCHECK(next_handshake_state_ == STATE_NONE); 1310 DCHECK(next_handshake_state_ == STATE_NONE);
1307 1311
1308 if (result < 0) 1312 if (result < 0)
1309 return result; 1313 return result;
1310 1314
1311 if (!nss_bufs_) { 1315 if (!nss_bufs_) {
1312 LOG(DFATAL) << "!nss_bufs_"; 1316 LOG(DFATAL) << "!nss_bufs_";
1313 int rv = ERR_UNEXPECTED; 1317 int rv = ERR_UNEXPECTED;
1314 net_log_.AddEvent(NetLog::TYPE_SSL_WRITE_ERROR, 1318 net_log_.AddEvent(NetLog::TYPE_SSL_WRITE_ERROR,
1315 make_scoped_refptr(new SSLErrorParams(rv, 0))); 1319 make_scoped_refptr(new SSLErrorParams(rv, 0)));
1316 return rv; 1320 return rv;
1317 } 1321 }
1318 1322
1319 bool network_moved; 1323 bool network_moved;
1320 int rv; 1324 int rv;
1321 do { 1325 do {
1322 rv = DoPayloadWrite(); 1326 rv = DoPayloadWrite();
1323 network_moved = DoTransportIO(); 1327 network_moved = DoTransportIO();
1324 } while (rv == ERR_IO_PENDING && network_moved); 1328 } while (rv == ERR_IO_PENDING && network_moved);
1325 1329
1330 do {
1331 network_moved = DoTransportIO();
1332 } while (network_moved);
1333
1326 LeaveFunction(""); 1334 LeaveFunction("");
1327 return rv; 1335 return rv;
1328 } 1336 }
1329 1337
1330 bool SSLClientSocketNSS::LoadSSLHostInfo() { 1338 bool SSLClientSocketNSS::LoadSSLHostInfo() {
1331 const SSLHostInfo::State& state(ssl_host_info_->state()); 1339 const SSLHostInfo::State& state(ssl_host_info_->state());
1332 1340
1333 if (state.certs.empty()) 1341 if (state.certs.empty())
1334 return false; 1342 return false;
1335 1343
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 } 1743 }
1736 1744
1737 // Do network I/O between the given buffer and the given socket. 1745 // 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) 1746 // Return true if some I/O performed, false otherwise (error or ERR_IO_PENDING)
1739 bool SSLClientSocketNSS::DoTransportIO() { 1747 bool SSLClientSocketNSS::DoTransportIO() {
1740 EnterFunction(""); 1748 EnterFunction("");
1741 bool network_moved = false; 1749 bool network_moved = false;
1742 if (nss_bufs_ != NULL) { 1750 if (nss_bufs_ != NULL) {
1743 int nsent = BufferSend(); 1751 int nsent = BufferSend();
1744 int nreceived = BufferRecv(); 1752 int nreceived = BufferRecv();
1745 network_moved = (nsent > 0 || nreceived >= 0); 1753 network_moved = (nsent > 0 || nreceived > 0);
Sergey Ulanov 2011/07/18 17:58:36 I'm not sure why why we were returning true for nr
1746 } 1754 }
1747 LeaveFunction(network_moved); 1755 LeaveFunction(network_moved);
1748 return network_moved; 1756 return network_moved;
1749 } 1757 }
1750 1758
1751 // Return 0 for EOF, 1759 // Return 0 for EOF,
1752 // > 0 for bytes transferred immediately, 1760 // > 0 for bytes transferred immediately,
1753 // < 0 for error (or the non-error ERR_IO_PENDING). 1761 // < 0 for error (or the non-error ERR_IO_PENDING).
1754 int SSLClientSocketNSS::BufferSend(void) { 1762 int SSLClientSocketNSS::BufferSend(void) {
1755 if (transport_send_busy_) 1763 if (transport_send_busy_)
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 valid_thread_id_ = base::PlatformThread::CurrentId(); 2277 valid_thread_id_ = base::PlatformThread::CurrentId();
2270 } 2278 }
2271 2279
2272 bool SSLClientSocketNSS::CalledOnValidThread() const { 2280 bool SSLClientSocketNSS::CalledOnValidThread() const {
2273 EnsureThreadIdAssigned(); 2281 EnsureThreadIdAssigned();
2274 base::AutoLock auto_lock(lock_); 2282 base::AutoLock auto_lock(lock_);
2275 return valid_thread_id_ == base::PlatformThread::CurrentId(); 2283 return valid_thread_id_ == base::PlatformThread::CurrentId();
2276 } 2284 }
2277 2285
2278 } // namespace net 2286 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/socket/ssl_server_socket_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698