summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-24 21:35:28 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-24 21:35:28 +0000
commita19f1c60e05e289ea46958c10d71b5a8a72ccb80 (patch)
treea882eb472466f672e79dc72327dc2ca600f7b9eb /net/http
parent506f2af1d451493f79ec15d73c7893fd5ed5082a (diff)
downloadchromium_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
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_network_transaction.cc9
-rw-r--r--net/http/http_network_transaction.h4
2 files changed, 8 insertions, 5 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.