Skip to content

Conversation

eziskind
Copy link
Contributor

Description: Return a handle from registration methods that can be used to unregister. This is needed for registrations made by objects that can have a shorter lifetime than the server (such as filters or access logs). When those objects are destroyed the callbacks will be invalidated so the registrations should be removed to avoid memory access violations.
Risk Level: low
Testing: unit tests
Signed-off-by: Elisha Ziskind eziskind@google.com

eziskind added 2 commits May 17, 2019 10:59
Signed-off-by: Elisha Ziskind <eziskind@google.com>
Signed-off-by: Elisha Ziskind <eziskind@google.com>
@eziskind
Copy link
Contributor Author

/review @htuch

@repokitteh-read-only repokitteh-read-only bot requested a review from htuch May 17, 2019 15:19
public:
virtual ~Handle() = default;

virtual void unregister() PURE;
Copy link
Member

Choose a reason for hiding this comment

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

drive by: Can we just have destruction of the Handle unregister.

Bonus points: we have this pattern in quite a few different places, and I'm wondering if we could make this some type of generic mix-in class? WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved unregister to the destructor.

Can you point me to some other examples of this pattern?

eziskind added 2 commits May 17, 2019 15:49
Signed-off-by: Elisha Ziskind <eziskind@google.com>
Signed-off-by: Elisha Ziskind <eziskind@google.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

@eziskind thanks, LGTM. I think in terms of other places where this patterns comes up, check out ClusterUpdateCallbacksHandleImpl and ConfigTrackerImpl::EntryOwnerImpl. Probably others as well. Do you want to generalize in this PR or leave this as a TODO?

@eziskind
Copy link
Contributor Author

@eziskind thanks, LGTM. I think in terms of other places where this patterns comes up, check out ClusterUpdateCallbacksHandleImpl and ConfigTrackerImpl::EntryOwnerImpl. Probably others as well. Do you want to generalize in this PR or leave this as a TODO?

Thanks, I'll leave this as a TODO for a followup PR.

@htuch
Copy link
Member

htuch commented May 21, 2019

@eziskind LGTM if you can add the TODO or file an issue for the general case.

@eziskind
Copy link
Contributor Author

@eziskind LGTM if you can add the TODO or file an issue for the general case.

Filed #7020

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks!

@htuch htuch merged commit 75d9b99 into envoyproxy:master May 21, 2019
@eziskind eziskind deleted the lifecycle branch May 21, 2019 12:58
mpuncel added a commit to mpuncel/envoy that referenced this pull request May 22, 2019
* master: (65 commits)
  proto: Add PATCH method to RequestMethod enum (envoyproxy#6737)
  exe: drop unused deps on zlib compressor code (envoyproxy#7022)
  coverage: fix some misc coverage (envoyproxy#7033)
  Enable proto schema for router_check_tool (envoyproxy#6992)
  stats: rework stat sink flushing to centralize counter latching (envoyproxy#6996)
  [test] convert lds api test config stubs to v2 (envoyproxy#7021)
  router: scoped rds (2c): implement scoped rds API (envoyproxy#6932)
  build: Add option for size-optimized binary (envoyproxy#6960)
  test: adding an integration test framework for file-based LDS (envoyproxy#6933)
  doc: update obsolete ref to api/XDS_PROTOCOL.md (envoyproxy#7002)
  dispatcher: faster runOnAllThreads (envoyproxy#7011)
  example: add csrf sandbox (envoyproxy#6805)
  fix syntax of gcov exclusion zone. (envoyproxy#7023)
  /runtime_modify: add support for query params in body (envoyproxy#6977)
  stats: Create stats for http codes with the symbol table. (envoyproxy#6733)
  health check: fix more fallout from inline deletion change (envoyproxy#6988)
  Max heap fix (envoyproxy#7016)
  Add support to unregister from lifecycle notifications (envoyproxy#6984)
  build spdy_core_alt_svc_wire_format (envoyproxy#7010)
  ext_authz: Make sure initiateCall only called once (envoyproxy#6949)
  ...

Signed-off-by: Michael Puncel <mpuncel@squareup.com>
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.

3 participants