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

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

Issue 2736103002: Only pump SSL_read extra times when there is data available synchronously. (Closed)
Patch Set: svaldez comments, SSLClientSocketReadTest Created 3 years, 9 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
« no previous file with comments | « no previous file | net/socket/ssl_client_socket_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/socket/ssl_client_socket_impl.h" 5 #include "net/socket/ssl_client_socket_impl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 return rv; 1393 return rv;
1394 } 1394 }
1395 1395
1396 int total_bytes_read = 0; 1396 int total_bytes_read = 0;
1397 int ssl_ret; 1397 int ssl_ret;
1398 do { 1398 do {
1399 ssl_ret = SSL_read(ssl_.get(), buf->data() + total_bytes_read, 1399 ssl_ret = SSL_read(ssl_.get(), buf->data() + total_bytes_read,
1400 buf_len - total_bytes_read); 1400 buf_len - total_bytes_read);
1401 if (ssl_ret > 0) 1401 if (ssl_ret > 0)
1402 total_bytes_read += ssl_ret; 1402 total_bytes_read += ssl_ret;
1403 } while (total_bytes_read < buf_len && ssl_ret > 0); 1403 // Continue processing records as long as there is more data available
1404 // synchronously.
1405 } while (total_bytes_read < buf_len && ssl_ret > 0 &&
1406 transport_adapter_->HasPendingReadData());
1404 1407
1405 // Although only the final SSL_read call may have failed, the failure needs to 1408 // Although only the final SSL_read call may have failed, the failure needs to
1406 // processed immediately, while the information still available in OpenSSL's 1409 // processed immediately, while the information still available in OpenSSL's
1407 // error queue. 1410 // error queue.
1408 if (ssl_ret <= 0) { 1411 if (ssl_ret <= 0) {
1409 // A zero return from SSL_read may mean any of: 1412 // A zero return from SSL_read may mean any of:
1410 // - The underlying BIO_read returned 0. 1413 // - The underlying BIO_read returned 0.
1411 // - The peer sent a close_notify. 1414 // - The peer sent a close_notify.
1412 // - Any arbitrary error. https://crbug.com/466303 1415 // - Any arbitrary error. https://crbug.com/466303
1413 // 1416 //
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && 1991 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED &&
1989 !certificate_requested_) { 1992 !certificate_requested_) {
1990 net_error = ERR_SSL_PROTOCOL_ERROR; 1993 net_error = ERR_SSL_PROTOCOL_ERROR;
1991 } 1994 }
1992 } 1995 }
1993 1996
1994 return net_error; 1997 return net_error;
1995 } 1998 }
1996 1999
1997 } // namespace net 2000 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698