summaryrefslogtreecommitdiffstats
path: root/net/socket/tcp_client_socket_pool.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 23:14:34 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 23:14:34 +0000
commit974ebd6a315608d44b0e2ad4ce2bf6f38b8c63d0 (patch)
tree427fb567b95c5e5200a7e5ef99d127a0cd868d41 /net/socket/tcp_client_socket_pool.cc
parentb04bcffa7d1713d4a28f1c6a8b422899b6f833a1 (diff)
downloadchromium_src-974ebd6a315608d44b0e2ad4ce2bf6f38b8c63d0.zip
chromium_src-974ebd6a315608d44b0e2ad4ce2bf6f38b8c63d0.tar.gz
chromium_src-974ebd6a315608d44b0e2ad4ce2bf6f38b8c63d0.tar.bz2
Add timeouts for ConnectJobs. Limit ConnectJobs per group to number of Requests per group + 1.
In the histograms for Net.SocketRequestTime, late binding has a much longer tail. This is presumably because I didn't implement timeouts and CancelRequest() never cancelled jobs. I'm limiting TCPConnectJobs to 60 seconds and cancelling jobs if there are too many more than there are requests. Review URL: http://codereview.chromium.org/160499 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_pool.cc')
-rw-r--r--net/socket/tcp_client_socket_pool.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index decc23f1..197ccdb 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -18,14 +18,19 @@ using base::TimeDelta;
namespace net {
+// TCPConnectJobs will time out after this many seconds. Note this is the total
+// time, including both host resolution and TCP connect() times.
+static const int kTCPConnectJobTimeoutInSeconds = 60;
+
TCPConnectJob::TCPConnectJob(
const std::string& group_name,
const HostResolver::RequestInfo& resolve_info,
const ClientSocketHandle* handle,
+ base::TimeDelta timeout_duration,
ClientSocketFactory* client_socket_factory,
HostResolver* host_resolver,
Delegate* delegate)
- : ConnectJob(group_name, handle, delegate),
+ : ConnectJob(group_name, handle, timeout_duration, delegate),
resolve_info_(resolve_info),
client_socket_factory_(client_socket_factory),
ALLOW_THIS_IN_INITIALIZER_LIST(
@@ -38,7 +43,7 @@ TCPConnectJob::~TCPConnectJob() {
// ~SingleRequestHostResolver and ~ClientSocket will take care of it.
}
-int TCPConnectJob::Connect() {
+int TCPConnectJob::ConnectInternal() {
next_state_ = kStateResolveHost;
return DoLoop(OK);
}
@@ -128,6 +133,7 @@ ConnectJob* TCPClientSocketPool::TCPConnectJobFactory::NewConnectJob(
ConnectJob::Delegate* delegate) const {
return new TCPConnectJob(
group_name, request.resolve_info, request.handle,
+ base::TimeDelta::FromSeconds(kTCPConnectJobTimeoutInSeconds),
client_socket_factory_, host_resolver_, delegate);
}