diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-22 14:02:03 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-22 14:02:03 +0000 |
commit | 49ba272340e45d1532361ac1c71cc74716ffda93 (patch) | |
tree | 661c9332c0daae1eefe89320afcf91d4780dfbdd /net | |
parent | 5f2960aa0da5a47e3ffe8701615212bba1e07b81 (diff) | |
download | chromium_src-49ba272340e45d1532361ac1c71cc74716ffda93.zip chromium_src-49ba272340e45d1532361ac1c71cc74716ffda93.tar.gz chromium_src-49ba272340e45d1532361ac1c71cc74716ffda93.tar.bz2 |
Throttle writes rather than just taking it all at once. Fixes crashing as well as slowness.
BUG=http://crbug.com/41775 ; http://crbug.com/42232
TEST=none
Review URL: http://codereview.chromium.org/1756004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/socket/ssl_client_socket_mac.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/net/socket/ssl_client_socket_mac.cc b/net/socket/ssl_client_socket_mac.cc index 134e6b6..9a51395 100644 --- a/net/socket/ssl_client_socket_mac.cc +++ b/net/socket/ssl_client_socket_mac.cc @@ -98,6 +98,10 @@ namespace net { namespace { +// Pause if we have 2MB of data in flight, resume once we're down below 1MB. +const unsigned int kWriteSizePauseLimit = 2 * 1024 * 1024; +const unsigned int kWriteSizeResumeLimit = 1 * 1024 * 1024; + // You can change this to LOG(WARNING) during development. #define SSL_LOG LOG(INFO) << "SSL: " @@ -910,8 +914,13 @@ void SSLClientSocketMac::OnTransportWriteComplete(int result) { if (!send_buffer_.empty()) SSLWriteCallback(this, NULL, NULL); - // Since SSLWriteCallback() lies to return noErr even if transport_->Write() - // returns ERR_IO_PENDING, we don't need to call any callbacks here. + // If paused because too much data is in flight, try writing again and make + // the promised callback. + if (user_write_buf_ && send_buffer_.size() < kWriteSizeResumeLimit) { + int rv = DoPayloadWrite(); + if (rv != ERR_IO_PENDING) + DoWriteCallback(rv); + } } // This is the main loop driving the state machine. Most calls coming from the @@ -1174,6 +1183,10 @@ int SSLClientSocketMac::DoPayloadRead() { } int SSLClientSocketMac::DoPayloadWrite() { + // Too much data in flight? + if (send_buffer_.size() > kWriteSizePauseLimit) + return ERR_IO_PENDING; + size_t processed = 0; OSStatus status = SSLWrite(ssl_context_, user_write_buf_->data(), |