Commit 2ab5fe79 authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

SpdySessionPool: Don't use IP pooling for requests that don't want it.

This CL prevents the SpdySession pool from returning an IP pooled
session to a request that does not want one.

Bug: 912727
Change-Id: I06938adae3e1eca07e36d33f154a9bc473517785
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572584Reviewed-by: default avatarBence Béky <bnc@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652226}
parent e138d1b8
......@@ -54,10 +54,12 @@ SpdySessionPool::SpdySessionRequest::Delegate::~Delegate() = default;
SpdySessionPool::SpdySessionRequest::SpdySessionRequest(
const SpdySessionKey& key,
bool enable_ip_based_pooling,
bool is_websocket,
Delegate* delegate,
SpdySessionPool* spdy_session_pool)
: key_(key),
enable_ip_based_pooling_(enable_ip_based_pooling),
is_websocket_(is_websocket),
delegate_(delegate),
spdy_session_pool_(spdy_session_pool) {}
......@@ -333,8 +335,8 @@ base::WeakPtr<SpdySession> SpdySessionPool::RequestSession(
RequestSet* request_set = &spdy_session_request_map_[key];
*is_first_request_for_session = request_set->empty();
*spdy_session_request =
std::make_unique<SpdySessionRequest>(key, is_websocket, delegate, this);
*spdy_session_request = std::make_unique<SpdySessionRequest>(
key, enable_ip_based_pooling, is_websocket, delegate, this);
request_set->insert(spdy_session_request->get());
if (on_request_destroyed_callback && !*is_first_request_for_session) {
......@@ -632,6 +634,7 @@ void SpdySessionPool::UpdatePendingRequests(const SpdySessionKey& key) {
auto it = LookupAvailableSessionByKey(key);
if (it != available_sessions_.end()) {
base::WeakPtr<SpdySession> new_session = it->second->GetWeakPtr();
bool is_pooled = (key != new_session->spdy_session_key());
while (new_session && new_session->IsAvailable()) {
// Each iteration may empty out the RequestSet for |spdy_session_key| in
// |spdy_session_request_map_|. So each time, check for RequestSet and use
......@@ -654,6 +657,9 @@ void SpdySessionPool::UpdatePendingRequests(const SpdySessionKey& key) {
// support websockets, skip over the request.
if ((*request)->is_websocket() && !new_session->support_websocket())
continue;
// Don't use IP pooled session if not allowed.
if (!(*request)->enable_ip_based_pooling() && is_pooled)
continue;
break;
}
if (request == request_set->end())
......
......@@ -100,6 +100,7 @@ class NET_EXPORT SpdySessionPool
// Constructor - this is called by the SpdySessionPool.
SpdySessionRequest(const SpdySessionKey& key,
bool enable_ip_based_pooling,
bool is_websocket,
Delegate* delegate,
SpdySessionPool* spdy_session_pool);
......@@ -111,6 +112,7 @@ class NET_EXPORT SpdySessionPool
void OnRemovedFromPool();
const SpdySessionKey& key() const { return key_; }
bool enable_ip_based_pooling() const { return enable_ip_based_pooling_; }
bool is_websocket() const { return is_websocket_; }
Delegate* delegate() { return delegate_; }
......@@ -120,6 +122,7 @@ class NET_EXPORT SpdySessionPool
private:
const SpdySessionKey key_;
const bool enable_ip_based_pooling_;
const bool is_websocket_;
Delegate* const delegate_;
SpdySessionPool* spdy_session_pool_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment