Skip to content

hcm: ensure data added during filter callbacks get propagated#7700

Closed
snowp wants to merge 3 commits intoenvoyproxy:masterfrom
snowp:buffer-inline
Closed

hcm: ensure data added during filter callbacks get propagated#7700
snowp wants to merge 3 commits intoenvoyproxy:masterfrom
snowp:buffer-inline

Conversation

@snowp
Copy link
Copy Markdown
Contributor

@snowp snowp commented Jul 23, 2019

Currently, addData will write data to the filter buffer, but we only
ever read from said buffer if we ever transition from stopping ->
continuing. This means that if add
Data is called when every callback
returns Continue, the data is never propagated to the next filter.

This change adds a flag that is set whenever data is written to the
buffer, using this to flush the buffer when onData returns Continue even
if filter iteration was never stopped.

Fixes #7579

Signed-off-by: Snow Pettersen snowp@squareup.com

Risk Level: Medium
Testing: Added HCM UT
Docs Changes: n/a
Release Notes: n/a
Fixes #7579

Currently, add*Data will write data to the filter buffer, but we only
ever read from said buffer if we ever transition from stopping ->
continuing. This means that if add*Data is called when every callback
returns Continue, the data is never propagated to the next filter.

This change adds a flag that is set whenever data is written to the
buffer, using this to flush the buffer when onData returns Continue even
if filter iteration was never stopped.

Fixes envoyproxy#7579

Signed-off-by: Snow Pettersen <snowp@squareup.com>
@dio
Copy link
Copy Markdown
Member

dio commented Jul 23, 2019

@soya3129 could you help to do the first pass? Thank you.

recordLatestDataFilter(entry, state_.latest_data_decoding_filter_, decoder_filters_);

state_.filter_call_state_ |= FilterCallState::DecodeData;
(*entry)->inline_buffered_data_ = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we don't need (*entry)->inline_buffered_data_ = false; in ActiveStream::encodeData()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do :) good catch


ENVOY_STREAM_LOG(trace, "continuing filter chain: filter={}", parent_,
static_cast<const void*>(this));
ASSERT(!canIterate());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this solution! It's simple and it works! The only concern I have is the removal of ASSERT here and below. Is it possible to keep the assert? For example: ASSERT(!canIterate() || inline_buffered_data_)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep that makes sense. I was ripping out all the asserts that failed, makes sense to make it more exact instead

Snow Pettersen added 2 commits July 31, 2019 19:14
Signed-off-by: Snow Pettersen <snowp@squareup.com>
Signed-off-by: Snow Pettersen <snowp@squareup.com>
@stale
Copy link
Copy Markdown

stale bot commented Aug 15, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Aug 15, 2019
@stale
Copy link
Copy Markdown

stale bot commented Aug 22, 2019

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot unassigned soya3129 Aug 22, 2019
@stale stale bot closed this Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale stalebot believes this issue/PR has not been touched recently

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HCM: buffered data ignored when onData never returns StopIteration

3 participants