Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http filters: pass configs by reference instead of shared_ptr #14737

Closed
wants to merge 10 commits into from

Conversation

rgs1
Copy link
Member

@rgs1 rgs1 commented Jan 18, 2021

Similar as #14711, but for HTTP filters.

This change has two goals:

  1. consistently deal with filter configs across all HTTP filters,
    thus making it clear that it's fine to refence objects bound
    to the FilterFactoryCb
  2. avoid confusing future filter writers who might think they need
    shared_ptrs when they really don't. I get confused every 6 months,
    so this includes me

As a very small bonus, we create fewer shared_ptrs on every request
though this won't show up in a profiler. It still makes me happy :-)

Signed-off-by: Raul Gutierrez Segales [email protected]

Similar as envoyproxy#14711, but for HTTP filters.

This change has two goals:

1) consistently deal with filter configs across all HTTP filters,
   thus making it clear that it's _fine_ to refence objects bound
   to the FilterFactoryCb
2) avoid confusing future filter writers who might think they need
   shared_ptrs when they really don't. I get confused every 6 months,
   so this includes me

As a very small bonus, we create fewer shared_ptrs on every request
though this won't show up in a profiler. It still makes me happy :-)

Signed-off-by: Raul Gutierrez Segales <[email protected]>
Raul Gutierrez Segales added 5 commits January 18, 2021 14:24
Missed part of this in the 1st pass.

Signed-off-by: Raul Gutierrez Segales <[email protected]>
Signed-off-by: Raul Gutierrez Segales <[email protected]>
Signed-off-by: Raul Gutierrez Segales <[email protected]>
I _think_ some integration tests are not properly keeping the
FilterFactoryCb around (as they should), which is causing
issues. We can clean those up in a follow-up.

Signed-off-by: Raul Gutierrez Segales <[email protected]>
Raul Gutierrez Segales added 4 commits January 19, 2021 07:57
Signed-off-by: Raul Gutierrez Segales <[email protected]>
Signed-off-by: Raul Gutierrez Segales <[email protected]>
Turns out that keeping a reference to an object stored in the lambda
itself causes issues, but if it's a shared_ptr it's fine. I am guessing
that the FilterFactoryCb gets moved around so the reference goes stale.
Thus we need to bind shared_ptrs to it.

Signed-off-by: Raul Gutierrez Segales <[email protected]>
@mattklein123
Copy link
Member

Based on discussion in https://envoyproxy.slack.com/archives/C78HA81DH/p1611093479022600 I think we are going in a different direction here so I'm going to close this and @rgs1 is going to work on a different proposal!

@wangjian-pg
Copy link

Is it still true that HTTP filters can reference objects bound to the FilterFactoryCb and the FilterFactoryCb lambda always outlives the filters it creates? It seems that there are no new proposals coming out yet...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants