grpc 1.41.1 → 1.42.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 (416) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +55 -43
  3. data/include/grpc/event_engine/event_engine.h +82 -42
  4. data/include/grpc/event_engine/internal/memory_allocator_impl.h +98 -0
  5. data/include/grpc/event_engine/memory_allocator.h +210 -0
  6. data/include/grpc/grpc.h +4 -0
  7. data/include/grpc/grpc_security.h +18 -0
  8. data/include/grpc/grpc_security_constants.h +1 -0
  9. data/include/grpc/impl/codegen/port_platform.h +7 -0
  10. data/src/core/ext/filters/client_channel/backend_metric.cc +18 -19
  11. data/src/core/ext/filters/client_channel/backup_poller.cc +2 -1
  12. data/src/core/ext/filters/client_channel/channel_connectivity.cc +71 -89
  13. data/src/core/ext/filters/client_channel/client_channel.cc +187 -252
  14. data/src/core/ext/filters/client_channel/client_channel.h +74 -27
  15. data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -1
  16. data/src/core/ext/filters/client_channel/client_channel_factory.h +17 -19
  17. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +8 -14
  18. data/src/core/ext/filters/client_channel/config_selector.cc +1 -1
  19. data/src/core/ext/filters/client_channel/config_selector.h +4 -5
  20. data/src/core/ext/filters/client_channel/connector.h +18 -18
  21. data/src/core/ext/filters/client_channel/dynamic_filters.cc +1 -1
  22. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +0 -1
  23. data/src/core/ext/filters/client_channel/health/health_check_client.cc +12 -11
  24. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
  25. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +4 -0
  26. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -15
  27. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +166 -82
  28. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +4 -0
  29. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +1 -1
  30. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -4
  31. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +23 -7
  32. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +15 -10
  33. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +2 -3
  34. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +2502 -0
  35. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -1
  36. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +7 -1
  37. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +6 -2
  38. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +1 -1
  39. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +5 -0
  40. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +8 -1
  41. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +7 -16
  42. data/src/core/ext/filters/client_channel/lb_policy.h +11 -1
  43. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -0
  44. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +139 -0
  45. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +11 -5
  46. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -3
  47. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +12 -39
  48. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +21 -1
  49. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +6 -2
  50. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +3 -1
  51. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +77 -68
  52. data/src/core/ext/filters/client_channel/resolver.h +1 -1
  53. data/src/core/ext/filters/client_channel/resolver_factory.h +2 -0
  54. data/src/core/ext/filters/client_channel/resolver_registry.cc +6 -8
  55. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
  56. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +1 -1
  57. data/src/core/ext/filters/client_channel/retry_filter.cc +48 -86
  58. data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
  59. data/src/core/ext/filters/client_channel/retry_throttle.cc +17 -48
  60. data/src/core/ext/filters/client_channel/server_address.h +1 -1
  61. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +49 -36
  62. data/src/core/ext/filters/client_channel/subchannel.cc +85 -143
  63. data/src/core/ext/filters/client_channel/subchannel.h +29 -49
  64. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +22 -7
  65. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +11 -2
  66. data/src/core/ext/filters/client_idle/client_idle_filter.cc +27 -210
  67. data/src/core/ext/filters/client_idle/idle_filter_state.cc +96 -0
  68. data/src/core/ext/filters/client_idle/idle_filter_state.h +66 -0
  69. data/src/core/ext/filters/deadline/deadline_filter.cc +23 -26
  70. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +19 -19
  71. data/src/core/ext/filters/fault_injection/service_config_parser.cc +0 -1
  72. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  73. data/src/core/ext/filters/http/client/http_client_filter.cc +41 -44
  74. data/src/core/ext/filters/http/client_authority_filter.cc +14 -15
  75. data/src/core/ext/filters/http/http_filters_plugin.cc +53 -71
  76. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +17 -12
  77. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +1 -1
  78. data/src/core/ext/filters/http/server/http_server_filter.cc +72 -69
  79. data/src/core/ext/filters/max_age/max_age_filter.cc +24 -26
  80. data/src/core/ext/filters/message_size/message_size_filter.cc +19 -16
  81. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  82. data/src/core/ext/{filters/client_channel → service_config}/service_config.cc +2 -2
  83. data/src/core/ext/{filters/client_channel → service_config}/service_config.h +4 -4
  84. data/src/core/ext/service_config/service_config_call_data.h +72 -0
  85. data/src/core/ext/{filters/client_channel → service_config}/service_config_parser.cc +3 -3
  86. data/src/core/ext/{filters/client_channel → service_config}/service_config_parser.h +8 -6
  87. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -5
  88. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +19 -24
  89. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +27 -50
  90. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +14 -16
  91. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +59 -58
  92. data/src/core/ext/transport/chttp2/transport/flow_control.cc +19 -16
  93. data/src/core/ext/transport/chttp2/transport/flow_control.h +4 -4
  94. data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
  95. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -1
  96. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -1
  97. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -3
  98. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -2
  99. data/src/core/ext/transport/chttp2/transport/hpack_constants.h +1 -1
  100. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +41 -1
  101. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +8 -4
  102. data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +1 -1
  103. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +136 -98
  104. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +27 -8
  105. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +12 -25
  106. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +37 -30
  107. data/src/core/ext/transport/chttp2/transport/internal.h +4 -3
  108. data/src/core/ext/transport/chttp2/transport/parsing.cc +30 -173
  109. data/src/core/ext/transport/chttp2/transport/popularity_count.h +1 -1
  110. data/src/core/ext/transport/chttp2/transport/writing.cc +29 -22
  111. data/src/core/ext/transport/inproc/inproc_transport.cc +105 -109
  112. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +68 -34
  113. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +139 -1
  114. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +16 -4
  115. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +53 -4
  116. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +3 -2
  117. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +15 -0
  118. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +13 -8
  119. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +23 -0
  120. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +0 -1
  121. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +14 -11
  122. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +17 -0
  123. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +15 -12
  124. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +49 -19
  125. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c +55 -0
  126. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.h +154 -0
  127. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +0 -2
  128. data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.c +58 -0
  129. data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.h +182 -0
  130. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +1 -1
  131. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +1 -1
  132. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +1 -1
  133. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +1 -1
  134. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +1 -1
  135. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +1 -1
  136. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +58 -0
  137. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +130 -0
  138. data/src/core/ext/upb-generated/{udpa/type/v1 → xds/type/v3}/typed_struct.upb.c +7 -7
  139. data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.h +83 -0
  140. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +310 -286
  141. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +10 -0
  142. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +101 -88
  143. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +5 -0
  144. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +59 -56
  145. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +59 -46
  146. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +78 -82
  147. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +323 -316
  148. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +5 -4
  149. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +19 -23
  150. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +4 -3
  151. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +5 -3
  152. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +5 -4
  153. data/src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.c +75 -0
  154. data/src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.h +50 -0
  155. data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c +13 -12
  156. data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c +25 -24
  157. data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c +16 -15
  158. data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c +17 -16
  159. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c +33 -32
  160. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c +19 -18
  161. data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.c +45 -0
  162. data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.h +35 -0
  163. data/src/core/ext/xds/xds_api.cc +325 -362
  164. data/src/core/ext/xds/xds_api.h +134 -82
  165. data/src/core/ext/xds/xds_bootstrap.h +10 -0
  166. data/src/core/ext/xds/xds_certificate_provider.cc +3 -3
  167. data/src/core/ext/xds/xds_channel_stack_modifier.cc +113 -0
  168. data/src/core/ext/xds/xds_channel_stack_modifier.h +52 -0
  169. data/src/core/ext/xds/xds_client.cc +527 -314
  170. data/src/core/ext/xds/xds_client.h +42 -37
  171. data/src/core/ext/xds/xds_client_stats.h +1 -1
  172. data/src/core/ext/xds/xds_server_config_fetcher.cc +5 -7
  173. data/src/core/lib/address_utils/parse_address.cc +2 -0
  174. data/src/core/lib/avl/avl.cc +5 -5
  175. data/src/core/lib/backoff/backoff.cc +1 -1
  176. data/src/core/lib/channel/channel_args.cc +24 -6
  177. data/src/core/lib/channel/channel_args.h +9 -0
  178. data/src/core/lib/channel/channel_stack_builder.cc +3 -3
  179. data/src/core/lib/channel/channel_trace.cc +1 -1
  180. data/src/core/lib/channel/channel_trace.h +1 -1
  181. data/src/core/lib/channel/channelz.cc +3 -3
  182. data/src/core/lib/channel/channelz.h +2 -2
  183. data/src/core/lib/channel/channelz_registry.cc +1 -1
  184. data/src/core/lib/channel/channelz_registry.h +1 -1
  185. data/src/core/lib/channel/connected_channel.cc +1 -3
  186. data/src/core/lib/channel/connected_channel.h +1 -2
  187. data/src/core/lib/compression/compression.cc +2 -2
  188. data/src/core/lib/compression/compression_args.cc +6 -4
  189. data/src/core/lib/compression/compression_internal.cc +2 -2
  190. data/src/core/lib/compression/compression_internal.h +1 -1
  191. data/src/core/lib/config/core_configuration.cc +44 -2
  192. data/src/core/lib/config/core_configuration.h +39 -1
  193. data/src/core/lib/debug/stats.cc +1 -1
  194. data/src/core/lib/debug/stats_data.cc +13 -13
  195. data/src/core/lib/gpr/atm.cc +1 -1
  196. data/src/core/lib/gpr/cpu_posix.cc +1 -1
  197. data/src/core/lib/gpr/string.cc +2 -2
  198. data/src/core/lib/gpr/tls.h +1 -1
  199. data/src/core/lib/gpr/useful.h +79 -32
  200. data/src/core/lib/gprpp/arena.h +10 -0
  201. data/src/core/lib/gprpp/bitset.h +38 -16
  202. data/src/core/lib/gprpp/chunked_vector.h +211 -0
  203. data/src/core/lib/gprpp/construct_destruct.h +1 -1
  204. data/src/core/lib/gprpp/match.h +1 -1
  205. data/src/core/lib/gprpp/memory.h +6 -0
  206. data/src/core/lib/gprpp/overload.h +1 -1
  207. data/src/core/lib/gprpp/status_helper.cc +23 -3
  208. data/src/core/lib/gprpp/status_helper.h +12 -1
  209. data/src/core/lib/gprpp/table.h +411 -0
  210. data/src/core/lib/http/httpcli.cc +200 -182
  211. data/src/core/lib/http/parser.cc +2 -2
  212. data/src/core/lib/iomgr/call_combiner.cc +28 -10
  213. data/src/core/lib/iomgr/combiner.cc +6 -21
  214. data/src/core/lib/iomgr/endpoint_cfstream.cc +7 -6
  215. data/src/core/lib/iomgr/error.cc +113 -52
  216. data/src/core/lib/iomgr/error.h +50 -9
  217. data/src/core/lib/iomgr/error_cfstream.cc +5 -0
  218. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -2
  219. data/src/core/lib/iomgr/ev_epollex_linux.cc +7 -7
  220. data/src/core/lib/iomgr/ev_poll_posix.cc +29 -20
  221. data/src/core/lib/iomgr/event_engine/closure.cc +41 -18
  222. data/src/core/lib/iomgr/event_engine/closure.h +10 -1
  223. data/src/core/lib/iomgr/event_engine/endpoint.cc +3 -3
  224. data/src/core/lib/iomgr/event_engine/iomgr.cc +1 -1
  225. data/src/core/lib/iomgr/event_engine/pollset.cc +5 -4
  226. data/src/core/lib/iomgr/event_engine/resolver.cc +10 -7
  227. data/src/core/lib/iomgr/event_engine/tcp.cc +9 -8
  228. data/src/core/lib/iomgr/event_engine/timer.cc +7 -2
  229. data/src/core/lib/iomgr/exec_ctx.cc +1 -9
  230. data/src/core/lib/iomgr/executor/mpmcqueue.cc +5 -7
  231. data/src/core/lib/iomgr/executor/mpmcqueue.h +3 -8
  232. data/src/core/lib/iomgr/executor.cc +6 -20
  233. data/src/core/lib/iomgr/iomgr.cc +3 -1
  234. data/src/core/lib/iomgr/iomgr_internal.cc +4 -9
  235. data/src/core/lib/iomgr/iomgr_internal.h +3 -2
  236. data/src/core/lib/iomgr/load_file.cc +2 -2
  237. data/src/core/lib/iomgr/lockfree_event.cc +18 -0
  238. data/src/core/lib/iomgr/pollset_custom.cc +1 -1
  239. data/src/core/lib/iomgr/pollset_custom.h +1 -1
  240. data/src/core/lib/iomgr/resolve_address_posix.cc +5 -7
  241. data/src/core/lib/iomgr/resource_quota.cc +13 -11
  242. data/src/core/lib/iomgr/socket_factory_posix.cc +2 -2
  243. data/src/core/lib/iomgr/socket_mutator.cc +2 -2
  244. data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -2
  245. data/src/core/lib/iomgr/tcp_client_cfstream.cc +5 -3
  246. data/src/core/lib/iomgr/tcp_client_custom.cc +1 -1
  247. data/src/core/lib/iomgr/tcp_client_posix.cc +9 -18
  248. data/src/core/lib/iomgr/tcp_client_windows.cc +2 -3
  249. data/src/core/lib/iomgr/tcp_posix.cc +4 -5
  250. data/src/core/lib/iomgr/tcp_server_custom.cc +2 -1
  251. data/src/core/lib/iomgr/tcp_server_posix.cc +3 -4
  252. data/src/core/lib/iomgr/tcp_server_windows.cc +4 -5
  253. data/src/core/lib/iomgr/tcp_windows.cc +2 -2
  254. data/src/core/lib/iomgr/timer_generic.cc +13 -13
  255. data/src/core/lib/iomgr/timer_heap.cc +1 -1
  256. data/src/core/lib/json/json_util.cc +68 -0
  257. data/src/core/lib/json/json_util.h +57 -99
  258. data/src/core/lib/json/json_writer.cc +0 -3
  259. data/src/core/lib/security/authorization/authorization_policy_provider.h +1 -1
  260. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +1 -1
  261. data/src/core/lib/security/authorization/evaluate_args.cc +14 -12
  262. data/src/core/lib/security/authorization/sdk_server_authz_filter.cc +13 -1
  263. data/src/core/lib/security/context/security_context.cc +4 -2
  264. data/src/core/lib/security/credentials/composite/composite_credentials.cc +1 -1
  265. data/src/core/lib/security/credentials/credentials.cc +4 -2
  266. data/src/core/lib/security/credentials/credentials.h +6 -1
  267. data/src/core/lib/security/credentials/external/external_account_credentials.cc +47 -11
  268. data/src/core/lib/security/credentials/external/external_account_credentials.h +1 -0
  269. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -1
  270. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +5 -9
  271. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -2
  272. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +2 -2
  273. data/src/core/lib/security/security_connector/security_connector.cc +9 -4
  274. data/src/core/lib/security/security_connector/security_connector.h +1 -1
  275. data/src/core/lib/security/security_connector/ssl_utils.cc +1 -1
  276. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +1 -0
  277. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +0 -2
  278. data/src/core/lib/security/transport/client_auth_filter.cc +5 -5
  279. data/src/core/lib/security/transport/security_handshaker.cc +73 -43
  280. data/src/core/lib/security/transport/server_auth_filter.cc +3 -5
  281. data/src/core/lib/security/transport/tsi_error.cc +3 -5
  282. data/src/core/lib/slice/slice.cc +0 -16
  283. data/src/core/lib/slice/slice_api.cc +39 -0
  284. data/src/core/lib/slice/slice_buffer.cc +5 -5
  285. data/src/core/lib/slice/slice_intern.cc +8 -13
  286. data/src/core/lib/slice/slice_internal.h +1 -244
  287. data/src/core/lib/slice/slice_refcount.cc +17 -0
  288. data/src/core/lib/slice/slice_refcount.h +121 -0
  289. data/src/core/lib/slice/slice_refcount_base.h +173 -0
  290. data/src/core/lib/slice/slice_split.cc +100 -0
  291. data/src/core/lib/slice/slice_split.h +40 -0
  292. data/src/core/lib/slice/slice_string_helpers.cc +0 -83
  293. data/src/core/lib/slice/slice_string_helpers.h +0 -11
  294. data/src/core/lib/slice/static_slice.cc +529 -0
  295. data/src/core/lib/slice/static_slice.h +331 -0
  296. data/src/core/lib/surface/builtins.cc +49 -0
  297. data/src/core/{ext/filters/workarounds/workaround_cronet_compression_filter.h → lib/surface/builtins.h} +8 -9
  298. data/src/core/lib/surface/call.cc +103 -120
  299. data/src/core/lib/surface/call.h +0 -6
  300. data/src/core/lib/surface/channel.cc +19 -32
  301. data/src/core/lib/surface/channel.h +0 -9
  302. data/src/core/lib/surface/channel_init.cc +23 -76
  303. data/src/core/lib/surface/channel_init.h +52 -44
  304. data/src/core/lib/surface/completion_queue.cc +6 -5
  305. data/src/core/lib/surface/init.cc +0 -39
  306. data/src/core/lib/surface/init_secure.cc +17 -14
  307. data/src/core/lib/surface/lame_client.cc +18 -11
  308. data/src/core/lib/surface/lame_client.h +1 -1
  309. data/src/core/lib/surface/server.cc +25 -17
  310. data/src/core/lib/surface/server.h +17 -10
  311. data/src/core/lib/surface/validate_metadata.cc +5 -2
  312. data/src/core/lib/surface/version.cc +2 -2
  313. data/src/core/lib/transport/bdp_estimator.cc +1 -1
  314. data/src/core/lib/transport/error_utils.cc +42 -17
  315. data/src/core/lib/transport/error_utils.h +1 -1
  316. data/src/core/lib/transport/metadata.cc +31 -10
  317. data/src/core/lib/transport/metadata.h +2 -1
  318. data/src/core/lib/transport/metadata_batch.cc +35 -371
  319. data/src/core/lib/transport/metadata_batch.h +905 -71
  320. data/src/core/lib/transport/parsed_metadata.h +263 -0
  321. data/src/core/lib/transport/pid_controller.cc +4 -4
  322. data/src/core/lib/transport/static_metadata.cc +714 -846
  323. data/src/core/lib/transport/static_metadata.h +115 -379
  324. data/src/core/lib/transport/status_metadata.cc +1 -0
  325. data/src/core/lib/transport/transport.cc +4 -5
  326. data/src/core/lib/transport/transport_op_string.cc +40 -20
  327. data/src/core/plugin_registry/grpc_plugin_registry.cc +64 -43
  328. data/src/core/tsi/alts/crypt/aes_gcm.cc +3 -1
  329. data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +13 -12
  330. data/src/core/tsi/alts/frame_protector/frame_handler.cc +10 -11
  331. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -2
  332. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +12 -2
  333. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +1 -1
  334. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +2 -2
  335. data/src/core/tsi/fake_transport_security.cc +15 -7
  336. data/src/core/tsi/local_transport_security.cc +36 -73
  337. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +16 -50
  338. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -3
  339. data/src/core/tsi/ssl_transport_security.cc +10 -2
  340. data/src/core/tsi/transport_security.cc +12 -0
  341. data/src/core/tsi/transport_security.h +16 -1
  342. data/src/core/tsi/transport_security_interface.h +26 -0
  343. data/src/ruby/ext/grpc/extconf.rb +12 -9
  344. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  345. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
  346. data/src/ruby/lib/grpc/version.rb +1 -1
  347. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -2
  348. data/src/ruby/spec/client_server_spec.rb +1 -1
  349. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +4 -4
  350. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +11 -6
  351. data/third_party/address_sorting/address_sorting_posix.c +1 -0
  352. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +20 -21
  353. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +104 -114
  354. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +13 -0
  355. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +4 -6
  356. data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +38 -47
  357. data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c +32 -34
  358. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.c +5 -9
  359. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/des.c +10 -11
  360. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/internal.h +1 -3
  361. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +3 -6
  362. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +4 -7
  363. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +35 -35
  364. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +11 -10
  365. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +10 -37
  366. data/third_party/boringssl-with-bazel/src/crypto/internal.h +39 -0
  367. data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c +6 -6
  368. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +0 -1
  369. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +72 -45
  370. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +5 -1
  371. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +2 -2
  372. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +479 -15
  373. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +16 -564
  374. data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +0 -1
  375. data/third_party/re2/re2/compile.cc +91 -109
  376. data/third_party/re2/re2/dfa.cc +27 -39
  377. data/third_party/re2/re2/filtered_re2.cc +18 -2
  378. data/third_party/re2/re2/filtered_re2.h +10 -5
  379. data/third_party/re2/re2/nfa.cc +1 -1
  380. data/third_party/re2/re2/parse.cc +42 -23
  381. data/third_party/re2/re2/perl_groups.cc +34 -34
  382. data/third_party/re2/re2/prefilter.cc +3 -2
  383. data/third_party/re2/re2/prog.cc +182 -4
  384. data/third_party/re2/re2/prog.h +28 -9
  385. data/third_party/re2/re2/re2.cc +87 -118
  386. data/third_party/re2/re2/re2.h +156 -141
  387. data/third_party/re2/re2/regexp.cc +12 -5
  388. data/third_party/re2/re2/regexp.h +8 -2
  389. data/third_party/re2/re2/set.cc +31 -9
  390. data/third_party/re2/re2/set.h +9 -4
  391. data/third_party/re2/re2/simplify.cc +11 -3
  392. data/third_party/re2/re2/tostring.cc +1 -1
  393. data/third_party/re2/re2/walker-inl.h +1 -1
  394. data/third_party/re2/util/mutex.h +2 -2
  395. data/third_party/re2/util/pcre.h +3 -3
  396. metadata +78 -66
  397. data/include/grpc/event_engine/slice_allocator.h +0 -71
  398. data/src/core/ext/filters/client_channel/service_config_call_data.h +0 -126
  399. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +0 -211
  400. data/src/core/ext/filters/workarounds/workaround_utils.cc +0 -53
  401. data/src/core/ext/filters/workarounds/workaround_utils.h +0 -39
  402. data/src/core/ext/transport/chttp2/client/authority.cc +0 -42
  403. data/src/core/ext/transport/chttp2/client/authority.h +0 -36
  404. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.cc +0 -67
  405. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +0 -74
  406. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +0 -66
  407. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +0 -58
  408. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +0 -58
  409. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +0 -130
  410. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +0 -83
  411. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +0 -44
  412. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +0 -35
  413. data/src/core/lib/iomgr/udp_server.cc +0 -747
  414. data/src/core/lib/iomgr/udp_server.h +0 -103
  415. data/src/core/lib/transport/authority_override.cc +0 -40
  416. data/src/core/lib/transport/authority_override.h +0 -37
@@ -51,10 +51,10 @@
51
51
  #include "src/core/ext/filters/client_channel/resolver_registry.h"
52
52
  #include "src/core/ext/filters/client_channel/resolver_result_parsing.h"
53
53
  #include "src/core/ext/filters/client_channel/retry_filter.h"
54
- #include "src/core/ext/filters/client_channel/service_config.h"
55
- #include "src/core/ext/filters/client_channel/service_config_call_data.h"
56
54
  #include "src/core/ext/filters/client_channel/subchannel.h"
57
55
  #include "src/core/ext/filters/deadline/deadline_filter.h"
56
+ #include "src/core/ext/service_config/service_config.h"
57
+ #include "src/core/ext/service_config/service_config_call_data.h"
58
58
  #include "src/core/lib/backoff/backoff.h"
59
59
  #include "src/core/lib/channel/channel_args.h"
60
60
  #include "src/core/lib/channel/connected_channel.h"
@@ -79,6 +79,9 @@
79
79
  // Client channel filter
80
80
  //
81
81
 
82
+ #define GRPC_ARG_HEALTH_CHECK_SERVICE_NAME \
83
+ "grpc.internal.health_check_service_name"
84
+
82
85
  namespace grpc_core {
83
86
 
84
87
  using internal::ClientChannelGlobalParsedConfig;
@@ -254,7 +257,7 @@ namespace {
254
257
  // Channel arg pointer vtable for GRPC_ARG_CLIENT_CHANNEL.
255
258
  void* ClientChannelArgCopy(void* p) { return p; }
256
259
  void ClientChannelArgDestroy(void* /*p*/) {}
257
- int ClientChannelArgCmp(void* p, void* q) { return GPR_ICMP(p, q); }
260
+ int ClientChannelArgCmp(void* p, void* q) { return QsortCompare(p, q); }
258
261
  const grpc_arg_pointer_vtable kClientChannelArgPointerVtable = {
259
262
  ClientChannelArgCopy, ClientChannelArgDestroy, ClientChannelArgCmp};
260
263
 
@@ -268,7 +271,7 @@ void ServiceConfigObjArgDestroy(void* p) {
268
271
  auto* service_config = static_cast<ServiceConfig*>(p);
269
272
  service_config->Unref();
270
273
  }
271
- int ServiceConfigObjArgCmp(void* p, void* q) { return GPR_ICMP(p, q); }
274
+ int ServiceConfigObjArgCmp(void* p, void* q) { return QsortCompare(p, q); }
272
275
  const grpc_arg_pointer_vtable kServiceConfigObjArgPointerVtable = {
273
276
  ServiceConfigObjArgCopy, ServiceConfigObjArgDestroy,
274
277
  ServiceConfigObjArgCmp};
@@ -346,8 +349,9 @@ class DynamicTerminationFilter::CallData {
346
349
  calld->call_context_, calld->path_,
347
350
  /*start_time=*/0, calld->deadline_,
348
351
  calld->arena_, calld->call_combiner_};
349
- auto* service_config_call_data = static_cast<ServiceConfigCallData*>(
350
- calld->call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
352
+ auto* service_config_call_data =
353
+ static_cast<ClientChannelServiceConfigCallData*>(
354
+ calld->call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
351
355
  calld->lb_call_ = client_channel->CreateLoadBalancedCall(
352
356
  args, pollent, nullptr,
353
357
  service_config_call_data->call_dispatch_controller(),
@@ -456,15 +460,17 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
456
460
  chand, this, subchannel_.get());
457
461
  }
458
462
  GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper");
459
- auto* subchannel_node = subchannel_->channelz_node();
460
- if (subchannel_node != nullptr) {
461
- auto it = chand_->subchannel_refcount_map_.find(subchannel_.get());
462
- if (it == chand_->subchannel_refcount_map_.end()) {
463
- chand_->channelz_node_->AddChildSubchannel(subchannel_node->uuid());
464
- it = chand_->subchannel_refcount_map_.emplace(subchannel_.get(), 0)
465
- .first;
463
+ if (chand_->channelz_node_ != nullptr) {
464
+ auto* subchannel_node = subchannel_->channelz_node();
465
+ if (subchannel_node != nullptr) {
466
+ auto it = chand_->subchannel_refcount_map_.find(subchannel_.get());
467
+ if (it == chand_->subchannel_refcount_map_.end()) {
468
+ chand_->channelz_node_->AddChildSubchannel(subchannel_node->uuid());
469
+ it = chand_->subchannel_refcount_map_.emplace(subchannel_.get(), 0)
470
+ .first;
471
+ }
472
+ ++it->second;
466
473
  }
467
- ++it->second;
468
474
  }
469
475
  chand_->subchannel_wrappers_.insert(this);
470
476
  }
@@ -476,32 +482,30 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
476
482
  chand_, this, subchannel_.get());
477
483
  }
478
484
  chand_->subchannel_wrappers_.erase(this);
479
- auto* subchannel_node = subchannel_->channelz_node();
480
- if (subchannel_node != nullptr) {
481
- auto it = chand_->subchannel_refcount_map_.find(subchannel_.get());
482
- GPR_ASSERT(it != chand_->subchannel_refcount_map_.end());
483
- --it->second;
484
- if (it->second == 0) {
485
- chand_->channelz_node_->RemoveChildSubchannel(subchannel_node->uuid());
486
- chand_->subchannel_refcount_map_.erase(it);
485
+ if (chand_->channelz_node_ != nullptr) {
486
+ auto* subchannel_node = subchannel_->channelz_node();
487
+ if (subchannel_node != nullptr) {
488
+ auto it = chand_->subchannel_refcount_map_.find(subchannel_.get());
489
+ GPR_ASSERT(it != chand_->subchannel_refcount_map_.end());
490
+ --it->second;
491
+ if (it->second == 0) {
492
+ chand_->channelz_node_->RemoveChildSubchannel(
493
+ subchannel_node->uuid());
494
+ chand_->subchannel_refcount_map_.erase(it);
495
+ }
487
496
  }
488
497
  }
489
498
  GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "SubchannelWrapper");
490
499
  }
491
500
 
492
- grpc_connectivity_state CheckConnectivityState() override
493
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(chand_->work_serializer_) {
494
- RefCountedPtr<ConnectedSubchannel> connected_subchannel;
495
- grpc_connectivity_state connectivity_state =
496
- subchannel_->CheckConnectivityState(health_check_service_name_,
497
- &connected_subchannel);
498
- MaybeUpdateConnectedSubchannel(std::move(connected_subchannel));
499
- return connectivity_state;
501
+ grpc_connectivity_state CheckConnectivityState() override {
502
+ return subchannel_->CheckConnectivityState(health_check_service_name_);
500
503
  }
501
504
 
502
505
  void WatchConnectivityState(
503
506
  grpc_connectivity_state initial_state,
504
- std::unique_ptr<ConnectivityStateWatcherInterface> watcher) override {
507
+ std::unique_ptr<ConnectivityStateWatcherInterface> watcher) override
508
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(chand_->work_serializer_) {
505
509
  auto& watcher_wrapper = watcher_map_[watcher.get()];
506
510
  GPR_ASSERT(watcher_wrapper == nullptr);
507
511
  watcher_wrapper = new WatcherWrapper(std::move(watcher),
@@ -513,8 +517,8 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
513
517
  watcher_wrapper));
514
518
  }
515
519
 
516
- void CancelConnectivityStateWatch(
517
- ConnectivityStateWatcherInterface* watcher) override {
520
+ void CancelConnectivityStateWatch(ConnectivityStateWatcherInterface* watcher)
521
+ override ABSL_EXCLUSIVE_LOCKS_REQUIRED(chand_->work_serializer_) {
518
522
  auto it = watcher_map_.find(watcher);
519
523
  GPR_ASSERT(it != watcher_map_.end());
520
524
  subchannel_->CancelConnectivityStateWatch(health_check_service_name_,
@@ -522,6 +526,10 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
522
526
  watcher_map_.erase(it);
523
527
  }
524
528
 
529
+ RefCountedPtr<ConnectedSubchannel> connected_subchannel() const {
530
+ return subchannel_->connected_subchannel();
531
+ }
532
+
525
533
  void AttemptToConnect() override { subchannel_->AttemptToConnect(); }
526
534
 
527
535
  void ResetBackoff() override { subchannel_->ResetBackoff(); }
@@ -534,57 +542,6 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
534
542
  subchannel_->ThrottleKeepaliveTime(new_keepalive_time);
535
543
  }
536
544
 
537
- void UpdateHealthCheckServiceName(
538
- absl::optional<std::string> health_check_service_name) {
539
- if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
540
- gpr_log(GPR_INFO,
541
- "chand=%p: subchannel wrapper %p: updating health check service "
542
- "name from \"%s\" to \"%s\"",
543
- chand_, this, health_check_service_name_->c_str(),
544
- health_check_service_name->c_str());
545
- }
546
- for (auto& p : watcher_map_) {
547
- WatcherWrapper*& watcher_wrapper = p.second;
548
- // Cancel the current watcher and create a new one using the new
549
- // health check service name.
550
- // TODO(roth): If there is not already an existing health watch
551
- // call for the new name, then the watcher will initially report
552
- // state CONNECTING. If the LB policy is currently reporting
553
- // state READY, this may cause it to switch to CONNECTING before
554
- // switching back to READY. This could cause a small delay for
555
- // RPCs being started on the channel. If/when this becomes a
556
- // problem, we may be able to handle it by waiting for the new
557
- // watcher to report READY before we use it to replace the old one.
558
- WatcherWrapper* replacement = watcher_wrapper->MakeReplacement();
559
- subchannel_->CancelConnectivityStateWatch(health_check_service_name_,
560
- watcher_wrapper);
561
- watcher_wrapper = replacement;
562
- subchannel_->WatchConnectivityState(
563
- replacement->last_seen_state(), health_check_service_name,
564
- RefCountedPtr<Subchannel::ConnectivityStateWatcherInterface>(
565
- replacement));
566
- }
567
- // Save the new health check service name.
568
- health_check_service_name_ = std::move(health_check_service_name);
569
- }
570
-
571
- // Caller must be holding the control-plane work_serializer.
572
- ConnectedSubchannel* connected_subchannel() const
573
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::work_serializer_) {
574
- return connected_subchannel_.get();
575
- }
576
-
577
- // Caller must be holding the data-plane mutex.
578
- ConnectedSubchannel* connected_subchannel_in_data_plane() const
579
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::data_plane_mu_) {
580
- return connected_subchannel_in_data_plane_.get();
581
- }
582
- void set_connected_subchannel_in_data_plane(
583
- RefCountedPtr<ConnectedSubchannel> connected_subchannel)
584
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::data_plane_mu_) {
585
- connected_subchannel_in_data_plane_ = std::move(connected_subchannel);
586
- }
587
-
588
545
  private:
589
546
  // Subchannel and SubchannelInterface have different interfaces for
590
547
  // their respective ConnectivityStateWatcherInterface classes.
@@ -696,8 +653,6 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
696
653
  // since this callback was scheduled.
697
654
  if (watcher_ != nullptr) {
698
655
  last_seen_state_ = state_change.state;
699
- parent_->MaybeUpdateConnectedSubchannel(
700
- std::move(state_change.connected_subchannel));
701
656
  watcher_->OnConnectivityStateChange(state_change.state);
702
657
  }
703
658
  }
@@ -709,28 +664,6 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
709
664
  WatcherWrapper* replacement_ = nullptr;
710
665
  };
711
666
 
712
- void MaybeUpdateConnectedSubchannel(
713
- RefCountedPtr<ConnectedSubchannel> connected_subchannel)
714
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::work_serializer_) {
715
- // Update the connected subchannel only if the channel is not shutting
716
- // down. This is because once the channel is shutting down, we
717
- // ignore picker updates from the LB policy, which means that
718
- // UpdateStateAndPickerLocked() will never process the entries
719
- // in chand_->pending_subchannel_updates_. So we don't want to add
720
- // entries there that will never be processed, since that would
721
- // leave dangling refs to the channel and prevent its destruction.
722
- grpc_error_handle disconnect_error = chand_->disconnect_error();
723
- if (disconnect_error != GRPC_ERROR_NONE) return;
724
- // Not shutting down, so do the update.
725
- if (connected_subchannel_ != connected_subchannel) {
726
- connected_subchannel_ = std::move(connected_subchannel);
727
- // Record the new connected subchannel so that it can be updated
728
- // in the data plane mutex the next time the picker is updated.
729
- chand_->pending_subchannel_updates_[Ref(
730
- DEBUG_LOCATION, "ConnectedSubchannelUpdate")] = connected_subchannel_;
731
- }
732
- }
733
-
734
667
  ClientChannel* chand_;
735
668
  RefCountedPtr<Subchannel> subchannel_;
736
669
  absl::optional<std::string> health_check_service_name_;
@@ -739,13 +672,8 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
739
672
  // subchannel. This is needed so that when the LB policy calls
740
673
  // CancelConnectivityStateWatch() with its watcher, we know the
741
674
  // corresponding WrapperWatcher to cancel on the underlying subchannel.
742
- std::map<ConnectivityStateWatcherInterface*, WatcherWrapper*> watcher_map_;
743
- // To be accessed only in the control plane work_serializer.
744
- RefCountedPtr<ConnectedSubchannel> connected_subchannel_
675
+ std::map<ConnectivityStateWatcherInterface*, WatcherWrapper*> watcher_map_
745
676
  ABSL_GUARDED_BY(&ClientChannel::work_serializer_);
746
- // To be accessed only in the data plane mutex.
747
- RefCountedPtr<ConnectedSubchannel> connected_subchannel_in_data_plane_
748
- ABSL_GUARDED_BY(&ClientChannel::data_plane_mu_);
749
677
  };
750
678
 
751
679
  //
@@ -942,35 +870,62 @@ class ClientChannel::ClientChannelControlHelper
942
870
  ABSL_EXCLUSIVE_LOCKS_REQUIRED(chand_->work_serializer_) {
943
871
  if (chand_->resolver_ == nullptr) return nullptr; // Shutting down.
944
872
  // Determine health check service name.
945
- bool inhibit_health_checking = grpc_channel_args_find_bool(
946
- &args, GRPC_ARG_INHIBIT_HEALTH_CHECKING, false);
947
873
  absl::optional<std::string> health_check_service_name;
948
- if (!inhibit_health_checking) {
949
- health_check_service_name = chand_->health_check_service_name_;
874
+ const char* health_check_service_name_arg = grpc_channel_args_find_string(
875
+ &args, GRPC_ARG_HEALTH_CHECK_SERVICE_NAME);
876
+ if (health_check_service_name_arg != nullptr) {
877
+ bool inhibit_health_checking = grpc_channel_args_find_bool(
878
+ &args, GRPC_ARG_INHIBIT_HEALTH_CHECKING, false);
879
+ if (!inhibit_health_checking) {
880
+ health_check_service_name = health_check_service_name_arg;
881
+ }
950
882
  }
883
+ // Construct channel args for subchannel.
951
884
  // Remove channel args that should not affect subchannel uniqueness.
952
- static const char* args_to_remove[] = {
885
+ absl::InlinedVector<const char*, 4> args_to_remove = {
886
+ GRPC_ARG_HEALTH_CHECK_SERVICE_NAME,
953
887
  GRPC_ARG_INHIBIT_HEALTH_CHECKING,
954
888
  GRPC_ARG_CHANNELZ_CHANNEL_NODE,
955
889
  };
956
890
  // Add channel args needed for the subchannel.
957
- absl::InlinedVector<grpc_arg, 3> args_to_add = {
958
- Subchannel::CreateSubchannelAddressArg(&address.address()),
891
+ absl::InlinedVector<grpc_arg, 2> args_to_add = {
959
892
  SubchannelPoolInterface::CreateChannelArg(
960
893
  chand_->subchannel_pool_.get()),
961
894
  };
895
+ // Check if default authority arg is already set.
896
+ const char* default_authority =
897
+ grpc_channel_args_find_string(&args, GRPC_ARG_DEFAULT_AUTHORITY);
898
+ // Add args from subchannel address.
962
899
  if (address.args() != nullptr) {
963
900
  for (size_t j = 0; j < address.args()->num_args; ++j) {
964
- args_to_add.emplace_back(address.args()->args[j]);
901
+ grpc_arg& arg = address.args()->args[j];
902
+ if (strcmp(arg.key, GRPC_ARG_DEFAULT_AUTHORITY) == 0) {
903
+ // Don't add default authority arg from subchannel address if
904
+ // it's already set at the channel level -- the value from the
905
+ // application should take precedence over what is set by the
906
+ // resolver.
907
+ if (default_authority != nullptr) continue;
908
+ default_authority = arg.value.string;
909
+ }
910
+ args_to_add.emplace_back(arg);
965
911
  }
966
912
  }
913
+ // If we haven't already set the default authority arg, add it from
914
+ // the channel.
915
+ if (default_authority == nullptr) {
916
+ // Remove it, just in case it's actually present but is the wrong type.
917
+ args_to_remove.push_back(GRPC_ARG_DEFAULT_AUTHORITY);
918
+ args_to_add.push_back(grpc_channel_arg_string_create(
919
+ const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY),
920
+ const_cast<char*>(chand_->default_authority_.c_str())));
921
+ }
967
922
  grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
968
- &args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove),
969
- args_to_add.data(), args_to_add.size());
970
- gpr_free(args_to_add[0].value.string);
923
+ &args, args_to_remove.data(), args_to_remove.size(), args_to_add.data(),
924
+ args_to_add.size());
971
925
  // Create subchannel.
972
926
  RefCountedPtr<Subchannel> subchannel =
973
- chand_->client_channel_factory_->CreateSubchannel(new_args);
927
+ chand_->client_channel_factory_->CreateSubchannel(address.address(),
928
+ new_args);
974
929
  grpc_channel_args_destroy(new_args);
975
930
  if (subchannel == nullptr) return nullptr;
976
931
  // Make sure the subchannel has updated keepalive time.
@@ -985,9 +940,8 @@ class ClientChannel::ClientChannelControlHelper
985
940
  std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker) override
986
941
  ABSL_EXCLUSIVE_LOCKS_REQUIRED(chand_->work_serializer_) {
987
942
  if (chand_->resolver_ == nullptr) return; // Shutting down.
988
- grpc_error_handle disconnect_error = chand_->disconnect_error();
989
943
  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
990
- const char* extra = disconnect_error == GRPC_ERROR_NONE
944
+ const char* extra = chand_->disconnect_error_ == GRPC_ERROR_NONE
991
945
  ? ""
992
946
  : " (ignoring -- channel shutting down)";
993
947
  gpr_log(GPR_INFO, "chand=%p: update: state=%s status=(%s) picker=%p%s",
@@ -995,7 +949,7 @@ class ClientChannel::ClientChannelControlHelper
995
949
  picker.get(), extra);
996
950
  }
997
951
  // Do update only if not shutting down.
998
- if (disconnect_error == GRPC_ERROR_NONE) {
952
+ if (chand_->disconnect_error_ == GRPC_ERROR_NONE) {
999
953
  chand_->UpdateStateAndPickerLocked(state, status, "helper",
1000
954
  std::move(picker));
1001
955
  }
@@ -1010,6 +964,10 @@ class ClientChannel::ClientChannelControlHelper
1010
964
  chand_->resolver_->RequestReresolutionLocked();
1011
965
  }
1012
966
 
967
+ absl::string_view GetAuthority() override {
968
+ return chand_->default_authority_;
969
+ }
970
+
1013
971
  void AddTraceEvent(TraceSeverity severity, absl::string_view message) override
1014
972
  ABSL_EXCLUSIVE_LOCKS_REQUIRED(chand_->work_serializer_) {
1015
973
  if (chand_->resolver_ == nullptr) return; // Shutting down.
@@ -1086,8 +1044,7 @@ ClientChannel::ClientChannel(grpc_channel_element_args* args,
1086
1044
  interested_parties_(grpc_pollset_set_create()),
1087
1045
  work_serializer_(std::make_shared<WorkSerializer>()),
1088
1046
  state_tracker_("client_channel", GRPC_CHANNEL_IDLE),
1089
- subchannel_pool_(GetSubchannelPool(args->channel_args)),
1090
- disconnect_error_(GRPC_ERROR_NONE) {
1047
+ subchannel_pool_(GetSubchannelPool(args->channel_args)) {
1091
1048
  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1092
1049
  gpr_log(GPR_INFO, "chand=%p: creating client_channel for channel stack %p",
1093
1050
  this, owning_stack_);
@@ -1100,15 +1057,6 @@ ClientChannel::ClientChannel(grpc_channel_element_args* args,
1100
1057
  "Missing client channel factory in args for client channel filter");
1101
1058
  return;
1102
1059
  }
1103
- // Get server name to resolve, using proxy mapper if needed.
1104
- const char* server_uri =
1105
- grpc_channel_args_find_string(args->channel_args, GRPC_ARG_SERVER_URI);
1106
- if (server_uri == nullptr) {
1107
- *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1108
- "server URI channel arg missing or wrong type in client channel "
1109
- "filter");
1110
- return;
1111
- }
1112
1060
  // Get default service config. If none is specified via the client API,
1113
1061
  // we use an empty config.
1114
1062
  const char* service_config_json = grpc_channel_args_find_string(
@@ -1121,30 +1069,50 @@ ClientChannel::ClientChannel(grpc_channel_element_args* args,
1121
1069
  default_service_config_.reset();
1122
1070
  return;
1123
1071
  }
1124
- absl::StatusOr<URI> uri = URI::Parse(server_uri);
1125
- if (uri.ok() && !uri->path().empty()) {
1126
- server_name_ = std::string(absl::StripPrefix(uri->path(), "/"));
1072
+ // Get URI to resolve, using proxy mapper if needed.
1073
+ const char* server_uri =
1074
+ grpc_channel_args_find_string(args->channel_args, GRPC_ARG_SERVER_URI);
1075
+ if (server_uri == nullptr) {
1076
+ *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1077
+ "target URI channel arg missing or wrong type in client channel "
1078
+ "filter");
1079
+ return;
1127
1080
  }
1081
+ uri_to_resolve_ = server_uri;
1128
1082
  char* proxy_name = nullptr;
1129
1083
  grpc_channel_args* new_args = nullptr;
1130
1084
  ProxyMapperRegistry::MapName(server_uri, args->channel_args, &proxy_name,
1131
1085
  &new_args);
1132
- target_uri_.reset(proxy_name != nullptr ? proxy_name
1133
- : gpr_strdup(server_uri));
1086
+ if (proxy_name != nullptr) {
1087
+ uri_to_resolve_ = proxy_name;
1088
+ gpr_free(proxy_name);
1089
+ }
1090
+ // Make sure the URI to resolve is valid, so that we know that
1091
+ // resolver creation will succeed later.
1092
+ if (!ResolverRegistry::IsValidTarget(uri_to_resolve_)) {
1093
+ *error = GRPC_ERROR_CREATE_FROM_CPP_STRING(
1094
+ absl::StrCat("the target uri is not valid: ", uri_to_resolve_.c_str()));
1095
+ return;
1096
+ }
1134
1097
  // Strip out service config channel arg, so that it doesn't affect
1135
1098
  // subchannel uniqueness when the args flow down to that layer.
1136
1099
  const char* arg_to_remove = GRPC_ARG_SERVICE_CONFIG;
1137
1100
  channel_args_ = grpc_channel_args_copy_and_remove(
1138
1101
  new_args != nullptr ? new_args : args->channel_args, &arg_to_remove, 1);
1139
1102
  grpc_channel_args_destroy(new_args);
1103
+ // Set initial keepalive time.
1140
1104
  keepalive_time_ = grpc_channel_args_find_integer(
1141
1105
  channel_args_, GRPC_ARG_KEEPALIVE_TIME_MS,
1142
1106
  {-1 /* default value, unset */, 1, INT_MAX});
1143
- if (!ResolverRegistry::IsValidTarget(target_uri_.get())) {
1144
- *error = GRPC_ERROR_CREATE_FROM_CPP_STRING(
1145
- absl::StrCat("the target uri is not valid: ", target_uri_.get()));
1146
- return;
1107
+ // Set default authority.
1108
+ const char* default_authority =
1109
+ grpc_channel_args_find_string(channel_args_, GRPC_ARG_DEFAULT_AUTHORITY);
1110
+ if (default_authority == nullptr) {
1111
+ default_authority_ = ResolverRegistry::GetDefaultAuthority(server_uri);
1112
+ } else {
1113
+ default_authority_ = default_authority;
1147
1114
  }
1115
+ // Success.
1148
1116
  *error = GRPC_ERROR_NONE;
1149
1117
  }
1150
1118
 
@@ -1158,7 +1126,7 @@ ClientChannel::~ClientChannel() {
1158
1126
  // Stop backup polling.
1159
1127
  grpc_client_channel_stop_backup_polling(interested_parties_);
1160
1128
  grpc_pollset_set_destroy(interested_parties_);
1161
- GRPC_ERROR_UNREF(disconnect_error_.load(std::memory_order_relaxed));
1129
+ GRPC_ERROR_UNREF(disconnect_error_);
1162
1130
  }
1163
1131
 
1164
1132
  OrphanablePtr<ClientChannel::LoadBalancedCall>
@@ -1307,15 +1275,16 @@ void ClientChannel::OnResolverResultChangedLocked(Resolver::Result result) {
1307
1275
  // If either has changed, apply the global parameters now.
1308
1276
  if (service_config_changed || config_selector_changed) {
1309
1277
  // Update service config in control plane.
1310
- UpdateServiceConfigInControlPlaneLocked(
1311
- std::move(service_config), std::move(config_selector),
1312
- parsed_service_config, lb_policy_config->name());
1278
+ UpdateServiceConfigInControlPlaneLocked(std::move(service_config),
1279
+ std::move(config_selector),
1280
+ lb_policy_config->name());
1313
1281
  } else if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1314
1282
  gpr_log(GPR_INFO, "chand=%p: service config not changed", this);
1315
1283
  }
1316
1284
  // Create or update LB policy, as needed.
1317
- CreateOrUpdateLbPolicyLocked(std::move(lb_policy_config),
1318
- std::move(result));
1285
+ CreateOrUpdateLbPolicyLocked(
1286
+ std::move(lb_policy_config),
1287
+ parsed_service_config->health_check_service_name(), std::move(result));
1319
1288
  if (service_config_changed || config_selector_changed) {
1320
1289
  // Start using new service config for calls.
1321
1290
  // This needs to happen after the LB policy has been updated, since
@@ -1381,17 +1350,25 @@ void ClientChannel::OnResolverErrorLocked(grpc_error_handle error) {
1381
1350
 
1382
1351
  void ClientChannel::CreateOrUpdateLbPolicyLocked(
1383
1352
  RefCountedPtr<LoadBalancingPolicy::Config> lb_policy_config,
1353
+ const absl::optional<std::string>& health_check_service_name,
1384
1354
  Resolver::Result result) {
1385
1355
  // Construct update.
1386
1356
  LoadBalancingPolicy::UpdateArgs update_args;
1387
1357
  update_args.addresses = std::move(result.addresses);
1388
1358
  update_args.config = std::move(lb_policy_config);
1359
+ // Add health check service name to channel args.
1360
+ absl::InlinedVector<grpc_arg, 1> args_to_add;
1361
+ if (health_check_service_name.has_value()) {
1362
+ args_to_add.push_back(grpc_channel_arg_string_create(
1363
+ const_cast<char*>(GRPC_ARG_HEALTH_CHECK_SERVICE_NAME),
1364
+ const_cast<char*>(health_check_service_name->c_str())));
1365
+ }
1389
1366
  // Remove the config selector from channel args so that we're not holding
1390
1367
  // unnecessary refs that cause it to be destroyed somewhere other than in the
1391
1368
  // WorkSerializer.
1392
- const char* arg_name = GRPC_ARG_CONFIG_SELECTOR;
1393
- update_args.args =
1394
- grpc_channel_args_copy_and_remove(result.args, &arg_name, 1);
1369
+ const char* arg_to_remove = GRPC_ARG_CONFIG_SELECTOR;
1370
+ update_args.args = grpc_channel_args_copy_and_add_and_remove(
1371
+ result.args, &arg_to_remove, 1, args_to_add.data(), args_to_add.size());
1395
1372
  // Create policy if needed.
1396
1373
  if (lb_policy_ == nullptr) {
1397
1374
  lb_policy_ = CreateLbPolicyLocked(*update_args.args);
@@ -1450,9 +1427,7 @@ void ClientChannel::RemoveResolverQueuedCall(ResolverQueuedCall* to_remove,
1450
1427
 
1451
1428
  void ClientChannel::UpdateServiceConfigInControlPlaneLocked(
1452
1429
  RefCountedPtr<ServiceConfig> service_config,
1453
- RefCountedPtr<ConfigSelector> config_selector,
1454
- const internal::ClientChannelGlobalParsedConfig* parsed_service_config,
1455
- const char* lb_policy_name) {
1430
+ RefCountedPtr<ConfigSelector> config_selector, const char* lb_policy_name) {
1456
1431
  UniquePtr<char> service_config_json(
1457
1432
  gpr_strdup(service_config->json_string().c_str()));
1458
1433
  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
@@ -1462,17 +1437,6 @@ void ClientChannel::UpdateServiceConfigInControlPlaneLocked(
1462
1437
  }
1463
1438
  // Save service config.
1464
1439
  saved_service_config_ = std::move(service_config);
1465
- // Update health check service name if needed.
1466
- if (health_check_service_name_ !=
1467
- parsed_service_config->health_check_service_name()) {
1468
- health_check_service_name_ =
1469
- parsed_service_config->health_check_service_name();
1470
- // Update health check service name used by existing subchannel wrappers.
1471
- for (auto* subchannel_wrapper : subchannel_wrappers_) {
1472
- subchannel_wrapper->UpdateHealthCheckServiceName(
1473
- health_check_service_name_);
1474
- }
1475
- }
1476
1440
  // Swap out the data used by GetChannelInfo().
1477
1441
  UniquePtr<char> lb_policy_name_owned(gpr_strdup(lb_policy_name));
1478
1442
  {
@@ -1530,7 +1494,6 @@ void ClientChannel::UpdateServiceConfigInDataPlaneLocked() {
1530
1494
  //
1531
1495
  // We defer unreffing the old values (and deallocating memory) until
1532
1496
  // after releasing the lock to keep the critical section small.
1533
- std::set<grpc_call_element*> calls_pending_resolver_result;
1534
1497
  {
1535
1498
  MutexLock lock(&resolution_mu_);
1536
1499
  GRPC_ERROR_UNREF(resolver_transient_failure_error_);
@@ -1570,8 +1533,8 @@ void ClientChannel::CreateResolverLocked() {
1570
1533
  gpr_log(GPR_INFO, "chand=%p: starting name resolution", this);
1571
1534
  }
1572
1535
  resolver_ = ResolverRegistry::CreateResolver(
1573
- target_uri_.get(), channel_args_, interested_parties_, work_serializer_,
1574
- absl::make_unique<ResolverResultHandler>(this));
1536
+ uri_to_resolve_.c_str(), channel_args_, interested_parties_,
1537
+ work_serializer_, absl::make_unique<ResolverResultHandler>(this));
1575
1538
  // Since the validity of the args was checked when the channel was created,
1576
1539
  // CreateResolver() must return a non-null result.
1577
1540
  GPR_ASSERT(resolver_ != nullptr);
@@ -1635,30 +1598,9 @@ void ClientChannel::UpdateStateAndPickerLocked(
1635
1598
  channelz::ChannelNode::GetChannelConnectivityStateChangeString(
1636
1599
  state)));
1637
1600
  }
1638
- // Grab data plane lock to do subchannel updates and update the picker.
1639
- //
1640
- // Note that we want to minimize the work done while holding the data
1641
- // plane lock, to keep the critical section small. So, for all of the
1642
- // objects that we might wind up unreffing here, we actually hold onto
1643
- // the refs until after we release the lock, and then unref them at
1644
- // that point. This includes the following:
1645
- // - refs to subchannel wrappers in the keys of pending_subchannel_updates_
1646
- // - ownership of the existing picker in picker_
1601
+ // Grab data plane lock to update the picker.
1647
1602
  {
1648
1603
  MutexLock lock(&data_plane_mu_);
1649
- // Handle subchannel updates.
1650
- for (auto& p : pending_subchannel_updates_) {
1651
- if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1652
- gpr_log(GPR_INFO,
1653
- "chand=%p: updating subchannel wrapper %p data plane "
1654
- "connected_subchannel to %p",
1655
- this, p.first.get(), p.second.get());
1656
- }
1657
- // Note: We do not remove the entry from pending_subchannel_updates_
1658
- // here, since this would unref the subchannel wrapper; instead,
1659
- // we wait until we've released the lock to clear the map.
1660
- p.first->set_connected_subchannel_in_data_plane(std::move(p.second));
1661
- }
1662
1604
  // Swap out the picker.
1663
1605
  // Note: Original value will be destroyed after the lock is released.
1664
1606
  picker_.swap(picker);
@@ -1680,9 +1622,6 @@ void ClientChannel::UpdateStateAndPickerLocked(
1680
1622
  }
1681
1623
  }
1682
1624
  }
1683
- // Clear the pending update map after releasing the lock, to keep the
1684
- // critical section small.
1685
- pending_subchannel_updates_.clear();
1686
1625
  }
1687
1626
 
1688
1627
  namespace {
@@ -1735,7 +1674,7 @@ grpc_error_handle ClientChannel::DoPingLocked(grpc_transport_op* op) {
1735
1674
  ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::work_serializer_) {
1736
1675
  SubchannelWrapper* subchannel = static_cast<SubchannelWrapper*>(
1737
1676
  complete_pick->subchannel.get());
1738
- ConnectedSubchannel* connected_subchannel =
1677
+ RefCountedPtr<ConnectedSubchannel> connected_subchannel =
1739
1678
  subchannel->connected_subchannel();
1740
1679
  connected_subchannel->Ping(op->send_ping.on_initiate,
1741
1680
  op->send_ping.on_ack);
@@ -1793,7 +1732,7 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) {
1793
1732
  if (grpc_error_get_int(op->disconnect_with_error,
1794
1733
  GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, &value) &&
1795
1734
  static_cast<grpc_connectivity_state>(value) == GRPC_CHANNEL_IDLE) {
1796
- if (disconnect_error() == GRPC_ERROR_NONE) {
1735
+ if (disconnect_error_ == GRPC_ERROR_NONE) {
1797
1736
  // Enter IDLE state.
1798
1737
  UpdateStateAndPickerLocked(GRPC_CHANNEL_IDLE, absl::Status(),
1799
1738
  "channel entering IDLE", nullptr);
@@ -1801,10 +1740,8 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) {
1801
1740
  GRPC_ERROR_UNREF(op->disconnect_with_error);
1802
1741
  } else {
1803
1742
  // Disconnect.
1804
- GPR_ASSERT(disconnect_error_.load(std::memory_order_relaxed) ==
1805
- GRPC_ERROR_NONE);
1806
- disconnect_error_.store(op->disconnect_with_error,
1807
- std::memory_order_release);
1743
+ GPR_ASSERT(disconnect_error_ == GRPC_ERROR_NONE);
1744
+ disconnect_error_ = op->disconnect_with_error;
1808
1745
  UpdateStateAndPickerLocked(
1809
1746
  GRPC_CHANNEL_SHUTDOWN, absl::Status(), "shutdown from API",
1810
1747
  absl::make_unique<LoadBalancingPolicy::TransientFailurePicker>(
@@ -1869,17 +1806,6 @@ void ClientChannel::RemoveLbQueuedCall(LbQueuedCall* to_remove,
1869
1806
  }
1870
1807
  }
1871
1808
 
1872
- RefCountedPtr<ConnectedSubchannel>
1873
- ClientChannel::GetConnectedSubchannelInDataPlane(
1874
- SubchannelInterface* subchannel) const {
1875
- SubchannelWrapper* subchannel_wrapper =
1876
- static_cast<SubchannelWrapper*>(subchannel);
1877
- ConnectedSubchannel* connected_subchannel =
1878
- subchannel_wrapper->connected_subchannel_in_data_plane();
1879
- if (connected_subchannel == nullptr) return nullptr;
1880
- return connected_subchannel->Ref();
1881
- }
1882
-
1883
1809
  void ClientChannel::TryToConnectLocked() {
1884
1810
  if (lb_policy_ != nullptr) {
1885
1811
  lb_policy_->ExitIdleLocked();
@@ -2274,15 +2200,16 @@ grpc_error_handle ClientChannel::CallData::ApplyServiceConfigToCallLocked(
2274
2200
  ConfigSelector::CallConfig call_config =
2275
2201
  config_selector->GetCallConfig({&path_, initial_metadata, arena_});
2276
2202
  if (call_config.error != GRPC_ERROR_NONE) return call_config.error;
2277
- // Create a ServiceConfigCallData for the call. This stores a ref to the
2278
- // ServiceConfig and caches the right set of parsed configs to use for
2279
- // the call. The MethodConfig will store itself in the call context,
2280
- // so that it can be accessed by filters in the subchannel, and it
2281
- // will be cleaned up when the call ends.
2282
- auto* service_config_call_data = arena_->New<ServiceConfigCallData>(
2283
- std::move(call_config.service_config), call_config.method_configs,
2284
- std::move(call_config.call_attributes),
2285
- call_config.call_dispatch_controller, call_context_);
2203
+ // Create a ClientChannelServiceConfigCallData for the call. This stores
2204
+ // a ref to the ServiceConfig and caches the right set of parsed configs
2205
+ // to use for the call. The ClientChannelServiceConfigCallData will store
2206
+ // itself in the call context, so that it can be accessed by filters
2207
+ // below us in the stack, and it will be cleaned up when the call ends.
2208
+ auto* service_config_call_data =
2209
+ arena_->New<ClientChannelServiceConfigCallData>(
2210
+ std::move(call_config.service_config), call_config.method_configs,
2211
+ std::move(call_config.call_attributes),
2212
+ call_config.call_dispatch_controller, call_context_);
2286
2213
  // Apply our own method params to the call.
2287
2214
  auto* method_params = static_cast<ClientChannelMethodParsedConfig*>(
2288
2215
  service_config_call_data->GetMethodParsedConfig(
@@ -2324,8 +2251,9 @@ void ClientChannel::CallData::
2324
2251
  RecvTrailingMetadataReadyForConfigSelectorCommitCallback(
2325
2252
  void* arg, grpc_error_handle error) {
2326
2253
  auto* self = static_cast<CallData*>(arg);
2327
- auto* service_config_call_data = static_cast<ServiceConfigCallData*>(
2328
- self->call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
2254
+ auto* service_config_call_data =
2255
+ static_cast<ClientChannelServiceConfigCallData*>(
2256
+ self->call_context_[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
2329
2257
  if (service_config_call_data != nullptr) {
2330
2258
  service_config_call_data->call_dispatch_controller()->Commit();
2331
2259
  }
@@ -2495,24 +2423,28 @@ class ClientChannel::LoadBalancedCall::Metadata
2495
2423
  linked_mdelem->md = grpc_mdelem_from_slices(
2496
2424
  ExternallyManagedSlice(key.data(), key.size()),
2497
2425
  ExternallyManagedSlice(value.data(), value.size()));
2498
- GPR_ASSERT(grpc_metadata_batch_link_tail(batch_, linked_mdelem) ==
2499
- GRPC_ERROR_NONE);
2426
+ GPR_ASSERT(batch_->LinkTail(linked_mdelem) == GRPC_ERROR_NONE);
2500
2427
  }
2501
2428
 
2502
2429
  std::vector<std::pair<std::string, std::string>> TestOnlyCopyToVector()
2503
2430
  override {
2504
2431
  std::vector<std::pair<std::string, std::string>> result;
2505
- for (grpc_linked_mdelem* entry = batch_->list.head; entry != nullptr;
2506
- entry = entry->next) {
2507
- if (batch_->idx.named.path != entry) {
2508
- result.push_back(std::make_pair(
2509
- std::string(StringViewFromSlice(GRPC_MDKEY(entry->md))),
2510
- std::string(StringViewFromSlice(GRPC_MDVALUE(entry->md)))));
2432
+ batch_->ForEach([&](grpc_mdelem md) {
2433
+ auto key = std::string(StringViewFromSlice(GRPC_MDKEY(md)));
2434
+ if (key != ":path") {
2435
+ result.push_back(
2436
+ std::make_pair(std::move(key),
2437
+ std::string(StringViewFromSlice(GRPC_MDVALUE(md)))));
2511
2438
  }
2512
- }
2439
+ });
2513
2440
  return result;
2514
2441
  }
2515
2442
 
2443
+ absl::optional<absl::string_view> Lookup(absl::string_view key,
2444
+ std::string* buffer) const override {
2445
+ return batch_->GetValue(key, buffer);
2446
+ }
2447
+
2516
2448
  private:
2517
2449
  LoadBalancedCall* lb_call_;
2518
2450
  grpc_metadata_batch* batch_;
@@ -2532,8 +2464,8 @@ class ClientChannel::LoadBalancedCall::LbCallState
2532
2464
  const LoadBalancingPolicy::BackendMetricData* GetBackendMetricData()
2533
2465
  override {
2534
2466
  if (lb_call_->backend_metric_data_ == nullptr) {
2535
- grpc_linked_mdelem* md = lb_call_->recv_trailing_metadata_->idx.named
2536
- .x_endpoint_load_metrics_bin;
2467
+ grpc_linked_mdelem* md = lb_call_->recv_trailing_metadata_->legacy_index()
2468
+ ->named.x_endpoint_load_metrics_bin;
2537
2469
  if (md != nullptr) {
2538
2470
  lb_call_->backend_metric_data_ =
2539
2471
  ParseBackendMetricData(GRPC_MDVALUE(md->md), lb_call_->arena_);
@@ -2906,14 +2838,13 @@ void ClientChannel::LoadBalancedCall::RecvTrailingMetadataReady(
2906
2838
  if (error != GRPC_ERROR_NONE) {
2907
2839
  // Get status from error.
2908
2840
  grpc_status_code code;
2909
- grpc_slice message = grpc_empty_slice();
2841
+ std::string message;
2910
2842
  grpc_error_get_status(error, self->deadline_, &code, &message,
2911
2843
  /*http_error=*/nullptr, /*error_string=*/nullptr);
2912
- status = absl::Status(static_cast<absl::StatusCode>(code),
2913
- StringViewFromSlice(message));
2844
+ status = absl::Status(static_cast<absl::StatusCode>(code), message);
2914
2845
  } else {
2915
2846
  // Get status from headers.
2916
- const auto& fields = self->recv_trailing_metadata_->idx.named;
2847
+ const auto& fields = self->recv_trailing_metadata_->legacy_index()->named;
2917
2848
  GPR_ASSERT(fields.grpc_status != nullptr);
2918
2849
  grpc_status_code code =
2919
2850
  grpc_get_status_code_from_metadata(fields.grpc_status->md);
@@ -3116,9 +3047,20 @@ bool ClientChannel::LoadBalancedCall::PickSubchannelLocked(
3116
3047
  GPR_ASSERT(complete_pick->subchannel != nullptr);
3117
3048
  // Grab a ref to the connected subchannel while we're still
3118
3049
  // holding the data plane mutex.
3119
- connected_subchannel_ = chand_->GetConnectedSubchannelInDataPlane(
3050
+ SubchannelWrapper* subchannel = static_cast<SubchannelWrapper*>(
3120
3051
  complete_pick->subchannel.get());
3121
- GPR_ASSERT(connected_subchannel_ != nullptr);
3052
+ connected_subchannel_ = subchannel->connected_subchannel();
3053
+ // If the subchannel has no connected subchannel (e.g., if the
3054
+ // subchannel has moved out of state READY but the LB policy hasn't
3055
+ // yet seen that change and given us a new picker), then just
3056
+ // queue the pick. We'll try again as soon as we get a new picker.
3057
+ // TODO(roth): In this case, we need to invoke the LB
3058
+ // policy's recv_trailing_metadata_ready callback to tell it
3059
+ // that the pick has been abandoned.
3060
+ if (connected_subchannel_ == nullptr) {
3061
+ MaybeAddCallToLbQueuedCallsLocked();
3062
+ return false;
3063
+ }
3122
3064
  lb_recv_trailing_metadata_ready_ =
3123
3065
  std::move(complete_pick->recv_trailing_metadata_ready);
3124
3066
  MaybeRemoveCallFromLbQueuedCallsLocked();
@@ -3142,13 +3084,6 @@ bool ClientChannel::LoadBalancedCall::PickSubchannelLocked(
3142
3084
  gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick failed: %s",
3143
3085
  chand_, this, fail_pick->status.ToString().c_str());
3144
3086
  }
3145
- // If we're shutting down, fail all RPCs.
3146
- grpc_error_handle disconnect_error = chand_->disconnect_error();
3147
- if (disconnect_error != GRPC_ERROR_NONE) {
3148
- MaybeRemoveCallFromLbQueuedCallsLocked();
3149
- *error = GRPC_ERROR_REF(disconnect_error);
3150
- return true;
3151
- }
3152
3087
  // If wait_for_ready is false, then the error indicates the RPC
3153
3088
  // attempt's final status.
3154
3089
  if ((send_initial_metadata_flags &