Chromium Code Reviews| Index: net/spdy/spdy_session_pool.cc |
| =================================================================== |
| --- net/spdy/spdy_session_pool.cc (revision 92397) |
| +++ net/spdy/spdy_session_pool.cc (working copy) |
| @@ -150,6 +150,22 @@ |
| make_scoped_refptr(new NetLogSourceParameter( |
| "session", (*spdy_session)->net_log().source()))); |
| + // We have a new session. Lookup the IP address for this session so that we |
| + // can match future Sessions (potentially to different domains) which can |
| + // potentially be pooled with this one. Because GetPeerAddress() reports the |
| + // proxy's address instead of the origin server, added the check to see if |
| + // this is a direct connection. |
| + if (g_enable_ip_pooling && host_port_proxy_pair.second.is_direct()) { |
| + AddressList addresses; |
| + if (connection->socket()->GetPeerAddress(&addresses) == net::OK) { |
| + const addrinfo* address = addresses.head(); |
| + DCHECK(address); |
| + IPEndPoint endpoint; |
| + endpoint.FromSockAddr(address->ai_addr, address->ai_addrlen); |
| + AddAlias(endpoint, host_port_proxy_pair); |
| + } |
| + } |
| + |
| // Now we can initialize the session with the SSL socket. |
| return (*spdy_session)->InitializeWithSocket(connection, is_secure, |
| certificate_error_code); |
| @@ -302,16 +318,6 @@ |
| DCHECK(sessions_.find(pair) == sessions_.end()); |
| SpdySessionPool::SpdySessionList* list = new SpdySessionList(); |
| sessions_[pair] = list; |
| - |
| - // We have a new session. Lookup the IP addresses for this session so that |
| - // we can match future Sessions (potentially to different domains) which can |
| - // potentially be pooled with this one. |
| - if (g_enable_ip_pooling) { |
| - AddressList addresses; |
| - if (LookupAddresses(host_port_proxy_pair, &addresses)) |
| - AddAliases(addresses, host_port_proxy_pair); |
| - } |
| - |
| return list; |
| } |
| @@ -351,26 +357,11 @@ |
| return rv == OK; |
| } |
| -void SpdySessionPool::AddAliases(const AddressList& addresses, |
| - const HostPortProxyPair& pair) { |
| - // Note: it is possible to think of strange overlapping sets of ip addresses |
| - // for hosts such that a new session can override the alias for an IP |
| - // address that was previously aliased to a different host. This is probably |
| - // undesirable, but seemingly unlikely and complicated to fix. |
| - // Example: |
| - // host1 = 1.1.1.1, 1.1.1.4 |
| - // host2 = 1.1.1.4, 1.1.1.5 |
| - // host3 = 1.1.1.3, 1.1.1.5 |
| - // Creating session1 (to host1), creates an alias for host2 to host1. |
| - // Creating session2 (to host3), overrides the alias for host2 to host3. |
| - |
| - const addrinfo* address = addresses.head(); |
| - while (address) { |
| - IPEndPoint endpoint; |
| - endpoint.FromSockAddr(address->ai_addr, address->ai_addrlen); |
| - aliases_[endpoint] = pair; |
| - address = address->ai_next; |
| - } |
| +void SpdySessionPool::AddAlias(const IPEndPoint& endpoint, |
| + const HostPortProxyPair& pair) { |
| + if (!g_enable_ip_pooling) |
|
willchan no longer on Chromium
2011/07/17 12:44:47
I think it should be DCHECK(g_enable_ip_pooling).
ramant (doing other things)
2011/07/17 19:45:34
Done.
|
| + return; |
| + aliases_[endpoint] = pair; |
| } |
| void SpdySessionPool::RemoveAliases(const HostPortProxyPair& pair) { |