grpc 1.21.0 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +422 -62
  3. data/include/grpc/grpc_security.h +61 -5
  4. data/include/grpc/grpc_security_constants.h +1 -1
  5. data/include/grpc/impl/codegen/gpr_types.h +1 -1
  6. data/include/grpc/slice.h +2 -2
  7. data/src/core/ext/filters/client_channel/backup_poller.cc +2 -3
  8. data/src/core/ext/filters/client_channel/backup_poller.h +5 -2
  9. data/src/core/ext/filters/client_channel/client_channel.cc +260 -122
  10. data/src/core/ext/filters/client_channel/client_channel.h +0 -8
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +3 -84
  12. data/src/core/ext/filters/client_channel/client_channel_channelz.h +2 -28
  13. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +2 -8
  14. data/src/core/ext/filters/client_channel/health/health_check_client.cc +5 -4
  15. data/src/core/ext/filters/client_channel/lb_policy.cc +16 -2
  16. data/src/core/ext/filters/client_channel/lb_policy.h +92 -98
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +63 -87
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +6 -2
  19. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +35 -87
  20. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +18 -74
  21. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +167 -217
  22. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +216 -190
  23. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +6 -2
  24. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
  25. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +1 -1
  26. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  27. data/src/core/ext/filters/client_channel/resolver.h +1 -1
  28. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +6 -3
  29. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +0 -1
  30. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -0
  31. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +8 -8
  32. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +7 -7
  33. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +28 -64
  34. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +4 -12
  35. data/src/core/ext/filters/client_channel/server_address.cc +4 -6
  36. data/src/core/ext/filters/client_channel/server_address.h +1 -3
  37. data/src/core/ext/filters/client_channel/service_config.cc +20 -22
  38. data/src/core/ext/filters/client_channel/service_config.h +26 -28
  39. data/src/core/ext/filters/client_channel/subchannel.cc +261 -160
  40. data/src/core/ext/filters/client_channel/subchannel.h +97 -23
  41. data/src/core/ext/filters/client_channel/subchannel_interface.h +113 -0
  42. data/src/core/ext/filters/message_size/message_size_filter.cc +12 -12
  43. data/src/core/ext/filters/message_size/message_size_filter.h +2 -2
  44. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +50 -2
  45. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -2
  46. data/src/core/ext/transport/chttp2/transport/frame_data.cc +31 -36
  47. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +3 -2
  48. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +71 -52
  49. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +18 -3
  50. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +5 -12
  51. data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -1
  52. data/src/core/ext/transport/chttp2/transport/internal.h +3 -3
  53. data/src/core/ext/transport/chttp2/transport/parsing.cc +39 -57
  54. data/src/core/lib/channel/channelz.cc +136 -19
  55. data/src/core/lib/channel/channelz.h +36 -40
  56. data/src/core/lib/channel/channelz_registry.cc +74 -106
  57. data/src/core/lib/channel/channelz_registry.h +10 -28
  58. data/src/core/lib/channel/context.h +1 -1
  59. data/src/core/lib/channel/handshaker.cc +6 -0
  60. data/src/core/lib/compression/compression.cc +13 -8
  61. data/src/core/lib/compression/compression_internal.cc +14 -10
  62. data/src/core/lib/compression/compression_internal.h +1 -1
  63. data/src/core/lib/compression/stream_compression.cc +3 -2
  64. data/src/core/lib/compression/stream_compression.h +2 -2
  65. data/src/core/lib/compression/stream_compression_gzip.cc +9 -9
  66. data/src/core/lib/gpr/env.h +1 -1
  67. data/src/core/lib/gpr/string.cc +8 -1
  68. data/src/core/lib/gpr/string.h +6 -1
  69. data/src/core/lib/gprpp/fork.cc +1 -1
  70. data/src/core/lib/gprpp/fork.h +5 -1
  71. data/src/core/lib/gprpp/global_config.h +9 -0
  72. data/src/core/lib/gprpp/global_config_custom.h +1 -1
  73. data/src/core/lib/gprpp/inlined_vector.h +8 -0
  74. data/src/core/lib/gprpp/map.h +38 -21
  75. data/src/core/lib/gprpp/memory.h +2 -2
  76. data/src/core/lib/gprpp/orphanable.h +1 -1
  77. data/src/core/lib/gprpp/ref_counted.h +9 -4
  78. data/src/core/lib/http/httpcli.cc +3 -3
  79. data/src/core/lib/iomgr/buffer_list.h +1 -1
  80. data/src/core/lib/iomgr/call_combiner.cc +1 -1
  81. data/src/core/lib/iomgr/call_combiner.h +1 -1
  82. data/src/core/lib/iomgr/cfstream_handle.cc +3 -2
  83. data/src/core/lib/iomgr/cfstream_handle.h +4 -0
  84. data/src/core/lib/iomgr/error.cc +3 -3
  85. data/src/core/lib/iomgr/error.h +9 -3
  86. data/src/core/lib/iomgr/error_internal.h +1 -1
  87. data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -1
  88. data/src/core/lib/iomgr/ev_posix.cc +3 -3
  89. data/src/core/lib/iomgr/ev_posix.h +3 -2
  90. data/src/core/lib/iomgr/ev_windows.cc +2 -2
  91. data/src/core/lib/iomgr/iomgr.cc +4 -4
  92. data/src/core/lib/iomgr/lockfree_event.cc +1 -1
  93. data/src/core/lib/iomgr/port.h +5 -1
  94. data/src/core/lib/iomgr/tcp_posix.cc +1 -3
  95. data/src/core/lib/iomgr/tcp_server.cc +5 -0
  96. data/src/core/lib/iomgr/tcp_server.h +24 -0
  97. data/src/core/lib/iomgr/tcp_server_custom.cc +11 -9
  98. data/src/core/lib/iomgr/tcp_server_posix.cc +72 -11
  99. data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
  100. data/src/core/lib/iomgr/tcp_server_windows.cc +11 -9
  101. data/src/core/lib/iomgr/tcp_uv.cc +5 -6
  102. data/src/core/lib/iomgr/timer.h +2 -1
  103. data/src/core/lib/iomgr/udp_server.cc +2 -2
  104. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -1
  105. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -2
  106. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -2
  107. data/src/core/lib/security/security_connector/security_connector.h +1 -1
  108. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +1 -1
  109. data/src/core/lib/security/transport/auth_filters.h +3 -0
  110. data/src/core/lib/security/transport/client_auth_filter.cc +13 -0
  111. data/src/core/lib/security/transport/security_handshaker.cc +7 -7
  112. data/src/core/lib/slice/b64.h +2 -2
  113. data/src/core/lib/slice/slice.cc +82 -10
  114. data/src/core/lib/slice/slice_buffer.cc +49 -21
  115. data/src/core/lib/slice/slice_hash_table.h +2 -2
  116. data/src/core/lib/slice/slice_intern.cc +15 -16
  117. data/src/core/lib/slice/slice_internal.h +52 -0
  118. data/src/core/lib/slice/slice_string_helpers.cc +10 -1
  119. data/src/core/lib/slice/slice_string_helpers.h +3 -1
  120. data/src/core/lib/slice/slice_utils.h +50 -0
  121. data/src/core/lib/slice/slice_weak_hash_table.h +2 -2
  122. data/src/core/lib/surface/call.cc +14 -8
  123. data/src/core/lib/surface/channel.cc +89 -97
  124. data/src/core/lib/surface/channel.h +60 -6
  125. data/src/core/lib/surface/completion_queue.cc +49 -36
  126. data/src/core/lib/surface/completion_queue.h +2 -1
  127. data/src/core/lib/surface/server.cc +8 -8
  128. data/src/core/lib/surface/validate_metadata.cc +14 -8
  129. data/src/core/lib/surface/validate_metadata.h +13 -2
  130. data/src/core/lib/surface/version.cc +1 -1
  131. data/src/core/lib/transport/metadata.cc +56 -26
  132. data/src/core/lib/transport/metadata.h +91 -75
  133. data/src/core/lib/transport/static_metadata.cc +262 -176
  134. data/src/core/lib/transport/static_metadata.h +272 -180
  135. data/src/core/lib/transport/transport.cc +1 -1
  136. data/src/core/lib/transport/transport.h +8 -2
  137. data/src/core/tsi/alts/handshaker/alts_shared_resource.h +1 -1
  138. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  139. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +5 -2
  140. data/src/ruby/lib/grpc/version.rb +1 -1
  141. metadata +33 -31
@@ -67,8 +67,12 @@ xds_grpclb_request* xds_grpclb_request_create(const char* lb_service_name) {
67
67
  req->has_client_stats = false;
68
68
  req->has_initial_request = true;
69
69
  req->initial_request.has_name = true;
70
- strncpy(req->initial_request.name, lb_service_name,
71
- XDS_SERVICE_NAME_MAX_LENGTH);
70
+ // GCC warns (-Wstringop-truncation) because the destination
71
+ // buffer size is identical to max-size, leading to a potential
72
+ // char[] with no null terminator. nanopb can handle it fine,
73
+ // and parantheses around strncpy silence that compiler warning.
74
+ (strncpy(req->initial_request.name, lb_service_name,
75
+ XDS_SERVICE_NAME_MAX_LENGTH));
72
76
  return req;
73
77
  }
74
78
 
@@ -37,7 +37,7 @@ class LoadBalancingPolicyFactory {
37
37
  /// Caller does NOT take ownership of result.
38
38
  virtual const char* name() const GRPC_ABSTRACT;
39
39
 
40
- virtual RefCountedPtr<ParsedLoadBalancingConfig> ParseLoadBalancingConfig(
40
+ virtual RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
41
41
  const grpc_json* json, grpc_error** error) const GRPC_ABSTRACT;
42
42
 
43
43
  virtual ~LoadBalancingPolicyFactory() {}
@@ -176,7 +176,7 @@ grpc_json* ParseLoadBalancingConfigHelper(const grpc_json* lb_config_array,
176
176
  }
177
177
  } // namespace
178
178
 
179
- RefCountedPtr<ParsedLoadBalancingConfig>
179
+ RefCountedPtr<LoadBalancingPolicy::Config>
180
180
  LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(const grpc_json* json,
181
181
  grpc_error** error) {
182
182
  GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
@@ -56,7 +56,7 @@ class LoadBalancingPolicyRegistry {
56
56
 
57
57
  /// Returns a parsed object of the load balancing policy to be used from a
58
58
  /// LoadBalancingConfig array \a json.
59
- static RefCountedPtr<ParsedLoadBalancingConfig> ParseLoadBalancingConfig(
59
+ static RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
60
60
  const grpc_json* json, grpc_error** error);
61
61
  };
62
62
 
@@ -128,7 +128,7 @@ class Resolver : public InternallyRefCounted<Resolver> {
128
128
  GRPC_ABSTRACT_BASE_CLASS
129
129
 
130
130
  protected:
131
- GPRC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE
131
+ GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE
132
132
 
133
133
  /// Does NOT take ownership of the reference to \a combiner.
134
134
  // TODO(roth): Once we have a C++-like interface for combiners, this
@@ -473,10 +473,13 @@ static bool should_use_ares(const char* resolver_env) {
473
473
  }
474
474
  #endif /* GRPC_UV */
475
475
 
476
+ static bool g_use_ares_dns_resolver;
477
+
476
478
  void grpc_resolver_dns_ares_init() {
477
479
  grpc_core::UniquePtr<char> resolver =
478
480
  GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
479
481
  if (should_use_ares(resolver.get())) {
482
+ g_use_ares_dns_resolver = true;
480
483
  gpr_log(GPR_DEBUG, "Using ares dns resolver");
481
484
  address_sorting_init();
482
485
  grpc_error* error = grpc_ares_init();
@@ -491,13 +494,13 @@ void grpc_resolver_dns_ares_init() {
491
494
  grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
492
495
  grpc_core::UniquePtr<grpc_core::ResolverFactory>(
493
496
  grpc_core::New<grpc_core::AresDnsResolverFactory>()));
497
+ } else {
498
+ g_use_ares_dns_resolver = false;
494
499
  }
495
500
  }
496
501
 
497
502
  void grpc_resolver_dns_ares_shutdown() {
498
- grpc_core::UniquePtr<char> resolver =
499
- GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
500
- if (should_use_ares(resolver.get())) {
503
+ if (g_use_ares_dns_resolver) {
501
504
  address_sorting_shutdown();
502
505
  grpc_ares_cleanup();
503
506
  }
@@ -231,7 +231,6 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
231
231
 
232
232
  ares_ssize_t TrySendWriteBufSyncNonBlocking() {
233
233
  GPR_ASSERT(write_state_ == WRITE_IDLE);
234
- ares_ssize_t total_sent;
235
234
  DWORD bytes_sent = 0;
236
235
  if (SendWriteBuf(&bytes_sent, nullptr) != 0) {
237
236
  int wsa_last_error = WSAGetLastError();
@@ -175,11 +175,13 @@ void FakeResolverResponseGenerator::SetResponseLocked(void* arg,
175
175
  resolver->next_result_ = std::move(closure_arg->result);
176
176
  resolver->has_next_result_ = true;
177
177
  resolver->MaybeSendResultLocked();
178
+ closure_arg->generator->Unref();
178
179
  Delete(closure_arg);
179
180
  }
180
181
 
181
182
  void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) {
182
183
  if (resolver_ != nullptr) {
184
+ Ref().release(); // ref to be held by closure
183
185
  SetResponseClosureArg* closure_arg = New<SetResponseClosureArg>();
184
186
  closure_arg->generator = this;
185
187
  closure_arg->result = std::move(result);
@@ -92,11 +92,11 @@ bool ParseDuration(grpc_json* field, grpc_millis* duration) {
92
92
  return true;
93
93
  }
94
94
 
95
- UniquePtr<ClientChannelMethodParsedObject::RetryPolicy> ParseRetryPolicy(
95
+ UniquePtr<ClientChannelMethodParsedConfig::RetryPolicy> ParseRetryPolicy(
96
96
  grpc_json* field, grpc_error** error) {
97
97
  GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
98
98
  auto retry_policy =
99
- MakeUnique<ClientChannelMethodParsedObject::RetryPolicy>();
99
+ MakeUnique<ClientChannelMethodParsedConfig::RetryPolicy>();
100
100
  if (field->type != GRPC_JSON_OBJECT) {
101
101
  *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
102
102
  "field:retryPolicy error:should be of type object");
@@ -268,9 +268,9 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
268
268
  grpc_error** error) {
269
269
  GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
270
270
  InlinedVector<grpc_error*, 4> error_list;
271
- RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config;
271
+ RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config;
272
272
  UniquePtr<char> lb_policy_name;
273
- Optional<ClientChannelGlobalParsedObject::RetryThrottling> retry_throttling;
273
+ Optional<ClientChannelGlobalParsedConfig::RetryThrottling> retry_throttling;
274
274
  const char* health_check_service_name = nullptr;
275
275
  for (grpc_json* field = json->child; field != nullptr; field = field->next) {
276
276
  if (field->key == nullptr) {
@@ -409,7 +409,7 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
409
409
  }
410
410
  }
411
411
  }
412
- ClientChannelGlobalParsedObject::RetryThrottling data;
412
+ ClientChannelGlobalParsedConfig::RetryThrottling data;
413
413
  if (!max_milli_tokens.has_value()) {
414
414
  error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
415
415
  "field:retryThrottling field:maxTokens error:Not found"));
@@ -440,7 +440,7 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
440
440
  &error_list);
441
441
  if (*error == GRPC_ERROR_NONE) {
442
442
  return UniquePtr<ServiceConfig::ParsedConfig>(
443
- New<ClientChannelGlobalParsedObject>(
443
+ New<ClientChannelGlobalParsedConfig>(
444
444
  std::move(parsed_lb_config), std::move(lb_policy_name),
445
445
  retry_throttling, health_check_service_name));
446
446
  }
@@ -454,7 +454,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json,
454
454
  InlinedVector<grpc_error*, 4> error_list;
455
455
  Optional<bool> wait_for_ready;
456
456
  grpc_millis timeout = 0;
457
- UniquePtr<ClientChannelMethodParsedObject::RetryPolicy> retry_policy;
457
+ UniquePtr<ClientChannelMethodParsedConfig::RetryPolicy> retry_policy;
458
458
  for (grpc_json* field = json->child; field != nullptr; field = field->next) {
459
459
  if (field->key == nullptr) continue;
460
460
  if (strcmp(field->key, "waitForReady") == 0) {
@@ -494,7 +494,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json,
494
494
  *error = GRPC_ERROR_CREATE_FROM_VECTOR("Client channel parser", &error_list);
495
495
  if (*error == GRPC_ERROR_NONE) {
496
496
  return UniquePtr<ServiceConfig::ParsedConfig>(
497
- New<ClientChannelMethodParsedObject>(timeout, wait_for_ready,
497
+ New<ClientChannelMethodParsedConfig>(timeout, wait_for_ready,
498
498
  std::move(retry_policy)));
499
499
  }
500
500
  return nullptr;
@@ -37,15 +37,15 @@
37
37
  namespace grpc_core {
38
38
  namespace internal {
39
39
 
40
- class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig {
40
+ class ClientChannelGlobalParsedConfig : public ServiceConfig::ParsedConfig {
41
41
  public:
42
42
  struct RetryThrottling {
43
43
  intptr_t max_milli_tokens = 0;
44
44
  intptr_t milli_token_ratio = 0;
45
45
  };
46
46
 
47
- ClientChannelGlobalParsedObject(
48
- RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config,
47
+ ClientChannelGlobalParsedConfig(
48
+ RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config,
49
49
  UniquePtr<char> parsed_deprecated_lb_policy,
50
50
  const Optional<RetryThrottling>& retry_throttling,
51
51
  const char* health_check_service_name)
@@ -58,7 +58,7 @@ class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig {
58
58
  return retry_throttling_;
59
59
  }
60
60
 
61
- RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config() const {
61
+ RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config() const {
62
62
  return parsed_lb_config_;
63
63
  }
64
64
 
@@ -71,13 +71,13 @@ class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig {
71
71
  }
72
72
 
73
73
  private:
74
- RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config_;
74
+ RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config_;
75
75
  UniquePtr<char> parsed_deprecated_lb_policy_;
76
76
  Optional<RetryThrottling> retry_throttling_;
77
77
  const char* health_check_service_name_;
78
78
  };
79
79
 
80
- class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig {
80
+ class ClientChannelMethodParsedConfig : public ServiceConfig::ParsedConfig {
81
81
  public:
82
82
  struct RetryPolicy {
83
83
  int max_attempts = 0;
@@ -87,7 +87,7 @@ class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig {
87
87
  StatusCodeSet retryable_status_codes;
88
88
  };
89
89
 
90
- ClientChannelMethodParsedObject(grpc_millis timeout,
90
+ ClientChannelMethodParsedConfig(grpc_millis timeout,
91
91
  const Optional<bool>& wait_for_ready,
92
92
  UniquePtr<RetryPolicy> retry_policy)
93
93
  : timeout_(timeout),
@@ -106,7 +106,8 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
106
106
  RefCountedPtr<ResolvingLoadBalancingPolicy> parent)
107
107
  : parent_(std::move(parent)) {}
108
108
 
109
- Subchannel* CreateSubchannel(const grpc_channel_args& args) override {
109
+ RefCountedPtr<SubchannelInterface> CreateSubchannel(
110
+ const grpc_channel_args& args) override {
110
111
  if (parent_->resolver_ == nullptr) return nullptr; // Shutting down.
111
112
  if (!CalledByCurrentChild() && !CalledByPendingChild()) return nullptr;
112
113
  return parent_->channel_control_helper()->CreateSubchannel(args);
@@ -136,7 +137,6 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
136
137
  grpc_pollset_set_del_pollset_set(
137
138
  parent_->lb_policy_->interested_parties(),
138
139
  parent_->interested_parties());
139
- MutexLock lock(&parent_->lb_policy_mu_);
140
140
  parent_->lb_policy_ = std::move(parent_->pending_lb_policy_);
141
141
  } else if (!CalledByCurrentChild()) {
142
142
  // This request is from an outdated child, so ignore it.
@@ -184,7 +184,7 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
184
184
  ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy(
185
185
  Args args, TraceFlag* tracer, UniquePtr<char> target_uri,
186
186
  UniquePtr<char> child_policy_name,
187
- RefCountedPtr<ParsedLoadBalancingConfig> child_lb_config,
187
+ RefCountedPtr<LoadBalancingPolicy::Config> child_lb_config,
188
188
  grpc_error** error)
189
189
  : LoadBalancingPolicy(std::move(args)),
190
190
  tracer_(tracer),
@@ -213,7 +213,6 @@ ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy(
213
213
  process_resolver_result_(process_resolver_result),
214
214
  process_resolver_result_user_data_(process_resolver_result_user_data) {
215
215
  GPR_ASSERT(process_resolver_result != nullptr);
216
- gpr_mu_init(&lb_policy_mu_);
217
216
  *error = Init(*args.args);
218
217
  }
219
218
 
@@ -233,13 +232,11 @@ grpc_error* ResolvingLoadBalancingPolicy::Init(const grpc_channel_args& args) {
233
232
  ResolvingLoadBalancingPolicy::~ResolvingLoadBalancingPolicy() {
234
233
  GPR_ASSERT(resolver_ == nullptr);
235
234
  GPR_ASSERT(lb_policy_ == nullptr);
236
- gpr_mu_destroy(&lb_policy_mu_);
237
235
  }
238
236
 
239
237
  void ResolvingLoadBalancingPolicy::ShutdownLocked() {
240
238
  if (resolver_ != nullptr) {
241
239
  resolver_.reset();
242
- MutexLock lock(&lb_policy_mu_);
243
240
  if (lb_policy_ != nullptr) {
244
241
  if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
245
242
  gpr_log(GPR_INFO, "resolving_lb=%p: shutting down lb_policy=%p", this,
@@ -281,22 +278,6 @@ void ResolvingLoadBalancingPolicy::ResetBackoffLocked() {
281
278
  if (pending_lb_policy_ != nullptr) pending_lb_policy_->ResetBackoffLocked();
282
279
  }
283
280
 
284
- void ResolvingLoadBalancingPolicy::FillChildRefsForChannelz(
285
- channelz::ChildRefsList* child_subchannels,
286
- channelz::ChildRefsList* child_channels) {
287
- // Delegate to the lb_policy_ to fill the children subchannels.
288
- // This must be done holding lb_policy_mu_, since this method does not
289
- // run in the combiner.
290
- MutexLock lock(&lb_policy_mu_);
291
- if (lb_policy_ != nullptr) {
292
- lb_policy_->FillChildRefsForChannelz(child_subchannels, child_channels);
293
- }
294
- if (pending_lb_policy_ != nullptr) {
295
- pending_lb_policy_->FillChildRefsForChannelz(child_subchannels,
296
- child_channels);
297
- }
298
- }
299
-
300
281
  void ResolvingLoadBalancingPolicy::StartResolvingLocked() {
301
282
  if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
302
283
  gpr_log(GPR_INFO, "resolving_lb=%p: starting name resolution", this);
@@ -333,7 +314,7 @@ void ResolvingLoadBalancingPolicy::OnResolverError(grpc_error* error) {
333
314
 
334
315
  void ResolvingLoadBalancingPolicy::CreateOrUpdateLbPolicyLocked(
335
316
  const char* lb_policy_name,
336
- RefCountedPtr<ParsedLoadBalancingConfig> lb_policy_config,
317
+ RefCountedPtr<LoadBalancingPolicy::Config> lb_policy_config,
337
318
  Resolver::Result result, TraceStringVector* trace_strings) {
338
319
  // If the child policy name changes, we need to create a new child
339
320
  // policy. When this happens, we leave child_policy_ as-is and store
@@ -402,13 +383,9 @@ void ResolvingLoadBalancingPolicy::CreateOrUpdateLbPolicyLocked(
402
383
  gpr_log(GPR_INFO, "resolving_lb=%p: Creating new %schild policy %s", this,
403
384
  lb_policy_ == nullptr ? "" : "pending ", lb_policy_name);
404
385
  }
405
- auto new_policy =
406
- CreateLbPolicyLocked(lb_policy_name, *result.args, trace_strings);
407
386
  auto& lb_policy = lb_policy_ == nullptr ? lb_policy_ : pending_lb_policy_;
408
- {
409
- MutexLock lock(&lb_policy_mu_);
410
- lb_policy = std::move(new_policy);
411
- }
387
+ lb_policy =
388
+ CreateLbPolicyLocked(lb_policy_name, *result.args, trace_strings);
412
389
  policy_to_update = lb_policy.get();
413
390
  } else {
414
391
  // Cases 2a and 3a: update an existing policy.
@@ -450,11 +427,9 @@ ResolvingLoadBalancingPolicy::CreateLbPolicyLocked(
450
427
  lb_policy_name, std::move(lb_policy_args));
451
428
  if (GPR_UNLIKELY(lb_policy == nullptr)) {
452
429
  gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name);
453
- if (channelz_node() != nullptr) {
454
- char* str;
455
- gpr_asprintf(&str, "Could not create LB policy \"%s\"", lb_policy_name);
456
- trace_strings->push_back(str);
457
- }
430
+ char* str;
431
+ gpr_asprintf(&str, "Could not create LB policy \"%s\"", lb_policy_name);
432
+ trace_strings->push_back(str);
458
433
  return nullptr;
459
434
  }
460
435
  helper->set_child(lb_policy.get());
@@ -462,16 +437,9 @@ ResolvingLoadBalancingPolicy::CreateLbPolicyLocked(
462
437
  gpr_log(GPR_INFO, "resolving_lb=%p: created new LB policy \"%s\" (%p)",
463
438
  this, lb_policy_name, lb_policy.get());
464
439
  }
465
- if (channelz_node() != nullptr) {
466
- char* str;
467
- gpr_asprintf(&str, "Created new LB policy \"%s\"", lb_policy_name);
468
- trace_strings->push_back(str);
469
- }
470
- // Propagate channelz node.
471
- auto* channelz = channelz_node();
472
- if (channelz != nullptr) {
473
- lb_policy->set_channelz_node(channelz->Ref());
474
- }
440
+ char* str;
441
+ gpr_asprintf(&str, "Created new LB policy \"%s\"", lb_policy_name);
442
+ trace_strings->push_back(str);
475
443
  grpc_pollset_set_add_pollset_set(lb_policy->interested_parties(),
476
444
  interested_parties());
477
445
  return lb_policy;
@@ -501,11 +469,10 @@ void ResolvingLoadBalancingPolicy::ConcatenateAndAddChannelTraceLocked(
501
469
  is_first = false;
502
470
  gpr_strvec_add(&v, (*trace_strings)[i]);
503
471
  }
504
- char* flat;
505
- size_t flat_len = 0;
506
- flat = gpr_strvec_flatten(&v, &flat_len);
507
- channelz_node()->AddTraceEvent(channelz::ChannelTrace::Severity::Info,
508
- grpc_slice_new(flat, flat_len, gpr_free));
472
+ size_t len = 0;
473
+ UniquePtr<char> message(gpr_strvec_flatten(&v, &len));
474
+ channel_control_helper()->AddTraceEvent(ChannelControlHelper::TRACE_INFO,
475
+ message.get());
509
476
  gpr_strvec_destroy(&v);
510
477
  }
511
478
  }
@@ -530,7 +497,7 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked(
530
497
  const bool resolution_contains_addresses = result.addresses.size() > 0;
531
498
  // Process the resolver result.
532
499
  const char* lb_policy_name = nullptr;
533
- RefCountedPtr<ParsedLoadBalancingConfig> lb_policy_config;
500
+ RefCountedPtr<LoadBalancingPolicy::Config> lb_policy_config;
534
501
  bool service_config_changed = false;
535
502
  char* service_config_error_string = nullptr;
536
503
  if (process_resolver_result_ != nullptr) {
@@ -559,21 +526,18 @@ void ResolvingLoadBalancingPolicy::OnResolverResultChangedLocked(
559
526
  std::move(result), &trace_strings);
560
527
  }
561
528
  // Add channel trace event.
562
- if (channelz_node() != nullptr) {
563
- if (service_config_changed) {
564
- // TODO(ncteisen): might be worth somehow including a snippet of the
565
- // config in the trace, at the risk of bloating the trace logs.
566
- trace_strings.push_back(gpr_strdup("Service config changed"));
567
- }
568
- if (service_config_error_string != nullptr) {
569
- trace_strings.push_back(service_config_error_string);
570
- service_config_error_string = nullptr;
571
- }
572
- MaybeAddTraceMessagesForAddressChangesLocked(resolution_contains_addresses,
573
- &trace_strings);
574
- ConcatenateAndAddChannelTraceLocked(&trace_strings);
529
+ if (service_config_changed) {
530
+ // TODO(ncteisen): might be worth somehow including a snippet of the
531
+ // config in the trace, at the risk of bloating the trace logs.
532
+ trace_strings.push_back(gpr_strdup("Service config changed"));
533
+ }
534
+ if (service_config_error_string != nullptr) {
535
+ trace_strings.push_back(service_config_error_string);
536
+ service_config_error_string = nullptr;
575
537
  }
576
- gpr_free(service_config_error_string);
538
+ MaybeAddTraceMessagesForAddressChangesLocked(resolution_contains_addresses,
539
+ &trace_strings);
540
+ ConcatenateAndAddChannelTraceLocked(&trace_strings);
577
541
  }
578
542
 
579
543
  } // namespace grpc_core
@@ -21,7 +21,6 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
- #include "src/core/ext/filters/client_channel/client_channel_channelz.h"
25
24
  #include "src/core/ext/filters/client_channel/lb_policy.h"
26
25
  #include "src/core/ext/filters/client_channel/lb_policy_factory.h"
27
26
  #include "src/core/ext/filters/client_channel/resolver.h"
@@ -57,7 +56,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
57
56
  ResolvingLoadBalancingPolicy(
58
57
  Args args, TraceFlag* tracer, UniquePtr<char> target_uri,
59
58
  UniquePtr<char> child_policy_name,
60
- RefCountedPtr<ParsedLoadBalancingConfig> child_lb_config,
59
+ RefCountedPtr<LoadBalancingPolicy::Config> child_lb_config,
61
60
  grpc_error** error);
62
61
 
63
62
  // Private ctor, to be used by client_channel only!
@@ -71,7 +70,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
71
70
  typedef bool (*ProcessResolverResultCallback)(
72
71
  void* user_data, const Resolver::Result& result,
73
72
  const char** lb_policy_name,
74
- RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config,
73
+ RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config,
75
74
  grpc_error** service_config_error);
76
75
  // If error is set when this returns, then construction failed, and
77
76
  // the caller may not use the new object.
@@ -91,10 +90,6 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
91
90
 
92
91
  void ResetBackoffLocked() override;
93
92
 
94
- void FillChildRefsForChannelz(
95
- channelz::ChildRefsList* child_subchannels,
96
- channelz::ChildRefsList* child_channels) override;
97
-
98
93
  private:
99
94
  using TraceStringVector = InlinedVector<char*, 3>;
100
95
 
@@ -110,7 +105,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
110
105
  void OnResolverError(grpc_error* error);
111
106
  void CreateOrUpdateLbPolicyLocked(
112
107
  const char* lb_policy_name,
113
- RefCountedPtr<ParsedLoadBalancingConfig> lb_policy_config,
108
+ RefCountedPtr<LoadBalancingPolicy::Config> lb_policy_config,
114
109
  Resolver::Result result, TraceStringVector* trace_strings);
115
110
  OrphanablePtr<LoadBalancingPolicy> CreateLbPolicyLocked(
116
111
  const char* lb_policy_name, const grpc_channel_args& args,
@@ -127,7 +122,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
127
122
  ProcessResolverResultCallback process_resolver_result_ = nullptr;
128
123
  void* process_resolver_result_user_data_ = nullptr;
129
124
  UniquePtr<char> child_policy_name_;
130
- RefCountedPtr<ParsedLoadBalancingConfig> child_lb_config_;
125
+ RefCountedPtr<LoadBalancingPolicy::Config> child_lb_config_;
131
126
 
132
127
  // Resolver and associated state.
133
128
  OrphanablePtr<Resolver> resolver_;
@@ -137,9 +132,6 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
137
132
  // Child LB policy.
138
133
  OrphanablePtr<LoadBalancingPolicy> lb_policy_;
139
134
  OrphanablePtr<LoadBalancingPolicy> pending_lb_policy_;
140
- // Lock held when modifying the value of child_policy_ or
141
- // pending_child_policy_.
142
- gpr_mu lb_policy_mu_;
143
135
  };
144
136
 
145
137
  } // namespace grpc_core