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

Add scoped routing #8

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve the comment per htuch's suggestion.
Signed-off-by: Xin Zhuang <[email protected]>
  • Loading branch information
stevenzzzz committed Jul 31, 2019
commit f074e9d97394480bfa8e78d3200dad1bf9976207
11 changes: 7 additions & 4 deletions source/common/config/config_provider_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,21 @@ class ConfigSubscriptionCommonBase
using ConfigUpdateCb =
std::function<ConfigProvider::ConfigConstSharedPtr(ConfigProvider::ConfigConstSharedPtr)>;
void applyConfigUpdate(
const ConfigUpdateFn& update_fn, const Event::PostCb& complete_cb = []() {}) {
const ConfigUpdateCb& update_fn, const Event::PostCb& complete_cb = []() {}) {
// It is safe to call shared_from_this here as this is in main thread, and destruction of a
// ConfigSubscriptionCommonBase owner (i.e., a provider) happens in main thread as well.
auto shared_this = shared_from_this();
tls_->runOnAllThreads(
[this, update_fn]() {
tls_->getTyped<ThreadLocalConfig>().config_ = update_fn(this->getConfig());
},
/*During the update propagation, a subscription may get teared down in main thread due to
/* During the update propagation, a subscription may get teared down in main thread due to
all owners/providers destructed in a xDS update (e.g. LDS demolishes a RouteConfigProvider
and its subscription). Hold a reference to the shared subscription instance to make sure the
update can be safely pushed to workers in such an event.*/
and its subscription).
If such a race condition happens, hold a reference to the "*this" subscription instance in
this cb will ensure the shared "*this" gets posted back to main thread, after all the
workers finish calling the update_fn, at which point it's safe to destruct "*this"
instance. */
[shared_this, complete_cb]() { complete_cb(); });
}

Expand Down