diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-24 21:35:28 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-24 21:35:28 +0000 |
commit | a19f1c60e05e289ea46958c10d71b5a8a72ccb80 (patch) | |
tree | a882eb472466f672e79dc72327dc2ca600f7b9eb | |
parent | 506f2af1d451493f79ec15d73c7893fd5ed5082a (diff) | |
download | chromium_src-a19f1c60e05e289ea46958c10d71b5a8a72ccb80.zip chromium_src-a19f1c60e05e289ea46958c10d71b5a8a72ccb80.tar.gz chromium_src-a19f1c60e05e289ea46958c10d71b5a8a72ccb80.tar.bz2 |
Only retry on unused, idle sockets if the socket error is ERR_CONNECTION_RESET.
In particular, don't do it on ERR_CONNECTION_ABORT or ERR_CONNECTION_CLOSED.
Fix spelling error in ClientSocketHandle comment.
Review URL: http://codereview.chromium.org/173278
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24152 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/http/http_network_transaction.cc | 9 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 4 | ||||
-rw-r--r-- | net/socket/client_socket_handle.h | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 7098d6b..fd59c5f 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -884,7 +884,7 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) { if (result < 0) return HandleIOError(result); - if (result == 0 && ShouldResendRequest()) { + if (result == 0 && ShouldResendRequest(result)) { ResetConnectionAndRequestForResend(); return result; } @@ -1562,7 +1562,7 @@ int HttpNetworkTransaction::HandleIOError(int error) { case ERR_CONNECTION_CLOSED: case ERR_CONNECTION_ABORTED: LogIOErrorMetrics(connection_); - if (ShouldResendRequest()) { + if (ShouldResendRequest(error)) { ResetConnectionAndRequestForResend(); error = OK; } @@ -1589,13 +1589,16 @@ void HttpNetworkTransaction::ResetStateForRestart() { response_ = HttpResponseInfo(); } -bool HttpNetworkTransaction::ShouldResendRequest() const { +bool HttpNetworkTransaction::ShouldResendRequest(int error) const { // NOTE: we resend a request only if we reused a keep-alive connection. // This automatically prevents an infinite resend loop because we'll run // out of the cached keep-alive connections eventually. if (establishing_tunnel_ || // We used a socket that was never idle. connection_.reuse_type() == ClientSocketHandle::UNUSED || + // We used an unused, idle socket and got a error that wasn't a TCP RST. + (connection_.reuse_type() == ClientSocketHandle::UNUSED_IDLE && + (error != OK && error != ERR_CONNECTION_RESET)) || header_buf_len_) { // We have received some response headers. return false; } diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index b201aa1..86946f4 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -192,8 +192,8 @@ class HttpNetworkTransaction : public HttpTransaction { int HandleIOError(int error); // Called when we reached EOF or got an error. Returns true if we should - // resend the request. - bool ShouldResendRequest() const; + // resend the request. |error| is OK when we reached EOF. + bool ShouldResendRequest(int error) const; // Resets the connection and the request headers for resend. Called when // ShouldResendRequest() is true. diff --git a/net/socket/client_socket_handle.h b/net/socket/client_socket_handle.h index d323313..83aa70f 100644 --- a/net/socket/client_socket_handle.h +++ b/net/socket/client_socket_handle.h @@ -28,7 +28,7 @@ namespace net { class ClientSocketHandle { public: typedef enum { - UNUSED = 0, // unused socket that just finished connectin + UNUSED = 0, // unused socket that just finished connecting UNUSED_IDLE, // unused socket that has been idle for awhile REUSED_IDLE, // previously used socket NUM_TYPES, |