Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions source/common/http/http2/conn_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,15 @@ ConnectionPool::Cancellable* ConnPoolImpl::newStream(Http::StreamDecoder& respon
primary_client_.reset(new ActiveClient(*this));
}

if (primary_client_->client_->numActiveRequests() >= maxConcurrentStreams() ||
!host_->cluster().resourceManager(priority_).requests().canCreate()) {
log_debug("max requests overflow");
callbacks.onPoolFailure(ConnectionPool::PoolFailureReason::Overflow, nullptr);
host_->cluster().stats().upstream_rq_pending_overflow_.inc();
} else {
conn_log_debug("creating stream", *primary_client_->client_);
primary_client_->total_streams_++;
host_->stats().rq_total_.inc();
host_->stats().rq_active_.inc();
host_->cluster().stats().upstream_rq_total_.inc();
host_->cluster().stats().upstream_rq_active_.inc();
host_->cluster().resourceManager(priority_).requests().inc();
callbacks.onPoolReady(primary_client_->client_->newStream(response_decoder),
primary_client_->real_host_description_);
}
conn_log_debug("creating stream", *primary_client_->client_);
primary_client_->total_streams_++;
host_->stats().rq_total_.inc();
host_->stats().rq_active_.inc();
host_->cluster().stats().upstream_rq_total_.inc();
host_->cluster().stats().upstream_rq_active_.inc();
host_->cluster().resourceManager(priority_).requests().inc();
callbacks.onPoolReady(primary_client_->client_->newStream(response_decoder),
primary_client_->real_host_description_);

return nullptr;
}
Expand Down Expand Up @@ -247,8 +240,6 @@ CodecClientPtr ProdConnPoolImpl::createCodecClient(Upstream::Host::CreateConnect
return codec;
}

uint64_t ProdConnPoolImpl::maxConcurrentStreams() { return ConnectionImpl::MAX_CONCURRENT_STREAMS; }

uint32_t ProdConnPoolImpl::maxTotalStreams() { return MAX_STREAMS; }

} // Http2
Expand Down
2 changes: 0 additions & 2 deletions source/common/http/http2/conn_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class ConnPoolImpl : Logger::Loggable<Logger::Id::pool>, public ConnectionPool::

void checkForDrained();
virtual CodecClientPtr createCodecClient(Upstream::Host::CreateConnectionData& data) PURE;
virtual uint64_t maxConcurrentStreams() PURE;
virtual uint32_t maxTotalStreams() PURE;
void movePrimaryClientToDraining();
void onConnectionEvent(ActiveClient& client, uint32_t events);
Expand All @@ -93,7 +92,6 @@ class ProdConnPoolImpl : public ConnPoolImpl {

private:
CodecClientPtr createCodecClient(Upstream::Host::CreateConnectionData& data) override;
uint64_t maxConcurrentStreams() override;
uint32_t maxTotalStreams() override;

// All streams are 2^31. Client streams are half that, minus stream 0. Just to be on the safe
Expand Down
22 changes: 0 additions & 22 deletions test/common/http/http2/conn_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ class TestConnPoolImpl : public ConnPoolImpl {

MOCK_METHOD1(createCodecClient_, CodecClient*(Upstream::Host::CreateConnectionData& data));

uint64_t maxConcurrentStreams() override { return max_concurrent_streams_; }
uint32_t maxTotalStreams() override { return max_streams_; }

uint64_t max_concurrent_streams_{std::numeric_limits<uint64_t>::max()};
uint32_t max_streams_{std::numeric_limits<uint32_t>::max()};
};

Expand Down Expand Up @@ -356,26 +354,6 @@ TEST_F(Http2ConnPoolImplTest, ConnectTimeout) {
EXPECT_EQ(1U, cluster_->stats_.upstream_rq_pending_failure_eject_.value());
}

TEST_F(Http2ConnPoolImplTest, MaxRequests) {
InSequence s;
pool_.max_concurrent_streams_ = 1;

expectClientCreate();
ActiveTestRequest r1(*this, 0);
EXPECT_CALL(r1.inner_encoder_, encodeHeaders(_, true));
r1.callbacks_.outer_encoder_->encodeHeaders(HeaderMapImpl{}, true);
expectClientConnect(0);

ConnPoolCallbacks callbacks;
Http::MockStreamDecoder decoder;
EXPECT_CALL(callbacks.pool_failure_, ready());
EXPECT_EQ(nullptr, pool_.newStream(decoder, callbacks));

test_clients_[0].connection_->raiseEvents(Network::ConnectionEvent::RemoteClose);
EXPECT_CALL(*this, onClientDestroy());
dispatcher_.clearDeferredDeleteList();
}

TEST_F(Http2ConnPoolImplTest, MaxGlobalRequests) {
InSequence s;
cluster_->resource_manager_.reset(
Expand Down