diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index ea2b28f14e1..9fcb045527d 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -3953,8 +3953,7 @@ grpc_error* CallData::ApplyServiceConfigToCallLocked( chand, this); } ConfigSelector* config_selector = chand->config_selector(); - auto service_config = chand->service_config(); - if (service_config != nullptr) { + if (config_selector != nullptr) { // Use the ConfigSelector to determine the config for the call. ConfigSelector::CallConfig call_config = config_selector->GetCallConfig({&path_, initial_metadata, arena_}); @@ -3967,7 +3966,8 @@ grpc_error* CallData::ApplyServiceConfigToCallLocked( // so that it can be accessed by filters in the subchannel, and it // will be cleaned up when the call ends. auto* service_config_call_data = arena_->New( - std::move(service_config), call_config.method_configs, call_context_); + std::move(call_config.service_config), call_config.method_configs, + call_context_); // Apply our own method params to the call. method_params_ = static_cast( service_config_call_data->GetMethodParsedConfig( diff --git a/src/core/ext/filters/client_channel/config_selector.h b/src/core/ext/filters/client_channel/config_selector.h index 30457d701d6..e43afd31662 100644 --- a/src/core/ext/filters/client_channel/config_selector.h +++ b/src/core/ext/filters/client_channel/config_selector.h @@ -55,6 +55,9 @@ class ConfigSelector : public RefCounted { // The per-method parsed configs that will be passed to // ServiceConfigCallData. const ServiceConfigParser::ParsedConfigVector* method_configs = nullptr; + // A ref to the service config that contains method_configs, held by + // the call to ensure that method_configs lives long enough. + RefCountedPtr service_config; // Call attributes that will be accessible to LB policy implementations. std::map call_attributes; // A callback that, if set, will be invoked when the call is @@ -106,6 +109,7 @@ class DefaultConfigSelector : public ConfigSelector { CallConfig call_config; call_config.method_configs = service_config_->GetMethodParsedConfigVector(*args.path); + call_config.service_config = service_config_; return call_config; }