grpc 1.39.0.pre1 → 1.40.0.pre1

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 (168) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +34 -18
  3. data/include/grpc/event_engine/event_engine.h +10 -14
  4. data/include/grpc/event_engine/slice_allocator.h +8 -33
  5. data/include/grpc/impl/codegen/grpc_types.h +18 -8
  6. data/include/grpc/impl/codegen/port_platform.h +24 -0
  7. data/src/core/ext/filters/client_channel/client_channel.cc +413 -247
  8. data/src/core/ext/filters/client_channel/client_channel.h +42 -18
  9. data/src/core/ext/filters/client_channel/config_selector.h +19 -6
  10. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +7 -8
  11. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +12 -21
  12. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +3 -5
  13. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +17 -38
  14. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -15
  15. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -6
  16. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +8 -12
  17. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -22
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -9
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +5 -8
  20. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -15
  21. data/src/core/ext/filters/client_channel/lb_policy.h +70 -46
  22. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +101 -73
  23. data/src/core/ext/filters/client_channel/retry_filter.cc +392 -243
  24. data/src/core/ext/filters/client_channel/retry_service_config.cc +36 -26
  25. data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
  26. data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
  27. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +0 -6
  28. data/src/core/ext/filters/http/client/http_client_filter.cc +5 -2
  29. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +5 -1
  30. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
  31. data/src/core/{lib/event_engine/slice_allocator.cc → ext/transport/chttp2/transport/chttp2_slice_allocator.cc} +15 -38
  32. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
  33. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -6
  34. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
  35. data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
  36. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +8 -8
  37. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +5 -5
  38. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +639 -752
  39. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +190 -69
  40. data/src/core/ext/transport/chttp2/transport/internal.h +1 -1
  41. data/src/core/ext/transport/chttp2/transport/parsing.cc +70 -54
  42. data/src/core/ext/transport/chttp2/transport/varint.cc +6 -4
  43. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +56 -35
  44. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +180 -76
  45. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -27
  46. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +97 -48
  47. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -9
  48. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +67 -7
  49. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +66 -9
  50. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +227 -0
  51. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +46 -0
  52. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +121 -0
  53. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -0
  54. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +35 -0
  55. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +90 -0
  56. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +32 -24
  57. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -73
  58. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +4 -2
  59. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +15 -0
  60. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +48 -0
  61. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +171 -0
  62. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +8 -6
  63. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +27 -19
  64. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +1 -0
  65. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -7
  66. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +57 -0
  67. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +29 -17
  68. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +72 -0
  69. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +3 -2
  70. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +4 -0
  71. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -5
  72. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +15 -11
  73. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +85 -43
  74. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +274 -91
  75. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +11 -8
  76. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +30 -13
  77. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +33 -5
  78. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +115 -0
  79. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +60 -0
  80. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +181 -0
  81. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +1 -0
  82. data/src/core/ext/upb-generated/validate/validate.upb.c +82 -66
  83. data/src/core/ext/upb-generated/validate/validate.upb.h +220 -124
  84. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +15 -7
  85. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +53 -52
  86. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +318 -277
  87. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +5 -0
  88. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +437 -410
  89. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +198 -170
  90. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
  91. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +9 -8
  92. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +219 -163
  93. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +15 -0
  94. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +59 -0
  95. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.h +40 -0
  96. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +29 -25
  97. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +52 -0
  98. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.h +35 -0
  99. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +135 -125
  100. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
  101. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +131 -123
  102. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +90 -0
  103. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.h +35 -0
  104. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +32 -24
  105. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +69 -55
  106. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
  107. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +684 -664
  108. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
  109. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +13 -10
  110. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +13 -10
  111. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +441 -375
  112. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +10 -0
  113. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +122 -114
  114. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +1 -1
  115. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +112 -79
  116. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +5 -0
  117. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +64 -0
  118. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.h +50 -0
  119. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +35 -32
  120. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +4 -4
  121. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +182 -160
  122. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  123. data/src/core/ext/xds/xds_api.cc +320 -121
  124. data/src/core/ext/xds/xds_api.h +31 -2
  125. data/src/core/ext/xds/xds_bootstrap.cc +4 -1
  126. data/src/core/ext/xds/xds_client.cc +66 -43
  127. data/src/core/ext/xds/xds_client.h +0 -4
  128. data/src/core/ext/xds/xds_http_filters.cc +3 -2
  129. data/src/core/ext/xds/xds_http_filters.h +3 -0
  130. data/src/core/lib/channel/call_tracer.h +85 -0
  131. data/src/core/lib/channel/channel_stack.h +1 -1
  132. data/src/core/lib/channel/context.h +3 -0
  133. data/src/core/lib/channel/status_util.h +4 -0
  134. data/src/core/lib/compression/stream_compression.h +1 -1
  135. data/src/core/lib/compression/stream_compression_gzip.h +1 -1
  136. data/src/core/lib/compression/stream_compression_identity.h +1 -1
  137. data/src/core/lib/debug/stats.h +1 -1
  138. data/src/core/lib/gpr/murmur_hash.cc +4 -2
  139. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  140. data/src/core/lib/gprpp/orphanable.h +3 -3
  141. data/src/core/lib/gprpp/sync.h +2 -30
  142. data/src/core/lib/iomgr/buffer_list.cc +1 -1
  143. data/src/core/lib/iomgr/ev_apple.h +1 -1
  144. data/src/core/lib/iomgr/event_engine/endpoint.cc +6 -8
  145. data/src/core/lib/iomgr/event_engine/tcp.cc +30 -10
  146. data/src/core/lib/iomgr/python_util.h +1 -1
  147. data/src/core/lib/iomgr/resource_quota.cc +2 -0
  148. data/src/core/lib/iomgr/tcp_client_windows.cc +2 -0
  149. data/src/core/lib/iomgr/tcp_server_posix.cc +1 -0
  150. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  151. data/src/core/lib/json/json_reader.cc +1 -2
  152. data/src/core/lib/matchers/matchers.cc +8 -20
  153. data/src/core/lib/matchers/matchers.h +2 -1
  154. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +49 -0
  155. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -0
  156. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -18
  157. data/src/core/lib/security/transport/security_handshaker.cc +12 -4
  158. data/src/core/lib/security/transport/server_auth_filter.cc +0 -7
  159. data/src/core/lib/slice/slice_internal.h +1 -0
  160. data/src/core/lib/surface/call.cc +5 -6
  161. data/src/core/lib/surface/server.cc +3 -1
  162. data/src/core/lib/surface/server.h +3 -3
  163. data/src/core/lib/surface/version.cc +2 -4
  164. data/src/ruby/ext/grpc/extconf.rb +1 -1
  165. data/src/ruby/lib/grpc/version.rb +1 -1
  166. data/third_party/xxhash/xxhash.h +77 -195
  167. metadata +57 -40
  168. data/src/core/lib/gpr/arena.h +0 -47
@@ -159,9 +159,9 @@ RetryServiceConfigParser::ParseGlobalParams(const grpc_channel_args* /*args*/,
159
159
  namespace {
160
160
 
161
161
  grpc_error_handle ParseRetryPolicy(
162
- const Json& json, int* max_attempts, grpc_millis* initial_backoff,
163
- grpc_millis* max_backoff, float* backoff_multiplier,
164
- StatusCodeSet* retryable_status_codes,
162
+ const grpc_channel_args* args, const Json& json, int* max_attempts,
163
+ grpc_millis* initial_backoff, grpc_millis* max_backoff,
164
+ float* backoff_multiplier, StatusCodeSet* retryable_status_codes,
165
165
  absl::optional<grpc_millis>* per_attempt_recv_timeout) {
166
166
  if (json.type() != Json::Type::OBJECT) {
167
167
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -251,28 +251,38 @@ grpc_error_handle ParseRetryPolicy(
251
251
  }
252
252
  }
253
253
  // Parse perAttemptRecvTimeout.
254
- it = json.object_value().find("perAttemptRecvTimeout");
255
- if (it != json.object_value().end()) {
256
- grpc_millis per_attempt_recv_timeout_value;
257
- if (!ParseDurationFromJson(it->second, &per_attempt_recv_timeout_value)) {
258
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
259
- "field:perAttemptRecvTimeout error:type must be STRING of the "
260
- "form given by google.proto.Duration."));
261
- } else {
262
- *per_attempt_recv_timeout = per_attempt_recv_timeout_value;
263
- // TODO(roth): As part of implementing hedging, relax this check such
264
- // that we allow a value of 0 if a hedging policy is specified.
265
- if (per_attempt_recv_timeout_value == 0) {
254
+ if (grpc_channel_args_find_bool(args, GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING,
255
+ false)) {
256
+ it = json.object_value().find("perAttemptRecvTimeout");
257
+ if (it != json.object_value().end()) {
258
+ grpc_millis per_attempt_recv_timeout_value;
259
+ if (!ParseDurationFromJson(it->second, &per_attempt_recv_timeout_value)) {
266
260
  error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
267
- "field:perAttemptRecvTimeout error:must be greater than 0"));
261
+ "field:perAttemptRecvTimeout error:type must be STRING of the "
262
+ "form given by google.proto.Duration."));
263
+ } else {
264
+ *per_attempt_recv_timeout = per_attempt_recv_timeout_value;
265
+ // TODO(roth): As part of implementing hedging, relax this check such
266
+ // that we allow a value of 0 if a hedging policy is specified.
267
+ if (per_attempt_recv_timeout_value == 0) {
268
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
269
+ "field:perAttemptRecvTimeout error:must be greater than 0"));
270
+ }
268
271
  }
272
+ } else if (retryable_status_codes->Empty()) {
273
+ // If perAttemptRecvTimeout not present, retryableStatusCodes must be
274
+ // non-empty.
275
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
276
+ "field:retryableStatusCodes error:must be non-empty if "
277
+ "perAttemptRecvTimeout not present"));
278
+ }
279
+ } else {
280
+ // Hedging not enabled, so the error message for
281
+ // retryableStatusCodes unset should be different.
282
+ if (retryable_status_codes->Empty()) {
283
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
284
+ "field:retryableStatusCodes error:must be non-empty"));
269
285
  }
270
- } else if (retryable_status_codes->Empty()) {
271
- // If perAttemptRecvTimeout not present, retryableStatusCodes must be
272
- // non-empty.
273
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
274
- "field:retryableStatusCodes error:must be non-empty if "
275
- "perAttemptRecvTimeout not present"));
276
286
  }
277
287
  return GRPC_ERROR_CREATE_FROM_VECTOR("retryPolicy", &error_list);
278
288
  }
@@ -280,9 +290,9 @@ grpc_error_handle ParseRetryPolicy(
280
290
  } // namespace
281
291
 
282
292
  std::unique_ptr<ServiceConfigParser::ParsedConfig>
283
- RetryServiceConfigParser::ParsePerMethodParams(
284
- const grpc_channel_args* /*args*/, const Json& json,
285
- grpc_error_handle* error) {
293
+ RetryServiceConfigParser::ParsePerMethodParams(const grpc_channel_args* args,
294
+ const Json& json,
295
+ grpc_error_handle* error) {
286
296
  GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
287
297
  // Parse retry policy.
288
298
  auto it = json.object_value().find("retryPolicy");
@@ -293,7 +303,7 @@ RetryServiceConfigParser::ParsePerMethodParams(
293
303
  float backoff_multiplier = 0;
294
304
  StatusCodeSet retryable_status_codes;
295
305
  absl::optional<grpc_millis> per_attempt_recv_timeout;
296
- *error = ParseRetryPolicy(it->second, &max_attempts, &initial_backoff,
306
+ *error = ParseRetryPolicy(args, it->second, &max_attempts, &initial_backoff,
297
307
  &max_backoff, &backoff_multiplier,
298
308
  &retryable_status_codes, &per_attempt_recv_timeout);
299
309
  if (*error != GRPC_ERROR_NONE) return nullptr;
@@ -83,7 +83,7 @@ class RetryServiceConfigParser : public ServiceConfigParser::Parser {
83
83
  grpc_error_handle* error) override;
84
84
 
85
85
  std::unique_ptr<ServiceConfigParser::ParsedConfig> ParsePerMethodParams(
86
- const grpc_channel_args* /*args*/, const Json& json,
86
+ const grpc_channel_args* args, const Json& json,
87
87
  grpc_error_handle* error) override;
88
88
 
89
89
  static size_t ParserIndex();
@@ -23,6 +23,7 @@
23
23
 
24
24
  #include "absl/strings/string_view.h"
25
25
 
26
+ #include "src/core/ext/filters/client_channel/config_selector.h"
26
27
  #include "src/core/ext/filters/client_channel/service_config.h"
27
28
  #include "src/core/ext/filters/client_channel/service_config_parser.h"
28
29
  #include "src/core/lib/channel/context.h"
@@ -39,11 +40,13 @@ class ServiceConfigCallData {
39
40
  ServiceConfigCallData(
40
41
  RefCountedPtr<ServiceConfig> service_config,
41
42
  const ServiceConfigParser::ParsedConfigVector* method_configs,
42
- std::map<const char*, absl::string_view> call_attributes,
43
+ ConfigSelector::CallAttributes call_attributes,
44
+ ConfigSelector::CallDispatchController* call_dispatch_controller,
43
45
  grpc_call_context_element* call_context)
44
46
  : service_config_(std::move(service_config)),
45
47
  method_configs_(method_configs),
46
- call_attributes_(std::move(call_attributes)) {
48
+ call_attributes_(std::move(call_attributes)),
49
+ call_dispatch_controller_(call_dispatch_controller) {
47
50
  call_context[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value = this;
48
51
  call_context[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].destroy = Destroy;
49
52
  }
@@ -53,7 +56,7 @@ class ServiceConfigCallData {
53
56
  const ServiceConfigParser::ParsedConfigVector* method_configs,
54
57
  grpc_call_context_element* call_context)
55
58
  : ServiceConfigCallData(std::move(service_config), method_configs, {},
56
- call_context) {}
59
+ nullptr, call_context) {}
57
60
 
58
61
  ServiceConfig* service_config() { return service_config_.get(); }
59
62
 
@@ -70,15 +73,52 @@ class ServiceConfigCallData {
70
73
  return call_attributes_;
71
74
  }
72
75
 
76
+ ConfigSelector::CallDispatchController* call_dispatch_controller() {
77
+ return &call_dispatch_controller_;
78
+ }
79
+
73
80
  private:
81
+ // A wrapper for the CallDispatchController returned by the ConfigSelector.
82
+ // Handles the case where the ConfigSelector doees not return any
83
+ // CallDispatchController.
84
+ // Also ensures that we call Commit() at most once, which allows the
85
+ // client channel code to call Commit() when the call is complete in case
86
+ // it wasn't called earlier, without needing to know whether or not it was.
87
+ class SingleCommitCallDispatchController
88
+ : public ConfigSelector::CallDispatchController {
89
+ public:
90
+ explicit SingleCommitCallDispatchController(
91
+ ConfigSelector::CallDispatchController* call_dispatch_controller)
92
+ : call_dispatch_controller_(call_dispatch_controller) {}
93
+
94
+ bool ShouldRetry() override {
95
+ if (call_dispatch_controller_ != nullptr) {
96
+ return call_dispatch_controller_->ShouldRetry();
97
+ }
98
+ return true;
99
+ }
100
+
101
+ void Commit() override {
102
+ if (call_dispatch_controller_ != nullptr && !commit_called_) {
103
+ call_dispatch_controller_->Commit();
104
+ commit_called_ = true;
105
+ }
106
+ }
107
+
108
+ private:
109
+ ConfigSelector::CallDispatchController* call_dispatch_controller_;
110
+ bool commit_called_ = false;
111
+ };
112
+
74
113
  static void Destroy(void* ptr) {
75
114
  ServiceConfigCallData* self = static_cast<ServiceConfigCallData*>(ptr);
76
115
  self->~ServiceConfigCallData();
77
116
  }
78
117
 
79
118
  RefCountedPtr<ServiceConfig> service_config_;
80
- const ServiceConfigParser::ParsedConfigVector* method_configs_ = nullptr;
81
- std::map<const char*, absl::string_view> call_attributes_;
119
+ const ServiceConfigParser::ParsedConfigVector* method_configs_;
120
+ ConfigSelector::CallAttributes call_attributes_;
121
+ SingleCommitCallDispatchController call_dispatch_controller_;
82
122
  };
83
123
 
84
124
  } // namespace grpc_core
@@ -428,12 +428,6 @@ void CallData::DelayBatch(grpc_call_element* elem,
428
428
  MutexLock lock(&delay_mu_);
429
429
  delayed_batch_ = batch;
430
430
  resume_batch_canceller_ = new ResumeBatchCanceller(elem);
431
- // Without this line, ExecCtx::Get()->Now() will return a cached timestamp. If
432
- // there are thousands of RPCs happen on one thread, we might observe ms-level
433
- // error in Now(). This could mean the construction of RPC object is
434
- // microseconds earlier than the filter execution. But we still haven't found
435
- // the root cause. Read more: https://github.com/grpc/grpc/pull/25738.
436
- ExecCtx::Get()->InvalidateNow();
437
431
  grpc_millis resume_time = ExecCtx::Get()->Now() + fi_policy_->delay;
438
432
  GRPC_CLOSURE_INIT(&batch->handler_private.closure, ResumeBatch, elem,
439
433
  grpc_schedule_on_exec_ctx);
@@ -232,6 +232,9 @@ static void send_message_on_complete(void* arg, grpc_error_handle error) {
232
232
  grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
233
233
  call_data* calld = static_cast<call_data*>(elem->call_data);
234
234
  calld->send_message_cache.Destroy();
235
+ // Set the batch's send_message bit back to true, so the retry code
236
+ // above knows what was in this batch.
237
+ calld->send_message_batch->send_message = true;
235
238
  grpc_core::Closure::Run(DEBUG_LOCATION,
236
239
  calld->original_send_message_on_complete,
237
240
  GRPC_ERROR_REF(error));
@@ -474,8 +477,8 @@ static void http_client_start_transport_stream_op_batch(
474
477
 
475
478
  done:
476
479
  if (error != GRPC_ERROR_NONE) {
477
- grpc_transport_stream_op_batch_finish_with_failure(
478
- calld->send_message_batch, error, calld->call_combiner);
480
+ grpc_transport_stream_op_batch_finish_with_failure(batch, error,
481
+ calld->call_combiner);
479
482
  } else if (!batch_will_be_handled_asynchronously) {
480
483
  grpc_call_next_op(elem, batch);
481
484
  }
@@ -127,7 +127,7 @@ class Chttp2ServerListener : public Server::ListenerInterface {
127
127
  static void OnHandshakeDone(void* arg, grpc_error_handle error);
128
128
  RefCountedPtr<ActiveConnection> const connection_;
129
129
  grpc_pollset* const accepting_pollset_;
130
- grpc_tcp_server_acceptor* const acceptor_;
130
+ grpc_tcp_server_acceptor* acceptor_;
131
131
  RefCountedPtr<HandshakeManager> handshake_mgr_
132
132
  ABSL_GUARDED_BY(&connection_->mu_);
133
133
  // State for enforcing handshake timeout on receiving HTTP/2 settings.
@@ -320,6 +320,7 @@ Chttp2ServerListener::ActiveConnection::HandshakingState::HandshakingState(
320
320
  Chttp2ServerListener::ActiveConnection::HandshakingState::~HandshakingState() {
321
321
  grpc_pollset_set_del_pollset(interested_parties_, accepting_pollset_);
322
322
  grpc_pollset_set_destroy(interested_parties_);
323
+ gpr_free(acceptor_);
323
324
  }
324
325
 
325
326
  void Chttp2ServerListener::ActiveConnection::HandshakingState::Orphan() {
@@ -477,6 +478,7 @@ void Chttp2ServerListener::ActiveConnection::HandshakingState::OnHandshakeDone(
477
478
  handshaking_state_ref = std::move(self->connection_->handshaking_state_);
478
479
  }
479
480
  gpr_free(self->acceptor_);
481
+ self->acceptor_ = nullptr;
480
482
  OrphanablePtr<ActiveConnection> connection;
481
483
  if (free_resource_quota && resource_user != nullptr) {
482
484
  grpc_resource_user_free(resource_user, GRPC_RESOURCE_QUOTA_CHANNEL_SIZE);
@@ -744,6 +746,8 @@ void Chttp2ServerListener::OnAccept(void* arg, grpc_endpoint* tcp,
744
746
  }
745
747
  auto connection =
746
748
  MakeOrphanable<ActiveConnection>(accepting_pollset, acceptor, args);
749
+ // We no longer own acceptor
750
+ acceptor = nullptr;
747
751
  // Hold a ref to connection to allow starting handshake outside the
748
752
  // critical region
749
753
  RefCountedPtr<ActiveConnection> connection_ref = connection->Ref();
@@ -146,7 +146,7 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx) {
146
146
  switch (input_tail) {
147
147
  case 3:
148
148
  ctx->output_cur[1] = COMPOSE_OUTPUT_BYTE_1(ctx->input_cur);
149
- /* fallthrough */
149
+ ABSL_FALLTHROUGH_INTENDED;
150
150
  case 2:
151
151
  ctx->output_cur[0] = COMPOSE_OUTPUT_BYTE_0(ctx->input_cur);
152
152
  }
@@ -17,71 +17,48 @@
17
17
 
18
18
  #include <functional>
19
19
 
20
+ #include "absl/memory/memory.h"
20
21
  #include "absl/status/status.h"
21
22
 
23
+ #include "src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h"
22
24
  #include "src/core/lib/iomgr/resource_quota.h"
23
25
 
24
26
  namespace grpc_event_engine {
25
27
  namespace experimental {
26
28
 
27
- SliceAllocator::SliceAllocator(grpc_resource_user* user)
28
- : resource_user_(user) {
29
- grpc_resource_user_ref(resource_user_);
30
- };
29
+ Chttp2SliceAllocator::Chttp2SliceAllocator(grpc_resource_user* user)
30
+ : resource_user_(user) {}
31
31
 
32
- SliceAllocator::~SliceAllocator() {
32
+ Chttp2SliceAllocator::~Chttp2SliceAllocator() {
33
33
  if (resource_user_ != nullptr) {
34
34
  grpc_resource_user_unref(resource_user_);
35
35
  }
36
- };
37
-
38
- SliceAllocator::SliceAllocator(SliceAllocator&& other) noexcept
39
- : resource_user_(other.resource_user_) {
40
- other.resource_user_ = nullptr;
41
- }
42
-
43
- SliceAllocator& SliceAllocator::operator=(SliceAllocator&& other) noexcept {
44
- resource_user_ = other.resource_user_;
45
- other.resource_user_ = nullptr;
46
- return *this;
47
36
  }
48
37
 
49
- absl::Status SliceAllocator::Allocate(size_t size, SliceBuffer* dest,
50
- SliceAllocator::AllocateCallback cb) {
38
+ absl::Status Chttp2SliceAllocator::Allocate(
39
+ size_t size, SliceBuffer* dest, SliceAllocator::AllocateCallback cb) {
51
40
  // TODO(hork): merge the implementation from the uv-ee branch.
52
41
  (void)size;
53
42
  (void)dest;
54
43
  (void)cb;
55
44
  return absl::OkStatus();
56
- };
45
+ }
57
46
 
58
- SliceAllocatorFactory::SliceAllocatorFactory(grpc_resource_quota* quota)
47
+ Chttp2SliceAllocatorFactory::Chttp2SliceAllocatorFactory(
48
+ grpc_resource_quota* quota)
59
49
  : resource_quota_(quota) {
60
50
  grpc_resource_quota_ref_internal(resource_quota_);
61
- };
51
+ }
62
52
 
63
- SliceAllocatorFactory::~SliceAllocatorFactory() {
53
+ Chttp2SliceAllocatorFactory::~Chttp2SliceAllocatorFactory() {
64
54
  if (resource_quota_ != nullptr) {
65
55
  grpc_resource_quota_unref_internal(resource_quota_);
66
56
  }
67
57
  }
68
58
 
69
- SliceAllocatorFactory::SliceAllocatorFactory(
70
- SliceAllocatorFactory&& other) noexcept
71
- : resource_quota_(other.resource_quota_) {
72
- other.resource_quota_ = nullptr;
73
- }
74
-
75
- SliceAllocatorFactory& SliceAllocatorFactory::operator=(
76
- SliceAllocatorFactory&& other) noexcept {
77
- resource_quota_ = other.resource_quota_;
78
- other.resource_quota_ = nullptr;
79
- return *this;
80
- }
81
-
82
- SliceAllocator SliceAllocatorFactory::CreateSliceAllocator(
83
- absl::string_view peer_name) {
84
- return SliceAllocator(
59
+ std::unique_ptr<SliceAllocator>
60
+ Chttp2SliceAllocatorFactory::CreateSliceAllocator(absl::string_view peer_name) {
61
+ return absl::make_unique<Chttp2SliceAllocator>(
85
62
  grpc_resource_user_create(resource_quota_, peer_name.data()));
86
63
  }
87
64
 
@@ -0,0 +1,74 @@
1
+ // Copyright 2021 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_SLICE_ALLOCATOR_H
15
+ #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_SLICE_ALLOCATOR_H
16
+
17
+ #include <grpc/support/port_platform.h>
18
+
19
+ #include "grpc/event_engine/slice_allocator.h"
20
+
21
+ #include <functional>
22
+
23
+ #include "absl/status/status.h"
24
+
25
+ #include "src/core/lib/iomgr/resource_quota.h"
26
+
27
+ namespace grpc_event_engine {
28
+ namespace experimental {
29
+
30
+ class Chttp2SliceAllocator
31
+ : public grpc_event_engine::experimental::SliceAllocator {
32
+ public:
33
+ /// gRPC-internal constructor. Takes ownership of a resource_user ref from the
34
+ /// caller.
35
+ explicit Chttp2SliceAllocator(grpc_resource_user* user);
36
+ // Not copyable
37
+ Chttp2SliceAllocator(Chttp2SliceAllocator& other) = delete;
38
+ Chttp2SliceAllocator& operator=(const Chttp2SliceAllocator& other) = delete;
39
+ // Not Moveable
40
+ Chttp2SliceAllocator(Chttp2SliceAllocator&& other) = delete;
41
+ Chttp2SliceAllocator& operator=(Chttp2SliceAllocator&& other) = delete;
42
+ ~Chttp2SliceAllocator() override;
43
+ absl::Status Allocate(size_t size, SliceBuffer* dest,
44
+ SliceAllocator::AllocateCallback cb) override;
45
+
46
+ private:
47
+ grpc_resource_user* resource_user_;
48
+ };
49
+
50
+ class Chttp2SliceAllocatorFactory
51
+ : public grpc_event_engine::experimental::SliceAllocatorFactory {
52
+ public:
53
+ // gRPC-internal constructor
54
+ explicit Chttp2SliceAllocatorFactory(grpc_resource_quota* quota);
55
+ // Not copyable
56
+ Chttp2SliceAllocatorFactory(Chttp2SliceAllocatorFactory& other) = delete;
57
+ Chttp2SliceAllocatorFactory& operator=(
58
+ const Chttp2SliceAllocatorFactory& other) = delete;
59
+ // Not Moveable
60
+ Chttp2SliceAllocatorFactory(Chttp2SliceAllocatorFactory&& other) = delete;
61
+ Chttp2SliceAllocatorFactory& operator=(Chttp2SliceAllocatorFactory&& other) =
62
+ delete;
63
+ ~Chttp2SliceAllocatorFactory() override;
64
+ std::unique_ptr<SliceAllocator> CreateSliceAllocator(
65
+ absl::string_view peer_name) override;
66
+
67
+ private:
68
+ grpc_resource_quota* resource_quota_;
69
+ };
70
+
71
+ } // namespace experimental
72
+ } // namespace grpc_event_engine
73
+
74
+ #endif // GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_SLICE_ALLOCATOR_H
@@ -215,7 +215,6 @@ grpc_chttp2_transport::~grpc_chttp2_transport() {
215
215
  cl = nullptr;
216
216
 
217
217
  grpc_slice_buffer_destroy_internal(&read_buffer);
218
- grpc_chttp2_hpack_parser_destroy(&hpack_parser);
219
218
  grpc_chttp2_goaway_parser_destroy(&goaway_parser);
220
219
 
221
220
  for (i = 0; i < STREAM_LIST_COUNT; i++) {
@@ -485,7 +484,6 @@ grpc_chttp2_transport::grpc_chttp2_transport(
485
484
  settings[j][i] = grpc_chttp2_settings_parameters[i].default_value;
486
485
  }
487
486
  }
488
- grpc_chttp2_hpack_parser_init(&hpack_parser);
489
487
  grpc_chttp2_goaway_parser_init(&goaway_parser);
490
488
 
491
489
  // configure http2 the way we like it
@@ -1288,7 +1286,6 @@ static void continue_fetching_send_locked(grpc_chttp2_transport* t,
1288
1286
  if (s->fetching_send_message == nullptr) {
1289
1287
  // Stream was cancelled before message fetch completed
1290
1288
  abort(); /* TODO(ctiller): what cleanup here? */
1291
- return; /* early out */
1292
1289
  }
1293
1290
  if (s->fetched_send_message_length == s->fetching_send_message->length()) {
1294
1291
  int64_t notify_offset = s->next_message_end_offset;
@@ -1593,8 +1590,7 @@ static void perform_stream_op_locked(void* stream_op,
1593
1590
  grpc_chttp2_maybe_complete_recv_message(t, s);
1594
1591
  if (s->id != 0) {
1595
1592
  if (!s->read_closed && s->frame_storage.length == 0) {
1596
- size_t after = s->frame_storage.length +
1597
- s->unprocessed_incoming_frames_buffer_cached_length;
1593
+ size_t after = s->unprocessed_incoming_frames_buffer_cached_length;
1598
1594
  s->flow_control->IncomingByteStreamUpdate(GRPC_HEADER_SIZE_IN_BYTES,
1599
1595
  before - after);
1600
1596
  grpc_chttp2_act_on_flowctl_action(s->flow_control->MakeAction(), t, s);
@@ -2447,7 +2443,7 @@ static void WithUrgency(grpc_chttp2_transport* t,
2447
2443
  break;
2448
2444
  case grpc_core::chttp2::FlowControlAction::Urgency::UPDATE_IMMEDIATELY:
2449
2445
  grpc_chttp2_initiate_write(t, reason);
2450
- // fallthrough
2446
+ ABSL_FALLTHROUGH_INTENDED;
2451
2447
  case grpc_core::chttp2::FlowControlAction::Urgency::QUEUE_UPDATE:
2452
2448
  action();
2453
2449
  break;