Skip to content

callbacks: use RAII for handle tracking - #15195

Merged
mattklein123 merged 1 commit into
mainfrom
fix_callbacks
Feb 26, 2021
Merged

mattklein123 merged 1 commit into
mainfrom
fix_callbacks

Conversation

@mattklein123

Copy link
Copy Markdown
Member

This changes the callback code to use RAII with weak
pointers. This allows both the callee and the callback
manager to be safely destructed in different orders which
does happen during normal operation, for example with cluster
and listener changes.

Fixes #14866

Risk Level: Low
Testing: New and existing tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

This changes the callback code to use RAII with weak
pointers. This allows both the callee and the callback
manager to be safely destructed in different orders which
does happen during normal operation, for example with cluster
and listener changes.

Fixes #14866

Signed-off-by: Matt Klein <[email protected]>
@mattklein123

Copy link
Copy Markdown
Member Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #15195 (comment) was created by @mattklein123.

see: more, trace.

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is so great; a reference for future situations where the value of RAII is questioned!

target_cluster_info->name(), parent_info_->name());
refresh();
});
member_update_cbs_[thread_local_cluster.info()->name()] =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For this and other places that we now capture, were we leaking before, since there was never a remove()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, if someone had delivered the aggregate cluster via CDS and then removed it, there would be crashes. I think this change has fixed multiple different latent bugs.

@inf-rno

inf-rno commented Jun 14, 2021

Copy link
Copy Markdown
Contributor

Awesome work here. We ran into this while getting setup to move our configs to xDS. ❤️

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.

Crash when updating UDP clusters through CDS

3 participants