Skip to content

Commit

Permalink
Prevent recursion during premature reset check (envoyproxy#30270)
Browse files Browse the repository at this point in the history
Prevent doConnectionClose to be called recursively when connection with active requests is disconnected due to premature reset check.

Signed-off-by: Yan Avlasov <yavlasov@google.com>
  • Loading branch information
yanavlasov committed Oct 18, 2023
1 parent 19264de commit e87063f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/common/http/conn_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ void ConnectionManagerImpl::maybeDrainDueToPrematureResets() {
}
}

if (drain_state_ == DrainState::NotDraining) {
if (read_callbacks_->connection().state() == Network::Connection::State::Open) {
stats_.named_.downstream_rq_too_many_premature_resets_.inc();
doConnectionClose(Network::ConnectionCloseType::Abort, absl::nullopt,
"too_many_premature_resets");
Expand Down
5 changes: 2 additions & 3 deletions test/integration/multiplexed_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2471,16 +2471,15 @@ TEST_P(Http2FrameIntegrationTest, ResettingDeferredRequestsTriggersPrematureRese
TEST_P(Http2FrameIntegrationTest, CloseConnectionWithDeferredStreams) {
// Use large number of requests to ensure close is detected while there are
// still some deferred streams.
const int kRequestsSentPerIOCycle = 1000;
const int kRequestsSentPerIOCycle = 20000;
config_helper_.addRuntimeOverride("http.max_requests_per_io_cycle", "1");
// Ensure premature reset detection does not get in the way
config_helper_.addRuntimeOverride("overload.premature_reset_total_stream_count", "1001");
beginSession();

std::string buffer;
for (int i = 0; i < kRequestsSentPerIOCycle; ++i) {
auto request = Http2Frame::makeRequest(Http2Frame::makeClientStreamId(i), "a", "/",
{{"response_data_blocks", "0"}, {"no_trailers", "1"}});
auto request = Http2Frame::makeRequest(Http2Frame::makeClientStreamId(i), "a", "/");
absl::StrAppend(&buffer, std::string(request));
}

Expand Down

0 comments on commit e87063f

Please sign in to comment.