From ff4df06a663e1ed7c9e22392c61dcf982ab0f9ff Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Mon, 22 Aug 2016 15:02:49 -0700 Subject: [PATCH 1/3] Rename grpc_client_config to grpc_resolver_result. --- BUILD | 16 ++-- CMakeLists.txt | 6 +- Makefile | 6 +- binding.gyp | 2 +- build.yaml | 4 +- config.m4 | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- package.xml | 4 +- src/core/ext/client_config/README.md | 4 +- src/core/ext/client_config/client_channel.c | 81 ++++++++++--------- .../ext/client_config/lb_policy_factory.h | 2 - src/core/ext/client_config/resolver.c | 4 +- src/core/ext/client_config/resolver.h | 12 +-- src/core/ext/client_config/resolver_factory.h | 2 +- .../{client_config.c => resolver_result.c} | 23 +++--- .../{client_config.h => resolver_result.h} | 27 +++---- .../ext/resolver/dns/native/dns_resolver.c | 42 +++++----- .../ext/resolver/sockaddr/sockaddr_resolver.c | 18 ++--- src/python/grpcio/grpc_core_dependencies.py | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/sources_and_headers.json | 6 +- vsprojects/vcxproj/grpc/grpc.vcxproj | 6 +- vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 12 +-- .../grpc_unsecure/grpc_unsecure.vcxproj | 6 +- .../grpc_unsecure.vcxproj.filters | 12 +-- 26 files changed, 156 insertions(+), 157 deletions(-) rename src/core/ext/client_config/{client_config.c => resolver_result.c} (73%) rename src/core/ext/client_config/{client_config.h => resolver_result.h} (68%) diff --git a/BUILD b/BUILD index b7044c5e685..12f0fd316ea 100644 --- a/BUILD +++ b/BUILD @@ -286,7 +286,6 @@ cc_library( "src/core/lib/tsi/transport_security_interface.h", "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -296,6 +295,7 @@ cc_library( "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", @@ -459,7 +459,6 @@ cc_library( "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", - "src/core/ext/client_config/client_config.c", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/default_initial_connect_string.c", @@ -471,6 +470,7 @@ cc_library( "src/core/ext/client_config/resolver.c", "src/core/ext/client_config/resolver_factory.c", "src/core/ext/client_config/resolver_registry.c", + "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", @@ -658,7 +658,6 @@ cc_library( "src/core/ext/transport/chttp2/alpn/alpn.h", "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -668,6 +667,7 @@ cc_library( "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", @@ -815,7 +815,6 @@ cc_library( "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", - "src/core/ext/client_config/client_config.c", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/default_initial_connect_string.c", @@ -827,6 +826,7 @@ cc_library( "src/core/ext/client_config/resolver.c", "src/core/ext/client_config/resolver_factory.c", "src/core/ext/client_config/resolver_registry.c", + "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", @@ -1011,7 +1011,6 @@ cc_library( "src/core/ext/transport/chttp2/alpn/alpn.h", "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -1021,6 +1020,7 @@ cc_library( "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", @@ -1159,7 +1159,6 @@ cc_library( "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", - "src/core/ext/client_config/client_config.c", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/default_initial_connect_string.c", @@ -1171,6 +1170,7 @@ cc_library( "src/core/ext/client_config/resolver.c", "src/core/ext/client_config/resolver_factory.c", "src/core/ext/client_config/resolver_registry.c", + "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", @@ -1952,7 +1952,6 @@ objc_library( "src/core/ext/client_config/channel_connectivity.c", "src/core/ext/client_config/client_channel.c", "src/core/ext/client_config/client_channel_factory.c", - "src/core/ext/client_config/client_config.c", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/default_initial_connect_string.c", @@ -1964,6 +1963,7 @@ objc_library( "src/core/ext/client_config/resolver.c", "src/core/ext/client_config/resolver_factory.c", "src/core/ext/client_config/resolver_registry.c", + "src/core/ext/client_config/resolver_result.c", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel_call_holder.c", "src/core/ext/client_config/subchannel_index.c", @@ -2153,7 +2153,6 @@ objc_library( "src/core/lib/tsi/transport_security_interface.h", "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -2163,6 +2162,7 @@ objc_library( "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 5754e6fc1f6..f847c9b0e68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -435,7 +435,6 @@ add_library(grpc src/core/ext/client_config/channel_connectivity.c src/core/ext/client_config/client_channel.c src/core/ext/client_config/client_channel_factory.c - src/core/ext/client_config/client_config.c src/core/ext/client_config/client_config_plugin.c src/core/ext/client_config/connector.c src/core/ext/client_config/default_initial_connect_string.c @@ -447,6 +446,7 @@ add_library(grpc src/core/ext/client_config/resolver.c src/core/ext/client_config/resolver_factory.c src/core/ext/client_config/resolver_registry.c + src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c @@ -667,7 +667,6 @@ add_library(grpc_cronet src/core/ext/client_config/channel_connectivity.c src/core/ext/client_config/client_channel.c src/core/ext/client_config/client_channel_factory.c - src/core/ext/client_config/client_config.c src/core/ext/client_config/client_config_plugin.c src/core/ext/client_config/connector.c src/core/ext/client_config/default_initial_connect_string.c @@ -679,6 +678,7 @@ add_library(grpc_cronet src/core/ext/client_config/resolver.c src/core/ext/client_config/resolver_factory.c src/core/ext/client_config/resolver_registry.c + src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c @@ -899,7 +899,6 @@ add_library(grpc_unsecure src/core/ext/client_config/channel_connectivity.c src/core/ext/client_config/client_channel.c src/core/ext/client_config/client_channel_factory.c - src/core/ext/client_config/client_config.c src/core/ext/client_config/client_config_plugin.c src/core/ext/client_config/connector.c src/core/ext/client_config/default_initial_connect_string.c @@ -911,6 +910,7 @@ add_library(grpc_unsecure src/core/ext/client_config/resolver.c src/core/ext/client_config/resolver_factory.c src/core/ext/client_config/resolver_registry.c + src/core/ext/client_config/resolver_result.c src/core/ext/client_config/subchannel.c src/core/ext/client_config/subchannel_call_holder.c src/core/ext/client_config/subchannel_index.c diff --git a/Makefile b/Makefile index 2db87e83ae4..6b619e310b9 100644 --- a/Makefile +++ b/Makefile @@ -2651,7 +2651,6 @@ LIBGRPC_SRC = \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ - src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -2663,6 +2662,7 @@ LIBGRPC_SRC = \ src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ + src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ @@ -2901,7 +2901,6 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ - src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -2913,6 +2912,7 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ + src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ @@ -3359,7 +3359,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ - src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -3371,6 +3370,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ + src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ diff --git a/binding.gyp b/binding.gyp index 17dbfc0d381..a29cfda6fc5 100644 --- a/binding.gyp +++ b/binding.gyp @@ -707,7 +707,6 @@ 'src/core/ext/client_config/channel_connectivity.c', 'src/core/ext/client_config/client_channel.c', 'src/core/ext/client_config/client_channel_factory.c', - 'src/core/ext/client_config/client_config.c', 'src/core/ext/client_config/client_config_plugin.c', 'src/core/ext/client_config/connector.c', 'src/core/ext/client_config/default_initial_connect_string.c', @@ -719,6 +718,7 @@ 'src/core/ext/client_config/resolver.c', 'src/core/ext/client_config/resolver_factory.c', 'src/core/ext/client_config/resolver_registry.c', + 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', diff --git a/build.yaml b/build.yaml index 2f57859fc16..73c626351da 100644 --- a/build.yaml +++ b/build.yaml @@ -332,7 +332,6 @@ filegroups: headers: - src/core/ext/client_config/client_channel.h - src/core/ext/client_config/client_channel_factory.h - - src/core/ext/client_config/client_config.h - src/core/ext/client_config/connector.h - src/core/ext/client_config/initial_connect_string.h - src/core/ext/client_config/lb_policy.h @@ -342,6 +341,7 @@ filegroups: - src/core/ext/client_config/resolver.h - src/core/ext/client_config/resolver_factory.h - src/core/ext/client_config/resolver_registry.h + - src/core/ext/client_config/resolver_result.h - src/core/ext/client_config/subchannel.h - src/core/ext/client_config/subchannel_call_holder.h - src/core/ext/client_config/subchannel_index.h @@ -350,7 +350,6 @@ filegroups: - src/core/ext/client_config/channel_connectivity.c - src/core/ext/client_config/client_channel.c - src/core/ext/client_config/client_channel_factory.c - - src/core/ext/client_config/client_config.c - src/core/ext/client_config/client_config_plugin.c - src/core/ext/client_config/connector.c - src/core/ext/client_config/default_initial_connect_string.c @@ -362,6 +361,7 @@ filegroups: - src/core/ext/client_config/resolver.c - src/core/ext/client_config/resolver_factory.c - src/core/ext/client_config/resolver_registry.c + - src/core/ext/client_config/resolver_result.c - src/core/ext/client_config/subchannel.c - src/core/ext/client_config/subchannel_call_holder.c - src/core/ext/client_config/subchannel_index.c diff --git a/config.m4 b/config.m4 index b37658dc617..5b47074bcd7 100644 --- a/config.m4 +++ b/config.m4 @@ -226,7 +226,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ - src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -238,6 +237,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ + src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 200f9c21252..02a500f626e 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -379,7 +379,6 @@ Pod::Spec.new do |s| 'src/core/lib/tsi/transport_security_interface.h', 'src/core/ext/client_config/client_channel.h', 'src/core/ext/client_config/client_channel_factory.h', - 'src/core/ext/client_config/client_config.h', 'src/core/ext/client_config/connector.h', 'src/core/ext/client_config/initial_connect_string.h', 'src/core/ext/client_config/lb_policy.h', @@ -389,6 +388,7 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver.h', 'src/core/ext/client_config/resolver_factory.h', 'src/core/ext/client_config/resolver_registry.h', + 'src/core/ext/client_config/resolver_result.h', 'src/core/ext/client_config/subchannel.h', 'src/core/ext/client_config/subchannel_call_holder.h', 'src/core/ext/client_config/subchannel_index.h', @@ -556,7 +556,6 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/channel_connectivity.c', 'src/core/ext/client_config/client_channel.c', 'src/core/ext/client_config/client_channel_factory.c', - 'src/core/ext/client_config/client_config.c', 'src/core/ext/client_config/client_config_plugin.c', 'src/core/ext/client_config/connector.c', 'src/core/ext/client_config/default_initial_connect_string.c', @@ -568,6 +567,7 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver.c', 'src/core/ext/client_config/resolver_factory.c', 'src/core/ext/client_config/resolver_registry.c', + 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', @@ -740,7 +740,6 @@ Pod::Spec.new do |s| 'src/core/lib/tsi/transport_security_interface.h', 'src/core/ext/client_config/client_channel.h', 'src/core/ext/client_config/client_channel_factory.h', - 'src/core/ext/client_config/client_config.h', 'src/core/ext/client_config/connector.h', 'src/core/ext/client_config/initial_connect_string.h', 'src/core/ext/client_config/lb_policy.h', @@ -750,6 +749,7 @@ Pod::Spec.new do |s| 'src/core/ext/client_config/resolver.h', 'src/core/ext/client_config/resolver_factory.h', 'src/core/ext/client_config/resolver_registry.h', + 'src/core/ext/client_config/resolver_result.h', 'src/core/ext/client_config/subchannel.h', 'src/core/ext/client_config/subchannel_call_holder.h', 'src/core/ext/client_config/subchannel_index.h', diff --git a/grpc.gemspec b/grpc.gemspec index a7516a369f8..9c82db8ee30 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -298,7 +298,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/tsi/transport_security_interface.h ) s.files += %w( src/core/ext/client_config/client_channel.h ) s.files += %w( src/core/ext/client_config/client_channel_factory.h ) - s.files += %w( src/core/ext/client_config/client_config.h ) s.files += %w( src/core/ext/client_config/connector.h ) s.files += %w( src/core/ext/client_config/initial_connect_string.h ) s.files += %w( src/core/ext/client_config/lb_policy.h ) @@ -308,6 +307,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/resolver.h ) s.files += %w( src/core/ext/client_config/resolver_factory.h ) s.files += %w( src/core/ext/client_config/resolver_registry.h ) + s.files += %w( src/core/ext/client_config/resolver_result.h ) s.files += %w( src/core/ext/client_config/subchannel.h ) s.files += %w( src/core/ext/client_config/subchannel_call_holder.h ) s.files += %w( src/core/ext/client_config/subchannel_index.h ) @@ -475,7 +475,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/channel_connectivity.c ) s.files += %w( src/core/ext/client_config/client_channel.c ) s.files += %w( src/core/ext/client_config/client_channel_factory.c ) - s.files += %w( src/core/ext/client_config/client_config.c ) s.files += %w( src/core/ext/client_config/client_config_plugin.c ) s.files += %w( src/core/ext/client_config/connector.c ) s.files += %w( src/core/ext/client_config/default_initial_connect_string.c ) @@ -487,6 +486,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/client_config/resolver.c ) s.files += %w( src/core/ext/client_config/resolver_factory.c ) s.files += %w( src/core/ext/client_config/resolver_registry.c ) + s.files += %w( src/core/ext/client_config/resolver_result.c ) s.files += %w( src/core/ext/client_config/subchannel.c ) s.files += %w( src/core/ext/client_config/subchannel_call_holder.c ) s.files += %w( src/core/ext/client_config/subchannel_index.c ) diff --git a/package.xml b/package.xml index 890cf323372..be8c08d766c 100644 --- a/package.xml +++ b/package.xml @@ -306,7 +306,6 @@ - @@ -316,6 +315,7 @@ + @@ -483,7 +483,6 @@ - @@ -495,6 +494,7 @@ + diff --git a/src/core/ext/client_config/README.md b/src/core/ext/client_config/README.md index 7024fd540d8..eda01e3e715 100644 --- a/src/core/ext/client_config/README.md +++ b/src/core/ext/client_config/README.md @@ -12,7 +12,7 @@ data might include: - a load balancing policy to decide which server to send a request to - a set of filters to mutate outgoing requests (say, by adding metadata) -The resolver provides this data as a stream of grpc_client_config objects to +The resolver provides this data as a stream of grpc_resolver_result objects to the channel. We represent configuration as a stream so that it can be changed by the resolver during execution, by reacting to external events (such as a new configuration file being pushed to some store). @@ -22,7 +22,7 @@ Load Balancing -------------- Load balancing configuration is provided by a grpc_lb_policy object, stored as -part of grpc_client_config. +part of grpc_resolver_result. The primary job of the load balancing policies is to pick a target server given only the initial metadata for a request. It does this by providing a grpc_subchannel diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index 2c0c4abffc7..852e45e35f7 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -62,16 +62,15 @@ typedef struct client_channel_channel_data { /** mutex protecting client configuration, including all variables below in this data structure */ - gpr_mu mu_config; - /** currently active load balancer - guarded by mu_config */ + gpr_mu mu; + /** currently active load balancer - guarded by mu */ grpc_lb_policy *lb_policy; - /** incoming configuration - set by resolver.next - guarded by mu_config */ - grpc_client_config *incoming_configuration; + /** incoming resolver result - set by resolver.next(), guarded by mu */ + grpc_resolver_result *resolver_result; /** a list of closures that are all waiting for config to come in */ grpc_closure_list waiting_for_config_closures; /** resolver callback */ - grpc_closure on_config_changed; + grpc_closure on_resolver_result_changed; /** connectivity state being tracked */ grpc_connectivity_state_tracker state_tracker; /** when an lb_policy arrives, should we try to exit idle */ @@ -156,9 +155,9 @@ static void on_lb_policy_state_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { lb_policy_connectivity_watcher *w = arg; - gpr_mu_lock(&w->chand->mu_config); + gpr_mu_lock(&w->chand->mu); on_lb_policy_state_changed_locked(exec_ctx, w, error); - gpr_mu_unlock(&w->chand->mu_config); + gpr_mu_unlock(&w->chand->mu); GRPC_CHANNEL_STACK_UNREF(exec_ctx, w->chand->owning_stack, "watch_lb_policy"); gpr_free(w); @@ -178,8 +177,8 @@ static void watch_lb_policy(grpc_exec_ctx *exec_ctx, channel_data *chand, &w->on_changed); } -static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { channel_data *chand = arg; grpc_lb_policy *lb_policy = NULL; grpc_lb_policy *old_lb_policy; @@ -187,8 +186,9 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, int exit_idle = 0; grpc_error *state_error = GRPC_ERROR_CREATE("No load balancing policy"); - if (chand->incoming_configuration != NULL) { - lb_policy = grpc_client_config_get_lb_policy(chand->incoming_configuration); + if (chand->resolver_result != NULL) { + lb_policy = + grpc_resolver_result_get_lb_policy(chand->resolver_result); if (lb_policy != NULL) { GRPC_LB_POLICY_REF(lb_policy, "channel"); GRPC_LB_POLICY_REF(lb_policy, "config_change"); @@ -197,17 +197,17 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_lb_policy_check_connectivity(exec_ctx, lb_policy, &state_error); } - grpc_client_config_unref(exec_ctx, chand->incoming_configuration); + grpc_resolver_result_unref(exec_ctx, chand->resolver_result); } - chand->incoming_configuration = NULL; + chand->resolver_result = NULL; if (lb_policy != NULL) { grpc_pollset_set_add_pollset_set(exec_ctx, lb_policy->interested_parties, chand->interested_parties); } - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); old_lb_policy = chand->lb_policy; chand->lb_policy = lb_policy; if (lb_policy != NULL) { @@ -234,9 +234,9 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, } GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); grpc_resolver_next(exec_ctx, chand->resolver, - &chand->incoming_configuration, - &chand->on_config_changed); - gpr_mu_unlock(&chand->mu_config); + &chand->resolver_result, + &chand->on_resolver_result_changed); + gpr_mu_unlock(&chand->mu); } else { if (chand->resolver != NULL) { grpc_resolver_shutdown(exec_ctx, chand->resolver); @@ -249,7 +249,7 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg, GRPC_ERROR_CREATE_REFERENCING("Got config after disconnection", refs, GPR_ARRAY_SIZE(refs)), "resolver_gone"); - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); } if (exit_idle) { @@ -284,7 +284,7 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx, op->bind_pollset); } - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); if (op->on_connectivity_state_change != NULL) { grpc_connectivity_state_notify_on_state_change( exec_ctx, &chand->state_tracker, op->connectivity_state, @@ -329,7 +329,7 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx, } GRPC_ERROR_UNREF(op->disconnect_with_error); } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); } typedef struct { @@ -377,7 +377,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, GPR_ASSERT(connected_subchannel); - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); if (initial_metadata == NULL) { if (chand->lb_policy != NULL) { grpc_lb_policy_cancel_pick(exec_ctx, chand->lb_policy, @@ -392,7 +392,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, GRPC_ERROR_CREATE("Pick cancelled"), NULL); } } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); GPR_TIMER_END("cc_pick_subchannel", 0); return 1; } @@ -400,7 +400,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, grpc_lb_policy *lb_policy = chand->lb_policy; int r; GRPC_LB_POLICY_REF(lb_policy, "cc_pick_subchannel"); - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); r = grpc_lb_policy_pick(exec_ctx, lb_policy, calld->pollent, initial_metadata, initial_metadata_flags, connected_subchannel, on_ready); @@ -412,8 +412,8 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, chand->started_resolving = 1; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); grpc_resolver_next(exec_ctx, chand->resolver, - &chand->incoming_configuration, - &chand->on_config_changed); + &chand->resolver_result, + &chand->on_resolver_result_changed); } if (chand->resolver != NULL) { cpa = gpr_malloc(sizeof(*cpa)); @@ -429,7 +429,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, grpc_exec_ctx_sched(exec_ctx, on_ready, GRPC_ERROR_CREATE("Disconnected"), NULL); } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); GPR_TIMER_END("cc_pick_subchannel", 0); return 0; @@ -463,8 +463,9 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, GPR_ASSERT(args->is_last); GPR_ASSERT(elem->filter == &grpc_client_channel_filter); - gpr_mu_init(&chand->mu_config); - grpc_closure_init(&chand->on_config_changed, cc_on_config_changed, chand); + gpr_mu_init(&chand->mu); + grpc_closure_init(&chand->on_resolver_result_changed, + cc_on_resolver_result_changed, chand); chand->owning_stack = args->channel_stack; grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE, @@ -489,7 +490,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, } grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker); grpc_pollset_set_destroy(chand->interested_parties); - gpr_mu_destroy(&chand->mu_config); + gpr_mu_destroy(&chand->mu); } static void cc_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx, @@ -519,7 +520,7 @@ void grpc_client_channel_set_resolver(grpc_exec_ctx *exec_ctx, /* post construction initialization: set the transport setup pointer */ grpc_channel_element *elem = grpc_channel_stack_last_element(channel_stack); channel_data *chand = elem->channel_data; - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); GPR_ASSERT(!chand->resolver); chand->resolver = resolver; GRPC_RESOLVER_REF(resolver, "channel"); @@ -527,17 +528,17 @@ void grpc_client_channel_set_resolver(grpc_exec_ctx *exec_ctx, chand->exit_idle_when_lb_policy_arrives) { chand->started_resolving = 1; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, resolver, &chand->incoming_configuration, - &chand->on_config_changed); + grpc_resolver_next(exec_ctx, resolver, &chand->resolver_result, + &chand->on_resolver_result_changed); } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); } grpc_connectivity_state grpc_client_channel_check_connectivity_state( grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect) { channel_data *chand = elem->channel_data; grpc_connectivity_state out; - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); out = grpc_connectivity_state_check(&chand->state_tracker, NULL); if (out == GRPC_CHANNEL_IDLE && try_to_connect) { if (chand->lb_policy != NULL) { @@ -548,12 +549,12 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state( GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); chand->started_resolving = 1; grpc_resolver_next(exec_ctx, chand->resolver, - &chand->incoming_configuration, - &chand->on_config_changed); + &chand->resolver_result, + &chand->on_resolver_result_changed); } } } - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); return out; } @@ -588,8 +589,8 @@ void grpc_client_channel_watch_connectivity_state( grpc_closure_init(&w->my_closure, on_external_watch_complete, w); GRPC_CHANNEL_STACK_REF(w->chand->owning_stack, "external_connectivity_watcher"); - gpr_mu_lock(&chand->mu_config); + gpr_mu_lock(&chand->mu); grpc_connectivity_state_notify_on_state_change( exec_ctx, &chand->state_tracker, state, &w->my_closure); - gpr_mu_unlock(&chand->mu_config); + gpr_mu_unlock(&chand->mu); } diff --git a/src/core/ext/client_config/lb_policy_factory.h b/src/core/ext/client_config/lb_policy_factory.h index 1c89b28b59a..da1de3579a0 100644 --- a/src/core/ext/client_config/lb_policy_factory.h +++ b/src/core/ext/client_config/lb_policy_factory.h @@ -43,8 +43,6 @@ typedef struct grpc_lb_policy_factory grpc_lb_policy_factory; typedef struct grpc_lb_policy_factory_vtable grpc_lb_policy_factory_vtable; -/** grpc_lb_policy provides grpc_client_config objects to grpc_channel - objects */ struct grpc_lb_policy_factory { const grpc_lb_policy_factory_vtable *vtable; }; diff --git a/src/core/ext/client_config/resolver.c b/src/core/ext/client_config/resolver.c index eb004455bd0..7534ea62af5 100644 --- a/src/core/ext/client_config/resolver.c +++ b/src/core/ext/client_config/resolver.c @@ -76,7 +76,7 @@ void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx, } void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, + grpc_resolver_result **result, grpc_closure *on_complete) { - resolver->vtable->next(exec_ctx, resolver, target_config, on_complete); + resolver->vtable->next(exec_ctx, resolver, result, on_complete); } diff --git a/src/core/ext/client_config/resolver.h b/src/core/ext/client_config/resolver.h index 6ecb5d2774f..88ac262d513 100644 --- a/src/core/ext/client_config/resolver.h +++ b/src/core/ext/client_config/resolver.h @@ -34,14 +34,14 @@ #ifndef GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H #define GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H -#include "src/core/ext/client_config/client_config.h" +#include "src/core/ext/client_config/resolver_result.h" #include "src/core/ext/client_config/subchannel.h" #include "src/core/lib/iomgr/iomgr.h" typedef struct grpc_resolver grpc_resolver; typedef struct grpc_resolver_vtable grpc_resolver_vtable; -/** grpc_resolver provides grpc_client_config objects to grpc_channel +/** grpc_resolver provides grpc_resolver_result objects to grpc_channel objects */ struct grpc_resolver { const grpc_resolver_vtable *vtable; @@ -53,7 +53,7 @@ struct grpc_resolver_vtable { void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); void (*channel_saw_error)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); void (*next)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, grpc_closure *on_complete); + grpc_resolver_result **result, grpc_closure *on_complete); }; #ifdef GRPC_RESOLVER_REFCOUNT_DEBUG @@ -82,13 +82,13 @@ void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver); /** Get the next client config. Called by the channel to fetch a new - configuration. Expected to set *target_config with a new configuration, + configuration. Expected to set *result with a new configuration, and then schedule on_complete for execution. - If resolution is fatally broken, set *target_config to NULL and + If resolution is fatally broken, set *result to NULL and schedule on_complete. */ void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, + grpc_resolver_result **result, grpc_closure *on_complete); #endif /* GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_H */ diff --git a/src/core/ext/client_config/resolver_factory.h b/src/core/ext/client_config/resolver_factory.h index 4eb6979aad8..f69bf795649 100644 --- a/src/core/ext/client_config/resolver_factory.h +++ b/src/core/ext/client_config/resolver_factory.h @@ -41,7 +41,7 @@ typedef struct grpc_resolver_factory grpc_resolver_factory; typedef struct grpc_resolver_factory_vtable grpc_resolver_factory_vtable; -/** grpc_resolver provides grpc_client_config objects to grpc_channel +/** grpc_resolver provides grpc_resolver_result objects to grpc_channel objects */ struct grpc_resolver_factory { const grpc_resolver_factory_vtable *vtable; diff --git a/src/core/ext/client_config/client_config.c b/src/core/ext/client_config/resolver_result.c similarity index 73% rename from src/core/ext/client_config/client_config.c rename to src/core/ext/client_config/resolver_result.c index f9b8e686988..c6c4166e834 100644 --- a/src/core/ext/client_config/client_config.c +++ b/src/core/ext/client_config/resolver_result.c @@ -31,44 +31,45 @@ * */ -#include "src/core/ext/client_config/client_config.h" +#include "src/core/ext/client_config/resolver_result.h" #include #include -struct grpc_client_config { +struct grpc_resolver_result { gpr_refcount refs; grpc_lb_policy *lb_policy; }; -grpc_client_config *grpc_client_config_create() { - grpc_client_config *c = gpr_malloc(sizeof(*c)); +grpc_resolver_result *grpc_resolver_result_create() { + grpc_resolver_result *c = gpr_malloc(sizeof(*c)); memset(c, 0, sizeof(*c)); gpr_ref_init(&c->refs, 1); return c; } -void grpc_client_config_ref(grpc_client_config *c) { gpr_ref(&c->refs); } +void grpc_resolver_result_ref(grpc_resolver_result *c) { gpr_ref(&c->refs); } -void grpc_client_config_unref(grpc_exec_ctx *exec_ctx, grpc_client_config *c) { +void grpc_resolver_result_unref(grpc_exec_ctx *exec_ctx, + grpc_resolver_result *c) { if (gpr_unref(&c->refs)) { if (c->lb_policy != NULL) { - GRPC_LB_POLICY_UNREF(exec_ctx, c->lb_policy, "client_config"); + GRPC_LB_POLICY_UNREF(exec_ctx, c->lb_policy, "resolver_result"); } gpr_free(c); } } -void grpc_client_config_set_lb_policy(grpc_client_config *c, - grpc_lb_policy *lb_policy) { +void grpc_resolver_result_set_lb_policy(grpc_resolver_result *c, + grpc_lb_policy *lb_policy) { GPR_ASSERT(c->lb_policy == NULL); if (lb_policy) { - GRPC_LB_POLICY_REF(lb_policy, "client_config"); + GRPC_LB_POLICY_REF(lb_policy, "resolver_result"); } c->lb_policy = lb_policy; } -grpc_lb_policy *grpc_client_config_get_lb_policy(grpc_client_config *c) { +grpc_lb_policy *grpc_resolver_result_get_lb_policy(grpc_resolver_result *c) { return c->lb_policy; } diff --git a/src/core/ext/client_config/client_config.h b/src/core/ext/client_config/resolver_result.h similarity index 68% rename from src/core/ext/client_config/client_config.h rename to src/core/ext/client_config/resolver_result.h index a6290cbcf00..402f7dbd7e6 100644 --- a/src/core/ext/client_config/client_config.h +++ b/src/core/ext/client_config/resolver_result.h @@ -31,23 +31,22 @@ * */ -#ifndef GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H -#define GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H +#ifndef GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H +#define GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H #include "src/core/ext/client_config/lb_policy.h" -/** Total configuration for a client. Provided, and updated, by - grpc_resolver */ -typedef struct grpc_client_config grpc_client_config; +/** Results reported from a grpc_resolver. */ +typedef struct grpc_resolver_result grpc_resolver_result; -grpc_client_config *grpc_client_config_create(); -void grpc_client_config_ref(grpc_client_config *client_config); -void grpc_client_config_unref(grpc_exec_ctx *exec_ctx, - grpc_client_config *client_config); +grpc_resolver_result *grpc_resolver_result_create(); +void grpc_resolver_result_ref(grpc_resolver_result *client_config); +void grpc_resolver_result_unref(grpc_exec_ctx *exec_ctx, + grpc_resolver_result *client_config); -void grpc_client_config_set_lb_policy(grpc_client_config *client_config, - grpc_lb_policy *lb_policy); -grpc_lb_policy *grpc_client_config_get_lb_policy( - grpc_client_config *client_config); +void grpc_resolver_result_set_lb_policy(grpc_resolver_result *client_config, + grpc_lb_policy *lb_policy); +grpc_lb_policy *grpc_resolver_result_get_lb_policy( + grpc_resolver_result *client_config); -#endif /* GRPC_CORE_EXT_CLIENT_CONFIG_CLIENT_CONFIG_H */ +#endif /* GRPC_CORE_EXT_CLIENT_CONFIG_RESOLVER_RESULT_H */ diff --git a/src/core/ext/resolver/dns/native/dns_resolver.c b/src/core/ext/resolver/dns/native/dns_resolver.c index 31ac968670f..79682e78b5d 100644 --- a/src/core/ext/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/resolver/dns/native/dns_resolver.c @@ -67,16 +67,16 @@ typedef struct { gpr_mu mu; /** are we currently resolving? */ int resolving; - /** which version of resolved_config have we published? */ + /** which version of the result have we published? */ int published_version; - /** which version of resolved_config is current? */ + /** which version of the result is current? */ int resolved_version; /** pending next completion, or NULL */ grpc_closure *next_completion; - /** target config address for next completion */ - grpc_client_config **target_config; - /** current (fully resolved) config */ - grpc_client_config *resolved_config; + /** target result address for next completion */ + grpc_resolver_result **target_result; + /** current (fully resolved) result */ + grpc_resolver_result *resolved_result; /** retry timer */ bool have_retry_timer; grpc_timer retry_timer; @@ -97,7 +97,7 @@ static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r, - grpc_client_config **target_config, + grpc_resolver_result **target_result, grpc_closure *on_complete); static const grpc_resolver_vtable dns_resolver_vtable = { @@ -110,7 +110,7 @@ static void dns_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver) { grpc_timer_cancel(exec_ctx, &r->retry_timer); } if (r->next_completion != NULL) { - *r->target_config = NULL; + *r->target_result = NULL; grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_CREATE("Resolver Shutdown"), NULL); r->next_completion = NULL; @@ -130,13 +130,13 @@ static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx, } static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, + grpc_resolver_result **target_result, grpc_closure *on_complete) { dns_resolver *r = (dns_resolver *)resolver; gpr_mu_lock(&r->mu); GPR_ASSERT(!r->next_completion); r->next_completion = on_complete; - r->target_config = target_config; + r->target_result = target_result; if (r->resolved_version == 0 && !r->resolving) { gpr_backoff_reset(&r->backoff_state); dns_start_resolving_locked(exec_ctx, r); @@ -165,7 +165,7 @@ static void dns_on_retry_timer(grpc_exec_ctx *exec_ctx, void *arg, static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { dns_resolver *r = arg; - grpc_client_config *config = NULL; + grpc_resolver_result *result = NULL; grpc_lb_policy *lb_policy; gpr_mu_lock(&r->mu); GPR_ASSERT(r->resolving); @@ -173,14 +173,14 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_resolved_addresses *addresses = r->addresses; if (addresses != NULL) { grpc_lb_policy_args lb_policy_args; - config = grpc_client_config_create(); + result = grpc_resolver_result_create(); memset(&lb_policy_args, 0, sizeof(lb_policy_args)); lb_policy_args.addresses = addresses; lb_policy_args.client_channel_factory = r->client_channel_factory; lb_policy = grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args); if (lb_policy != NULL) { - grpc_client_config_set_lb_policy(config, lb_policy); + grpc_resolver_result_set_lb_policy(result, lb_policy); GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "construction"); } grpc_resolved_addresses_destroy(addresses); @@ -203,10 +203,10 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_timer_init(exec_ctx, &r->retry_timer, next_try, dns_on_retry_timer, r, now); } - if (r->resolved_config) { - grpc_client_config_unref(exec_ctx, r->resolved_config); + if (r->resolved_result) { + grpc_resolver_result_unref(exec_ctx, r->resolved_result); } - r->resolved_config = config; + r->resolved_result = result; r->resolved_version++; dns_maybe_finish_next_locked(exec_ctx, r); gpr_mu_unlock(&r->mu); @@ -228,9 +228,9 @@ static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, dns_resolver *r) { if (r->next_completion != NULL && r->resolved_version != r->published_version) { - *r->target_config = r->resolved_config; - if (r->resolved_config) { - grpc_client_config_ref(r->resolved_config); + *r->target_result = r->resolved_result; + if (r->resolved_result) { + grpc_resolver_result_ref(r->resolved_result); } grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL); r->next_completion = NULL; @@ -241,8 +241,8 @@ static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) { dns_resolver *r = (dns_resolver *)gr; gpr_mu_destroy(&r->mu); - if (r->resolved_config) { - grpc_client_config_unref(exec_ctx, r->resolved_config); + if (r->resolved_result) { + grpc_resolver_result_unref(exec_ctx, r->resolved_result); } grpc_client_channel_factory_unref(exec_ctx, r->client_channel_factory); gpr_free(r->name); diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 1f7cce2f43a..3807522d2bd 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -66,8 +66,8 @@ typedef struct { int published; /** pending next completion, or NULL */ grpc_closure *next_completion; - /** target config address for next completion */ - grpc_client_config **target_config; + /** target result address for next completion */ + grpc_resolver_result **target_result; } sockaddr_resolver; static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r); @@ -79,7 +79,7 @@ static void sockaddr_shutdown(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *r, - grpc_client_config **target_config, + grpc_resolver_result **target_result, grpc_closure *on_complete); static const grpc_resolver_vtable sockaddr_resolver_vtable = { @@ -91,7 +91,7 @@ static void sockaddr_shutdown(grpc_exec_ctx *exec_ctx, sockaddr_resolver *r = (sockaddr_resolver *)resolver; gpr_mu_lock(&r->mu); if (r->next_completion != NULL) { - *r->target_config = NULL; + *r->target_result = NULL; grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL); r->next_completion = NULL; } @@ -108,13 +108,13 @@ static void sockaddr_channel_saw_error(grpc_exec_ctx *exec_ctx, } static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, - grpc_client_config **target_config, + grpc_resolver_result **target_result, grpc_closure *on_complete) { sockaddr_resolver *r = (sockaddr_resolver *)resolver; gpr_mu_lock(&r->mu); GPR_ASSERT(!r->next_completion); r->next_completion = on_complete; - r->target_config = target_config; + r->target_result = target_result; sockaddr_maybe_finish_next_locked(exec_ctx, r); gpr_mu_unlock(&r->mu); } @@ -122,17 +122,17 @@ static void sockaddr_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver, static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx, sockaddr_resolver *r) { if (r->next_completion != NULL && !r->published) { - grpc_client_config *cfg = grpc_client_config_create(); + grpc_resolver_result *result = grpc_resolver_result_create(); grpc_lb_policy_args lb_policy_args; memset(&lb_policy_args, 0, sizeof(lb_policy_args)); lb_policy_args.addresses = r->addresses; lb_policy_args.client_channel_factory = r->client_channel_factory; grpc_lb_policy *lb_policy = grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args); - grpc_client_config_set_lb_policy(cfg, lb_policy); + grpc_resolver_result_set_lb_policy(result, lb_policy); GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "sockaddr"); r->published = 1; - *r->target_config = cfg; + *r->target_result = result; grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL); r->next_completion = NULL; } diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 7ae76f52c1f..660e34d7420 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -220,7 +220,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/client_config/channel_connectivity.c', 'src/core/ext/client_config/client_channel.c', 'src/core/ext/client_config/client_channel_factory.c', - 'src/core/ext/client_config/client_config.c', 'src/core/ext/client_config/client_config_plugin.c', 'src/core/ext/client_config/connector.c', 'src/core/ext/client_config/default_initial_connect_string.c', @@ -232,6 +231,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/client_config/resolver.c', 'src/core/ext/client_config/resolver_factory.c', 'src/core/ext/client_config/resolver_registry.c', + 'src/core/ext/client_config/resolver_result.c', 'src/core/ext/client_config/subchannel.c', 'src/core/ext/client_config/subchannel_call_holder.c', 'src/core/ext/client_config/subchannel_index.c', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index dcb11bd9330..50cebfa84e4 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -917,7 +917,6 @@ src/core/lib/tsi/transport_security.h \ src/core/lib/tsi/transport_security_interface.h \ src/core/ext/client_config/client_channel.h \ src/core/ext/client_config/client_channel_factory.h \ -src/core/ext/client_config/client_config.h \ src/core/ext/client_config/connector.h \ src/core/ext/client_config/initial_connect_string.h \ src/core/ext/client_config/lb_policy.h \ @@ -927,6 +926,7 @@ src/core/ext/client_config/parse_address.h \ src/core/ext/client_config/resolver.h \ src/core/ext/client_config/resolver_factory.h \ src/core/ext/client_config/resolver_registry.h \ +src/core/ext/client_config/resolver_result.h \ src/core/ext/client_config/subchannel.h \ src/core/ext/client_config/subchannel_call_holder.h \ src/core/ext/client_config/subchannel_index.h \ @@ -1094,7 +1094,6 @@ src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \ src/core/ext/client_config/channel_connectivity.c \ src/core/ext/client_config/client_channel.c \ src/core/ext/client_config/client_channel_factory.c \ -src/core/ext/client_config/client_config.c \ src/core/ext/client_config/client_config_plugin.c \ src/core/ext/client_config/connector.c \ src/core/ext/client_config/default_initial_connect_string.c \ @@ -1106,6 +1105,7 @@ src/core/ext/client_config/parse_address.c \ src/core/ext/client_config/resolver.c \ src/core/ext/client_config/resolver_factory.c \ src/core/ext/client_config/resolver_registry.c \ +src/core/ext/client_config/resolver_result.c \ src/core/ext/client_config/subchannel.c \ src/core/ext/client_config/subchannel_call_holder.c \ src/core/ext/client_config/subchannel_index.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index e5946cc14ab..84f7da8cb9a 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6087,7 +6087,6 @@ "headers": [ "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/connector.h", "src/core/ext/client_config/initial_connect_string.h", "src/core/ext/client_config/lb_policy.h", @@ -6097,6 +6096,7 @@ "src/core/ext/client_config/resolver.h", "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.h", "src/core/ext/client_config/subchannel_index.h", @@ -6110,8 +6110,6 @@ "src/core/ext/client_config/client_channel.h", "src/core/ext/client_config/client_channel_factory.c", "src/core/ext/client_config/client_channel_factory.h", - "src/core/ext/client_config/client_config.c", - "src/core/ext/client_config/client_config.h", "src/core/ext/client_config/client_config_plugin.c", "src/core/ext/client_config/connector.c", "src/core/ext/client_config/connector.h", @@ -6132,6 +6130,8 @@ "src/core/ext/client_config/resolver_factory.h", "src/core/ext/client_config/resolver_registry.c", "src/core/ext/client_config/resolver_registry.h", + "src/core/ext/client_config/resolver_result.c", + "src/core/ext/client_config/resolver_result.h", "src/core/ext/client_config/subchannel.c", "src/core/ext/client_config/subchannel.h", "src/core/ext/client_config/subchannel_call_holder.c", diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index ed010c55b51..298887e9157 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -426,7 +426,6 @@ - @@ -436,6 +435,7 @@ + @@ -750,8 +750,6 @@ - - @@ -774,6 +772,8 @@ + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index b3101728ab1..539dbad3604 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -436,9 +436,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -472,6 +469,9 @@ src\core\ext\client_config + + src\core\ext\client_config + src\core\ext\client_config @@ -1046,9 +1046,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -1076,6 +1073,9 @@ src\core\ext\client_config + + src\core\ext\client_config + src\core\ext\client_config diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 7a5f8589ca9..6a890656548 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -391,7 +391,6 @@ - @@ -401,6 +400,7 @@ + @@ -665,8 +665,6 @@ - - @@ -689,6 +687,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 99db98eb7ce..8325d910ec2 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -361,9 +361,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -397,6 +394,9 @@ src\core\ext\client_config + + src\core\ext\client_config + src\core\ext\client_config @@ -881,9 +881,6 @@ src\core\ext\client_config - - src\core\ext\client_config - src\core\ext\client_config @@ -911,6 +908,9 @@ src\core\ext\client_config + + src\core\ext\client_config + src\core\ext\client_config From a275aea5300a72ea0d00ae1184bc38431854a8fa Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 23 Aug 2016 12:30:45 -0700 Subject: [PATCH 2/3] clang-format --- src/core/ext/client_config/client_channel.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c index 852e45e35f7..566d3d5ce49 100644 --- a/src/core/ext/client_config/client_channel.c +++ b/src/core/ext/client_config/client_channel.c @@ -187,8 +187,7 @@ static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *state_error = GRPC_ERROR_CREATE("No load balancing policy"); if (chand->resolver_result != NULL) { - lb_policy = - grpc_resolver_result_get_lb_policy(chand->resolver_result); + lb_policy = grpc_resolver_result_get_lb_policy(chand->resolver_result); if (lb_policy != NULL) { GRPC_LB_POLICY_REF(lb_policy, "channel"); GRPC_LB_POLICY_REF(lb_policy, "config_change"); @@ -233,8 +232,7 @@ static void cc_on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, watch_lb_policy(exec_ctx, chand, lb_policy, state); } GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, chand->resolver, - &chand->resolver_result, + grpc_resolver_next(exec_ctx, chand->resolver, &chand->resolver_result, &chand->on_resolver_result_changed); gpr_mu_unlock(&chand->mu); } else { @@ -411,8 +409,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp, if (chand->resolver != NULL && !chand->started_resolving) { chand->started_resolving = 1; GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); - grpc_resolver_next(exec_ctx, chand->resolver, - &chand->resolver_result, + grpc_resolver_next(exec_ctx, chand->resolver, &chand->resolver_result, &chand->on_resolver_result_changed); } if (chand->resolver != NULL) { @@ -548,8 +545,7 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state( if (!chand->started_resolving && chand->resolver != NULL) { GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver"); chand->started_resolving = 1; - grpc_resolver_next(exec_ctx, chand->resolver, - &chand->resolver_result, + grpc_resolver_next(exec_ctx, chand->resolver, &chand->resolver_result, &chand->on_resolver_result_changed); } } From 1edf65219eb47181ee9495deb4077c1d992d06c2 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 23 Aug 2016 12:35:40 -0700 Subject: [PATCH 3/3] Fix broken test. --- .../resolvers/dns_resolver_connectivity_test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/core/client_config/resolvers/dns_resolver_connectivity_test.c b/test/core/client_config/resolvers/dns_resolver_connectivity_test.c index 69c07d83f43..6a33525f629 100644 --- a/test/core/client_config/resolvers/dns_resolver_connectivity_test.c +++ b/test/core/client_config/resolvers/dns_resolver_connectivity_test.c @@ -127,26 +127,26 @@ int main(int argc, char **argv) { grpc_resolver *resolver = create_resolver("dns:test"); - grpc_client_config *config = (grpc_client_config *)1; + grpc_resolver_result *result = (grpc_resolver_result *)1; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_event ev1; gpr_event_init(&ev1); - grpc_resolver_next(&exec_ctx, resolver, &config, + grpc_resolver_next(&exec_ctx, resolver, &result, grpc_closure_create(on_done, &ev1)); grpc_exec_ctx_flush(&exec_ctx); GPR_ASSERT(wait_loop(5, &ev1)); - GPR_ASSERT(config == NULL); + GPR_ASSERT(result == NULL); gpr_event ev2; gpr_event_init(&ev2); - grpc_resolver_next(&exec_ctx, resolver, &config, + grpc_resolver_next(&exec_ctx, resolver, &result, grpc_closure_create(on_done, &ev2)); grpc_exec_ctx_flush(&exec_ctx); GPR_ASSERT(wait_loop(30, &ev2)); - GPR_ASSERT(config != NULL); + GPR_ASSERT(result != NULL); - grpc_client_config_unref(&exec_ctx, config); + grpc_resolver_result_unref(&exec_ctx, result); GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test"); grpc_exec_ctx_finish(&exec_ctx);