-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Conversation
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]>
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]>
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]>
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! |
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... |
Similar as #14711, but for HTTP filters.
This change has two goals:
thus making it clear that it's fine to refence objects bound
to the FilterFactoryCb
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]