Skip to content

Commit

Permalink
post merge fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Avlasov <yavlasov@google.com>
  • Loading branch information
yanavlasov committed Aug 12, 2024
1 parent 9c308ba commit 2d8cb15
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 8 additions & 6 deletions source/common/http/filter_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,29 +466,31 @@ void ActiveStreamDecoderFilter::encode1xxHeaders(ResponseHeaderMapPtr&& headers)
}
}

void ActiveStreamDecoderFilter::maybeStopDecoderFilterChain(bool end_stream) {
filter_encoded_end_stream_ = end_stream;
if (end_stream && end_stream_ && !parent_.state_.decoder_filter_chain_complete_) {
void ActiveStreamDecoderFilter::maybeMarkDecoderFilterTerminal(bool encoded_end_stream) {
filter_encoded_end_stream_ = encoded_end_stream;
// If this filter encoded end_stream and the decoder filter chain has not yet been finished
// then make this filter terminal. Decoding will not go past this filter.
if (encoded_end_stream && end_stream_ && !parent_.state_.decoder_filter_chain_complete_) {
parent_.state_.decoder_filter_chain_aborted_ = true;
}
}

void ActiveStreamDecoderFilter::encodeHeaders(ResponseHeaderMapPtr&& headers, bool end_stream,
absl::string_view details) {
maybeStopDecoderFilterChain(end_stream);
maybeMarkDecoderFilterTerminal(end_stream);
parent_.streamInfo().setResponseCodeDetails(details);
parent_.filter_manager_callbacks_.setResponseHeaders(std::move(headers));
parent_.encodeHeaders(nullptr, *parent_.filter_manager_callbacks_.responseHeaders(), end_stream);
}

void ActiveStreamDecoderFilter::encodeData(Buffer::Instance& data, bool end_stream) {
maybeStopDecoderFilterChain(end_stream);
maybeMarkDecoderFilterTerminal(end_stream);
parent_.encodeData(nullptr, data, end_stream,
FilterManager::FilterIterationStartState::CanStartFromCurrent);
}

void ActiveStreamDecoderFilter::encodeTrailers(ResponseTrailerMapPtr&& trailers) {
maybeStopDecoderFilterChain(true);
maybeMarkDecoderFilterTerminal(true);
parent_.filter_manager_callbacks_.setResponseTrailers(std::move(trailers));
parent_.encodeTrailers(nullptr, *parent_.filter_manager_callbacks_.responseTrailers());
}
Expand Down
2 changes: 1 addition & 1 deletion source/common/http/filter_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ struct ActiveStreamDecoderFilter : public ActiveStreamFilterBase,
// This allows non-terminal filters (i.e. cache filter) to encode responses when independent
// half-close is enabled. Encoding end_stream effectively makes the filter terminal - decoder
// filer chain will not go past this filter.
void maybeStopDecoderFilterChain(bool end_stream);
void maybeMarkDecoderFilterTerminal(bool encoded_end_stream);

StreamDecoderFilterSharedPtr handle_;
bool is_grpc_request_{};
Expand Down
14 changes: 7 additions & 7 deletions test/common/http/conn_manager_impl_test_2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TEST_F(HttpConnectionManagerImplTest, ResponseBeforeRequestCompleteWithUpstreamH
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues(
{{"envoy.reloadable_features.allow_multiplexed_upstream_half_close", "true"}});
setup(false, "envoy-server-test");
setup();
setupFilterChain(1, 0);

EXPECT_CALL(*decoder_filters_[0], decodeHeaders(_, false))
Expand Down Expand Up @@ -541,7 +541,7 @@ TEST_F(HttpConnectionManagerImplTest, DrainConnectionUponCompletionVsOnDrainTime
Event::MockTimer* connection_duration_timer = setUpTimer();
EXPECT_CALL(*connection_duration_timer, enableTimer(_, _));
// Set up connection.
setup(false, "");
setup();

// Create a filter so we can encode responses.
MockStreamDecoderFilter* filter = new NiceMock<MockStreamDecoderFilter>();
Expand Down Expand Up @@ -1910,7 +1910,7 @@ TEST_F(HttpConnectionManagerImplTest, FilterHeadReply) {

TEST_F(HttpConnectionManagerImplTest, LocalReplyStopsDecoding) {
InSequence s;
setup(false, "");
setup();

EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> Http::Status {
decoder_ = &conn_manager_->newStream(response_encoder_);
Expand Down Expand Up @@ -4449,7 +4449,7 @@ TEST_F(HttpConnectionManagerImplTest, EncodingByNonTerminalFilter) {
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues(
{{"envoy.reloadable_features.allow_multiplexed_upstream_half_close", "false"}});
setup(false, "");
setup();
constexpr int total_filters = 3;
constexpr int ecoder_filter_index = 1;
setupFilterChain(total_filters, total_filters);
Expand Down Expand Up @@ -4501,7 +4501,7 @@ TEST_F(HttpConnectionManagerImplTest, EncodingByNonTerminalFilterWithIndependent
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues(
{{"envoy.reloadable_features.allow_multiplexed_upstream_half_close", "true"}});
setup(false, "");
setup();
constexpr int total_filters = 3;
constexpr int ecoder_filter_index = 1;
setupFilterChain(total_filters, total_filters);
Expand Down Expand Up @@ -4556,7 +4556,7 @@ TEST_F(HttpConnectionManagerImplTest, DecodingByNonTerminalEncoderFilterWithInde
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues(
{{"envoy.reloadable_features.allow_multiplexed_upstream_half_close", "true"}});
setup(false, "");
setup();
constexpr int total_filters = 3;
constexpr int ecoder_filter_index = 1;
setupFilterChain(total_filters, total_filters);
Expand Down Expand Up @@ -4625,7 +4625,7 @@ TEST_F(HttpConnectionManagerImplTest, DecodingWithAddedTrailersByNonTerminalEnco
TestScopedRuntime scoped_runtime;
scoped_runtime.mergeValues(
{{"envoy.reloadable_features.allow_multiplexed_upstream_half_close", "true"}});
setup(false, "");
setup();
constexpr int total_filters = 3;
constexpr int ecoder_filter_index = 1;
setupFilterChain(total_filters, total_filters);
Expand Down

0 comments on commit 2d8cb15

Please sign in to comment.