summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-29 01:04:06 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-29 01:04:06 +0000
commit2d731a343fb695b7bf2c83ac7ddc0d1154a42586 (patch)
tree9beadc55993765f8973cfd40cb6c3aaf61de7047 /net/socket
parentb861e4eb19ba6d189e40fe4fb5f3c9d9b461a5f4 (diff)
downloadchromium_src-2d731a343fb695b7bf2c83ac7ddc0d1154a42586.zip
chromium_src-2d731a343fb695b7bf2c83ac7ddc0d1154a42586.tar.gz
chromium_src-2d731a343fb695b7bf2c83ac7ddc0d1154a42586.tar.bz2
Implement a 15 connection per proxy server limit.
Previously, we had a limit of 6 connections per proxy server, which was horrifically low. Connections to all endpoint hosts remains at 6. Basically, we have a map of socket pools, keyed by the proxy server. Each of these proxy socket pools has a socket limit of 15 and a connection limit per host of 6. The main TCP socket pool (non-proxied) has the standard 256 socket limit, and connection limit per host of 6. There are two maps currently, one for HTTP proxies and one for SOCKS proxies. Note that SSL tunnels over HTTP CONNECTs are still located within the standard http proxy socket pools. We depend on the fact that our code never returns a non-SSL connected socket to the pool for a |connection_group| that is to a HTTPS endpoint. A newly connected socket from the pool will only have the TCP connection done. An idle socket will have both the TCP and the HTTP CONNECT and the SSL handshake done for it. TODO(willchan): Remove the extra constructor overload for the old deprecated parameters. Switch to using HostPortPair everywhere. TODO(willchan): Finish SSL socket pools. TODO(willchan): Rip out the DoInitConnection() code so it can be shared by other caller (TCP pre-warming!). TODO(willchan): Flush out the socket pool maps when the proxy configuration changes. TODO(willchan): Fix up global socket limits. They're slightly broken in this case, since each pool instance has its own "global" limit, so obviously different pools don't share the same "global" limit. This is such a minor deal since the global limits are so small for proxy servers compared to the system global limits (256 vs 15), that it doesn't have a big effect. TODO(willchan): Drink moar b33r. BUG=12066 Review URL: http://codereview.chromium.org/1808001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45896 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/socks_client_socket_pool.h5
-rw-r--r--net/socket/socks_client_socket_pool_unittest.cc13
-rw-r--r--net/socket/tcp_client_socket_pool.h19
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc5
4 files changed, 30 insertions, 12 deletions
diff --git a/net/socket/socks_client_socket_pool.h b/net/socket/socks_client_socket_pool.h
index 2c30600..a786dc1 100644
--- a/net/socket/socks_client_socket_pool.h
+++ b/net/socket/socks_client_socket_pool.h
@@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
+#include "net/base/host_port_pair.h"
#include "net/base/host_resolver.h"
#include "net/proxy/proxy_server.h"
#include "net/socket/client_socket_pool_base.h"
@@ -25,10 +26,10 @@ class ConnectJobFactory;
class SOCKSSocketParams {
public:
SOCKSSocketParams(const TCPSocketParams& proxy_server, bool socks_v5,
- const std::string& destination_host, int destination_port,
+ const HostPortPair& host_port_pair,
RequestPriority priority, const GURL& referrer)
: tcp_params_(proxy_server),
- destination_(destination_host, destination_port),
+ destination_(host_port_pair.host, host_port_pair.port),
socks_v5_(socks_v5) {
// The referrer is used by the DNS prefetch system to correlate resolutions
// with the page that triggered them. It doesn't impact the actual addresses
diff --git a/net/socket/socks_client_socket_pool_unittest.cc b/net/socket/socks_client_socket_pool_unittest.cc
index 577a39b..89530f6 100644
--- a/net/socket/socks_client_socket_pool_unittest.cc
+++ b/net/socket/socks_client_socket_pool_unittest.cc
@@ -168,14 +168,17 @@ class SOCKSClientSocketPoolTest : public ClientSocketPoolTest {
};
SOCKSClientSocketPoolTest()
- : ignored_tcp_socket_params_("proxy", 80, MEDIUM, GURL(), false),
+ : ignored_tcp_socket_params_(
+ HostPortPair("proxy", 80), MEDIUM, GURL(), false),
tcp_socket_pool_(new MockTCPClientSocketPool(
kMaxSockets, kMaxSocketsPerGroup, "MockTCP",
&tcp_client_socket_factory_, &tcp_notifier_)),
- ignored_socket_params_(ignored_tcp_socket_params_, true, "host", 80,
- MEDIUM, GURL()),
- pool_(new SOCKSClientSocketPool(kMaxSockets, kMaxSocketsPerGroup,
- "SOCKSUnitTest", NULL, tcp_socket_pool_.get(), &socks_notifier_)) {
+ ignored_socket_params_(ignored_tcp_socket_params_, true,
+ HostPortPair("host", 80),
+ MEDIUM, GURL()),
+ pool_(new SOCKSClientSocketPool(
+ kMaxSockets, kMaxSocketsPerGroup, "SOCKSUnitTest", NULL,
+ tcp_socket_pool_.get(), &socks_notifier_)) {
}
int StartRequest(const std::string& group_name, RequestPriority priority) {
diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/tcp_client_socket_pool.h
index 76950c3..30158f6 100644
--- a/net/socket/tcp_client_socket_pool.h
+++ b/net/socket/tcp_client_socket_pool.h
@@ -12,6 +12,7 @@
#include "base/scoped_ptr.h"
#include "base/time.h"
#include "base/timer.h"
+#include "net/base/host_port_pair.h"
#include "net/base/host_resolver.h"
#include "net/socket/client_socket_pool_base.h"
#include "net/socket/client_socket_pool.h"
@@ -22,9 +23,24 @@ class ClientSocketFactory;
class TCPSocketParams {
public:
+ TCPSocketParams(const HostPortPair& host_port_pair, RequestPriority priority,
+ const GURL& referrer, bool disable_resolver_cache)
+ : destination_(host_port_pair.host, host_port_pair.port) {
+ Initialize(priority, referrer, disable_resolver_cache);
+ }
+
+ // TODO(willchan): Update all unittests so we don't need this.
TCPSocketParams(const std::string& host, int port, RequestPriority priority,
const GURL& referrer, bool disable_resolver_cache)
: destination_(host, port) {
+ Initialize(priority, referrer, disable_resolver_cache);
+ }
+
+ HostResolver::RequestInfo destination() const { return destination_; }
+
+ private:
+ void Initialize(RequestPriority priority, const GURL& referrer,
+ bool disable_resolver_cache) {
// The referrer is used by the DNS prefetch system to correlate resolutions
// with the page that triggered them. It doesn't impact the actual addresses
// that we resolve to.
@@ -34,9 +50,6 @@ class TCPSocketParams {
destination_.set_allow_cached_response(false);
}
- HostResolver::RequestInfo destination() const { return destination_; }
-
- private:
HostResolver::RequestInfo destination_;
};
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index 4986f32..6df566ba 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -256,7 +256,8 @@ class MockClientSocketFactory : public ClientSocketFactory {
class TCPClientSocketPoolTest : public ClientSocketPoolTest {
protected:
TCPClientSocketPoolTest()
- : ignored_socket_params_("ignored", 80, MEDIUM, GURL(), false),
+ : ignored_socket_params_(
+ HostPortPair("ignored", 80), MEDIUM, GURL(), false),
host_resolver_(new MockHostResolver),
pool_(new TCPClientSocketPool(kMaxSockets,
kMaxSocketsPerGroup,
@@ -281,7 +282,7 @@ class TCPClientSocketPoolTest : public ClientSocketPoolTest {
TEST_F(TCPClientSocketPoolTest, Basic) {
TestCompletionCallback callback;
ClientSocketHandle handle;
- TCPSocketParams dest("www.google.com", 80, LOW, GURL(), false);
+ TCPSocketParams dest(HostPortPair("www.google.com", 80), LOW, GURL(), false);
int rv = handle.Init("a", dest, LOW, &callback, pool_, BoundNetLog());
EXPECT_EQ(ERR_IO_PENDING, rv);
EXPECT_FALSE(handle.is_initialized());