grpc 1.30.2 → 1.35.0

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

Potentially problematic release.


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

Files changed (1231) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1055 -18213
  3. data/etc/roots.pem +257 -573
  4. data/include/grpc/compression.h +1 -1
  5. data/include/grpc/grpc.h +15 -7
  6. data/include/grpc/grpc_security.h +254 -186
  7. data/include/grpc/grpc_security_constants.h +3 -0
  8. data/include/grpc/impl/codegen/README.md +22 -0
  9. data/include/grpc/impl/codegen/atm_windows.h +4 -0
  10. data/include/grpc/impl/codegen/byte_buffer.h +1 -1
  11. data/include/grpc/impl/codegen/grpc_types.h +16 -12
  12. data/include/grpc/impl/codegen/log.h +0 -2
  13. data/include/grpc/impl/codegen/port_platform.h +28 -88
  14. data/include/grpc/impl/codegen/sync_windows.h +4 -0
  15. data/include/grpc/slice_buffer.h +3 -3
  16. data/include/grpc/support/sync.h +3 -3
  17. data/include/grpc/support/time.h +7 -7
  18. data/src/core/ext/filters/client_channel/backend_metric.cc +14 -13
  19. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -2
  20. data/src/core/ext/filters/client_channel/client_channel.cc +2991 -1559
  21. data/src/core/ext/filters/client_channel/client_channel.h +1 -5
  22. data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -3
  23. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
  24. data/src/core/ext/filters/client_channel/config_selector.cc +58 -0
  25. data/src/core/ext/filters/client_channel/config_selector.h +125 -0
  26. data/src/core/ext/filters/client_channel/dynamic_filters.cc +186 -0
  27. data/src/core/ext/filters/client_channel/dynamic_filters.h +99 -0
  28. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -2
  29. data/src/core/ext/filters/client_channel/health/health_check_client.cc +18 -8
  30. data/src/core/ext/filters/client_channel/health/health_check_client.h +4 -4
  31. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +13 -14
  32. data/src/core/ext/filters/client_channel/http_proxy.cc +27 -24
  33. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +48 -35
  34. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
  35. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +10 -7
  36. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +1 -1
  37. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +248 -214
  38. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +0 -13
  39. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +0 -3
  40. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -37
  41. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +3 -1
  42. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +3 -3
  43. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
  44. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +23 -17
  45. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +79 -30
  46. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +10 -9
  47. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +14 -36
  48. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +29 -19
  49. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +350 -130
  50. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +52 -24
  51. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +24 -0
  52. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +812 -0
  53. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +722 -0
  54. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +1262 -0
  55. data/src/core/ext/filters/client_channel/lb_policy.cc +6 -2
  56. data/src/core/ext/filters/client_channel/lb_policy.h +10 -7
  57. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +12 -6
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +14 -18
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -32
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +8 -6
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +10 -8
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +7 -5
  63. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +488 -65
  64. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -0
  65. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  66. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  67. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +13 -12
  68. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +4 -4
  69. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -1
  70. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +35 -28
  71. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +673 -69
  72. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +28 -0
  73. data/src/core/ext/filters/client_channel/resolver.cc +3 -1
  74. data/src/core/ext/filters/client_channel/resolver.h +4 -1
  75. data/src/core/ext/filters/client_channel/resolver_factory.h +6 -6
  76. data/src/core/ext/filters/client_channel/resolver_registry.cc +49 -49
  77. data/src/core/ext/filters/client_channel/resolver_registry.h +2 -2
  78. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +35 -81
  79. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +12 -11
  80. data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -3
  81. data/src/core/ext/filters/client_channel/retry_throttle.h +4 -2
  82. data/src/core/ext/filters/client_channel/server_address.cc +120 -7
  83. data/src/core/ext/filters/client_channel/server_address.h +44 -21
  84. data/src/core/ext/filters/client_channel/service_config.cc +18 -13
  85. data/src/core/ext/filters/client_channel/service_config.h +8 -5
  86. data/src/core/ext/filters/client_channel/service_config_call_data.h +19 -1
  87. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +142 -0
  88. data/src/core/ext/filters/client_channel/service_config_parser.cc +8 -6
  89. data/src/core/ext/filters/client_channel/service_config_parser.h +8 -5
  90. data/src/core/ext/filters/client_channel/subchannel.cc +116 -88
  91. data/src/core/ext/filters/client_channel/subchannel.h +30 -24
  92. data/src/core/ext/filters/client_channel/subchannel_interface.h +41 -5
  93. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +6 -2
  94. data/src/core/ext/filters/deadline/deadline_filter.cc +87 -79
  95. data/src/core/ext/filters/deadline/deadline_filter.h +7 -11
  96. data/src/core/ext/filters/http/client/http_client_filter.cc +6 -6
  97. data/src/core/ext/filters/http/client_authority_filter.cc +6 -6
  98. data/src/core/ext/filters/http/http_filters_plugin.cc +8 -4
  99. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +74 -33
  100. data/src/core/ext/filters/http/message_compress/message_decompress_filter.h +3 -1
  101. data/src/core/ext/filters/http/server/http_server_filter.cc +3 -3
  102. data/src/core/ext/filters/max_age/max_age_filter.cc +3 -2
  103. data/src/core/ext/filters/message_size/message_size_filter.cc +59 -82
  104. data/src/core/ext/filters/message_size/message_size_filter.h +8 -1
  105. data/src/core/ext/filters/workarounds/workaround_utils.cc +1 -1
  106. data/src/core/ext/transport/chttp2/client/authority.cc +3 -3
  107. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +87 -31
  108. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +19 -2
  109. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +20 -8
  110. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +21 -10
  111. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +34 -47
  112. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +478 -342
  113. data/src/core/ext/transport/chttp2/server/chttp2_server.h +7 -2
  114. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -3
  115. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +19 -18
  116. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +9 -9
  117. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -7
  118. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +284 -321
  119. data/src/core/ext/transport/chttp2/transport/flow_control.cc +33 -30
  120. data/src/core/ext/transport/chttp2/transport/flow_control.h +27 -19
  121. data/src/core/ext/transport/chttp2/transport/frame_data.cc +9 -12
  122. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -7
  123. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
  124. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +12 -13
  125. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +8 -9
  126. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
  127. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +15 -18
  128. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +37 -37
  129. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +13 -17
  130. data/src/core/ext/transport/chttp2/transport/internal.h +23 -2
  131. data/src/core/ext/transport/chttp2/transport/parsing.cc +52 -74
  132. data/src/core/ext/transport/chttp2/transport/writing.cc +17 -22
  133. data/src/core/ext/transport/inproc/inproc_transport.cc +87 -33
  134. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +1 -1
  135. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +1 -1
  136. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +10 -4
  137. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +244 -0
  138. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +865 -0
  139. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +74 -0
  140. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +253 -0
  141. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +458 -0
  142. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +1818 -0
  143. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +35 -0
  144. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +77 -0
  145. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +55 -0
  146. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +349 -0
  147. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +124 -0
  148. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +428 -0
  149. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +35 -0
  150. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +88 -0
  151. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +310 -0
  152. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +991 -0
  153. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +103 -0
  154. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +388 -0
  155. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +34 -0
  156. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +78 -0
  157. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +53 -0
  158. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +149 -0
  159. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +241 -0
  160. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +839 -0
  161. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +170 -0
  162. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +752 -0
  163. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +36 -0
  164. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +88 -0
  165. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +176 -0
  166. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +730 -0
  167. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +28 -0
  168. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +65 -0
  169. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/socket_option.upb.c +8 -8
  170. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +95 -0
  171. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +36 -0
  172. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +92 -0
  173. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +91 -0
  174. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +243 -0
  175. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +91 -0
  176. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +305 -0
  177. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +112 -0
  178. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +367 -0
  179. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +33 -0
  180. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +73 -0
  181. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +128 -0
  182. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +512 -0
  183. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +155 -0
  184. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +591 -0
  185. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +41 -0
  186. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +107 -0
  187. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +178 -0
  188. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +662 -0
  189. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +63 -0
  190. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +220 -0
  191. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +900 -0
  192. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +3640 -0
  193. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +60 -0
  194. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +159 -0
  195. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +50 -0
  196. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +122 -0
  197. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +364 -0
  198. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +1475 -0
  199. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +20 -0
  200. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +35 -0
  201. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +110 -0
  202. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +426 -0
  203. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +76 -0
  204. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +236 -0
  205. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +147 -0
  206. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +621 -0
  207. data/src/core/ext/upb-generated/envoy/{api/v2 → service/cluster/v3}/cds.upb.c +6 -7
  208. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +56 -0
  209. data/src/core/ext/upb-generated/envoy/service/discovery/{v2 → v3}/ads.upb.c +6 -5
  210. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +56 -0
  211. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +139 -0
  212. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +487 -0
  213. data/src/core/ext/upb-generated/envoy/{api/v2 → service/endpoint/v3}/eds.upb.c +6 -7
  214. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +56 -0
  215. data/src/core/ext/upb-generated/envoy/{api/v2 → service/listener/v3}/lds.upb.c +6 -7
  216. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +56 -0
  217. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +55 -0
  218. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +151 -0
  219. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/rds.upb.c +6 -7
  220. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +56 -0
  221. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/srds.upb.c +6 -7
  222. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +56 -0
  223. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +47 -0
  224. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +128 -0
  225. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +35 -0
  226. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +84 -0
  227. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +34 -0
  228. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +78 -0
  229. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +64 -0
  230. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +166 -0
  231. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +54 -0
  232. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +146 -0
  233. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +63 -0
  234. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +207 -0
  235. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +88 -0
  236. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +301 -0
  237. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +90 -0
  238. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +283 -0
  239. data/src/core/ext/upb-generated/envoy/type/{http.upb.c → v3/http.upb.c} +2 -2
  240. data/src/core/ext/upb-generated/envoy/type/{http.upb.h → v3/http.upb.h} +9 -9
  241. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +40 -0
  242. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +99 -0
  243. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +51 -0
  244. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +130 -0
  245. data/src/core/ext/upb-generated/envoy/type/{semantic_version.upb.c → v3/semantic_version.upb.c} +7 -6
  246. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +68 -0
  247. data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -1
  248. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +242 -0
  249. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +830 -0
  250. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +234 -0
  251. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +842 -0
  252. data/src/core/ext/upb-generated/google/api/http.upb.c +3 -3
  253. data/src/core/ext/upb-generated/google/api/http.upb.h +52 -32
  254. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +1 -1
  255. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +12 -6
  256. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +106 -106
  257. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +688 -499
  258. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +1 -1
  259. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +12 -6
  260. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +1 -1
  261. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +8 -2
  262. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +5 -5
  263. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +55 -57
  264. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +1 -1
  265. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +12 -6
  266. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +9 -9
  267. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +82 -28
  268. data/src/core/ext/upb-generated/google/rpc/status.upb.c +1 -1
  269. data/src/core/ext/upb-generated/google/rpc/status.upb.h +17 -10
  270. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +5 -5
  271. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +40 -45
  272. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +43 -43
  273. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +236 -184
  274. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +5 -5
  275. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +29 -13
  276. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +2 -2
  277. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +19 -7
  278. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +17 -17
  279. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +122 -62
  280. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +3 -3
  281. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +30 -12
  282. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +31 -0
  283. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +64 -0
  284. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +1 -1
  285. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +2 -2
  286. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +12 -6
  287. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +27 -0
  288. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +60 -0
  289. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.c +28 -0
  290. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +60 -0
  291. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +52 -0
  292. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +143 -0
  293. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +42 -0
  294. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +84 -0
  295. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +36 -0
  296. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +94 -0
  297. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +54 -0
  298. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +173 -0
  299. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +36 -0
  300. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +92 -0
  301. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +9 -9
  302. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +48 -68
  303. data/src/core/ext/upb-generated/validate/validate.upb.c +68 -68
  304. data/src/core/ext/upb-generated/validate/validate.upb.h +727 -587
  305. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +38 -0
  306. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.h +30 -0
  307. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.c +41 -0
  308. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.h +35 -0
  309. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +254 -0
  310. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.h +105 -0
  311. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +100 -0
  312. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.h +45 -0
  313. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +558 -0
  314. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +145 -0
  315. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.c +53 -0
  316. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.h +35 -0
  317. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +133 -0
  318. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.h +35 -0
  319. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c +127 -0
  320. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.h +65 -0
  321. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.c +56 -0
  322. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.h +35 -0
  323. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +266 -0
  324. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +125 -0
  325. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +143 -0
  326. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +55 -0
  327. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.c +56 -0
  328. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.h +35 -0
  329. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c +66 -0
  330. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.h +40 -0
  331. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +263 -0
  332. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.h +100 -0
  333. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +233 -0
  334. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.h +70 -0
  335. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.c +56 -0
  336. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.h +35 -0
  337. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +228 -0
  338. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +80 -0
  339. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +46 -0
  340. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.h +35 -0
  341. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c +59 -0
  342. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.h +35 -0
  343. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +55 -0
  344. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.h +35 -0
  345. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c +110 -0
  346. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.h +50 -0
  347. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +113 -0
  348. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.h +50 -0
  349. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.c +146 -0
  350. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.h +55 -0
  351. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.c +50 -0
  352. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.h +35 -0
  353. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +190 -0
  354. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +55 -0
  355. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +185 -0
  356. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.h +65 -0
  357. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +62 -0
  358. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.h +40 -0
  359. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +97 -0
  360. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +40 -0
  361. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +915 -0
  362. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +280 -0
  363. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.c +71 -0
  364. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.h +45 -0
  365. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c +64 -0
  366. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.h +40 -0
  367. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +511 -0
  368. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +115 -0
  369. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c +48 -0
  370. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.h +30 -0
  371. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +166 -0
  372. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.h +55 -0
  373. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c +105 -0
  374. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.h +45 -0
  375. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +249 -0
  376. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h +60 -0
  377. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.c +72 -0
  378. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.h +35 -0
  379. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c +60 -0
  380. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.h +35 -0
  381. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +152 -0
  382. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.h +60 -0
  383. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.c +83 -0
  384. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.h +35 -0
  385. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.c +82 -0
  386. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.h +35 -0
  387. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +83 -0
  388. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.h +40 -0
  389. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.c +86 -0
  390. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.h +35 -0
  391. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.c +74 -0
  392. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.h +35 -0
  393. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +64 -0
  394. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.h +40 -0
  395. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.c +54 -0
  396. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.h +35 -0
  397. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.c +53 -0
  398. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.h +35 -0
  399. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +73 -0
  400. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.h +45 -0
  401. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c +72 -0
  402. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.h +40 -0
  403. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.c +81 -0
  404. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.h +45 -0
  405. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.c +92 -0
  406. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.h +65 -0
  407. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.c +95 -0
  408. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.h +55 -0
  409. data/src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.c +34 -0
  410. data/src/core/ext/{upb-generated/gogoproto/gogo.upb.h → upbdefs-generated/envoy/type/v3/http.upbdefs.h} +10 -10
  411. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.c +59 -0
  412. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.h +40 -0
  413. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.c +54 -0
  414. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.h +45 -0
  415. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.c +47 -0
  416. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.h +35 -0
  417. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.c +40 -0
  418. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.h +30 -0
  419. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.c +61 -0
  420. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.h +45 -0
  421. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.c +39 -0
  422. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.h +35 -0
  423. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +386 -0
  424. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.h +165 -0
  425. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.c +40 -0
  426. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.h +35 -0
  427. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.c +37 -0
  428. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.h +35 -0
  429. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.c +65 -0
  430. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.h +50 -0
  431. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.c +40 -0
  432. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.h +35 -0
  433. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.c +66 -0
  434. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.h +75 -0
  435. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +42 -0
  436. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.h +35 -0
  437. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +70 -0
  438. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.h +45 -0
  439. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +56 -0
  440. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.h +35 -0
  441. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +33 -0
  442. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.h +30 -0
  443. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +49 -0
  444. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.h +35 -0
  445. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +43 -0
  446. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.h +35 -0
  447. data/src/core/ext/upbdefs-generated/udpa/core/v1/authority.upbdefs.c +42 -0
  448. data/src/core/ext/upbdefs-generated/udpa/core/v1/authority.upbdefs.h +35 -0
  449. data/src/core/ext/upbdefs-generated/udpa/core/v1/collection_entry.upbdefs.c +62 -0
  450. data/src/core/ext/upbdefs-generated/udpa/core/v1/collection_entry.upbdefs.h +40 -0
  451. data/src/core/ext/upbdefs-generated/udpa/core/v1/context_params.upbdefs.c +45 -0
  452. data/src/core/ext/upbdefs-generated/udpa/core/v1/context_params.upbdefs.h +40 -0
  453. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource.upbdefs.c +49 -0
  454. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource.upbdefs.h +35 -0
  455. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_locator.upbdefs.c +68 -0
  456. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_locator.upbdefs.h +40 -0
  457. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_name.upbdefs.c +51 -0
  458. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_name.upbdefs.h +35 -0
  459. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +307 -0
  460. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.h +145 -0
  461. data/src/core/ext/xds/certificate_provider_factory.h +61 -0
  462. data/src/core/ext/xds/certificate_provider_registry.cc +103 -0
  463. data/src/core/ext/xds/certificate_provider_registry.h +57 -0
  464. data/src/core/ext/xds/certificate_provider_store.cc +87 -0
  465. data/src/core/ext/xds/certificate_provider_store.h +112 -0
  466. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +144 -0
  467. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +69 -0
  468. data/src/core/ext/xds/xds_api.cc +2308 -0
  469. data/src/core/ext/xds/xds_api.h +469 -0
  470. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.cc +220 -42
  471. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.h +31 -11
  472. data/src/core/ext/xds/xds_certificate_provider.cc +299 -0
  473. data/src/core/ext/xds/xds_certificate_provider.h +112 -0
  474. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_args.h +9 -6
  475. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.cc +661 -791
  476. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.h +126 -99
  477. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.cc +61 -18
  478. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.h +48 -20
  479. data/src/core/ext/xds/xds_server_config_fetcher.cc +131 -0
  480. data/src/core/lib/channel/channel_args.cc +9 -8
  481. data/src/core/lib/channel/channel_args.h +0 -1
  482. data/src/core/lib/channel/channel_trace.cc +6 -8
  483. data/src/core/lib/channel/channel_trace.h +1 -1
  484. data/src/core/lib/channel/channelz.cc +41 -88
  485. data/src/core/lib/channel/channelz.h +14 -23
  486. data/src/core/lib/channel/channelz_registry.cc +15 -12
  487. data/src/core/lib/channel/channelz_registry.h +3 -1
  488. data/src/core/lib/channel/handshaker.cc +2 -2
  489. data/src/core/lib/channel/handshaker.h +2 -2
  490. data/src/core/lib/compression/compression.cc +8 -4
  491. data/src/core/lib/compression/compression_args.cc +3 -2
  492. data/src/core/lib/compression/compression_internal.cc +10 -5
  493. data/src/core/lib/compression/compression_internal.h +2 -1
  494. data/src/core/lib/compression/stream_compression_identity.cc +1 -3
  495. data/src/core/lib/debug/stats.h +2 -2
  496. data/src/core/lib/debug/stats_data.cc +1 -0
  497. data/src/core/lib/debug/stats_data.h +13 -13
  498. data/src/core/lib/gpr/alloc.cc +3 -2
  499. data/src/core/lib/gpr/cpu_iphone.cc +10 -2
  500. data/src/core/lib/gpr/log.cc +53 -16
  501. data/src/core/lib/gpr/log_linux.cc +23 -9
  502. data/src/core/lib/gpr/log_posix.cc +19 -7
  503. data/src/core/lib/gpr/log_windows.cc +18 -4
  504. data/src/core/lib/gpr/murmur_hash.cc +1 -1
  505. data/src/core/lib/gpr/spinlock.h +10 -2
  506. data/src/core/lib/gpr/string.cc +33 -31
  507. data/src/core/lib/gpr/string.h +9 -8
  508. data/src/core/lib/gpr/sync.cc +4 -4
  509. data/src/core/lib/gpr/sync_posix.cc +2 -8
  510. data/src/core/lib/gpr/time.cc +12 -12
  511. data/src/core/lib/gpr/time_precise.cc +5 -2
  512. data/src/core/lib/gpr/time_precise.h +6 -2
  513. data/src/core/lib/gpr/tls.h +4 -0
  514. data/src/core/lib/gpr/tls_msvc.h +2 -0
  515. data/src/core/lib/gpr/tls_stdcpp.h +48 -0
  516. data/src/core/lib/gpr/useful.h +5 -4
  517. data/src/core/lib/gprpp/arena.h +3 -2
  518. data/src/core/lib/gprpp/dual_ref_counted.h +331 -0
  519. data/src/core/lib/gprpp/examine_stack.cc +43 -0
  520. data/src/core/lib/gprpp/examine_stack.h +46 -0
  521. data/src/core/lib/gprpp/fork.cc +2 -2
  522. data/src/core/lib/gprpp/global_config_env.cc +8 -6
  523. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  524. data/src/core/lib/gprpp/orphanable.h +4 -8
  525. data/src/core/lib/gprpp/ref_counted.h +91 -68
  526. data/src/core/lib/gprpp/ref_counted_ptr.h +166 -7
  527. data/src/core/lib/gprpp/stat.h +38 -0
  528. data/src/core/lib/gprpp/stat_posix.cc +49 -0
  529. data/src/core/lib/gprpp/stat_windows.cc +48 -0
  530. data/src/core/lib/gprpp/thd.h +2 -2
  531. data/src/core/lib/gprpp/thd_posix.cc +42 -37
  532. data/src/core/lib/gprpp/thd_windows.cc +3 -1
  533. data/src/core/lib/http/httpcli.cc +14 -11
  534. data/src/core/lib/http/httpcli.h +2 -3
  535. data/src/core/lib/http/httpcli_security_connector.cc +6 -6
  536. data/src/core/lib/http/parser.cc +47 -27
  537. data/src/core/lib/iomgr/call_combiner.cc +8 -5
  538. data/src/core/lib/iomgr/cfstream_handle.cc +1 -0
  539. data/src/core/lib/iomgr/combiner.cc +2 -1
  540. data/src/core/lib/iomgr/endpoint.cc +5 -1
  541. data/src/core/lib/iomgr/endpoint.h +8 -4
  542. data/src/core/lib/iomgr/endpoint_cfstream.cc +36 -11
  543. data/src/core/lib/iomgr/endpoint_pair_posix.cc +10 -10
  544. data/src/core/lib/iomgr/error.cc +17 -12
  545. data/src/core/lib/iomgr/error_cfstream.cc +9 -8
  546. data/src/core/lib/iomgr/error_internal.h +1 -1
  547. data/src/core/lib/iomgr/ev_epoll1_linux.cc +25 -19
  548. data/src/core/lib/iomgr/ev_epollex_linux.cc +40 -38
  549. data/src/core/lib/iomgr/ev_poll_posix.cc +15 -12
  550. data/src/core/lib/iomgr/exec_ctx.cc +1 -1
  551. data/src/core/lib/iomgr/exec_ctx.h +16 -12
  552. data/src/core/lib/iomgr/executor/mpmcqueue.h +5 -5
  553. data/src/core/lib/iomgr/executor/threadpool.h +4 -4
  554. data/src/core/lib/iomgr/executor.cc +2 -1
  555. data/src/core/lib/iomgr/executor.h +1 -1
  556. data/src/core/lib/iomgr/iomgr.cc +1 -1
  557. data/src/core/lib/iomgr/is_epollexclusive_available.cc +14 -0
  558. data/src/core/lib/iomgr/load_file.h +1 -1
  559. data/src/core/lib/iomgr/lockfree_event.cc +19 -14
  560. data/src/core/lib/iomgr/lockfree_event.h +2 -2
  561. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.cc +128 -44
  562. data/src/core/lib/iomgr/parse_address.h +77 -0
  563. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +2 -1
  564. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +1 -1
  565. data/src/core/lib/iomgr/pollset_set_custom.cc +1 -1
  566. data/src/core/lib/iomgr/port.h +1 -21
  567. data/src/core/lib/iomgr/python_util.h +4 -4
  568. data/src/core/lib/iomgr/resolve_address.cc +4 -4
  569. data/src/core/lib/iomgr/resolve_address_custom.cc +13 -18
  570. data/src/core/lib/iomgr/resolve_address_posix.cc +1 -5
  571. data/src/core/lib/iomgr/resolve_address_windows.cc +8 -8
  572. data/src/core/lib/iomgr/resource_quota.cc +34 -31
  573. data/src/core/lib/iomgr/sockaddr_utils.cc +19 -16
  574. data/src/core/lib/iomgr/sockaddr_utils.h +4 -3
  575. data/src/core/lib/iomgr/socket_factory_posix.cc +3 -2
  576. data/src/core/lib/iomgr/socket_mutator.cc +3 -2
  577. data/src/core/lib/iomgr/socket_utils_common_posix.cc +95 -55
  578. data/src/core/lib/iomgr/socket_windows.cc +4 -5
  579. data/src/core/lib/iomgr/tcp_client.cc +3 -3
  580. data/src/core/lib/iomgr/tcp_client_cfstream.cc +9 -11
  581. data/src/core/lib/iomgr/tcp_client_custom.cc +13 -15
  582. data/src/core/lib/iomgr/tcp_client_posix.cc +27 -36
  583. data/src/core/lib/iomgr/tcp_client_windows.cc +9 -9
  584. data/src/core/lib/iomgr/tcp_custom.cc +54 -33
  585. data/src/core/lib/iomgr/tcp_custom.h +1 -1
  586. data/src/core/lib/iomgr/tcp_posix.cc +43 -21
  587. data/src/core/lib/iomgr/tcp_server.cc +3 -4
  588. data/src/core/lib/iomgr/tcp_server.h +7 -5
  589. data/src/core/lib/iomgr/tcp_server_custom.cc +34 -36
  590. data/src/core/lib/iomgr/tcp_server_posix.cc +34 -41
  591. data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -4
  592. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +5 -7
  593. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +4 -9
  594. data/src/core/lib/iomgr/tcp_server_windows.cc +16 -16
  595. data/src/core/lib/iomgr/tcp_windows.cc +26 -10
  596. data/src/core/lib/iomgr/timer_custom.cc +5 -5
  597. data/src/core/lib/iomgr/timer_generic.cc +16 -15
  598. data/src/core/lib/iomgr/timer_manager.cc +2 -2
  599. data/src/core/lib/iomgr/udp_server.cc +25 -25
  600. data/src/core/lib/iomgr/udp_server.h +6 -4
  601. data/src/core/lib/iomgr/unix_sockets_posix.cc +36 -30
  602. data/src/core/lib/iomgr/unix_sockets_posix.h +8 -1
  603. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +12 -2
  604. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -2
  605. data/src/core/lib/json/json.h +12 -2
  606. data/src/core/lib/json/json_reader.cc +28 -25
  607. data/src/core/lib/json/json_util.cc +58 -0
  608. data/src/core/lib/json/json_util.h +204 -0
  609. data/src/core/lib/json/json_writer.cc +2 -1
  610. data/src/core/lib/security/authorization/authorization_engine.cc +177 -0
  611. data/src/core/lib/security/authorization/authorization_engine.h +84 -0
  612. data/src/core/lib/security/authorization/evaluate_args.cc +148 -0
  613. data/src/core/lib/security/authorization/evaluate_args.h +59 -0
  614. data/src/core/lib/security/authorization/mock_cel/activation.h +57 -0
  615. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +44 -0
  616. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +69 -0
  617. data/src/core/lib/security/authorization/mock_cel/cel_value.h +97 -0
  618. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +67 -0
  619. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +57 -0
  620. data/src/core/lib/security/context/security_context.cc +4 -3
  621. data/src/core/lib/security/context/security_context.h +3 -1
  622. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +1 -1
  623. data/src/core/lib/security/credentials/credentials.cc +7 -7
  624. data/src/core/lib/security/credentials/credentials.h +8 -6
  625. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +413 -0
  626. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +80 -0
  627. data/src/core/lib/security/credentials/external/aws_request_signer.cc +213 -0
  628. data/src/core/lib/security/credentials/external/aws_request_signer.h +72 -0
  629. data/src/core/lib/security/credentials/external/external_account_credentials.cc +497 -0
  630. data/src/core/lib/security/credentials/external/external_account_credentials.h +120 -0
  631. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +135 -0
  632. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +48 -0
  633. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +213 -0
  634. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +58 -0
  635. data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -1
  636. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +8 -6
  637. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +82 -55
  638. data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +64 -0
  639. data/src/core/lib/security/credentials/jwt/json_token.cc +6 -3
  640. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +7 -4
  641. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +4 -3
  642. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +8 -4
  643. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +58 -74
  644. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -4
  645. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +7 -7
  646. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +25 -5
  647. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +11 -1
  648. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +346 -0
  649. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +213 -0
  650. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +399 -0
  651. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +138 -0
  652. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +78 -150
  653. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +65 -185
  654. data/src/core/lib/security/credentials/tls/tls_credentials.cc +16 -12
  655. data/src/core/lib/security/credentials/tls/tls_credentials.h +2 -2
  656. data/src/core/lib/security/credentials/tls/tls_utils.cc +91 -0
  657. data/src/core/lib/security/credentials/tls/tls_utils.h +38 -0
  658. data/src/core/lib/security/credentials/xds/xds_credentials.cc +175 -0
  659. data/src/core/lib/security/credentials/xds/xds_credentials.h +69 -0
  660. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -1
  661. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +20 -25
  662. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +121 -0
  663. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +87 -0
  664. data/src/core/lib/security/security_connector/load_system_roots.h +4 -0
  665. data/src/core/lib/security/security_connector/load_system_roots_linux.h +2 -0
  666. data/src/core/lib/security/security_connector/local/local_security_connector.cc +3 -3
  667. data/src/core/lib/security/security_connector/security_connector.cc +6 -3
  668. data/src/core/lib/security/security_connector/security_connector.h +5 -3
  669. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +22 -15
  670. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +5 -0
  671. data/src/core/lib/security/security_connector/ssl_utils.cc +46 -25
  672. data/src/core/lib/security/security_connector/ssl_utils.h +25 -21
  673. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +359 -293
  674. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +105 -61
  675. data/src/core/lib/security/transport/client_auth_filter.cc +10 -9
  676. data/src/core/lib/security/transport/secure_endpoint.cc +9 -3
  677. data/src/core/lib/security/transport/security_handshaker.cc +3 -3
  678. data/src/core/lib/security/transport/server_auth_filter.cc +2 -1
  679. data/src/core/lib/security/util/json_util.cc +12 -13
  680. data/src/core/lib/security/util/json_util.h +1 -0
  681. data/src/core/lib/slice/slice.cc +45 -5
  682. data/src/core/lib/slice/slice_buffer.cc +2 -1
  683. data/src/core/lib/slice/slice_intern.cc +6 -7
  684. data/src/core/lib/slice/slice_internal.h +3 -2
  685. data/src/core/lib/surface/call.cc +93 -85
  686. data/src/core/lib/surface/call.h +2 -1
  687. data/src/core/lib/surface/call_details.cc +8 -8
  688. data/src/core/lib/surface/channel.cc +53 -61
  689. data/src/core/lib/surface/channel.h +21 -5
  690. data/src/core/lib/surface/channel_init.cc +1 -1
  691. data/src/core/lib/surface/completion_queue.cc +30 -29
  692. data/src/core/lib/surface/completion_queue.h +16 -16
  693. data/src/core/lib/surface/init.cc +32 -14
  694. data/src/core/lib/surface/lame_client.cc +20 -46
  695. data/src/core/lib/surface/lame_client.h +4 -0
  696. data/src/core/lib/surface/server.cc +1144 -1343
  697. data/src/core/lib/surface/server.h +400 -70
  698. data/src/core/lib/surface/validate_metadata.h +3 -0
  699. data/src/core/lib/surface/version.cc +2 -2
  700. data/src/core/lib/transport/authority_override.cc +40 -0
  701. data/src/core/lib/transport/authority_override.h +37 -0
  702. data/src/core/lib/transport/bdp_estimator.cc +1 -1
  703. data/src/core/lib/transport/bdp_estimator.h +2 -1
  704. data/src/core/lib/transport/byte_stream.h +3 -3
  705. data/src/core/lib/transport/connectivity_state.cc +18 -13
  706. data/src/core/lib/transport/connectivity_state.h +26 -12
  707. data/src/core/lib/transport/error_utils.cc +13 -0
  708. data/src/core/lib/transport/error_utils.h +7 -1
  709. data/src/core/lib/transport/metadata.cc +11 -1
  710. data/src/core/lib/transport/metadata.h +2 -2
  711. data/src/core/lib/transport/metadata_batch.h +4 -4
  712. data/src/core/lib/transport/static_metadata.cc +296 -277
  713. data/src/core/lib/transport/static_metadata.h +80 -73
  714. data/src/core/lib/transport/status_metadata.cc +4 -3
  715. data/src/core/lib/transport/timeout_encoding.cc +4 -4
  716. data/src/core/lib/transport/transport.cc +5 -3
  717. data/src/core/lib/transport/transport.h +21 -8
  718. data/src/core/lib/uri/uri_parser.cc +135 -258
  719. data/src/core/lib/uri/uri_parser.h +58 -20
  720. data/src/core/plugin_registry/grpc_plugin_registry.cc +45 -20
  721. data/src/core/tsi/alts/crypt/gsec.cc +5 -4
  722. data/src/core/tsi/alts/frame_protector/frame_handler.cc +8 -6
  723. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +24 -14
  724. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +51 -26
  725. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +2 -0
  726. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +8 -6
  727. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +4 -4
  728. data/src/core/tsi/fake_transport_security.cc +6 -3
  729. data/src/core/tsi/local_transport_security.cc +5 -1
  730. data/src/core/tsi/local_transport_security.h +6 -7
  731. data/src/core/tsi/ssl/session_cache/ssl_session.h +3 -0
  732. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
  733. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -1
  734. data/src/core/tsi/ssl_transport_security.cc +177 -66
  735. data/src/core/tsi/ssl_transport_security.h +23 -8
  736. data/src/core/tsi/transport_security.cc +10 -8
  737. data/src/core/tsi/transport_security_interface.h +6 -1
  738. data/src/ruby/bin/math_services_pb.rb +4 -4
  739. data/src/ruby/ext/grpc/extconf.rb +6 -3
  740. data/src/ruby/ext/grpc/rb_call.c +3 -2
  741. data/src/ruby/ext/grpc/rb_call.h +4 -0
  742. data/src/ruby/ext/grpc/rb_call_credentials.c +54 -10
  743. data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
  744. data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
  745. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +38 -18
  746. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +74 -44
  747. data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
  748. data/src/ruby/lib/grpc/generic/interceptors.rb +1 -1
  749. data/src/ruby/lib/grpc/version.rb +1 -1
  750. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +2 -2
  751. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +33 -0
  752. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +46 -12
  753. data/src/ruby/spec/channel_credentials_spec.rb +10 -0
  754. data/src/ruby/spec/generic/active_call_spec.rb +19 -8
  755. data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
  756. data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
  757. data/src/ruby/spec/pb/codegen/package_option_spec.rb +22 -6
  758. data/src/ruby/spec/user_agent_spec.rb +74 -0
  759. data/third_party/abseil-cpp/absl/algorithm/container.h +1764 -0
  760. data/third_party/abseil-cpp/absl/base/attributes.h +99 -38
  761. data/third_party/abseil-cpp/absl/base/call_once.h +1 -1
  762. data/third_party/abseil-cpp/absl/base/casts.h +9 -6
  763. data/third_party/abseil-cpp/absl/base/config.h +60 -17
  764. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +428 -335
  765. data/third_party/abseil-cpp/absl/base/internal/bits.h +17 -16
  766. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +166 -0
  767. data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +398 -0
  768. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc +93 -0
  769. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.h +130 -0
  770. data/third_party/abseil-cpp/absl/base/internal/invoke.h +4 -4
  771. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +620 -0
  772. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +126 -0
  773. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +29 -1
  774. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +2 -2
  775. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +7 -5
  776. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +25 -38
  777. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +19 -25
  778. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +8 -0
  779. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +28 -5
  780. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +8 -0
  781. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +3 -1
  782. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +2 -2
  783. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +3 -3
  784. data/third_party/abseil-cpp/absl/base/macros.h +36 -109
  785. data/third_party/abseil-cpp/absl/base/optimization.h +61 -1
  786. data/third_party/abseil-cpp/absl/base/options.h +31 -4
  787. data/third_party/abseil-cpp/absl/base/policy_checks.h +1 -1
  788. data/third_party/abseil-cpp/absl/base/thread_annotations.h +94 -39
  789. data/third_party/abseil-cpp/absl/container/fixed_array.h +532 -0
  790. data/third_party/abseil-cpp/absl/container/flat_hash_map.h +606 -0
  791. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +504 -0
  792. data/third_party/abseil-cpp/absl/container/inlined_vector.h +33 -36
  793. data/third_party/abseil-cpp/absl/container/internal/common.h +206 -0
  794. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +33 -8
  795. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +460 -0
  796. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +161 -0
  797. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +208 -0
  798. data/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h +85 -0
  799. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +270 -0
  800. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +321 -0
  801. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +30 -0
  802. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +50 -0
  803. data/third_party/abseil-cpp/absl/container/internal/layout.h +743 -0
  804. data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +197 -0
  805. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +48 -0
  806. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1903 -0
  807. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +139 -0
  808. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h +32 -0
  809. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +1945 -0
  810. data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +71 -0
  811. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +382 -0
  812. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +134 -0
  813. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +196 -0
  814. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +134 -0
  815. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +89 -0
  816. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +108 -0
  817. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +248 -0
  818. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +24 -0
  819. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +93 -0
  820. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +346 -0
  821. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +149 -0
  822. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +173 -0
  823. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h +158 -0
  824. data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +140 -0
  825. data/third_party/abseil-cpp/absl/debugging/stacktrace.h +231 -0
  826. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +36 -0
  827. data/third_party/abseil-cpp/absl/debugging/symbolize.h +99 -0
  828. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +101 -0
  829. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +1560 -0
  830. data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +40 -0
  831. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +81 -0
  832. data/third_party/abseil-cpp/absl/functional/bind_front.h +184 -0
  833. data/third_party/abseil-cpp/absl/functional/function_ref.h +139 -0
  834. data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +95 -0
  835. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +106 -0
  836. data/third_party/abseil-cpp/absl/hash/hash.h +325 -0
  837. data/third_party/abseil-cpp/absl/hash/internal/city.cc +346 -0
  838. data/third_party/abseil-cpp/absl/hash/internal/city.h +96 -0
  839. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +55 -0
  840. data/third_party/abseil-cpp/absl/hash/internal/hash.h +996 -0
  841. data/third_party/abseil-cpp/absl/memory/memory.h +4 -0
  842. data/third_party/abseil-cpp/absl/meta/type_traits.h +2 -8
  843. data/third_party/abseil-cpp/absl/numeric/int128.cc +13 -27
  844. data/third_party/abseil-cpp/absl/numeric/int128.h +16 -15
  845. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +51 -0
  846. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +399 -0
  847. data/third_party/abseil-cpp/absl/status/status.cc +445 -0
  848. data/third_party/abseil-cpp/absl/status/status.h +817 -0
  849. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +38 -0
  850. data/third_party/abseil-cpp/absl/status/status_payload_printer.h +51 -0
  851. data/third_party/abseil-cpp/absl/status/statusor.cc +71 -0
  852. data/third_party/abseil-cpp/absl/status/statusor.h +760 -0
  853. data/third_party/abseil-cpp/absl/strings/charconv.cc +2 -2
  854. data/third_party/abseil-cpp/absl/strings/cord.cc +1998 -0
  855. data/third_party/abseil-cpp/absl/strings/cord.h +1276 -0
  856. data/third_party/abseil-cpp/absl/strings/escaping.cc +9 -9
  857. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +1 -1
  858. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
  859. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +2 -2
  860. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +2 -2
  861. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +173 -0
  862. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +222 -136
  863. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +136 -64
  864. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +1 -1
  865. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +14 -21
  866. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +7 -14
  867. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +31 -7
  868. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +147 -135
  869. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +999 -87
  870. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +3 -3
  871. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +4 -12
  872. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +8 -6
  873. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +13 -11
  874. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +2 -2
  875. data/third_party/abseil-cpp/absl/strings/str_cat.cc +4 -4
  876. data/third_party/abseil-cpp/absl/strings/str_cat.h +1 -1
  877. data/third_party/abseil-cpp/absl/strings/str_format.h +289 -13
  878. data/third_party/abseil-cpp/absl/strings/str_split.cc +2 -2
  879. data/third_party/abseil-cpp/absl/strings/str_split.h +1 -0
  880. data/third_party/abseil-cpp/absl/strings/string_view.h +26 -19
  881. data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -5
  882. data/third_party/abseil-cpp/absl/strings/substitute.h +32 -29
  883. data/third_party/abseil-cpp/absl/synchronization/barrier.cc +52 -0
  884. data/third_party/abseil-cpp/absl/synchronization/barrier.h +79 -0
  885. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +57 -0
  886. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +99 -0
  887. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +140 -0
  888. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +60 -0
  889. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +697 -0
  890. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h +141 -0
  891. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +155 -0
  892. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +249 -0
  893. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +106 -0
  894. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +115 -0
  895. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +492 -0
  896. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +159 -0
  897. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +2739 -0
  898. data/third_party/abseil-cpp/absl/synchronization/mutex.h +1065 -0
  899. data/third_party/abseil-cpp/absl/synchronization/notification.cc +78 -0
  900. data/third_party/abseil-cpp/absl/synchronization/notification.h +123 -0
  901. data/third_party/abseil-cpp/absl/time/civil_time.cc +9 -9
  902. data/third_party/abseil-cpp/absl/time/clock.cc +3 -3
  903. data/third_party/abseil-cpp/absl/time/duration.cc +90 -59
  904. data/third_party/abseil-cpp/absl/time/format.cc +43 -36
  905. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +26 -16
  906. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +4 -2
  907. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +1 -1
  908. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +136 -29
  909. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +13 -21
  910. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +1 -1
  911. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +136 -129
  912. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +4 -5
  913. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +8 -7
  914. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +6 -6
  915. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +2 -1
  916. data/third_party/abseil-cpp/absl/time/time.h +15 -16
  917. data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +64 -0
  918. data/third_party/abseil-cpp/absl/types/bad_variant_access.h +82 -0
  919. data/third_party/abseil-cpp/absl/types/internal/variant.h +1646 -0
  920. data/third_party/abseil-cpp/absl/types/optional.h +9 -9
  921. data/third_party/abseil-cpp/absl/types/span.h +49 -36
  922. data/third_party/abseil-cpp/absl/types/variant.h +861 -0
  923. data/third_party/abseil-cpp/absl/utility/utility.h +2 -2
  924. data/third_party/address_sorting/include/address_sorting/address_sorting.h +2 -0
  925. data/third_party/boringssl-with-bazel/err_data.c +482 -464
  926. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +3 -3
  927. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +3 -3
  928. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +1 -1
  929. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +3 -3
  930. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +2 -2
  931. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +1 -1
  932. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +1 -7
  933. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +1 -1
  934. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_enum.c +1 -1
  935. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +1 -1
  936. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +1 -1
  937. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +2 -0
  938. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +1 -0
  939. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +9 -43
  940. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +55 -4
  941. data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +34 -0
  942. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +12 -52
  943. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +0 -22
  944. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +4 -0
  945. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +159 -0
  946. data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +6 -2
  947. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +17 -1
  948. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +11 -1
  949. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +173 -35
  950. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
  951. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +2 -1
  952. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +13 -11
  953. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.c +24 -23
  954. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +20 -16
  955. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +2 -2
  956. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/util.c +3 -3
  957. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +4 -0
  958. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +30 -10
  959. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +56 -22
  960. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +70 -2
  961. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +543 -0
  962. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +237 -0
  963. data/third_party/boringssl-with-bazel/src/crypto/mem.c +29 -15
  964. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +7 -0
  965. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +36 -5
  966. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +110 -70
  967. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +348 -423
  968. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +217 -79
  969. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +766 -0
  970. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +7 -7
  971. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +10 -0
  972. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +4 -4
  973. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +3 -3
  974. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +1 -1
  975. data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +0 -67
  976. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +20 -8
  977. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +21 -18
  978. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -1
  979. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +10 -0
  980. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +65 -3
  981. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +7 -4
  982. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +67 -67
  983. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +3 -3
  984. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +57 -44
  985. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +38 -2
  986. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +9 -8
  987. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +10 -10
  988. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +37 -15
  989. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +28 -40
  990. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +0 -154
  991. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +20 -0
  992. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +30 -6
  993. data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +1 -4
  994. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +5 -0
  995. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +5 -3
  996. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +14 -14
  997. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +7 -3
  998. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +2 -2
  999. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +1 -1
  1000. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +1 -1
  1001. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +126 -40
  1002. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -1
  1003. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +24 -0
  1004. data/third_party/boringssl-with-bazel/src/include/openssl/aes.h +16 -4
  1005. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +54 -0
  1006. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +22 -23
  1007. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +7 -4
  1008. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +4 -0
  1009. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +6 -0
  1010. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +1 -1
  1011. data/third_party/boringssl-with-bazel/src/include/openssl/des.h +6 -0
  1012. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +12 -0
  1013. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +9 -0
  1014. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +73 -1
  1015. data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +3 -0
  1016. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +202 -134
  1017. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +136 -26
  1018. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +5 -2
  1019. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +43 -24
  1020. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +942 -747
  1021. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +482 -432
  1022. data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +18 -5
  1023. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +38 -3
  1024. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +27 -20
  1025. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +4 -5
  1026. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +10 -1
  1027. data/third_party/boringssl-with-bazel/src/ssl/internal.h +66 -24
  1028. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +48 -7
  1029. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +3 -6
  1030. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +8 -9
  1031. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +105 -0
  1032. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +11 -34
  1033. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +5 -5
  1034. data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +45 -24
  1035. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +250 -20
  1036. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -2
  1037. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +88 -40
  1038. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +152 -50
  1039. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +5 -3
  1040. data/third_party/re2/re2/bitmap256.h +117 -0
  1041. data/third_party/re2/re2/bitstate.cc +385 -0
  1042. data/third_party/re2/re2/compile.cc +1279 -0
  1043. data/third_party/re2/re2/dfa.cc +2130 -0
  1044. data/third_party/re2/re2/filtered_re2.cc +121 -0
  1045. data/third_party/re2/re2/filtered_re2.h +109 -0
  1046. data/third_party/re2/re2/mimics_pcre.cc +197 -0
  1047. data/third_party/re2/re2/nfa.cc +713 -0
  1048. data/third_party/re2/re2/onepass.cc +623 -0
  1049. data/third_party/re2/re2/parse.cc +2464 -0
  1050. data/third_party/re2/re2/perl_groups.cc +119 -0
  1051. data/third_party/re2/re2/pod_array.h +55 -0
  1052. data/third_party/re2/re2/prefilter.cc +710 -0
  1053. data/third_party/re2/re2/prefilter.h +108 -0
  1054. data/third_party/re2/re2/prefilter_tree.cc +407 -0
  1055. data/third_party/re2/re2/prefilter_tree.h +139 -0
  1056. data/third_party/re2/re2/prog.cc +988 -0
  1057. data/third_party/re2/re2/prog.h +436 -0
  1058. data/third_party/re2/re2/re2.cc +1362 -0
  1059. data/third_party/re2/re2/re2.h +1002 -0
  1060. data/third_party/re2/re2/regexp.cc +980 -0
  1061. data/third_party/re2/re2/regexp.h +659 -0
  1062. data/third_party/re2/re2/set.cc +154 -0
  1063. data/third_party/re2/re2/set.h +80 -0
  1064. data/third_party/re2/re2/simplify.cc +657 -0
  1065. data/third_party/re2/re2/sparse_array.h +392 -0
  1066. data/third_party/re2/re2/sparse_set.h +264 -0
  1067. data/third_party/re2/re2/stringpiece.cc +65 -0
  1068. data/third_party/re2/re2/stringpiece.h +210 -0
  1069. data/third_party/re2/re2/tostring.cc +351 -0
  1070. data/third_party/re2/re2/unicode_casefold.cc +582 -0
  1071. data/third_party/re2/re2/unicode_casefold.h +78 -0
  1072. data/third_party/re2/re2/unicode_groups.cc +6269 -0
  1073. data/third_party/re2/re2/unicode_groups.h +67 -0
  1074. data/third_party/re2/re2/walker-inl.h +246 -0
  1075. data/third_party/re2/util/benchmark.h +156 -0
  1076. data/third_party/re2/util/flags.h +26 -0
  1077. data/third_party/re2/util/logging.h +109 -0
  1078. data/third_party/re2/util/malloc_counter.h +19 -0
  1079. data/third_party/re2/util/mix.h +41 -0
  1080. data/third_party/re2/util/mutex.h +148 -0
  1081. data/third_party/re2/util/pcre.cc +1025 -0
  1082. data/third_party/re2/util/pcre.h +681 -0
  1083. data/third_party/re2/util/rune.cc +260 -0
  1084. data/third_party/re2/util/strutil.cc +149 -0
  1085. data/third_party/re2/util/strutil.h +21 -0
  1086. data/third_party/re2/util/test.h +50 -0
  1087. data/third_party/re2/util/utf.h +44 -0
  1088. data/third_party/re2/util/util.h +42 -0
  1089. data/third_party/upb/third_party/wyhash/wyhash.h +145 -0
  1090. data/third_party/upb/upb/decode.c +604 -511
  1091. data/third_party/upb/upb/decode.h +20 -1
  1092. data/third_party/upb/upb/decode.int.h +163 -0
  1093. data/third_party/upb/upb/decode_fast.c +1040 -0
  1094. data/third_party/upb/upb/decode_fast.h +126 -0
  1095. data/third_party/upb/upb/def.c +2178 -0
  1096. data/third_party/upb/upb/def.h +315 -0
  1097. data/third_party/upb/upb/def.hpp +439 -0
  1098. data/third_party/upb/upb/encode.c +311 -211
  1099. data/third_party/upb/upb/encode.h +27 -2
  1100. data/third_party/upb/upb/json_decode.c +1443 -0
  1101. data/third_party/upb/upb/json_decode.h +23 -0
  1102. data/third_party/upb/upb/json_encode.c +713 -0
  1103. data/third_party/upb/upb/json_encode.h +36 -0
  1104. data/third_party/upb/upb/msg.c +215 -70
  1105. data/third_party/upb/upb/msg.h +558 -14
  1106. data/third_party/upb/upb/port_def.inc +105 -63
  1107. data/third_party/upb/upb/port_undef.inc +10 -7
  1108. data/third_party/upb/upb/reflection.c +408 -0
  1109. data/third_party/upb/upb/reflection.h +168 -0
  1110. data/third_party/upb/upb/table.c +73 -269
  1111. data/third_party/upb/upb/table.int.h +25 -57
  1112. data/third_party/upb/upb/text_encode.c +421 -0
  1113. data/third_party/upb/upb/text_encode.h +38 -0
  1114. data/third_party/upb/upb/upb.c +138 -135
  1115. data/third_party/upb/upb/upb.h +119 -146
  1116. data/third_party/upb/upb/upb.hpp +88 -0
  1117. data/third_party/upb/upb/upb.int.h +29 -0
  1118. metadata +560 -166
  1119. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +0 -938
  1120. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +0 -528
  1121. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +0 -834
  1122. data/src/core/ext/filters/client_channel/parse_address.h +0 -53
  1123. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +0 -484
  1124. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +0 -68
  1125. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +0 -348
  1126. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +0 -123
  1127. data/src/core/ext/filters/client_channel/xds/xds_api.cc +0 -1906
  1128. data/src/core/ext/filters/client_channel/xds/xds_api.h +0 -280
  1129. data/src/core/ext/filters/client_channel/xds/xds_channel.h +0 -46
  1130. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +0 -106
  1131. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -21
  1132. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +0 -35
  1133. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +0 -114
  1134. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +0 -418
  1135. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +0 -72
  1136. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +0 -197
  1137. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +0 -105
  1138. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +0 -378
  1139. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +0 -53
  1140. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -74
  1141. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +0 -218
  1142. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +0 -35
  1143. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +0 -69
  1144. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +0 -55
  1145. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +0 -305
  1146. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +0 -403
  1147. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +0 -1447
  1148. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -112
  1149. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +0 -328
  1150. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.c +0 -35
  1151. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +0 -78
  1152. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +0 -313
  1153. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +0 -897
  1154. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +0 -96
  1155. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +0 -322
  1156. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +0 -34
  1157. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +0 -72
  1158. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +0 -197
  1159. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +0 -642
  1160. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +0 -172
  1161. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +0 -673
  1162. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +0 -36
  1163. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +0 -80
  1164. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +0 -152
  1165. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +0 -518
  1166. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +0 -89
  1167. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -129
  1168. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +0 -392
  1169. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +0 -53
  1170. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -18
  1171. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -33
  1172. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +0 -91
  1173. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +0 -266
  1174. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -112
  1175. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +0 -324
  1176. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +0 -92
  1177. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +0 -240
  1178. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +0 -53
  1179. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +0 -18
  1180. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -33
  1181. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +0 -145
  1182. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +0 -527
  1183. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +0 -43
  1184. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +0 -112
  1185. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +0 -109
  1186. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +0 -399
  1187. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +0 -53
  1188. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +0 -18
  1189. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -33
  1190. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +0 -815
  1191. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +0 -3032
  1192. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +0 -63
  1193. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +0 -199
  1194. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +0 -59
  1195. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +0 -134
  1196. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +0 -53
  1197. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +0 -228
  1198. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +0 -725
  1199. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +0 -316
  1200. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +0 -1132
  1201. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.c +0 -33
  1202. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +0 -65
  1203. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +0 -51
  1204. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +0 -125
  1205. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +0 -50
  1206. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +0 -54
  1207. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +0 -134
  1208. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +0 -63
  1209. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +0 -144
  1210. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +0 -53
  1211. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +0 -133
  1212. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +0 -88
  1213. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +0 -258
  1214. data/src/core/ext/upb-generated/envoy/type/percent.upb.c +0 -39
  1215. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +0 -87
  1216. data/src/core/ext/upb-generated/envoy/type/range.upb.c +0 -50
  1217. data/src/core/ext/upb-generated/envoy/type/range.upb.h +0 -112
  1218. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +0 -62
  1219. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +0 -89
  1220. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +0 -249
  1221. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +0 -17
  1222. data/src/core/lib/gprpp/map.h +0 -53
  1223. data/src/core/lib/security/transport/target_authority_table.cc +0 -75
  1224. data/src/core/lib/security/transport/target_authority_table.h +0 -40
  1225. data/src/core/lib/slice/slice_hash_table.h +0 -199
  1226. data/src/core/lib/slice/slice_weak_hash_table.h +0 -102
  1227. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +0 -129
  1228. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +0 -110
  1229. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +0 -274
  1230. data/third_party/upb/upb/generated_util.h +0 -105
  1231. data/third_party/upb/upb/port.c +0 -26
@@ -30,23 +30,18 @@
30
30
  #include <grpc/byte_buffer_reader.h>
31
31
  #include <grpc/grpc.h>
32
32
  #include <grpc/support/alloc.h>
33
- #include <grpc/support/string_util.h>
34
33
  #include <grpc/support/time.h>
35
34
 
36
35
  #include "src/core/ext/filters/client_channel/client_channel.h"
37
- #include "src/core/ext/filters/client_channel/parse_address.h"
38
- #include "src/core/ext/filters/client_channel/server_address.h"
39
36
  #include "src/core/ext/filters/client_channel/service_config.h"
40
- #include "src/core/ext/filters/client_channel/xds/xds_api.h"
41
- #include "src/core/ext/filters/client_channel/xds/xds_channel.h"
42
- #include "src/core/ext/filters/client_channel/xds/xds_channel_args.h"
43
- #include "src/core/ext/filters/client_channel/xds/xds_client.h"
44
- #include "src/core/ext/filters/client_channel/xds/xds_client_stats.h"
37
+ #include "src/core/ext/xds/xds_api.h"
38
+ #include "src/core/ext/xds/xds_channel_args.h"
39
+ #include "src/core/ext/xds/xds_client.h"
40
+ #include "src/core/ext/xds/xds_client_stats.h"
45
41
  #include "src/core/lib/backoff/backoff.h"
46
42
  #include "src/core/lib/channel/channel_args.h"
47
43
  #include "src/core/lib/channel/channel_stack.h"
48
44
  #include "src/core/lib/gpr/string.h"
49
- #include "src/core/lib/gprpp/map.h"
50
45
  #include "src/core/lib/gprpp/memory.h"
51
46
  #include "src/core/lib/gprpp/orphanable.h"
52
47
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
@@ -54,8 +49,6 @@
54
49
  #include "src/core/lib/iomgr/sockaddr.h"
55
50
  #include "src/core/lib/iomgr/sockaddr_utils.h"
56
51
  #include "src/core/lib/iomgr/timer.h"
57
- #include "src/core/lib/iomgr/work_serializer.h"
58
- #include "src/core/lib/slice/slice_hash_table.h"
59
52
  #include "src/core/lib/slice/slice_internal.h"
60
53
  #include "src/core/lib/slice/slice_string_helpers.h"
61
54
  #include "src/core/lib/surface/call.h"
@@ -72,6 +65,15 @@
72
65
  namespace grpc_core {
73
66
 
74
67
  TraceFlag grpc_xds_client_trace(false, "xds_client");
68
+ TraceFlag grpc_xds_client_refcount_trace(false, "xds_client_refcount");
69
+
70
+ namespace {
71
+
72
+ Mutex* g_mu = nullptr;
73
+ const grpc_channel_args* g_channel_args = nullptr;
74
+ XdsClient* g_xds_client = nullptr;
75
+
76
+ } // namespace
75
77
 
76
78
  //
77
79
  // Internal class declarations
@@ -139,22 +141,25 @@ class XdsClient::ChannelState::AdsCallState
139
141
  private:
140
142
  class ResourceState : public InternallyRefCounted<ResourceState> {
141
143
  public:
142
- ResourceState(const std::string& type_url, const std::string& name)
143
- : type_url_(type_url), name_(name) {
144
+ ResourceState(const std::string& type_url, const std::string& name,
145
+ bool sent_initial_request)
146
+ : type_url_(type_url),
147
+ name_(name),
148
+ sent_initial_request_(sent_initial_request) {
144
149
  GRPC_CLOSURE_INIT(&timer_callback_, OnTimer, this,
145
150
  grpc_schedule_on_exec_ctx);
146
151
  }
147
152
 
148
153
  void Orphan() override {
149
154
  Finish();
150
- Unref();
155
+ Unref(DEBUG_LOCATION, "Orphan");
151
156
  }
152
157
 
153
158
  void Start(RefCountedPtr<AdsCallState> ads_calld) {
154
- if (sent_) return;
155
- sent_ = true;
159
+ if (sent_initial_request_) return;
160
+ sent_initial_request_ = true;
156
161
  ads_calld_ = std::move(ads_calld);
157
- Ref().release();
162
+ Ref(DEBUG_LOCATION, "timer").release();
158
163
  timer_pending_ = true;
159
164
  grpc_timer_init(
160
165
  &timer_,
@@ -172,47 +177,52 @@ class XdsClient::ChannelState::AdsCallState
172
177
  private:
173
178
  static void OnTimer(void* arg, grpc_error* error) {
174
179
  ResourceState* self = static_cast<ResourceState*>(arg);
175
- GRPC_ERROR_REF(error); // ref owned by lambda
176
- self->ads_calld_->xds_client()->work_serializer_->Run(
177
- [self, error]() { self->OnTimerLocked(error); }, DEBUG_LOCATION);
180
+ {
181
+ MutexLock lock(&self->ads_calld_->xds_client()->mu_);
182
+ self->OnTimerLocked(GRPC_ERROR_REF(error));
183
+ }
184
+ self->ads_calld_.reset();
185
+ self->Unref(DEBUG_LOCATION, "timer");
178
186
  }
179
187
 
180
188
  void OnTimerLocked(grpc_error* error) {
181
189
  if (error == GRPC_ERROR_NONE && timer_pending_) {
182
190
  timer_pending_ = false;
183
- char* msg;
184
- gpr_asprintf(
185
- &msg,
186
- "timeout obtaining resource {type=%s name=%s} from xds server",
187
- type_url_.c_str(), name_.c_str());
188
- grpc_error* watcher_error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
189
- gpr_free(msg);
191
+ grpc_error* watcher_error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
192
+ absl::StrFormat(
193
+ "timeout obtaining resource {type=%s name=%s} from xds server",
194
+ type_url_, name_)
195
+ .c_str());
190
196
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
191
197
  gpr_log(GPR_INFO, "[xds_client %p] %s", ads_calld_->xds_client(),
192
198
  grpc_error_string(watcher_error));
193
199
  }
194
- if (type_url_ == XdsApi::kLdsTypeUrl ||
195
- type_url_ == XdsApi::kRdsTypeUrl) {
196
- ads_calld_->xds_client()->service_config_watcher_->OnError(
197
- watcher_error);
200
+ if (type_url_ == XdsApi::kLdsTypeUrl) {
201
+ ListenerState& state = ads_calld_->xds_client()->listener_map_[name_];
202
+ for (const auto& p : state.watchers) {
203
+ p.first->OnError(GRPC_ERROR_REF(watcher_error));
204
+ }
205
+ } else if (type_url_ == XdsApi::kRdsTypeUrl) {
206
+ RouteConfigState& state =
207
+ ads_calld_->xds_client()->route_config_map_[name_];
208
+ for (const auto& p : state.watchers) {
209
+ p.first->OnError(GRPC_ERROR_REF(watcher_error));
210
+ }
198
211
  } else if (type_url_ == XdsApi::kCdsTypeUrl) {
199
212
  ClusterState& state = ads_calld_->xds_client()->cluster_map_[name_];
200
213
  for (const auto& p : state.watchers) {
201
214
  p.first->OnError(GRPC_ERROR_REF(watcher_error));
202
215
  }
203
- GRPC_ERROR_UNREF(watcher_error);
204
216
  } else if (type_url_ == XdsApi::kEdsTypeUrl) {
205
217
  EndpointState& state = ads_calld_->xds_client()->endpoint_map_[name_];
206
218
  for (const auto& p : state.watchers) {
207
219
  p.first->OnError(GRPC_ERROR_REF(watcher_error));
208
220
  }
209
- GRPC_ERROR_UNREF(watcher_error);
210
221
  } else {
211
222
  GPR_UNREACHABLE_CODE(return );
212
223
  }
224
+ GRPC_ERROR_UNREF(watcher_error);
213
225
  }
214
- ads_calld_.reset();
215
- Unref();
216
226
  GRPC_ERROR_UNREF(error);
217
227
  }
218
228
 
@@ -220,7 +230,7 @@ class XdsClient::ChannelState::AdsCallState
220
230
  const std::string name_;
221
231
 
222
232
  RefCountedPtr<AdsCallState> ads_calld_;
223
- bool sent_ = false;
233
+ bool sent_initial_request_;
224
234
  bool timer_pending_ = false;
225
235
  grpc_timer timer_;
226
236
  grpc_closure timer_callback_;
@@ -229,8 +239,7 @@ class XdsClient::ChannelState::AdsCallState
229
239
  struct ResourceTypeState {
230
240
  ~ResourceTypeState() { GRPC_ERROR_UNREF(error); }
231
241
 
232
- // Version, nonce, and error for this resource type.
233
- std::string version;
242
+ // Nonce and error for this resource type.
234
243
  std::string nonce;
235
244
  grpc_error* error = GRPC_ERROR_NONE;
236
245
 
@@ -241,15 +250,15 @@ class XdsClient::ChannelState::AdsCallState
241
250
 
242
251
  void SendMessageLocked(const std::string& type_url);
243
252
 
244
- void AcceptLdsUpdate(absl::optional<XdsApi::LdsUpdate> lds_update);
245
- void AcceptRdsUpdate(absl::optional<XdsApi::RdsUpdate> rds_update);
253
+ void AcceptLdsUpdate(XdsApi::LdsUpdateMap lds_update_map);
254
+ void AcceptRdsUpdate(XdsApi::RdsUpdateMap rds_update_map);
246
255
  void AcceptCdsUpdate(XdsApi::CdsUpdateMap cds_update_map);
247
256
  void AcceptEdsUpdate(XdsApi::EdsUpdateMap eds_update_map);
248
257
 
249
258
  static void OnRequestSent(void* arg, grpc_error* error);
250
259
  void OnRequestSentLocked(grpc_error* error);
251
260
  static void OnResponseReceived(void* arg, grpc_error* error);
252
- void OnResponseReceivedLocked();
261
+ bool OnResponseReceivedLocked();
253
262
  static void OnStatusReceived(void* arg, grpc_error* error);
254
263
  void OnStatusReceivedLocked(grpc_error* error);
255
264
 
@@ -326,10 +335,10 @@ class XdsClient::ChannelState::LrsCallState
326
335
  private:
327
336
  void ScheduleNextReportLocked();
328
337
  static void OnNextReportTimer(void* arg, grpc_error* error);
329
- void OnNextReportTimerLocked(grpc_error* error);
330
- void SendReportLocked();
338
+ bool OnNextReportTimerLocked(grpc_error* error);
339
+ bool SendReportLocked();
331
340
  static void OnReportDone(void* arg, grpc_error* error);
332
- void OnReportDoneLocked(grpc_error* error);
341
+ bool OnReportDoneLocked(grpc_error* error);
333
342
 
334
343
  bool IsCurrentReporterOnCall() const {
335
344
  return this == parent_->reporter_.get();
@@ -351,7 +360,7 @@ class XdsClient::ChannelState::LrsCallState
351
360
  static void OnInitialRequestSent(void* arg, grpc_error* error);
352
361
  void OnInitialRequestSentLocked();
353
362
  static void OnResponseReceived(void* arg, grpc_error* error);
354
- void OnResponseReceivedLocked();
363
+ bool OnResponseReceivedLocked();
355
364
  static void OnStatusReceived(void* arg, grpc_error* error);
356
365
  void OnStatusReceivedLocked(grpc_error* error);
357
366
 
@@ -396,20 +405,22 @@ class XdsClient::ChannelState::StateWatcher
396
405
  : public AsyncConnectivityStateWatcherInterface {
397
406
  public:
398
407
  explicit StateWatcher(RefCountedPtr<ChannelState> parent)
399
- : AsyncConnectivityStateWatcherInterface(
400
- parent->xds_client()->work_serializer_),
401
- parent_(std::move(parent)) {}
408
+ : parent_(std::move(parent)) {}
402
409
 
403
410
  private:
404
- void OnConnectivityStateChange(grpc_connectivity_state new_state) override {
411
+ void OnConnectivityStateChange(grpc_connectivity_state new_state,
412
+ const absl::Status& status) override {
413
+ MutexLock lock(&parent_->xds_client_->mu_);
405
414
  if (!parent_->shutting_down_ &&
406
415
  new_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
407
416
  // In TRANSIENT_FAILURE. Notify all watchers of error.
408
417
  gpr_log(GPR_INFO,
409
- "[xds_client %p] xds channel in state TRANSIENT_FAILURE",
410
- parent_->xds_client());
411
- parent_->xds_client()->NotifyOnError(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
412
- "xds channel in TRANSIENT_FAILURE"));
418
+ "[xds_client %p] xds channel in state:TRANSIENT_FAILURE "
419
+ "status_message:(%s)",
420
+ parent_->xds_client(), status.ToString().c_str());
421
+ parent_->xds_client()->NotifyOnErrorLocked(
422
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
423
+ "xds channel in TRANSIENT_FAILURE"));
413
424
  }
414
425
  }
415
426
 
@@ -422,69 +433,43 @@ class XdsClient::ChannelState::StateWatcher
422
433
 
423
434
  namespace {
424
435
 
425
- // Returns the channel args for the xds channel.
426
- grpc_channel_args* BuildXdsChannelArgs(const grpc_channel_args& args) {
427
- static const char* args_to_remove[] = {
428
- // LB policy name, since we want to use the default (pick_first) in
429
- // the LB channel.
430
- GRPC_ARG_LB_POLICY_NAME,
431
- // The service config that contains the LB config. We don't want to
432
- // recursively use xds in the LB channel.
433
- GRPC_ARG_SERVICE_CONFIG,
434
- // The channel arg for the server URI, since that will be different for
435
- // the xds channel than for the parent channel. The client channel
436
- // factory will re-add this arg with the right value.
437
- GRPC_ARG_SERVER_URI,
438
- // The xds channel should use the authority indicated by the target
439
- // authority table (see \a ModifyXdsChannelArgs),
440
- // as opposed to the authority from the parent channel.
441
- GRPC_ARG_DEFAULT_AUTHORITY,
442
- // Just as for \a GRPC_ARG_DEFAULT_AUTHORITY, the xds channel should be
443
- // treated as a stand-alone channel and not inherit this argument from the
444
- // args of the parent channel.
445
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
446
- // Don't want to pass down channelz node from parent; the balancer
447
- // channel will get its own.
448
- GRPC_ARG_CHANNELZ_CHANNEL_NODE,
449
- // Keepalive interval. We are explicitly setting our own value below.
450
- GRPC_ARG_KEEPALIVE_TIME_MS,
436
+ grpc_channel* CreateXdsChannel(const XdsBootstrap::XdsServer& server) {
437
+ // Build channel args.
438
+ absl::InlinedVector<grpc_arg, 2> args_to_add = {
439
+ grpc_channel_arg_integer_create(
440
+ const_cast<char*>(GRPC_ARG_KEEPALIVE_TIME_MS),
441
+ 5 * 60 * GPR_MS_PER_SEC),
442
+ grpc_channel_arg_integer_create(
443
+ const_cast<char*>(GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL), 1),
451
444
  };
452
- // Channel args to add.
453
- absl::InlinedVector<grpc_arg, 3> args_to_add;
454
- // Keepalive interval.
455
- args_to_add.emplace_back(grpc_channel_arg_integer_create(
456
- const_cast<char*>(GRPC_ARG_KEEPALIVE_TIME_MS), 5000));
457
- // A channel arg indicating that the target is an xds server.
458
- // TODO(roth): Once we figure out our fallback and credentials story, decide
459
- // whether this is actually needed. Note that it's currently used by the
460
- // fake security connector as well.
461
- args_to_add.emplace_back(grpc_channel_arg_integer_create(
462
- const_cast<char*>(GRPC_ARG_ADDRESS_IS_XDS_SERVER), 1));
463
- // The parent channel's channelz uuid.
464
- channelz::ChannelNode* channelz_node = nullptr;
465
- const grpc_arg* arg =
466
- grpc_channel_args_find(&args, GRPC_ARG_CHANNELZ_CHANNEL_NODE);
467
- if (arg != nullptr && arg->type == GRPC_ARG_POINTER &&
468
- arg->value.pointer.p != nullptr) {
469
- channelz_node = static_cast<channelz::ChannelNode*>(arg->value.pointer.p);
470
- args_to_add.emplace_back(
471
- channelz::MakeParentUuidArg(channelz_node->uuid()));
472
- }
473
- // Construct channel args.
474
- grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
475
- &args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), args_to_add.data(),
476
- args_to_add.size());
477
- // Make any necessary modifications for security.
478
- return ModifyXdsChannelArgs(new_args);
445
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
446
+ g_channel_args, args_to_add.data(), args_to_add.size());
447
+ // Create channel creds.
448
+ RefCountedPtr<grpc_channel_credentials> channel_creds =
449
+ XdsChannelCredsRegistry::MakeChannelCreds(server.channel_creds_type,
450
+ server.channel_creds_config);
451
+ // Create channel.
452
+ grpc_channel* channel = grpc_secure_channel_create(
453
+ channel_creds.get(), server.server_uri.c_str(), new_args, nullptr);
454
+ grpc_channel_args_destroy(new_args);
455
+ return channel;
479
456
  }
480
457
 
481
458
  } // namespace
482
459
 
483
- XdsClient::ChannelState::ChannelState(RefCountedPtr<XdsClient> xds_client,
484
- grpc_channel* channel)
485
- : InternallyRefCounted<ChannelState>(&grpc_xds_client_trace),
460
+ XdsClient::ChannelState::ChannelState(WeakRefCountedPtr<XdsClient> xds_client,
461
+ const XdsBootstrap::XdsServer& server)
462
+ : InternallyRefCounted<ChannelState>(
463
+ GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace)
464
+ ? "ChannelState"
465
+ : nullptr),
486
466
  xds_client_(std::move(xds_client)),
487
- channel_(channel) {
467
+ server_(server) {
468
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
469
+ gpr_log(GPR_INFO, "[xds_client %p] creating channel to %s",
470
+ xds_client_.get(), server.server_uri.c_str());
471
+ }
472
+ channel_ = CreateXdsChannel(server);
488
473
  GPR_ASSERT(channel_ != nullptr);
489
474
  StartConnectivityWatchLocked();
490
475
  }
@@ -495,6 +480,7 @@ XdsClient::ChannelState::~ChannelState() {
495
480
  this);
496
481
  }
497
482
  grpc_channel_destroy(channel_);
483
+ xds_client_.reset(DEBUG_LOCATION, "ChannelState");
498
484
  }
499
485
 
500
486
  void XdsClient::ChannelState::Orphan() {
@@ -531,7 +517,7 @@ void XdsClient::ChannelState::StartConnectivityWatchLocked() {
531
517
  grpc_channel_element* client_channel_elem =
532
518
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel_));
533
519
  GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
534
- watcher_ = new StateWatcher(Ref());
520
+ watcher_ = new StateWatcher(Ref(DEBUG_LOCATION, "ChannelState+watch"));
535
521
  grpc_client_channel_start_connectivity_watch(
536
522
  client_channel_elem, GRPC_CHANNEL_IDLE,
537
523
  OrphanablePtr<AsyncConnectivityStateWatcherInterface>(watcher_));
@@ -566,8 +552,11 @@ void XdsClient::ChannelState::Unsubscribe(const std::string& type_url,
566
552
  const std::string& name,
567
553
  bool delay_unsubscription) {
568
554
  if (ads_calld_ != nullptr) {
569
- ads_calld_->calld()->Unsubscribe(type_url, name, delay_unsubscription);
570
- if (!ads_calld_->calld()->HasSubscribedResources()) ads_calld_.reset();
555
+ auto* calld = ads_calld_->calld();
556
+ if (calld != nullptr) {
557
+ calld->Unsubscribe(type_url, name, delay_unsubscription);
558
+ if (!calld->HasSubscribedResources()) ads_calld_.reset();
559
+ }
571
560
  }
572
561
  }
573
562
 
@@ -650,9 +639,11 @@ template <typename T>
650
639
  void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimer(
651
640
  void* arg, grpc_error* error) {
652
641
  RetryableCall* calld = static_cast<RetryableCall*>(arg);
653
- GRPC_ERROR_REF(error); // ref owned by lambda
654
- calld->chand_->xds_client()->work_serializer_->Run(
655
- [calld, error]() { calld->OnRetryTimerLocked(error); }, DEBUG_LOCATION);
642
+ {
643
+ MutexLock lock(&calld->chand_->xds_client()->mu_);
644
+ calld->OnRetryTimerLocked(GRPC_ERROR_REF(error));
645
+ }
646
+ calld->Unref(DEBUG_LOCATION, "RetryableCall+retry_timer_done");
656
647
  }
657
648
 
658
649
  template <typename T>
@@ -668,7 +659,6 @@ void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimerLocked(
668
659
  }
669
660
  StartNewCallLocked();
670
661
  }
671
- this->Unref(DEBUG_LOCATION, "RetryableCall+retry_timer_done");
672
662
  GRPC_ERROR_UNREF(error);
673
663
  }
674
664
 
@@ -678,19 +668,24 @@ void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimerLocked(
678
668
 
679
669
  XdsClient::ChannelState::AdsCallState::AdsCallState(
680
670
  RefCountedPtr<RetryableCall<AdsCallState>> parent)
681
- : InternallyRefCounted<AdsCallState>(&grpc_xds_client_trace),
671
+ : InternallyRefCounted<AdsCallState>(
672
+ GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace)
673
+ ? "AdsCallState"
674
+ : nullptr),
682
675
  parent_(std::move(parent)) {
683
676
  // Init the ADS call. Note that the call will progress every time there's
684
677
  // activity in xds_client()->interested_parties_, which is comprised of
685
678
  // the polling entities from client_channel.
686
679
  GPR_ASSERT(xds_client() != nullptr);
687
- GPR_ASSERT(!xds_client()->server_name_.empty());
688
680
  // Create a call with the specified method name.
681
+ const auto& method =
682
+ chand()->server_.ShouldUseV3()
683
+ ? GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V3_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES
684
+ : GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES;
689
685
  call_ = grpc_channel_create_pollset_set_call(
690
686
  chand()->channel_, nullptr, GRPC_PROPAGATE_DEFAULTS,
691
- xds_client()->interested_parties_,
692
- GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES,
693
- nullptr, GRPC_MILLIS_INF_FUTURE, nullptr);
687
+ xds_client()->interested_parties_, method, nullptr,
688
+ GRPC_MILLIS_INF_FUTURE, nullptr);
694
689
  GPR_ASSERT(call_ != nullptr);
695
690
  // Init data associated with the call.
696
691
  grpc_metadata_array_init(&initial_metadata_recv_);
@@ -714,19 +709,17 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
714
709
  GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET;
715
710
  op->reserved = nullptr;
716
711
  op++;
717
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
718
- nullptr);
712
+ call_error = grpc_call_start_batch_and_execute(
713
+ call_, ops, static_cast<size_t>(op - ops), nullptr);
719
714
  GPR_ASSERT(GRPC_CALL_OK == call_error);
720
715
  // Op: send request message.
721
716
  GRPC_CLOSURE_INIT(&on_request_sent_, OnRequestSent, this,
722
717
  grpc_schedule_on_exec_ctx);
723
- if (xds_client()->service_config_watcher_ != nullptr) {
724
- Subscribe(XdsApi::kLdsTypeUrl, xds_client()->server_name_);
725
- if (xds_client()->lds_result_.has_value() &&
726
- !xds_client()->lds_result_->route_config_name.empty()) {
727
- Subscribe(XdsApi::kRdsTypeUrl,
728
- xds_client()->lds_result_->route_config_name);
729
- }
718
+ for (const auto& p : xds_client()->listener_map_) {
719
+ Subscribe(XdsApi::kLdsTypeUrl, std::string(p.first));
720
+ }
721
+ for (const auto& p : xds_client()->route_config_map_) {
722
+ Subscribe(XdsApi::kRdsTypeUrl, std::string(p.first));
730
723
  }
731
724
  for (const auto& p : xds_client()->cluster_map_) {
732
725
  Subscribe(XdsApi::kCdsTypeUrl, std::string(p.first));
@@ -751,8 +744,8 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
751
744
  Ref(DEBUG_LOCATION, "ADS+OnResponseReceivedLocked").release();
752
745
  GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceived, this,
753
746
  grpc_schedule_on_exec_ctx);
754
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
755
- &on_response_received_);
747
+ call_error = grpc_call_start_batch_and_execute(
748
+ call_, ops, static_cast<size_t>(op - ops), &on_response_received_);
756
749
  GPR_ASSERT(GRPC_CALL_OK == call_error);
757
750
  // Op: recv server status.
758
751
  op = ops;
@@ -768,8 +761,8 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
768
761
  // unreffed.
769
762
  GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this,
770
763
  grpc_schedule_on_exec_ctx);
771
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
772
- &on_status_received_);
764
+ call_error = grpc_call_start_batch_and_execute(
765
+ call_, ops, static_cast<size_t>(op - ops), &on_status_received_);
773
766
  GPR_ASSERT(GRPC_CALL_OK == call_error);
774
767
  }
775
768
 
@@ -789,7 +782,7 @@ void XdsClient::ChannelState::AdsCallState::Orphan() {
789
782
  // on_status_received_ will complete the cancellation and clean up. Otherwise,
790
783
  // we are here because xds_client has to orphan a failed call, then the
791
784
  // following cancellation will be a no-op.
792
- grpc_call_cancel(call_, nullptr);
785
+ grpc_call_cancel_internal(call_);
793
786
  state_map_.clear();
794
787
  // Note that the initial ref is hold by on_status_received_. So the
795
788
  // corresponding unref happens in on_status_received_ instead of here.
@@ -807,7 +800,8 @@ void XdsClient::ChannelState::AdsCallState::SendMessageLocked(
807
800
  std::set<absl::string_view> resource_names =
808
801
  ResourceNamesForRequest(type_url);
809
802
  request_payload_slice = xds_client()->api_.CreateAdsRequest(
810
- type_url, resource_names, state.version, state.nonce,
803
+ chand()->server_, type_url, resource_names,
804
+ xds_client()->resource_version_map_[type_url], state.nonce,
811
805
  GRPC_ERROR_REF(state.error), !sent_initial_message_);
812
806
  if (type_url != XdsApi::kLdsTypeUrl && type_url != XdsApi::kRdsTypeUrl &&
813
807
  type_url != XdsApi::kCdsTypeUrl && type_url != XdsApi::kEdsTypeUrl) {
@@ -818,7 +812,8 @@ void XdsClient::ChannelState::AdsCallState::SendMessageLocked(
818
812
  gpr_log(GPR_INFO,
819
813
  "[xds_client %p] sending ADS request: type=%s version=%s nonce=%s "
820
814
  "error=%s resources=%s",
821
- xds_client(), type_url.c_str(), state.version.c_str(),
815
+ xds_client(), type_url.c_str(),
816
+ xds_client()->resource_version_map_[type_url].c_str(),
822
817
  state.nonce.c_str(), grpc_error_string(state.error),
823
818
  absl::StrJoin(resource_names, " ").c_str());
824
819
  }
@@ -850,7 +845,8 @@ void XdsClient::ChannelState::AdsCallState::Subscribe(
850
845
  const std::string& type_url, const std::string& name) {
851
846
  auto& state = state_map_[type_url].subscribed_resources[name];
852
847
  if (state == nullptr) {
853
- state = MakeOrphanable<ResourceState>(type_url, name);
848
+ state = MakeOrphanable<ResourceState>(
849
+ type_url, name, !xds_client()->resource_version_map_[type_url].empty());
854
850
  SendMessageLocked(type_url);
855
851
  }
856
852
  }
@@ -870,132 +866,139 @@ bool XdsClient::ChannelState::AdsCallState::HasSubscribedResources() const {
870
866
  }
871
867
 
872
868
  void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate(
873
- absl::optional<XdsApi::LdsUpdate> lds_update) {
874
- if (!lds_update.has_value()) {
875
- gpr_log(GPR_INFO,
876
- "[xds_client %p] LDS update does not include requested resource",
877
- xds_client());
878
- if (xds_client()->lds_result_.has_value() &&
879
- !xds_client()->lds_result_->route_config_name.empty()) {
880
- Unsubscribe(XdsApi::kRdsTypeUrl,
881
- xds_client()->lds_result_->route_config_name,
882
- /*delay_unsubscription=*/false);
883
- xds_client()->rds_result_.reset();
884
- }
885
- xds_client()->lds_result_.reset();
886
- xds_client()->service_config_watcher_->OnResourceDoesNotExist();
887
- return;
888
- }
869
+ XdsApi::LdsUpdateMap lds_update_map) {
889
870
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
890
871
  gpr_log(GPR_INFO,
891
- "[xds_client %p] LDS update received: route_config_name=%s",
892
- xds_client(),
893
- (!lds_update->route_config_name.empty()
894
- ? lds_update->route_config_name.c_str()
895
- : "<inlined>"));
896
- if (lds_update->rds_update.has_value()) {
897
- gpr_log(GPR_INFO, " RouteConfiguration contains %" PRIuPTR " routes",
898
- lds_update->rds_update.value().routes.size());
899
- for (const auto& route : lds_update->rds_update.value().routes) {
872
+ "[xds_client %p] LDS update received containing %" PRIuPTR
873
+ " resources",
874
+ xds_client(), lds_update_map.size());
875
+ }
876
+ auto& lds_state = state_map_[XdsApi::kLdsTypeUrl];
877
+ std::set<std::string> rds_resource_names_seen;
878
+ for (auto& p : lds_update_map) {
879
+ const std::string& listener_name = p.first;
880
+ XdsApi::LdsUpdate& lds_update = p.second;
881
+ auto& state = lds_state.subscribed_resources[listener_name];
882
+ if (state != nullptr) state->Finish();
883
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
884
+ gpr_log(GPR_INFO, "[xds_client %p] LDS resource %s: route_config_name=%s",
885
+ xds_client(), listener_name.c_str(),
886
+ (!lds_update.route_config_name.empty()
887
+ ? lds_update.route_config_name.c_str()
888
+ : "<inlined>"));
889
+ if (lds_update.rds_update.has_value()) {
890
+ gpr_log(GPR_INFO, "RouteConfiguration: %s",
891
+ lds_update.rds_update->ToString().c_str());
892
+ }
893
+ }
894
+ // Record the RDS resource names seen.
895
+ if (!lds_update.route_config_name.empty()) {
896
+ rds_resource_names_seen.insert(lds_update.route_config_name);
897
+ }
898
+ // Ignore identical update.
899
+ ListenerState& listener_state = xds_client()->listener_map_[listener_name];
900
+ if (listener_state.update.has_value() &&
901
+ *listener_state.update == lds_update) {
902
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
900
903
  gpr_log(GPR_INFO,
901
- " route: { service=\"%s\", "
902
- "method=\"%s\" }, cluster=\"%s\" }",
903
- route.service.c_str(), route.method.c_str(),
904
- route.cluster_name.c_str());
904
+ "[xds_client %p] LDS update for %s identical to current, "
905
+ "ignoring.",
906
+ xds_client(), listener_name.c_str());
905
907
  }
908
+ continue;
909
+ }
910
+ // Update the listener state.
911
+ listener_state.update = std::move(lds_update);
912
+ // Notify watchers.
913
+ for (const auto& p : listener_state.watchers) {
914
+ p.first->OnListenerChanged(*listener_state.update);
906
915
  }
907
916
  }
908
- auto& lds_state = state_map_[XdsApi::kLdsTypeUrl];
909
- auto& state = lds_state.subscribed_resources[xds_client()->server_name_];
910
- if (state != nullptr) state->Finish();
911
- // Ignore identical update.
912
- if (xds_client()->lds_result_ == lds_update) {
913
- if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
914
- gpr_log(GPR_INFO,
915
- "[xds_client %p] LDS update identical to current, ignoring.",
916
- xds_client());
917
+ // For any subscribed resource that is not present in the update,
918
+ // remove it from the cache and notify watchers that it does not exist.
919
+ for (const auto& p : lds_state.subscribed_resources) {
920
+ const std::string& listener_name = p.first;
921
+ if (lds_update_map.find(listener_name) == lds_update_map.end()) {
922
+ ListenerState& listener_state =
923
+ xds_client()->listener_map_[listener_name];
924
+ // If the resource was newly requested but has not yet been received,
925
+ // we don't want to generate an error for the watchers, because this LDS
926
+ // response may be in reaction to an earlier request that did not yet
927
+ // request the new resource, so its absence from the response does not
928
+ // necessarily indicate that the resource does not exist.
929
+ // For that case, we rely on the request timeout instead.
930
+ if (!listener_state.update.has_value()) continue;
931
+ listener_state.update.reset();
932
+ for (const auto& p : listener_state.watchers) {
933
+ p.first->OnResourceDoesNotExist();
934
+ }
917
935
  }
918
- return;
919
936
  }
920
- if (xds_client()->lds_result_.has_value() &&
921
- !xds_client()->lds_result_->route_config_name.empty()) {
922
- Unsubscribe(
923
- XdsApi::kRdsTypeUrl, xds_client()->lds_result_->route_config_name,
924
- /*delay_unsubscription=*/!lds_update->route_config_name.empty());
925
- xds_client()->rds_result_.reset();
926
- }
927
- xds_client()->lds_result_ = std::move(lds_update);
928
- if (xds_client()->lds_result_->rds_update.has_value()) {
929
- // If the RouteConfiguration was found inlined in LDS response, notify
930
- // the watcher immediately.
931
- RefCountedPtr<ServiceConfig> service_config;
932
- grpc_error* error = xds_client()->CreateServiceConfig(
933
- xds_client()->lds_result_->rds_update.value(), &service_config);
934
- if (error == GRPC_ERROR_NONE) {
935
- xds_client()->service_config_watcher_->OnServiceConfigChanged(
936
- std::move(service_config));
937
- } else {
938
- xds_client()->service_config_watcher_->OnError(error);
937
+ // For any RDS resource that is no longer referred to by any LDS
938
+ // resources, remove it from the cache and notify watchers that it
939
+ // does not exist.
940
+ auto& rds_state = state_map_[XdsApi::kRdsTypeUrl];
941
+ for (const auto& p : rds_state.subscribed_resources) {
942
+ const std::string& rds_resource_name = p.first;
943
+ if (rds_resource_names_seen.find(rds_resource_name) ==
944
+ rds_resource_names_seen.end()) {
945
+ RouteConfigState& route_config_state =
946
+ xds_client()->route_config_map_[rds_resource_name];
947
+ route_config_state.update.reset();
948
+ for (const auto& p : route_config_state.watchers) {
949
+ p.first->OnResourceDoesNotExist();
950
+ }
939
951
  }
940
- } else {
941
- // Send RDS request for dynamic resolution.
942
- Subscribe(XdsApi::kRdsTypeUrl,
943
- xds_client()->lds_result_->route_config_name);
944
952
  }
945
953
  }
946
954
 
947
955
  void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate(
948
- absl::optional<XdsApi::RdsUpdate> rds_update) {
949
- if (!rds_update.has_value()) {
950
- gpr_log(GPR_INFO,
951
- "[xds_client %p] RDS update does not include requested resource",
952
- xds_client());
953
- xds_client()->rds_result_.reset();
954
- xds_client()->service_config_watcher_->OnResourceDoesNotExist();
955
- return;
956
- }
956
+ XdsApi::RdsUpdateMap rds_update_map) {
957
957
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
958
958
  gpr_log(GPR_INFO,
959
- "[xds_client %p] RDS update received; RouteConfiguration contains "
960
- "%" PRIuPTR " routes",
961
- this, rds_update.value().routes.size());
962
- for (const auto& route : rds_update.value().routes) {
963
- gpr_log(GPR_INFO,
964
- " route: { service=\"%s\", "
965
- "method=\"%s\" }, cluster=\"%s\" }",
966
- route.service.c_str(), route.method.c_str(),
967
- route.cluster_name.c_str());
968
- }
959
+ "[xds_client %p] RDS update received containing %" PRIuPTR
960
+ " resources",
961
+ xds_client(), rds_update_map.size());
969
962
  }
970
963
  auto& rds_state = state_map_[XdsApi::kRdsTypeUrl];
971
- auto& state =
972
- rds_state
973
- .subscribed_resources[xds_client()->lds_result_->route_config_name];
974
- if (state != nullptr) state->Finish();
975
- // Ignore identical update.
976
- if (xds_client()->rds_result_ == rds_update) {
964
+ for (auto& p : rds_update_map) {
965
+ const std::string& route_config_name = p.first;
966
+ XdsApi::RdsUpdate& rds_update = p.second;
967
+ auto& state = rds_state.subscribed_resources[route_config_name];
968
+ if (state != nullptr) state->Finish();
977
969
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
978
- gpr_log(GPR_INFO,
979
- "[xds_client %p] RDS update identical to current, ignoring.",
980
- xds_client());
970
+ gpr_log(GPR_INFO, "[xds_client %p] RDS resource:\n%s", xds_client(),
971
+ rds_update.ToString().c_str());
972
+ }
973
+ RouteConfigState& route_config_state =
974
+ xds_client()->route_config_map_[route_config_name];
975
+ // Ignore identical update.
976
+ if (route_config_state.update.has_value() &&
977
+ *route_config_state.update == rds_update) {
978
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
979
+ gpr_log(GPR_INFO,
980
+ "[xds_client %p] RDS resource identical to current, ignoring",
981
+ xds_client());
982
+ }
983
+ continue;
984
+ }
985
+ // Update the cache.
986
+ route_config_state.update = std::move(rds_update);
987
+ // Notify all watchers.
988
+ for (const auto& p : route_config_state.watchers) {
989
+ p.first->OnRouteConfigChanged(*route_config_state.update);
981
990
  }
982
- return;
983
- }
984
- xds_client()->rds_result_ = std::move(rds_update);
985
- // Notify the watcher.
986
- RefCountedPtr<ServiceConfig> service_config;
987
- grpc_error* error = xds_client()->CreateServiceConfig(
988
- xds_client()->rds_result_.value(), &service_config);
989
- if (error == GRPC_ERROR_NONE) {
990
- xds_client()->service_config_watcher_->OnServiceConfigChanged(
991
- std::move(service_config));
992
- } else {
993
- xds_client()->service_config_watcher_->OnError(error);
994
991
  }
995
992
  }
996
993
 
997
994
  void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
998
995
  XdsApi::CdsUpdateMap cds_update_map) {
996
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
997
+ gpr_log(GPR_INFO,
998
+ "[xds_client %p] CDS update received containing %" PRIuPTR
999
+ " resources",
1000
+ xds_client(), cds_update_map.size());
1001
+ }
999
1002
  auto& cds_state = state_map_[XdsApi::kCdsTypeUrl];
1000
1003
  std::set<std::string> eds_resource_names_seen;
1001
1004
  for (auto& p : cds_update_map) {
@@ -1004,13 +1007,8 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1004
1007
  auto& state = cds_state.subscribed_resources[cluster_name];
1005
1008
  if (state != nullptr) state->Finish();
1006
1009
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1007
- gpr_log(GPR_INFO,
1008
- "[xds_client %p] CDS update (cluster=%s) received: "
1009
- "eds_service_name=%s, lrs_load_reporting_server_name=%s",
1010
- xds_client(), cluster_name, cds_update.eds_service_name.c_str(),
1011
- cds_update.lrs_load_reporting_server_name.has_value()
1012
- ? cds_update.lrs_load_reporting_server_name.value().c_str()
1013
- : "(N/A)");
1010
+ gpr_log(GPR_INFO, "[xds_client %p] cluster=%s: %s", xds_client(),
1011
+ cluster_name, cds_update.ToString().c_str());
1014
1012
  }
1015
1013
  // Record the EDS resource names seen.
1016
1014
  eds_resource_names_seen.insert(cds_update.eds_service_name.empty()
@@ -1019,9 +1017,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1019
1017
  // Ignore identical update.
1020
1018
  ClusterState& cluster_state = xds_client()->cluster_map_[cluster_name];
1021
1019
  if (cluster_state.update.has_value() &&
1022
- cds_update.eds_service_name == cluster_state.update->eds_service_name &&
1023
- cds_update.lrs_load_reporting_server_name ==
1024
- cluster_state.update->lrs_load_reporting_server_name) {
1020
+ *cluster_state.update == cds_update) {
1025
1021
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1026
1022
  gpr_log(GPR_INFO,
1027
1023
  "[xds_client %p] CDS update identical to current, ignoring.",
@@ -1042,6 +1038,13 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1042
1038
  const std::string& cluster_name = p.first;
1043
1039
  if (cds_update_map.find(cluster_name) == cds_update_map.end()) {
1044
1040
  ClusterState& cluster_state = xds_client()->cluster_map_[cluster_name];
1041
+ // If the resource was newly requested but has not yet been received,
1042
+ // we don't want to generate an error for the watchers, because this CDS
1043
+ // response may be in reaction to an earlier request that did not yet
1044
+ // request the new resource, so its absence from the response does not
1045
+ // necessarily indicate that the resource does not exist.
1046
+ // For that case, we rely on the request timeout instead.
1047
+ if (!cluster_state.update.has_value()) continue;
1045
1048
  cluster_state.update.reset();
1046
1049
  for (const auto& p : cluster_state.watchers) {
1047
1050
  p.first->OnResourceDoesNotExist();
@@ -1068,6 +1071,12 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1068
1071
 
1069
1072
  void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1070
1073
  XdsApi::EdsUpdateMap eds_update_map) {
1074
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1075
+ gpr_log(GPR_INFO,
1076
+ "[xds_client %p] EDS update received containing %" PRIuPTR
1077
+ " resources",
1078
+ xds_client(), eds_update_map.size());
1079
+ }
1071
1080
  auto& eds_state = state_map_[XdsApi::kEdsTypeUrl];
1072
1081
  for (auto& p : eds_update_map) {
1073
1082
  const char* eds_service_name = p.first.c_str();
@@ -1075,70 +1084,20 @@ void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1075
1084
  auto& state = eds_state.subscribed_resources[eds_service_name];
1076
1085
  if (state != nullptr) state->Finish();
1077
1086
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1078
- gpr_log(GPR_INFO,
1079
- "[xds_client %p] EDS response with %" PRIuPTR
1080
- " priorities and %" PRIuPTR
1081
- " drop categories received (drop_all=%d)",
1082
- xds_client(), eds_update.priority_list_update.size(),
1083
- eds_update.drop_config->drop_category_list().size(),
1084
- eds_update.drop_config->drop_all());
1085
- for (size_t priority = 0;
1086
- priority < eds_update.priority_list_update.size(); ++priority) {
1087
- const auto* locality_map_update = eds_update.priority_list_update.Find(
1088
- static_cast<uint32_t>(priority));
1089
- gpr_log(GPR_INFO,
1090
- "[xds_client %p] Priority %" PRIuPTR " contains %" PRIuPTR
1091
- " localities",
1092
- xds_client(), priority, locality_map_update->size());
1093
- size_t locality_count = 0;
1094
- for (const auto& p : locality_map_update->localities) {
1095
- const auto& locality = p.second;
1096
- gpr_log(GPR_INFO,
1097
- "[xds_client %p] Priority %" PRIuPTR ", locality %" PRIuPTR
1098
- " %s has weight %d, contains %" PRIuPTR " server addresses",
1099
- xds_client(), priority, locality_count,
1100
- locality.name->AsHumanReadableString(), locality.lb_weight,
1101
- locality.serverlist.size());
1102
- for (size_t i = 0; i < locality.serverlist.size(); ++i) {
1103
- std::string ipport = grpc_sockaddr_to_string(
1104
- &locality.serverlist[i].address(), false);
1105
- gpr_log(GPR_INFO,
1106
- "[xds_client %p] Priority %" PRIuPTR ", locality %" PRIuPTR
1107
- " %s, server address %" PRIuPTR ": %s",
1108
- xds_client(), priority, locality_count,
1109
- locality.name->AsHumanReadableString(), i, ipport.c_str());
1110
- }
1111
- ++locality_count;
1112
- }
1113
- }
1114
- for (size_t i = 0;
1115
- i < eds_update.drop_config->drop_category_list().size(); ++i) {
1116
- const XdsApi::DropConfig::DropCategory& drop_category =
1117
- eds_update.drop_config->drop_category_list()[i];
1118
- gpr_log(GPR_INFO,
1119
- "[xds_client %p] Drop category %s has drop rate %d per million",
1120
- xds_client(), drop_category.name.c_str(),
1121
- drop_category.parts_per_million);
1122
- }
1087
+ gpr_log(GPR_INFO, "[xds_client %p] EDS resource %s: %s", xds_client(),
1088
+ eds_service_name, eds_update.ToString().c_str());
1123
1089
  }
1124
1090
  EndpointState& endpoint_state =
1125
1091
  xds_client()->endpoint_map_[eds_service_name];
1126
1092
  // Ignore identical update.
1127
- if (endpoint_state.update.has_value()) {
1128
- const XdsApi::EdsUpdate& prev_update = endpoint_state.update.value();
1129
- const bool priority_list_changed =
1130
- prev_update.priority_list_update != eds_update.priority_list_update;
1131
- const bool drop_config_changed =
1132
- prev_update.drop_config == nullptr ||
1133
- *prev_update.drop_config != *eds_update.drop_config;
1134
- if (!priority_list_changed && !drop_config_changed) {
1135
- if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1136
- gpr_log(GPR_INFO,
1137
- "[xds_client %p] EDS update identical to current, ignoring.",
1138
- xds_client());
1139
- }
1140
- continue;
1093
+ if (endpoint_state.update.has_value() &&
1094
+ *endpoint_state.update == eds_update) {
1095
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1096
+ gpr_log(GPR_INFO,
1097
+ "[xds_client %p] EDS update identical to current, ignoring.",
1098
+ xds_client());
1141
1099
  }
1100
+ continue;
1142
1101
  }
1143
1102
  // Update the cluster state.
1144
1103
  endpoint_state.update = std::move(eds_update);
@@ -1152,10 +1111,11 @@ void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1152
1111
  void XdsClient::ChannelState::AdsCallState::OnRequestSent(void* arg,
1153
1112
  grpc_error* error) {
1154
1113
  AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
1155
- GRPC_ERROR_REF(error); // ref owned by lambda
1156
- ads_calld->xds_client()->work_serializer_->Run(
1157
- [ads_calld, error]() { ads_calld->OnRequestSentLocked(error); },
1158
- DEBUG_LOCATION);
1114
+ {
1115
+ MutexLock lock(&ads_calld->xds_client()->mu_);
1116
+ ads_calld->OnRequestSentLocked(GRPC_ERROR_REF(error));
1117
+ }
1118
+ ads_calld->Unref(DEBUG_LOCATION, "ADS+OnRequestSentLocked");
1159
1119
  }
1160
1120
 
1161
1121
  void XdsClient::ChannelState::AdsCallState::OnRequestSentLocked(
@@ -1179,22 +1139,24 @@ void XdsClient::ChannelState::AdsCallState::OnRequestSentLocked(
1179
1139
  buffered_requests_.erase(it);
1180
1140
  }
1181
1141
  }
1182
- Unref(DEBUG_LOCATION, "ADS+OnRequestSentLocked");
1183
1142
  GRPC_ERROR_UNREF(error);
1184
1143
  }
1185
1144
 
1186
1145
  void XdsClient::ChannelState::AdsCallState::OnResponseReceived(
1187
1146
  void* arg, grpc_error* /* error */) {
1188
1147
  AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
1189
- ads_calld->xds_client()->work_serializer_->Run(
1190
- [ads_calld]() { ads_calld->OnResponseReceivedLocked(); }, DEBUG_LOCATION);
1148
+ bool done;
1149
+ {
1150
+ MutexLock lock(&ads_calld->xds_client()->mu_);
1151
+ done = ads_calld->OnResponseReceivedLocked();
1152
+ }
1153
+ if (done) ads_calld->Unref(DEBUG_LOCATION, "ADS+OnResponseReceivedLocked");
1191
1154
  }
1192
1155
 
1193
- void XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1156
+ bool XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1194
1157
  // Empty payload means the call was cancelled.
1195
1158
  if (!IsCurrentCallOnChannel() || recv_message_payload_ == nullptr) {
1196
- Unref(DEBUG_LOCATION, "ADS+OnResponseReceivedLocked");
1197
- return;
1159
+ return true;
1198
1160
  }
1199
1161
  // Read the response.
1200
1162
  grpc_byte_buffer_reader bbr;
@@ -1203,66 +1165,50 @@ void XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1203
1165
  grpc_byte_buffer_reader_destroy(&bbr);
1204
1166
  grpc_byte_buffer_destroy(recv_message_payload_);
1205
1167
  recv_message_payload_ = nullptr;
1206
- // TODO(juanlishen): When we convert this to use the xds protocol, the
1207
- // balancer will send us a fallback timeout such that we should go into
1208
- // fallback mode if we have lost contact with the balancer after a certain
1209
- // period of time. We will need to save the timeout value here, and then
1210
- // when the balancer call ends, we will need to start a timer for the
1211
- // specified period of time, and if the timer fires, we go into fallback
1212
- // mode. We will also need to cancel the timer when we receive a serverlist
1213
- // from the balancer.
1214
- // Parse the response.
1215
- absl::optional<XdsApi::LdsUpdate> lds_update;
1216
- absl::optional<XdsApi::RdsUpdate> rds_update;
1217
- XdsApi::CdsUpdateMap cds_update_map;
1218
- XdsApi::EdsUpdateMap eds_update_map;
1219
- std::string version;
1220
- std::string nonce;
1221
- std::string type_url;
1222
- // Note that ParseAdsResponse() also validates the response.
1223
- grpc_error* parse_error = xds_client()->api_.ParseAdsResponse(
1224
- response_slice, xds_client()->server_name_,
1168
+ // Parse and validate the response.
1169
+ XdsApi::AdsParseResult result = xds_client()->api_.ParseAdsResponse(
1170
+ response_slice, ResourceNamesForRequest(XdsApi::kLdsTypeUrl),
1225
1171
  ResourceNamesForRequest(XdsApi::kRdsTypeUrl),
1226
1172
  ResourceNamesForRequest(XdsApi::kCdsTypeUrl),
1227
- ResourceNamesForRequest(XdsApi::kEdsTypeUrl), &lds_update, &rds_update,
1228
- &cds_update_map, &eds_update_map, &version, &nonce, &type_url);
1173
+ ResourceNamesForRequest(XdsApi::kEdsTypeUrl));
1229
1174
  grpc_slice_unref_internal(response_slice);
1230
- if (type_url.empty()) {
1175
+ if (result.type_url.empty()) {
1231
1176
  // Ignore unparsable response.
1232
1177
  gpr_log(GPR_ERROR,
1233
1178
  "[xds_client %p] Error parsing ADS response (%s) -- ignoring",
1234
- xds_client(), grpc_error_string(parse_error));
1235
- GRPC_ERROR_UNREF(parse_error);
1179
+ xds_client(), grpc_error_string(result.parse_error));
1180
+ GRPC_ERROR_UNREF(result.parse_error);
1236
1181
  } else {
1237
1182
  // Update nonce.
1238
- auto& state = state_map_[type_url];
1239
- state.nonce = std::move(nonce);
1183
+ auto& state = state_map_[result.type_url];
1184
+ state.nonce = std::move(result.nonce);
1240
1185
  // NACK or ACK the response.
1241
- if (parse_error != GRPC_ERROR_NONE) {
1186
+ if (result.parse_error != GRPC_ERROR_NONE) {
1242
1187
  GRPC_ERROR_UNREF(state.error);
1243
- state.error = parse_error;
1188
+ state.error = result.parse_error;
1244
1189
  // NACK unacceptable update.
1245
1190
  gpr_log(GPR_ERROR,
1246
1191
  "[xds_client %p] ADS response invalid for resource type %s "
1247
1192
  "version %s, will NACK: nonce=%s error=%s",
1248
- xds_client(), type_url.c_str(), version.c_str(),
1249
- state.nonce.c_str(), grpc_error_string(parse_error));
1250
- SendMessageLocked(type_url);
1193
+ xds_client(), result.type_url.c_str(), result.version.c_str(),
1194
+ state.nonce.c_str(), grpc_error_string(result.parse_error));
1195
+ SendMessageLocked(result.type_url);
1251
1196
  } else {
1252
1197
  seen_response_ = true;
1253
1198
  // Accept the ADS response according to the type_url.
1254
- if (type_url == XdsApi::kLdsTypeUrl) {
1255
- AcceptLdsUpdate(std::move(lds_update));
1256
- } else if (type_url == XdsApi::kRdsTypeUrl) {
1257
- AcceptRdsUpdate(std::move(rds_update));
1258
- } else if (type_url == XdsApi::kCdsTypeUrl) {
1259
- AcceptCdsUpdate(std::move(cds_update_map));
1260
- } else if (type_url == XdsApi::kEdsTypeUrl) {
1261
- AcceptEdsUpdate(std::move(eds_update_map));
1199
+ if (result.type_url == XdsApi::kLdsTypeUrl) {
1200
+ AcceptLdsUpdate(std::move(result.lds_update_map));
1201
+ } else if (result.type_url == XdsApi::kRdsTypeUrl) {
1202
+ AcceptRdsUpdate(std::move(result.rds_update_map));
1203
+ } else if (result.type_url == XdsApi::kCdsTypeUrl) {
1204
+ AcceptCdsUpdate(std::move(result.cds_update_map));
1205
+ } else if (result.type_url == XdsApi::kEdsTypeUrl) {
1206
+ AcceptEdsUpdate(std::move(result.eds_update_map));
1262
1207
  }
1263
- state.version = std::move(version);
1208
+ xds_client()->resource_version_map_[result.type_url] =
1209
+ std::move(result.version);
1264
1210
  // ACK the update.
1265
- SendMessageLocked(type_url);
1211
+ SendMessageLocked(result.type_url);
1266
1212
  // Start load reporting if needed.
1267
1213
  auto& lrs_call = chand()->lrs_calld_;
1268
1214
  if (lrs_call != nullptr) {
@@ -1271,10 +1217,7 @@ void XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1271
1217
  }
1272
1218
  }
1273
1219
  }
1274
- if (xds_client()->shutting_down_) {
1275
- Unref(DEBUG_LOCATION, "ADS+OnResponseReceivedLocked+xds_shutdown");
1276
- return;
1277
- }
1220
+ if (xds_client()->shutting_down_) return true;
1278
1221
  // Keep listening for updates.
1279
1222
  grpc_op op;
1280
1223
  memset(&op, 0, sizeof(op));
@@ -1287,15 +1230,17 @@ void XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1287
1230
  const grpc_call_error call_error =
1288
1231
  grpc_call_start_batch_and_execute(call_, &op, 1, &on_response_received_);
1289
1232
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1233
+ return false;
1290
1234
  }
1291
1235
 
1292
1236
  void XdsClient::ChannelState::AdsCallState::OnStatusReceived(
1293
1237
  void* arg, grpc_error* error) {
1294
1238
  AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
1295
- GRPC_ERROR_REF(error); // ref owned by lambda
1296
- ads_calld->xds_client()->work_serializer_->Run(
1297
- [ads_calld, error]() { ads_calld->OnStatusReceivedLocked(error); },
1298
- DEBUG_LOCATION);
1239
+ {
1240
+ MutexLock lock(&ads_calld->xds_client()->mu_);
1241
+ ads_calld->OnStatusReceivedLocked(GRPC_ERROR_REF(error));
1242
+ }
1243
+ ads_calld->Unref(DEBUG_LOCATION, "ADS+OnStatusReceivedLocked");
1299
1244
  }
1300
1245
 
1301
1246
  void XdsClient::ChannelState::AdsCallState::OnStatusReceivedLocked(
@@ -1314,10 +1259,9 @@ void XdsClient::ChannelState::AdsCallState::OnStatusReceivedLocked(
1314
1259
  // Try to restart the call.
1315
1260
  parent_->OnCallFinishedLocked();
1316
1261
  // Send error to all watchers.
1317
- xds_client()->NotifyOnError(
1262
+ xds_client()->NotifyOnErrorLocked(
1318
1263
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("xds call failed"));
1319
1264
  }
1320
- Unref(DEBUG_LOCATION, "ADS+OnStatusReceivedLocked");
1321
1265
  GRPC_ERROR_UNREF(error);
1322
1266
  }
1323
1267
 
@@ -1337,7 +1281,7 @@ XdsClient::ChannelState::AdsCallState::ResourceNamesForRequest(
1337
1281
  for (auto& p : it->second.subscribed_resources) {
1338
1282
  resource_names.insert(p.first);
1339
1283
  OrphanablePtr<ResourceState>& state = p.second;
1340
- state->Start(Ref());
1284
+ state->Start(Ref(DEBUG_LOCATION, "ResourceState"));
1341
1285
  }
1342
1286
  }
1343
1287
  return resource_names;
@@ -1364,21 +1308,22 @@ void XdsClient::ChannelState::LrsCallState::Reporter::
1364
1308
  void XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimer(
1365
1309
  void* arg, grpc_error* error) {
1366
1310
  Reporter* self = static_cast<Reporter*>(arg);
1367
- GRPC_ERROR_REF(error); // ref owned by lambda
1368
- self->xds_client()->work_serializer_->Run(
1369
- [self, error]() { self->OnNextReportTimerLocked(error); },
1370
- DEBUG_LOCATION);
1311
+ bool done;
1312
+ {
1313
+ MutexLock lock(&self->xds_client()->mu_);
1314
+ done = self->OnNextReportTimerLocked(GRPC_ERROR_REF(error));
1315
+ }
1316
+ if (done) self->Unref(DEBUG_LOCATION, "Reporter+timer");
1371
1317
  }
1372
1318
 
1373
- void XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimerLocked(
1319
+ bool XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimerLocked(
1374
1320
  grpc_error* error) {
1375
1321
  next_report_timer_callback_pending_ = false;
1376
1322
  if (error != GRPC_ERROR_NONE || !IsCurrentReporterOnCall()) {
1377
- Unref(DEBUG_LOCATION, "Reporter+timer");
1378
- } else {
1379
- SendReportLocked();
1323
+ GRPC_ERROR_UNREF(error);
1324
+ return true;
1380
1325
  }
1381
- GRPC_ERROR_UNREF(error);
1326
+ return SendReportLocked();
1382
1327
  }
1383
1328
 
1384
1329
  namespace {
@@ -1386,9 +1331,7 @@ namespace {
1386
1331
  bool LoadReportCountersAreZero(const XdsApi::ClusterLoadReportMap& snapshot) {
1387
1332
  for (const auto& p : snapshot) {
1388
1333
  const XdsApi::ClusterLoadReport& cluster_snapshot = p.second;
1389
- for (const auto& q : cluster_snapshot.dropped_requests) {
1390
- if (q.second > 0) return false;
1391
- }
1334
+ if (!cluster_snapshot.dropped_requests.IsZero()) return false;
1392
1335
  for (const auto& q : cluster_snapshot.locality_stats) {
1393
1336
  const XdsClusterLocalityStats::Snapshot& locality_snapshot = q.second;
1394
1337
  if (!locality_snapshot.IsZero()) return false;
@@ -1399,17 +1342,22 @@ bool LoadReportCountersAreZero(const XdsApi::ClusterLoadReportMap& snapshot) {
1399
1342
 
1400
1343
  } // namespace
1401
1344
 
1402
- void XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
1345
+ bool XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
1403
1346
  // Construct snapshot from all reported stats.
1404
- XdsApi::ClusterLoadReportMap snapshot = xds_client()->BuildLoadReportSnapshot(
1405
- parent_->send_all_clusters_, parent_->cluster_names_);
1347
+ XdsApi::ClusterLoadReportMap snapshot =
1348
+ xds_client()->BuildLoadReportSnapshotLocked(parent_->send_all_clusters_,
1349
+ parent_->cluster_names_);
1406
1350
  // Skip client load report if the counters were all zero in the last
1407
1351
  // report and they are still zero in this one.
1408
1352
  const bool old_val = last_report_counters_were_zero_;
1409
1353
  last_report_counters_were_zero_ = LoadReportCountersAreZero(snapshot);
1410
1354
  if (old_val && last_report_counters_were_zero_) {
1355
+ if (xds_client()->load_report_map_.empty()) {
1356
+ parent_->chand()->StopLrsCall();
1357
+ return true;
1358
+ }
1411
1359
  ScheduleNextReportLocked();
1412
- return;
1360
+ return false;
1413
1361
  }
1414
1362
  // Create a request that contains the snapshot.
1415
1363
  grpc_slice request_payload_slice =
@@ -1430,37 +1378,41 @@ void XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
1430
1378
  xds_client(), this, call_error);
1431
1379
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1432
1380
  }
1381
+ return false;
1433
1382
  }
1434
1383
 
1435
1384
  void XdsClient::ChannelState::LrsCallState::Reporter::OnReportDone(
1436
1385
  void* arg, grpc_error* error) {
1437
1386
  Reporter* self = static_cast<Reporter*>(arg);
1438
- GRPC_ERROR_REF(error); // ref owned by lambda
1439
- self->xds_client()->work_serializer_->Run(
1440
- [self, error]() { self->OnReportDoneLocked(error); }, DEBUG_LOCATION);
1387
+ bool done;
1388
+ {
1389
+ MutexLock lock(&self->xds_client()->mu_);
1390
+ done = self->OnReportDoneLocked(GRPC_ERROR_REF(error));
1391
+ }
1392
+ if (done) self->Unref(DEBUG_LOCATION, "Reporter+report_done");
1441
1393
  }
1442
1394
 
1443
- void XdsClient::ChannelState::LrsCallState::Reporter::OnReportDoneLocked(
1395
+ bool XdsClient::ChannelState::LrsCallState::Reporter::OnReportDoneLocked(
1444
1396
  grpc_error* error) {
1445
1397
  grpc_byte_buffer_destroy(parent_->send_message_payload_);
1446
1398
  parent_->send_message_payload_ = nullptr;
1447
1399
  // If there are no more registered stats to report, cancel the call.
1448
1400
  if (xds_client()->load_report_map_.empty()) {
1449
1401
  parent_->chand()->StopLrsCall();
1450
- Unref(DEBUG_LOCATION, "Reporter+report_done+no_more_reporters");
1451
- return;
1402
+ GRPC_ERROR_UNREF(error);
1403
+ return true;
1452
1404
  }
1453
1405
  if (error != GRPC_ERROR_NONE || !IsCurrentReporterOnCall()) {
1406
+ GRPC_ERROR_UNREF(error);
1454
1407
  // If this reporter is no longer the current one on the call, the reason
1455
1408
  // might be that it was orphaned for a new one due to config update.
1456
1409
  if (!IsCurrentReporterOnCall()) {
1457
1410
  parent_->MaybeStartReportingLocked();
1458
1411
  }
1459
- Unref(DEBUG_LOCATION, "Reporter+report_done");
1460
- } else {
1461
- ScheduleNextReportLocked();
1412
+ return true;
1462
1413
  }
1463
- GRPC_ERROR_UNREF(error);
1414
+ ScheduleNextReportLocked();
1415
+ return false;
1464
1416
  }
1465
1417
 
1466
1418
  //
@@ -1469,22 +1421,27 @@ void XdsClient::ChannelState::LrsCallState::Reporter::OnReportDoneLocked(
1469
1421
 
1470
1422
  XdsClient::ChannelState::LrsCallState::LrsCallState(
1471
1423
  RefCountedPtr<RetryableCall<LrsCallState>> parent)
1472
- : InternallyRefCounted<LrsCallState>(&grpc_xds_client_trace),
1424
+ : InternallyRefCounted<LrsCallState>(
1425
+ GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace)
1426
+ ? "LrsCallState"
1427
+ : nullptr),
1473
1428
  parent_(std::move(parent)) {
1474
1429
  // Init the LRS call. Note that the call will progress every time there's
1475
1430
  // activity in xds_client()->interested_parties_, which is comprised of
1476
1431
  // the polling entities from client_channel.
1477
1432
  GPR_ASSERT(xds_client() != nullptr);
1478
- GPR_ASSERT(!xds_client()->server_name_.empty());
1433
+ const auto& method =
1434
+ chand()->server_.ShouldUseV3()
1435
+ ? GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V3_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS
1436
+ : GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS;
1479
1437
  call_ = grpc_channel_create_pollset_set_call(
1480
1438
  chand()->channel_, nullptr, GRPC_PROPAGATE_DEFAULTS,
1481
- xds_client()->interested_parties_,
1482
- GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS,
1483
- nullptr, GRPC_MILLIS_INF_FUTURE, nullptr);
1439
+ xds_client()->interested_parties_, method, nullptr,
1440
+ GRPC_MILLIS_INF_FUTURE, nullptr);
1484
1441
  GPR_ASSERT(call_ != nullptr);
1485
1442
  // Init the request payload.
1486
1443
  grpc_slice request_payload_slice =
1487
- xds_client()->api_.CreateLrsInitialRequest(xds_client()->server_name_);
1444
+ xds_client()->api_.CreateLrsInitialRequest(chand()->server_);
1488
1445
  send_message_payload_ =
1489
1446
  grpc_raw_byte_buffer_create(&request_payload_slice, 1);
1490
1447
  grpc_slice_unref_internal(request_payload_slice);
@@ -1520,8 +1477,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
1520
1477
  Ref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked").release();
1521
1478
  GRPC_CLOSURE_INIT(&on_initial_request_sent_, OnInitialRequestSent, this,
1522
1479
  grpc_schedule_on_exec_ctx);
1523
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
1524
- &on_initial_request_sent_);
1480
+ call_error = grpc_call_start_batch_and_execute(
1481
+ call_, ops, static_cast<size_t>(op - ops), &on_initial_request_sent_);
1525
1482
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1526
1483
  // Op: recv initial metadata.
1527
1484
  op = ops;
@@ -1540,8 +1497,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
1540
1497
  Ref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked").release();
1541
1498
  GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceived, this,
1542
1499
  grpc_schedule_on_exec_ctx);
1543
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
1544
- &on_response_received_);
1500
+ call_error = grpc_call_start_batch_and_execute(
1501
+ call_, ops, static_cast<size_t>(op - ops), &on_response_received_);
1545
1502
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1546
1503
  // Op: recv server status.
1547
1504
  op = ops;
@@ -1557,8 +1514,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
1557
1514
  // unreffed.
1558
1515
  GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this,
1559
1516
  grpc_schedule_on_exec_ctx);
1560
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
1561
- &on_status_received_);
1517
+ call_error = grpc_call_start_batch_and_execute(
1518
+ call_, ops, static_cast<size_t>(op - ops), &on_status_received_);
1562
1519
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1563
1520
  }
1564
1521
 
@@ -1579,7 +1536,7 @@ void XdsClient::ChannelState::LrsCallState::Orphan() {
1579
1536
  // on_status_received_ will complete the cancellation and clean up. Otherwise,
1580
1537
  // we are here because xds_client has to orphan a failed call, then the
1581
1538
  // following cancellation will be a no-op.
1582
- grpc_call_cancel(call_, nullptr);
1539
+ grpc_call_cancel_internal(call_);
1583
1540
  // Note that the initial ref is hold by on_status_received_. So the
1584
1541
  // corresponding unref happens in on_status_received_ instead of here.
1585
1542
  }
@@ -1608,9 +1565,11 @@ void XdsClient::ChannelState::LrsCallState::MaybeStartReportingLocked() {
1608
1565
  void XdsClient::ChannelState::LrsCallState::OnInitialRequestSent(
1609
1566
  void* arg, grpc_error* /*error*/) {
1610
1567
  LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1611
- lrs_calld->xds_client()->work_serializer_->Run(
1612
- [lrs_calld]() { lrs_calld->OnInitialRequestSentLocked(); },
1613
- DEBUG_LOCATION);
1568
+ {
1569
+ MutexLock lock(&lrs_calld->xds_client()->mu_);
1570
+ lrs_calld->OnInitialRequestSentLocked();
1571
+ }
1572
+ lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked");
1614
1573
  }
1615
1574
 
1616
1575
  void XdsClient::ChannelState::LrsCallState::OnInitialRequestSentLocked() {
@@ -1618,21 +1577,23 @@ void XdsClient::ChannelState::LrsCallState::OnInitialRequestSentLocked() {
1618
1577
  grpc_byte_buffer_destroy(send_message_payload_);
1619
1578
  send_message_payload_ = nullptr;
1620
1579
  MaybeStartReportingLocked();
1621
- Unref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked");
1622
1580
  }
1623
1581
 
1624
1582
  void XdsClient::ChannelState::LrsCallState::OnResponseReceived(
1625
1583
  void* arg, grpc_error* /*error*/) {
1626
1584
  LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1627
- lrs_calld->xds_client()->work_serializer_->Run(
1628
- [lrs_calld]() { lrs_calld->OnResponseReceivedLocked(); }, DEBUG_LOCATION);
1585
+ bool done;
1586
+ {
1587
+ MutexLock lock(&lrs_calld->xds_client()->mu_);
1588
+ done = lrs_calld->OnResponseReceivedLocked();
1589
+ }
1590
+ if (done) lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked");
1629
1591
  }
1630
1592
 
1631
- void XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked() {
1593
+ bool XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked() {
1632
1594
  // Empty payload means the call was cancelled.
1633
1595
  if (!IsCurrentCallOnChannel() || recv_message_payload_ == nullptr) {
1634
- Unref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked");
1635
- return;
1596
+ return true;
1636
1597
  }
1637
1598
  // Read the response.
1638
1599
  grpc_byte_buffer_reader bbr;
@@ -1705,10 +1666,7 @@ void XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked() {
1705
1666
  MaybeStartReportingLocked();
1706
1667
  }();
1707
1668
  grpc_slice_unref_internal(response_slice);
1708
- if (xds_client()->shutting_down_) {
1709
- Unref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked+xds_shutdown");
1710
- return;
1711
- }
1669
+ if (xds_client()->shutting_down_) return true;
1712
1670
  // Keep listening for LRS config updates.
1713
1671
  grpc_op op;
1714
1672
  memset(&op, 0, sizeof(op));
@@ -1721,15 +1679,17 @@ void XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked() {
1721
1679
  const grpc_call_error call_error =
1722
1680
  grpc_call_start_batch_and_execute(call_, &op, 1, &on_response_received_);
1723
1681
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1682
+ return false;
1724
1683
  }
1725
1684
 
1726
1685
  void XdsClient::ChannelState::LrsCallState::OnStatusReceived(
1727
1686
  void* arg, grpc_error* error) {
1728
1687
  LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1729
- GRPC_ERROR_REF(error); // ref owned by lambda
1730
- lrs_calld->xds_client()->work_serializer_->Run(
1731
- [lrs_calld, error]() { lrs_calld->OnStatusReceivedLocked(error); },
1732
- DEBUG_LOCATION);
1688
+ {
1689
+ MutexLock lock(&lrs_calld->xds_client()->mu_);
1690
+ lrs_calld->OnStatusReceivedLocked(GRPC_ERROR_REF(error));
1691
+ }
1692
+ lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnStatusReceivedLocked");
1733
1693
  }
1734
1694
 
1735
1695
  void XdsClient::ChannelState::LrsCallState::OnStatusReceivedLocked(
@@ -1750,7 +1710,6 @@ void XdsClient::ChannelState::LrsCallState::OnStatusReceivedLocked(
1750
1710
  // Try to restart the call.
1751
1711
  parent_->OnCallFinishedLocked();
1752
1712
  }
1753
- Unref(DEBUG_LOCATION, "LRS+OnStatusReceivedLocked");
1754
1713
  GRPC_ERROR_UNREF(error);
1755
1714
  }
1756
1715
 
@@ -1767,29 +1726,28 @@ bool XdsClient::ChannelState::LrsCallState::IsCurrentCallOnChannel() const {
1767
1726
 
1768
1727
  namespace {
1769
1728
 
1770
- grpc_millis GetRequestTimeout(const grpc_channel_args& args) {
1729
+ grpc_millis GetRequestTimeout() {
1771
1730
  return grpc_channel_args_find_integer(
1772
- &args, GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS,
1731
+ g_channel_args, GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS,
1773
1732
  {15000, 0, INT_MAX});
1774
1733
  }
1775
1734
 
1776
1735
  } // namespace
1777
1736
 
1778
- XdsClient::XdsClient(std::shared_ptr<WorkSerializer> work_serializer,
1779
- grpc_pollset_set* interested_parties,
1780
- absl::string_view server_name,
1781
- std::unique_ptr<ServiceConfigWatcherInterface> watcher,
1782
- const grpc_channel_args& channel_args, grpc_error** error)
1783
- : InternallyRefCounted<XdsClient>(&grpc_xds_client_trace),
1784
- request_timeout_(GetRequestTimeout(channel_args)),
1785
- work_serializer_(std::move(work_serializer)),
1786
- interested_parties_(interested_parties),
1737
+ XdsClient::XdsClient(grpc_error** error)
1738
+ : DualRefCounted<XdsClient>(
1739
+ GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace) ? "XdsClient"
1740
+ : nullptr),
1741
+ request_timeout_(GetRequestTimeout()),
1742
+ interested_parties_(grpc_pollset_set_create()),
1787
1743
  bootstrap_(
1788
1744
  XdsBootstrap::ReadFromFile(this, &grpc_xds_client_trace, error)),
1745
+ certificate_provider_store_(MakeOrphanable<CertificateProviderStore>(
1746
+ bootstrap_ == nullptr
1747
+ ? CertificateProviderStore::PluginDefinitionMap()
1748
+ : bootstrap_->certificate_providers())),
1789
1749
  api_(this, &grpc_xds_client_trace,
1790
- bootstrap_ == nullptr ? nullptr : bootstrap_->node()),
1791
- server_name_(server_name),
1792
- service_config_watcher_(std::move(watcher)) {
1750
+ bootstrap_ == nullptr ? nullptr : bootstrap_->node()) {
1793
1751
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1794
1752
  gpr_log(GPR_INFO, "[xds_client %p] creating xds client", this);
1795
1753
  }
@@ -1798,58 +1756,150 @@ XdsClient::XdsClient(std::shared_ptr<WorkSerializer> work_serializer,
1798
1756
  this, grpc_error_string(*error));
1799
1757
  return;
1800
1758
  }
1801
- if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1802
- gpr_log(GPR_INFO, "[xds_client %p] creating channel to %s", this,
1803
- bootstrap_->server().server_uri.c_str());
1804
- }
1805
- grpc_channel_args* new_args = BuildXdsChannelArgs(channel_args);
1806
- grpc_channel* channel = CreateXdsChannel(*bootstrap_, *new_args, error);
1807
- grpc_channel_args_destroy(new_args);
1808
- if (*error != GRPC_ERROR_NONE) {
1809
- gpr_log(GPR_ERROR, "[xds_client %p] failed to create xds channel: %s", this,
1810
- grpc_error_string(*error));
1811
- return;
1812
- }
1759
+ // Create ChannelState object.
1813
1760
  chand_ = MakeOrphanable<ChannelState>(
1814
- Ref(DEBUG_LOCATION, "XdsClient+ChannelState"), channel);
1815
- if (service_config_watcher_ != nullptr) {
1816
- chand_->Subscribe(XdsApi::kLdsTypeUrl, std::string(server_name));
1817
- }
1761
+ WeakRef(DEBUG_LOCATION, "XdsClient+ChannelState"), bootstrap_->server());
1818
1762
  }
1819
1763
 
1820
1764
  XdsClient::~XdsClient() {
1821
1765
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1822
1766
  gpr_log(GPR_INFO, "[xds_client %p] destroying xds client", this);
1823
1767
  }
1768
+ grpc_pollset_set_destroy(interested_parties_);
1769
+ }
1770
+
1771
+ void XdsClient::AddChannelzLinkage(
1772
+ channelz::ChannelNode* parent_channelz_node) {
1773
+ channelz::ChannelNode* xds_channelz_node =
1774
+ grpc_channel_get_channelz_node(chand_->channel());
1775
+ if (xds_channelz_node != nullptr) {
1776
+ parent_channelz_node->AddChildChannel(xds_channelz_node->uuid());
1777
+ }
1778
+ }
1779
+
1780
+ void XdsClient::RemoveChannelzLinkage(
1781
+ channelz::ChannelNode* parent_channelz_node) {
1782
+ channelz::ChannelNode* xds_channelz_node =
1783
+ grpc_channel_get_channelz_node(chand_->channel());
1784
+ if (xds_channelz_node != nullptr) {
1785
+ parent_channelz_node->RemoveChildChannel(xds_channelz_node->uuid());
1786
+ }
1824
1787
  }
1825
1788
 
1826
1789
  void XdsClient::Orphan() {
1827
1790
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1828
1791
  gpr_log(GPR_INFO, "[xds_client %p] shutting down xds client", this);
1829
1792
  }
1830
- shutting_down_ = true;
1831
- chand_.reset();
1832
- // We do not clear cluster_map_ and endpoint_map_ if the xds client was
1833
- // created by the XdsResolver because the maps contain refs for watchers which
1834
- // in turn hold refs to the loadbalancing policies. At this point, it is
1835
- // possible for ADS calls to be in progress. Unreffing the loadbalancing
1836
- // policies before those calls are done would lead to issues such as
1837
- // https://github.com/grpc/grpc/issues/20928.
1838
- if (service_config_watcher_ != nullptr) {
1839
- cluster_map_.clear();
1840
- endpoint_map_.clear();
1793
+ {
1794
+ MutexLock lock(g_mu);
1795
+ if (g_xds_client == this) g_xds_client = nullptr;
1796
+ }
1797
+ {
1798
+ MutexLock lock(&mu_);
1799
+ shutting_down_ = true;
1800
+ // Orphan ChannelState object.
1801
+ chand_.reset();
1802
+ // We do not clear cluster_map_ and endpoint_map_ if the xds client was
1803
+ // created by the XdsResolver because the maps contain refs for watchers
1804
+ // which in turn hold refs to the loadbalancing policies. At this point, it
1805
+ // is possible for ADS calls to be in progress. Unreffing the loadbalancing
1806
+ // policies before those calls are done would lead to issues such as
1807
+ // https://github.com/grpc/grpc/issues/20928.
1808
+ if (!listener_map_.empty()) {
1809
+ cluster_map_.clear();
1810
+ endpoint_map_.clear();
1811
+ }
1812
+ }
1813
+ }
1814
+
1815
+ void XdsClient::WatchListenerData(
1816
+ absl::string_view listener_name,
1817
+ std::unique_ptr<ListenerWatcherInterface> watcher) {
1818
+ std::string listener_name_str = std::string(listener_name);
1819
+ MutexLock lock(&mu_);
1820
+ ListenerState& listener_state = listener_map_[listener_name_str];
1821
+ ListenerWatcherInterface* w = watcher.get();
1822
+ listener_state.watchers[w] = std::move(watcher);
1823
+ // If we've already received an LDS update, notify the new watcher
1824
+ // immediately.
1825
+ if (listener_state.update.has_value()) {
1826
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1827
+ gpr_log(GPR_INFO, "[xds_client %p] returning cached listener data for %s",
1828
+ this, listener_name_str.c_str());
1829
+ }
1830
+ w->OnListenerChanged(*listener_state.update);
1831
+ }
1832
+ chand_->Subscribe(XdsApi::kLdsTypeUrl, listener_name_str);
1833
+ }
1834
+
1835
+ void XdsClient::CancelListenerDataWatch(absl::string_view listener_name,
1836
+ ListenerWatcherInterface* watcher,
1837
+ bool delay_unsubscription) {
1838
+ MutexLock lock(&mu_);
1839
+ if (shutting_down_) return;
1840
+ std::string listener_name_str = std::string(listener_name);
1841
+ ListenerState& listener_state = listener_map_[listener_name_str];
1842
+ auto it = listener_state.watchers.find(watcher);
1843
+ if (it != listener_state.watchers.end()) {
1844
+ listener_state.watchers.erase(it);
1845
+ if (listener_state.watchers.empty()) {
1846
+ listener_map_.erase(listener_name_str);
1847
+ chand_->Unsubscribe(XdsApi::kLdsTypeUrl, listener_name_str,
1848
+ delay_unsubscription);
1849
+ }
1850
+ }
1851
+ }
1852
+
1853
+ void XdsClient::WatchRouteConfigData(
1854
+ absl::string_view route_config_name,
1855
+ std::unique_ptr<RouteConfigWatcherInterface> watcher) {
1856
+ std::string route_config_name_str = std::string(route_config_name);
1857
+ MutexLock lock(&mu_);
1858
+ RouteConfigState& route_config_state =
1859
+ route_config_map_[route_config_name_str];
1860
+ RouteConfigWatcherInterface* w = watcher.get();
1861
+ route_config_state.watchers[w] = std::move(watcher);
1862
+ // If we've already received an RDS update, notify the new watcher
1863
+ // immediately.
1864
+ if (route_config_state.update.has_value()) {
1865
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1866
+ gpr_log(GPR_INFO,
1867
+ "[xds_client %p] returning cached route config data for %s", this,
1868
+ route_config_name_str.c_str());
1869
+ }
1870
+ w->OnRouteConfigChanged(*route_config_state.update);
1871
+ }
1872
+ chand_->Subscribe(XdsApi::kRdsTypeUrl, route_config_name_str);
1873
+ }
1874
+
1875
+ void XdsClient::CancelRouteConfigDataWatch(absl::string_view route_config_name,
1876
+ RouteConfigWatcherInterface* watcher,
1877
+ bool delay_unsubscription) {
1878
+ MutexLock lock(&mu_);
1879
+ if (shutting_down_) return;
1880
+ std::string route_config_name_str = std::string(route_config_name);
1881
+ RouteConfigState& route_config_state =
1882
+ route_config_map_[route_config_name_str];
1883
+ auto it = route_config_state.watchers.find(watcher);
1884
+ if (it != route_config_state.watchers.end()) {
1885
+ route_config_state.watchers.erase(it);
1886
+ if (route_config_state.watchers.empty()) {
1887
+ route_config_map_.erase(route_config_name_str);
1888
+ chand_->Unsubscribe(XdsApi::kRdsTypeUrl, route_config_name_str,
1889
+ delay_unsubscription);
1890
+ }
1841
1891
  }
1842
- Unref(DEBUG_LOCATION, "XdsClient::Orphan()");
1843
1892
  }
1844
1893
 
1845
1894
  void XdsClient::WatchClusterData(
1846
1895
  absl::string_view cluster_name,
1847
1896
  std::unique_ptr<ClusterWatcherInterface> watcher) {
1848
1897
  std::string cluster_name_str = std::string(cluster_name);
1898
+ MutexLock lock(&mu_);
1849
1899
  ClusterState& cluster_state = cluster_map_[cluster_name_str];
1850
1900
  ClusterWatcherInterface* w = watcher.get();
1851
1901
  cluster_state.watchers[w] = std::move(watcher);
1852
- // If we've already received an CDS update, notify the new watcher
1902
+ // If we've already received a CDS update, notify the new watcher
1853
1903
  // immediately.
1854
1904
  if (cluster_state.update.has_value()) {
1855
1905
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
@@ -1864,6 +1914,7 @@ void XdsClient::WatchClusterData(
1864
1914
  void XdsClient::CancelClusterDataWatch(absl::string_view cluster_name,
1865
1915
  ClusterWatcherInterface* watcher,
1866
1916
  bool delay_unsubscription) {
1917
+ MutexLock lock(&mu_);
1867
1918
  if (shutting_down_) return;
1868
1919
  std::string cluster_name_str = std::string(cluster_name);
1869
1920
  ClusterState& cluster_state = cluster_map_[cluster_name_str];
@@ -1882,6 +1933,7 @@ void XdsClient::WatchEndpointData(
1882
1933
  absl::string_view eds_service_name,
1883
1934
  std::unique_ptr<EndpointWatcherInterface> watcher) {
1884
1935
  std::string eds_service_name_str = std::string(eds_service_name);
1936
+ MutexLock lock(&mu_);
1885
1937
  EndpointState& endpoint_state = endpoint_map_[eds_service_name_str];
1886
1938
  EndpointWatcherInterface* w = watcher.get();
1887
1939
  endpoint_state.watchers[w] = std::move(watcher);
@@ -1900,6 +1952,7 @@ void XdsClient::WatchEndpointData(
1900
1952
  void XdsClient::CancelEndpointDataWatch(absl::string_view eds_service_name,
1901
1953
  EndpointWatcherInterface* watcher,
1902
1954
  bool delay_unsubscription) {
1955
+ MutexLock lock(&mu_);
1903
1956
  if (shutting_down_) return;
1904
1957
  std::string eds_service_name_str = std::string(eds_service_name);
1905
1958
  EndpointState& endpoint_state = endpoint_map_[eds_service_name_str];
@@ -1921,16 +1974,29 @@ RefCountedPtr<XdsClusterDropStats> XdsClient::AddClusterDropStats(
1921
1974
  // server name specified in lrs_server.
1922
1975
  auto key =
1923
1976
  std::make_pair(std::string(cluster_name), std::string(eds_service_name));
1977
+ MutexLock lock(&mu_);
1924
1978
  // We jump through some hoops here to make sure that the absl::string_views
1925
1979
  // stored in the XdsClusterDropStats object point to the strings
1926
1980
  // in the load_report_map_ key, so that they have the same lifetime.
1927
1981
  auto it = load_report_map_
1928
1982
  .emplace(std::make_pair(std::move(key), LoadReportState()))
1929
1983
  .first;
1930
- auto cluster_drop_stats = MakeRefCounted<XdsClusterDropStats>(
1931
- Ref(DEBUG_LOCATION, "DropStats"), lrs_server,
1932
- it->first.first /*cluster_name*/, it->first.second /*eds_service_name*/);
1933
- it->second.drop_stats.insert(cluster_drop_stats.get());
1984
+ LoadReportState& load_report_state = it->second;
1985
+ RefCountedPtr<XdsClusterDropStats> cluster_drop_stats;
1986
+ if (load_report_state.drop_stats != nullptr) {
1987
+ cluster_drop_stats = load_report_state.drop_stats->RefIfNonZero();
1988
+ }
1989
+ if (cluster_drop_stats == nullptr) {
1990
+ if (load_report_state.drop_stats != nullptr) {
1991
+ load_report_state.deleted_drop_stats +=
1992
+ load_report_state.drop_stats->GetSnapshotAndReset();
1993
+ }
1994
+ cluster_drop_stats = MakeRefCounted<XdsClusterDropStats>(
1995
+ Ref(DEBUG_LOCATION, "DropStats"), lrs_server,
1996
+ it->first.first /*cluster_name*/,
1997
+ it->first.second /*eds_service_name*/);
1998
+ load_report_state.drop_stats = cluster_drop_stats.get();
1999
+ }
1934
2000
  chand_->MaybeStartLrsCall();
1935
2001
  return cluster_drop_stats;
1936
2002
  }
@@ -1939,20 +2005,19 @@ void XdsClient::RemoveClusterDropStats(
1939
2005
  absl::string_view /*lrs_server*/, absl::string_view cluster_name,
1940
2006
  absl::string_view eds_service_name,
1941
2007
  XdsClusterDropStats* cluster_drop_stats) {
1942
- auto load_report_it = load_report_map_.find(
1943
- std::make_pair(std::string(cluster_name), std::string(eds_service_name)));
1944
- if (load_report_it == load_report_map_.end()) return;
1945
- LoadReportState& load_report_state = load_report_it->second;
2008
+ MutexLock lock(&mu_);
1946
2009
  // TODO(roth): When we add support for direct federation, use the
1947
2010
  // server name specified in lrs_server.
1948
- auto it = load_report_state.drop_stats.find(cluster_drop_stats);
1949
- if (it != load_report_state.drop_stats.end()) {
1950
- // Record final drop stats in deleted_drop_stats, which will be
2011
+ auto it = load_report_map_.find(
2012
+ std::make_pair(std::string(cluster_name), std::string(eds_service_name)));
2013
+ if (it == load_report_map_.end()) return;
2014
+ LoadReportState& load_report_state = it->second;
2015
+ if (load_report_state.drop_stats == cluster_drop_stats) {
2016
+ // Record final snapshot in deleted_drop_stats, which will be
1951
2017
  // added to the next load report.
1952
- for (const auto& p : cluster_drop_stats->GetSnapshotAndReset()) {
1953
- load_report_state.deleted_drop_stats[p.first] += p.second;
1954
- }
1955
- load_report_state.drop_stats.erase(it);
2018
+ load_report_state.deleted_drop_stats +=
2019
+ load_report_state.drop_stats->GetSnapshotAndReset();
2020
+ load_report_state.drop_stats = nullptr;
1956
2021
  }
1957
2022
  }
1958
2023
 
@@ -1964,18 +2029,31 @@ RefCountedPtr<XdsClusterLocalityStats> XdsClient::AddClusterLocalityStats(
1964
2029
  // server name specified in lrs_server.
1965
2030
  auto key =
1966
2031
  std::make_pair(std::string(cluster_name), std::string(eds_service_name));
2032
+ MutexLock lock(&mu_);
1967
2033
  // We jump through some hoops here to make sure that the absl::string_views
1968
2034
  // stored in the XdsClusterLocalityStats object point to the strings
1969
2035
  // in the load_report_map_ key, so that they have the same lifetime.
1970
2036
  auto it = load_report_map_
1971
2037
  .emplace(std::make_pair(std::move(key), LoadReportState()))
1972
2038
  .first;
1973
- auto cluster_locality_stats = MakeRefCounted<XdsClusterLocalityStats>(
1974
- Ref(DEBUG_LOCATION, "LocalityStats"), lrs_server,
1975
- it->first.first /*cluster_name*/, it->first.second /*eds_service_name*/,
1976
- locality);
1977
- it->second.locality_stats[std::move(locality)].locality_stats.insert(
1978
- cluster_locality_stats.get());
2039
+ LoadReportState& load_report_state = it->second;
2040
+ LoadReportState::LocalityState& locality_state =
2041
+ load_report_state.locality_stats[locality];
2042
+ RefCountedPtr<XdsClusterLocalityStats> cluster_locality_stats;
2043
+ if (locality_state.locality_stats != nullptr) {
2044
+ cluster_locality_stats = locality_state.locality_stats->RefIfNonZero();
2045
+ }
2046
+ if (cluster_locality_stats == nullptr) {
2047
+ if (locality_state.locality_stats != nullptr) {
2048
+ locality_state.deleted_locality_stats +=
2049
+ locality_state.locality_stats->GetSnapshotAndReset();
2050
+ }
2051
+ cluster_locality_stats = MakeRefCounted<XdsClusterLocalityStats>(
2052
+ Ref(DEBUG_LOCATION, "LocalityStats"), lrs_server,
2053
+ it->first.first /*cluster_name*/, it->first.second /*eds_service_name*/,
2054
+ std::move(locality));
2055
+ locality_state.locality_stats = cluster_locality_stats.get();
2056
+ }
1979
2057
  chand_->MaybeStartLrsCall();
1980
2058
  return cluster_locality_stats;
1981
2059
  }
@@ -1985,263 +2063,65 @@ void XdsClient::RemoveClusterLocalityStats(
1985
2063
  absl::string_view eds_service_name,
1986
2064
  const RefCountedPtr<XdsLocalityName>& locality,
1987
2065
  XdsClusterLocalityStats* cluster_locality_stats) {
1988
- auto load_report_it = load_report_map_.find(
1989
- std::make_pair(std::string(cluster_name), std::string(eds_service_name)));
1990
- if (load_report_it == load_report_map_.end()) return;
1991
- LoadReportState& load_report_state = load_report_it->second;
2066
+ MutexLock lock(&mu_);
1992
2067
  // TODO(roth): When we add support for direct federation, use the
1993
2068
  // server name specified in lrs_server.
2069
+ auto it = load_report_map_.find(
2070
+ std::make_pair(std::string(cluster_name), std::string(eds_service_name)));
2071
+ if (it == load_report_map_.end()) return;
2072
+ LoadReportState& load_report_state = it->second;
1994
2073
  auto locality_it = load_report_state.locality_stats.find(locality);
1995
2074
  if (locality_it == load_report_state.locality_stats.end()) return;
1996
- auto& locality_set = locality_it->second.locality_stats;
1997
- auto it = locality_set.find(cluster_locality_stats);
1998
- if (it != locality_set.end()) {
2075
+ LoadReportState::LocalityState& locality_state = locality_it->second;
2076
+ if (locality_state.locality_stats == cluster_locality_stats) {
1999
2077
  // Record final snapshot in deleted_locality_stats, which will be
2000
2078
  // added to the next load report.
2001
- locality_it->second.deleted_locality_stats.emplace_back(
2002
- cluster_locality_stats->GetSnapshotAndReset());
2003
- locality_set.erase(it);
2079
+ locality_state.deleted_locality_stats +=
2080
+ locality_state.locality_stats->GetSnapshotAndReset();
2081
+ locality_state.locality_stats = nullptr;
2004
2082
  }
2005
2083
  }
2006
2084
 
2007
2085
  void XdsClient::ResetBackoff() {
2086
+ MutexLock lock(&mu_);
2008
2087
  if (chand_ != nullptr) {
2009
2088
  grpc_channel_reset_connect_backoff(chand_->channel());
2010
2089
  }
2011
2090
  }
2012
2091
 
2013
- namespace {
2014
- std::string CreateServiceConfigActionCluster(const std::string& cluster_name) {
2015
- return absl::StrFormat(
2016
- " \"cds:%s\":{\n"
2017
- " \"childPolicy\":[ {\n"
2018
- " \"cds_experimental\":{\n"
2019
- " \"cluster\": \"%s\"\n"
2020
- " }\n"
2021
- " } ]\n"
2022
- " }",
2023
- cluster_name, cluster_name);
2024
- }
2025
-
2026
- std::string CreateServiceConfigRoute(const std::string& action_name,
2027
- const std::string& service,
2028
- const std::string& method) {
2029
- return absl::StrFormat(
2030
- " { \n"
2031
- " \"methodName\": {\n"
2032
- " \"service\": \"%s\",\n"
2033
- " \"method\": \"%s\"\n"
2034
- " },\n"
2035
- " \"action\": \"%s\"\n"
2036
- " }",
2037
- service, method, action_name);
2038
- }
2039
-
2040
- // Create the service config for one weighted cluster.
2041
- std::string CreateServiceConfigActionWeightedCluster(
2042
- const std::string& name,
2043
- const std::vector<XdsApi::RdsUpdate::RdsRoute::ClusterWeight>& clusters) {
2044
- std::vector<std::string> config_parts;
2045
- config_parts.push_back(
2046
- absl::StrFormat(" \"weighted:%s\":{\n"
2047
- " \"childPolicy\":[ {\n"
2048
- " \"weighted_target_experimental\":{\n"
2049
- " \"targets\":{\n",
2050
- name));
2051
- std::vector<std::string> weighted_targets;
2052
- weighted_targets.reserve(clusters.size());
2053
- for (const auto& cluster_weight : clusters) {
2054
- weighted_targets.push_back(absl::StrFormat(
2055
- " \"%s\":{\n"
2056
- " \"weight\":%d,\n"
2057
- " \"childPolicy\":[ {\n"
2058
- " \"cds_experimental\":{\n"
2059
- " \"cluster\": \"%s\"\n"
2060
- " }\n"
2061
- " } ]\n"
2062
- " }",
2063
- cluster_weight.name, cluster_weight.weight, cluster_weight.name));
2064
- }
2065
- config_parts.push_back(absl::StrJoin(weighted_targets, ",\n"));
2066
- config_parts.push_back(
2067
- " }\n"
2068
- " }\n"
2069
- " } ]\n"
2070
- " }");
2071
- return absl::StrJoin(config_parts, "");
2072
- }
2073
-
2074
- struct WeightedClustersKeys {
2075
- std::string cluster_names_key;
2076
- std::string cluster_weights_key;
2077
- };
2078
-
2079
- // Returns the cluster names and weights key or the cluster names only key.
2080
- WeightedClustersKeys GetWeightedClustersKey(
2081
- const std::vector<XdsApi::RdsUpdate::RdsRoute::ClusterWeight>&
2082
- weighted_clusters) {
2083
- std::set<std::string> cluster_names;
2084
- std::set<std::string> cluster_weights;
2085
- for (const auto& cluster_weight : weighted_clusters) {
2086
- cluster_names.emplace(absl::StrFormat("%s", cluster_weight.name));
2087
- cluster_weights.emplace(
2088
- absl::StrFormat("%s_%d", cluster_weight.name, cluster_weight.weight));
2089
- }
2090
- return {absl::StrJoin(cluster_names, "_"),
2091
- absl::StrJoin(cluster_weights, "_")};
2092
- }
2093
-
2094
- } // namespace
2095
-
2096
- std::string XdsClient::WeightedClustersActionName(
2097
- const std::vector<XdsApi::RdsUpdate::RdsRoute::ClusterWeight>&
2098
- weighted_clusters) {
2099
- WeightedClustersKeys keys = GetWeightedClustersKey(weighted_clusters);
2100
- auto cluster_names_map_it =
2101
- weighted_cluster_index_map_.find(keys.cluster_names_key);
2102
- GPR_ASSERT(cluster_names_map_it != weighted_cluster_index_map_.end());
2103
- const auto& cluster_weights_map =
2104
- cluster_names_map_it->second.cluster_weights_map;
2105
- auto cluster_weights_map_it =
2106
- cluster_weights_map.find(keys.cluster_weights_key);
2107
- GPR_ASSERT(cluster_weights_map_it != cluster_weights_map.end());
2108
- return absl::StrFormat("%s_%d", keys.cluster_names_key,
2109
- cluster_weights_map_it->second);
2110
- }
2111
-
2112
- void XdsClient::UpdateWeightedClusterIndexMap(
2113
- const XdsApi::RdsUpdate& rds_update) {
2114
- // Construct a list of unique WeightedCluster
2115
- // actions which we need to process: to find action names
2116
- std::map<std::string /* cluster_weights_key */,
2117
- std::string /* cluster_names_key */>
2118
- actions_to_process;
2119
- for (const auto& route : rds_update.routes) {
2120
- if (!route.weighted_clusters.empty()) {
2121
- WeightedClustersKeys keys =
2122
- GetWeightedClustersKey(route.weighted_clusters);
2123
- auto action_it = actions_to_process.find(keys.cluster_weights_key);
2124
- if (action_it == actions_to_process.end()) {
2125
- actions_to_process[std::move(keys.cluster_weights_key)] =
2126
- std::move(keys.cluster_names_key);
2127
- }
2092
+ void XdsClient::NotifyOnErrorLocked(grpc_error* error) {
2093
+ for (const auto& p : listener_map_) {
2094
+ const ListenerState& listener_state = p.second;
2095
+ for (const auto& p : listener_state.watchers) {
2096
+ p.first->OnError(GRPC_ERROR_REF(error));
2128
2097
  }
2129
2098
  }
2130
- // First pass of all unique WeightedCluster actions: if the exact same
2131
- // weighted target policy (same clusters and weights) appears in the old map,
2132
- // then that old action name is taken again and should be moved to the new
2133
- // map; any other action names from the old set of actions are candidates for
2134
- // reuse.
2135
- XdsClient::WeightedClusterIndexMap new_weighted_cluster_index_map;
2136
- for (auto action_it = actions_to_process.begin();
2137
- action_it != actions_to_process.end();) {
2138
- const std::string& cluster_names_key = action_it->second;
2139
- const std::string& cluster_weights_key = action_it->first;
2140
- auto old_cluster_names_map_it =
2141
- weighted_cluster_index_map_.find(cluster_names_key);
2142
- if (old_cluster_names_map_it != weighted_cluster_index_map_.end()) {
2143
- // Add cluster_names_key to the new map and copy next_index.
2144
- auto& new_cluster_names_info =
2145
- new_weighted_cluster_index_map[cluster_names_key];
2146
- new_cluster_names_info.next_index =
2147
- old_cluster_names_map_it->second.next_index;
2148
- // Lookup cluster_weights_key in old map.
2149
- auto& old_cluster_weights_map =
2150
- old_cluster_names_map_it->second.cluster_weights_map;
2151
- auto old_cluster_weights_map_it =
2152
- old_cluster_weights_map.find(cluster_weights_key);
2153
- if (old_cluster_weights_map_it != old_cluster_weights_map.end()) {
2154
- // same policy found, move from old map to new map.
2155
- new_cluster_names_info.cluster_weights_map[cluster_weights_key] =
2156
- old_cluster_weights_map_it->second;
2157
- old_cluster_weights_map.erase(old_cluster_weights_map_it);
2158
- // This action has been added to new map, so no need to process it
2159
- // again.
2160
- action_it = actions_to_process.erase(action_it);
2161
- continue;
2162
- }
2099
+ for (const auto& p : route_config_map_) {
2100
+ const RouteConfigState& route_config_state = p.second;
2101
+ for (const auto& p : route_config_state.watchers) {
2102
+ p.first->OnError(GRPC_ERROR_REF(error));
2163
2103
  }
2164
- ++action_it;
2165
- }
2166
- // Second pass of all remaining unique WeightedCluster actions: if clusters
2167
- // for a new action are the same as an old unused action, reuse the name. If
2168
- // clusters differ, use a brand new name.
2169
- for (const auto& action : actions_to_process) {
2170
- const std::string& cluster_names_key = action.second;
2171
- const std::string& cluster_weights_key = action.first;
2172
- auto& new_cluster_names_info =
2173
- new_weighted_cluster_index_map[cluster_names_key];
2174
- auto& old_cluster_weights_map =
2175
- weighted_cluster_index_map_[cluster_names_key].cluster_weights_map;
2176
- auto old_cluster_weights_it = old_cluster_weights_map.begin();
2177
- if (old_cluster_weights_it != old_cluster_weights_map.end()) {
2178
- // There is something to reuse: this action uses the same set
2179
- // of clusters as a previous action and that action name is not
2180
- // already taken.
2181
- new_cluster_names_info.cluster_weights_map[cluster_weights_key] =
2182
- old_cluster_weights_it->second;
2183
- // Remove the name from being able to reuse again.
2184
- old_cluster_weights_map.erase(old_cluster_weights_it);
2185
- } else {
2186
- // There is nothing to reuse, take the next index to use and
2187
- // increment.
2188
- new_cluster_names_info.cluster_weights_map[cluster_weights_key] =
2189
- new_cluster_names_info.next_index++;
2104
+ }
2105
+ for (const auto& p : cluster_map_) {
2106
+ const ClusterState& cluster_state = p.second;
2107
+ for (const auto& p : cluster_state.watchers) {
2108
+ p.first->OnError(GRPC_ERROR_REF(error));
2190
2109
  }
2191
2110
  }
2192
- weighted_cluster_index_map_ = std::move(new_weighted_cluster_index_map);
2193
- }
2194
-
2195
- grpc_error* XdsClient::CreateServiceConfig(
2196
- const XdsApi::RdsUpdate& rds_update,
2197
- RefCountedPtr<ServiceConfig>* service_config) {
2198
- UpdateWeightedClusterIndexMap(rds_update);
2199
- std::vector<std::string> actions_vector;
2200
- std::vector<std::string> route_table;
2201
- std::set<std::string> actions_set;
2202
- for (const auto& route : rds_update.routes) {
2203
- const std::string action_name =
2204
- route.weighted_clusters.empty()
2205
- ? route.cluster_name
2206
- : WeightedClustersActionName(route.weighted_clusters);
2207
- if (actions_set.find(action_name) == actions_set.end()) {
2208
- actions_set.emplace(action_name);
2209
- actions_vector.push_back(
2210
- route.weighted_clusters.empty()
2211
- ? CreateServiceConfigActionCluster(action_name)
2212
- : CreateServiceConfigActionWeightedCluster(
2213
- action_name, route.weighted_clusters));
2111
+ for (const auto& p : endpoint_map_) {
2112
+ const EndpointState& endpoint_state = p.second;
2113
+ for (const auto& p : endpoint_state.watchers) {
2114
+ p.first->OnError(GRPC_ERROR_REF(error));
2214
2115
  }
2215
- route_table.push_back(CreateServiceConfigRoute(
2216
- absl::StrFormat("%s:%s",
2217
- route.weighted_clusters.empty() ? "cds" : "weighted",
2218
- action_name),
2219
- route.service, route.method));
2220
- }
2221
- std::vector<std::string> config_parts;
2222
- config_parts.push_back(
2223
- "{\n"
2224
- " \"loadBalancingConfig\":[\n"
2225
- " { \"xds_routing_experimental\":{\n"
2226
- " \"actions\":{\n");
2227
- config_parts.push_back(absl::StrJoin(actions_vector, ",\n"));
2228
- config_parts.push_back(
2229
- " },\n"
2230
- " \"routes\":[\n");
2231
- config_parts.push_back(absl::StrJoin(route_table, ",\n"));
2232
- config_parts.push_back(
2233
- " ]\n"
2234
- " } }\n"
2235
- " ]\n"
2236
- "}");
2237
- std::string json = absl::StrJoin(config_parts, "");
2238
- grpc_error* error = GRPC_ERROR_NONE;
2239
- *service_config = ServiceConfig::Create(json.c_str(), &error);
2240
- return error;
2241
- }
2242
-
2243
- XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshot(
2116
+ }
2117
+ GRPC_ERROR_UNREF(error);
2118
+ }
2119
+
2120
+ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshotLocked(
2244
2121
  bool send_all_clusters, const std::set<std::string>& clusters) {
2122
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
2123
+ gpr_log(GPR_INFO, "[xds_client %p] start building load report", this);
2124
+ }
2245
2125
  XdsApi::ClusterLoadReportMap snapshot_map;
2246
2126
  for (auto load_report_it = load_report_map_.begin();
2247
2127
  load_report_it != load_report_map_.end();) {
@@ -2260,9 +2140,14 @@ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshot(
2260
2140
  XdsApi::ClusterLoadReport snapshot;
2261
2141
  // Aggregate drop stats.
2262
2142
  snapshot.dropped_requests = std::move(load_report.deleted_drop_stats);
2263
- for (auto& drop_stats : load_report.drop_stats) {
2264
- for (const auto& p : drop_stats->GetSnapshotAndReset()) {
2265
- snapshot.dropped_requests[p.first] += p.second;
2143
+ if (load_report.drop_stats != nullptr) {
2144
+ snapshot.dropped_requests +=
2145
+ load_report.drop_stats->GetSnapshotAndReset();
2146
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
2147
+ gpr_log(GPR_INFO,
2148
+ "[xds_client %p] cluster=%s eds_service_name=%s drop_stats=%p",
2149
+ this, cluster_key.first.c_str(), cluster_key.second.c_str(),
2150
+ load_report.drop_stats);
2266
2151
  }
2267
2152
  }
2268
2153
  // Aggregate locality stats.
@@ -2272,34 +2157,39 @@ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshot(
2272
2157
  auto& locality_state = it->second;
2273
2158
  XdsClusterLocalityStats::Snapshot& locality_snapshot =
2274
2159
  snapshot.locality_stats[locality_name];
2275
- for (auto& locality_stats : locality_state.locality_stats) {
2276
- locality_snapshot += locality_stats->GetSnapshotAndReset();
2277
- }
2278
- // Add final snapshots from recently deleted locality stats objects.
2279
- for (auto& deleted_locality_stats :
2280
- locality_state.deleted_locality_stats) {
2281
- locality_snapshot += deleted_locality_stats;
2160
+ locality_snapshot = std::move(locality_state.deleted_locality_stats);
2161
+ if (locality_state.locality_stats != nullptr) {
2162
+ locality_snapshot +=
2163
+ locality_state.locality_stats->GetSnapshotAndReset();
2164
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
2165
+ gpr_log(GPR_INFO,
2166
+ "[xds_client %p] cluster=%s eds_service_name=%s "
2167
+ "locality=%s locality_stats=%p",
2168
+ this, cluster_key.first.c_str(), cluster_key.second.c_str(),
2169
+ locality_name->AsHumanReadableString().c_str(),
2170
+ locality_state.locality_stats);
2171
+ }
2282
2172
  }
2283
- locality_state.deleted_locality_stats.clear();
2284
2173
  // If the only thing left in this entry was final snapshots from
2285
2174
  // deleted locality stats objects, remove the entry.
2286
- if (locality_state.locality_stats.empty()) {
2175
+ if (locality_state.locality_stats == nullptr) {
2287
2176
  it = load_report.locality_stats.erase(it);
2288
2177
  } else {
2289
2178
  ++it;
2290
2179
  }
2291
2180
  }
2181
+ // Compute load report interval.
2182
+ const grpc_millis now = ExecCtx::Get()->Now();
2183
+ snapshot.load_report_interval = now - load_report.last_report_time;
2184
+ load_report.last_report_time = now;
2185
+ // Record snapshot.
2292
2186
  if (record_stats) {
2293
- // Compute load report interval.
2294
- const grpc_millis now = ExecCtx::Get()->Now();
2295
- snapshot.load_report_interval = now - load_report.last_report_time;
2296
- load_report.last_report_time = now;
2297
- // Record snapshot.
2298
2187
  snapshot_map[cluster_key] = std::move(snapshot);
2299
2188
  }
2300
2189
  // If the only thing left in this entry was final snapshots from
2301
2190
  // deleted stats objects, remove the entry.
2302
- if (load_report.locality_stats.empty() && load_report.drop_stats.empty()) {
2191
+ if (load_report.locality_stats.empty() &&
2192
+ load_report.drop_stats == nullptr) {
2303
2193
  load_report_it = load_report_map_.erase(load_report_it);
2304
2194
  } else {
2305
2195
  ++load_report_it;
@@ -2308,60 +2198,40 @@ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshot(
2308
2198
  return snapshot_map;
2309
2199
  }
2310
2200
 
2311
- void XdsClient::NotifyOnError(grpc_error* error) {
2312
- if (service_config_watcher_ != nullptr) {
2313
- service_config_watcher_->OnError(GRPC_ERROR_REF(error));
2314
- }
2315
- for (const auto& p : cluster_map_) {
2316
- const ClusterState& cluster_state = p.second;
2317
- for (const auto& p : cluster_state.watchers) {
2318
- p.first->OnError(GRPC_ERROR_REF(error));
2319
- }
2320
- }
2321
- for (const auto& p : endpoint_map_) {
2322
- const EndpointState& endpoint_state = p.second;
2323
- for (const auto& p : endpoint_state.watchers) {
2324
- p.first->OnError(GRPC_ERROR_REF(error));
2325
- }
2326
- }
2327
- GRPC_ERROR_UNREF(error);
2328
- }
2201
+ //
2202
+ // accessors for global state
2203
+ //
2329
2204
 
2330
- void* XdsClient::ChannelArgCopy(void* p) {
2331
- XdsClient* xds_client = static_cast<XdsClient*>(p);
2332
- xds_client->Ref(DEBUG_LOCATION, "channel arg").release();
2333
- return p;
2334
- }
2205
+ void XdsClientGlobalInit() { g_mu = new Mutex; }
2335
2206
 
2336
- void XdsClient::ChannelArgDestroy(void* p) {
2337
- XdsClient* xds_client = static_cast<XdsClient*>(p);
2338
- xds_client->Unref(DEBUG_LOCATION, "channel arg");
2207
+ void XdsClientGlobalShutdown() {
2208
+ delete g_mu;
2209
+ g_mu = nullptr;
2339
2210
  }
2340
2211
 
2341
- int XdsClient::ChannelArgCmp(void* p, void* q) { return GPR_ICMP(p, q); }
2212
+ RefCountedPtr<XdsClient> XdsClient::GetOrCreate(grpc_error** error) {
2213
+ MutexLock lock(g_mu);
2214
+ if (g_xds_client != nullptr) {
2215
+ auto xds_client = g_xds_client->RefIfNonZero();
2216
+ if (xds_client != nullptr) return xds_client;
2217
+ }
2218
+ auto xds_client = MakeRefCounted<XdsClient>(error);
2219
+ g_xds_client = xds_client.get();
2220
+ return xds_client;
2221
+ }
2342
2222
 
2343
- const grpc_arg_pointer_vtable XdsClient::kXdsClientVtable = {
2344
- XdsClient::ChannelArgCopy, XdsClient::ChannelArgDestroy,
2345
- XdsClient::ChannelArgCmp};
2223
+ namespace internal {
2346
2224
 
2347
- grpc_arg XdsClient::MakeChannelArg() const {
2348
- return grpc_channel_arg_pointer_create(const_cast<char*>(GRPC_ARG_XDS_CLIENT),
2349
- const_cast<XdsClient*>(this),
2350
- &XdsClient::kXdsClientVtable);
2225
+ void SetXdsChannelArgsForTest(grpc_channel_args* args) {
2226
+ MutexLock lock(g_mu);
2227
+ g_channel_args = args;
2351
2228
  }
2352
2229
 
2353
- RefCountedPtr<XdsClient> XdsClient::GetFromChannelArgs(
2354
- const grpc_channel_args& args) {
2355
- XdsClient* xds_client =
2356
- grpc_channel_args_find_pointer<XdsClient>(&args, GRPC_ARG_XDS_CLIENT);
2357
- if (xds_client != nullptr) return xds_client->Ref();
2358
- return nullptr;
2230
+ void UnsetGlobalXdsClientForTest() {
2231
+ MutexLock lock(g_mu);
2232
+ g_xds_client = nullptr;
2359
2233
  }
2360
2234
 
2361
- grpc_channel_args* XdsClient::RemoveFromChannelArgs(
2362
- const grpc_channel_args& args) {
2363
- const char* arg_name = GRPC_ARG_XDS_CLIENT;
2364
- return grpc_channel_args_copy_and_remove(&args, &arg_name, 1);
2365
- }
2235
+ } // namespace internal
2366
2236
 
2367
2237
  } // namespace grpc_core