grpc 1.30.2

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 (1758) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -0
  3. data/Makefile +20074 -0
  4. data/etc/roots.pem +4644 -0
  5. data/include/grpc/byte_buffer.h +27 -0
  6. data/include/grpc/byte_buffer_reader.h +26 -0
  7. data/include/grpc/census.h +40 -0
  8. data/include/grpc/compression.h +75 -0
  9. data/include/grpc/fork.h +26 -0
  10. data/include/grpc/grpc.h +540 -0
  11. data/include/grpc/grpc_cronet.h +38 -0
  12. data/include/grpc/grpc_posix.h +59 -0
  13. data/include/grpc/grpc_security.h +1019 -0
  14. data/include/grpc/grpc_security_constants.h +146 -0
  15. data/include/grpc/impl/codegen/atm.h +95 -0
  16. data/include/grpc/impl/codegen/atm_gcc_atomic.h +91 -0
  17. data/include/grpc/impl/codegen/atm_gcc_sync.h +85 -0
  18. data/include/grpc/impl/codegen/atm_windows.h +128 -0
  19. data/include/grpc/impl/codegen/byte_buffer.h +101 -0
  20. data/include/grpc/impl/codegen/byte_buffer_reader.h +42 -0
  21. data/include/grpc/impl/codegen/compression_types.h +108 -0
  22. data/include/grpc/impl/codegen/connectivity_state.h +44 -0
  23. data/include/grpc/impl/codegen/fork.h +48 -0
  24. data/include/grpc/impl/codegen/gpr_slice.h +69 -0
  25. data/include/grpc/impl/codegen/gpr_types.h +59 -0
  26. data/include/grpc/impl/codegen/grpc_types.h +785 -0
  27. data/include/grpc/impl/codegen/log.h +112 -0
  28. data/include/grpc/impl/codegen/port_platform.h +720 -0
  29. data/include/grpc/impl/codegen/propagation_bits.h +52 -0
  30. data/include/grpc/impl/codegen/slice.h +127 -0
  31. data/include/grpc/impl/codegen/status.h +154 -0
  32. data/include/grpc/impl/codegen/sync.h +65 -0
  33. data/include/grpc/impl/codegen/sync_abseil.h +36 -0
  34. data/include/grpc/impl/codegen/sync_custom.h +38 -0
  35. data/include/grpc/impl/codegen/sync_generic.h +48 -0
  36. data/include/grpc/impl/codegen/sync_posix.h +52 -0
  37. data/include/grpc/impl/codegen/sync_windows.h +36 -0
  38. data/include/grpc/load_reporting.h +48 -0
  39. data/include/grpc/module.modulemap +64 -0
  40. data/include/grpc/slice.h +172 -0
  41. data/include/grpc/slice_buffer.h +84 -0
  42. data/include/grpc/status.h +26 -0
  43. data/include/grpc/support/alloc.h +52 -0
  44. data/include/grpc/support/atm.h +26 -0
  45. data/include/grpc/support/atm_gcc_atomic.h +26 -0
  46. data/include/grpc/support/atm_gcc_sync.h +26 -0
  47. data/include/grpc/support/atm_windows.h +26 -0
  48. data/include/grpc/support/cpu.h +44 -0
  49. data/include/grpc/support/log.h +26 -0
  50. data/include/grpc/support/log_windows.h +38 -0
  51. data/include/grpc/support/port_platform.h +24 -0
  52. data/include/grpc/support/string_util.h +51 -0
  53. data/include/grpc/support/sync.h +282 -0
  54. data/include/grpc/support/sync_abseil.h +26 -0
  55. data/include/grpc/support/sync_custom.h +26 -0
  56. data/include/grpc/support/sync_generic.h +26 -0
  57. data/include/grpc/support/sync_posix.h +26 -0
  58. data/include/grpc/support/sync_windows.h +26 -0
  59. data/include/grpc/support/thd_id.h +44 -0
  60. data/include/grpc/support/time.h +92 -0
  61. data/include/grpc/support/workaround_list.h +31 -0
  62. data/src/core/ext/filters/census/grpc_context.cc +38 -0
  63. data/src/core/ext/filters/client_channel/backend_metric.cc +81 -0
  64. data/src/core/ext/filters/client_channel/backend_metric.h +36 -0
  65. data/src/core/ext/filters/client_channel/backup_poller.cc +181 -0
  66. data/src/core/ext/filters/client_channel/backup_poller.h +41 -0
  67. data/src/core/ext/filters/client_channel/channel_connectivity.cc +264 -0
  68. data/src/core/ext/filters/client_channel/client_channel.cc +4059 -0
  69. data/src/core/ext/filters/client_channel/client_channel.h +82 -0
  70. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +95 -0
  71. data/src/core/ext/filters/client_channel/client_channel_channelz.h +78 -0
  72. data/src/core/ext/filters/client_channel/client_channel_factory.cc +55 -0
  73. data/src/core/ext/filters/client_channel/client_channel_factory.h +47 -0
  74. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +70 -0
  75. data/src/core/ext/filters/client_channel/connector.h +79 -0
  76. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +179 -0
  77. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
  78. data/src/core/ext/filters/client_channel/health/health_check_client.cc +606 -0
  79. data/src/core/ext/filters/client_channel/health/health_check_client.h +175 -0
  80. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +389 -0
  81. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +34 -0
  82. data/src/core/ext/filters/client_channel/http_proxy.cc +216 -0
  83. data/src/core/ext/filters/client_channel/http_proxy.h +28 -0
  84. data/src/core/ext/filters/client_channel/lb_policy.cc +138 -0
  85. data/src/core/ext/filters/client_channel/lb_policy.h +421 -0
  86. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +83 -0
  87. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +99 -0
  88. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +297 -0
  89. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +83 -0
  90. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +157 -0
  91. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +29 -0
  92. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +1754 -0
  93. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +43 -0
  94. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
  95. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
  96. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +45 -0
  97. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +121 -0
  98. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +91 -0
  99. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +75 -0
  100. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +193 -0
  101. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +74 -0
  102. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +509 -0
  103. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +871 -0
  104. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +504 -0
  105. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +448 -0
  106. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +734 -0
  107. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +417 -0
  108. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +938 -0
  109. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +528 -0
  110. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +32 -0
  111. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +834 -0
  112. data/src/core/ext/filters/client_channel/lb_policy_factory.h +47 -0
  113. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +182 -0
  114. data/src/core/ext/filters/client_channel/lb_policy_registry.h +65 -0
  115. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
  116. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +57 -0
  117. data/src/core/ext/filters/client_channel/parse_address.cc +238 -0
  118. data/src/core/ext/filters/client_channel/parse_address.h +53 -0
  119. data/src/core/ext/filters/client_channel/proxy_mapper.h +54 -0
  120. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +89 -0
  121. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +50 -0
  122. data/src/core/ext/filters/client_channel/resolver.cc +85 -0
  123. data/src/core/ext/filters/client_channel/resolver.h +144 -0
  124. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +535 -0
  125. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +484 -0
  126. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +104 -0
  127. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +177 -0
  128. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +107 -0
  129. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +897 -0
  130. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +819 -0
  131. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +97 -0
  132. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +68 -0
  133. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +38 -0
  134. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +29 -0
  135. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +34 -0
  136. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
  137. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +29 -0
  138. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +318 -0
  139. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +383 -0
  140. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +93 -0
  141. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +188 -0
  142. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +184 -0
  143. data/src/core/ext/filters/client_channel/resolver_factory.h +73 -0
  144. data/src/core/ext/filters/client_channel/resolver_registry.cc +197 -0
  145. data/src/core/ext/filters/client_channel/resolver_registry.h +89 -0
  146. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +443 -0
  147. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +127 -0
  148. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +348 -0
  149. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +123 -0
  150. data/src/core/ext/filters/client_channel/retry_throttle.cc +191 -0
  151. data/src/core/ext/filters/client_channel/retry_throttle.h +77 -0
  152. data/src/core/ext/filters/client_channel/server_address.cc +48 -0
  153. data/src/core/ext/filters/client_channel/server_address.h +90 -0
  154. data/src/core/ext/filters/client_channel/service_config.cc +221 -0
  155. data/src/core/ext/filters/client_channel/service_config.h +123 -0
  156. data/src/core/ext/filters/client_channel/service_config_call_data.h +68 -0
  157. data/src/core/ext/filters/client_channel/service_config_parser.cc +87 -0
  158. data/src/core/ext/filters/client_channel/service_config_parser.h +89 -0
  159. data/src/core/ext/filters/client_channel/subchannel.cc +1127 -0
  160. data/src/core/ext/filters/client_channel/subchannel.h +427 -0
  161. data/src/core/ext/filters/client_channel/subchannel_interface.h +94 -0
  162. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
  163. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +91 -0
  164. data/src/core/ext/filters/client_channel/xds/xds_api.cc +1906 -0
  165. data/src/core/ext/filters/client_channel/xds/xds_api.h +280 -0
  166. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +342 -0
  167. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +88 -0
  168. data/src/core/ext/filters/client_channel/xds/xds_channel.h +46 -0
  169. data/src/core/ext/filters/client_channel/xds/xds_channel_args.h +26 -0
  170. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +106 -0
  171. data/src/core/ext/filters/client_channel/xds/xds_client.cc +2367 -0
  172. data/src/core/ext/filters/client_channel/xds/xds_client.h +309 -0
  173. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +115 -0
  174. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +211 -0
  175. data/src/core/ext/filters/client_idle/client_idle_filter.cc +440 -0
  176. data/src/core/ext/filters/deadline/deadline_filter.cc +386 -0
  177. data/src/core/ext/filters/deadline/deadline_filter.h +90 -0
  178. data/src/core/ext/filters/http/client/http_client_filter.cc +596 -0
  179. data/src/core/ext/filters/http/client/http_client_filter.h +31 -0
  180. data/src/core/ext/filters/http/client_authority_filter.cc +159 -0
  181. data/src/core/ext/filters/http/client_authority_filter.h +34 -0
  182. data/src/core/ext/filters/http/http_filters_plugin.cc +104 -0
  183. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +546 -0
  184. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +53 -0
  185. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +358 -0
  186. data/src/core/ext/filters/http/message_compress/message_decompress_filter.h +29 -0
  187. data/src/core/ext/filters/http/server/http_server_filter.cc +528 -0
  188. data/src/core/ext/filters/http/server/http_server_filter.h +29 -0
  189. data/src/core/ext/filters/max_age/max_age_filter.cc +556 -0
  190. data/src/core/ext/filters/max_age/max_age_filter.h +26 -0
  191. data/src/core/ext/filters/message_size/message_size_filter.cc +423 -0
  192. data/src/core/ext/filters/message_size/message_size_filter.h +59 -0
  193. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +210 -0
  194. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +27 -0
  195. data/src/core/ext/filters/workarounds/workaround_utils.cc +53 -0
  196. data/src/core/ext/filters/workarounds/workaround_utils.h +39 -0
  197. data/src/core/ext/transport/chttp2/alpn/alpn.cc +44 -0
  198. data/src/core/ext/transport/chttp2/alpn/alpn.h +36 -0
  199. data/src/core/ext/transport/chttp2/client/authority.cc +42 -0
  200. data/src/core/ext/transport/chttp2/client/authority.h +36 -0
  201. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +206 -0
  202. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +58 -0
  203. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +112 -0
  204. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +79 -0
  205. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +225 -0
  206. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +451 -0
  207. data/src/core/ext/transport/chttp2/server/chttp2_server.h +33 -0
  208. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +45 -0
  209. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +75 -0
  210. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +86 -0
  211. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +250 -0
  212. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +56 -0
  213. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +230 -0
  214. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +42 -0
  215. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +37 -0
  216. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +3346 -0
  217. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +52 -0
  218. data/src/core/ext/transport/chttp2/transport/context_list.cc +69 -0
  219. data/src/core/ext/transport/chttp2/transport/context_list.h +53 -0
  220. data/src/core/ext/transport/chttp2/transport/flow_control.cc +408 -0
  221. data/src/core/ext/transport/chttp2/transport/flow_control.h +474 -0
  222. data/src/core/ext/transport/chttp2/transport/frame.h +47 -0
  223. data/src/core/ext/transport/chttp2/transport/frame_data.cc +307 -0
  224. data/src/core/ext/transport/chttp2/transport/frame_data.h +82 -0
  225. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +187 -0
  226. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +62 -0
  227. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +133 -0
  228. data/src/core/ext/transport/chttp2/transport/frame_ping.h +44 -0
  229. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +122 -0
  230. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +50 -0
  231. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +242 -0
  232. data/src/core/ext/transport/chttp2/transport/frame_settings.h +60 -0
  233. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +123 -0
  234. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +44 -0
  235. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +900 -0
  236. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +107 -0
  237. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1761 -0
  238. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +117 -0
  239. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +246 -0
  240. data/src/core/ext/transport/chttp2/transport/hpack_table.h +148 -0
  241. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +62 -0
  242. data/src/core/ext/transport/chttp2/transport/http2_settings.h +61 -0
  243. data/src/core/ext/transport/chttp2/transport/huffsyms.cc +92 -0
  244. data/src/core/ext/transport/chttp2/transport/huffsyms.h +32 -0
  245. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +66 -0
  246. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +58 -0
  247. data/src/core/ext/transport/chttp2/transport/internal.h +864 -0
  248. data/src/core/ext/transport/chttp2/transport/parsing.cc +803 -0
  249. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +216 -0
  250. data/src/core/ext/transport/chttp2/transport/stream_map.cc +177 -0
  251. data/src/core/ext/transport/chttp2/transport/stream_map.h +67 -0
  252. data/src/core/ext/transport/chttp2/transport/varint.cc +56 -0
  253. data/src/core/ext/transport/chttp2/transport/varint.h +60 -0
  254. data/src/core/ext/transport/chttp2/transport/writing.cc +706 -0
  255. data/src/core/ext/transport/inproc/inproc_plugin.cc +28 -0
  256. data/src/core/ext/transport/inproc/inproc_transport.cc +1296 -0
  257. data/src/core/ext/transport/inproc/inproc_transport.h +35 -0
  258. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +17 -0
  259. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +30 -0
  260. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +27 -0
  261. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +54 -0
  262. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +21 -0
  263. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +35 -0
  264. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +114 -0
  265. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +418 -0
  266. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +72 -0
  267. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +197 -0
  268. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +105 -0
  269. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +378 -0
  270. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +28 -0
  271. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +53 -0
  272. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +403 -0
  273. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +1447 -0
  274. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +74 -0
  275. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +218 -0
  276. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +35 -0
  277. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +69 -0
  278. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +55 -0
  279. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +305 -0
  280. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +112 -0
  281. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +328 -0
  282. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.c +35 -0
  283. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +78 -0
  284. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +313 -0
  285. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +897 -0
  286. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +96 -0
  287. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +322 -0
  288. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +34 -0
  289. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +72 -0
  290. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +197 -0
  291. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +642 -0
  292. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +172 -0
  293. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +673 -0
  294. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +36 -0
  295. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +80 -0
  296. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +152 -0
  297. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +518 -0
  298. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.c +34 -0
  299. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +89 -0
  300. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +129 -0
  301. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +392 -0
  302. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +31 -0
  303. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +53 -0
  304. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +92 -0
  305. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +240 -0
  306. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +18 -0
  307. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +33 -0
  308. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +91 -0
  309. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +266 -0
  310. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +112 -0
  311. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +324 -0
  312. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.c +31 -0
  313. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +53 -0
  314. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +109 -0
  315. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +399 -0
  316. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +18 -0
  317. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +33 -0
  318. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +145 -0
  319. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +527 -0
  320. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +43 -0
  321. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +112 -0
  322. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.c +30 -0
  323. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +53 -0
  324. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +63 -0
  325. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +199 -0
  326. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +18 -0
  327. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +33 -0
  328. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +815 -0
  329. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +3032 -0
  330. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +59 -0
  331. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +134 -0
  332. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.c +28 -0
  333. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +53 -0
  334. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +228 -0
  335. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +725 -0
  336. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +316 -0
  337. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +1132 -0
  338. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.c +33 -0
  339. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +65 -0
  340. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +51 -0
  341. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +125 -0
  342. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c +24 -0
  343. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +50 -0
  344. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +54 -0
  345. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +134 -0
  346. data/src/core/ext/upb-generated/envoy/type/http.upb.c +17 -0
  347. data/src/core/ext/upb-generated/envoy/type/http.upb.h +36 -0
  348. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +63 -0
  349. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +144 -0
  350. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +53 -0
  351. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +133 -0
  352. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +88 -0
  353. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +258 -0
  354. data/src/core/ext/upb-generated/envoy/type/percent.upb.c +39 -0
  355. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +87 -0
  356. data/src/core/ext/upb-generated/envoy/type/range.upb.c +50 -0
  357. data/src/core/ext/upb-generated/envoy/type/range.upb.h +112 -0
  358. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.c +29 -0
  359. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +62 -0
  360. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +89 -0
  361. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +249 -0
  362. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +17 -0
  363. data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +30 -0
  364. data/src/core/ext/upb-generated/google/api/annotations.upb.c +18 -0
  365. data/src/core/ext/upb-generated/google/api/annotations.upb.h +30 -0
  366. data/src/core/ext/upb-generated/google/api/http.upb.c +66 -0
  367. data/src/core/ext/upb-generated/google/api/http.upb.h +190 -0
  368. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +27 -0
  369. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +58 -0
  370. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +486 -0
  371. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +1696 -0
  372. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +27 -0
  373. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +58 -0
  374. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +22 -0
  375. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +50 -0
  376. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +79 -0
  377. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +215 -0
  378. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +27 -0
  379. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +58 -0
  380. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +106 -0
  381. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +238 -0
  382. data/src/core/ext/upb-generated/google/rpc/status.upb.c +33 -0
  383. data/src/core/ext/upb-generated/google/rpc/status.upb.h +74 -0
  384. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +49 -0
  385. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +126 -0
  386. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +212 -0
  387. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +693 -0
  388. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +42 -0
  389. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +109 -0
  390. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +36 -0
  391. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +84 -0
  392. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +141 -0
  393. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +393 -0
  394. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +48 -0
  395. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +104 -0
  396. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +17 -0
  397. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +30 -0
  398. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +28 -0
  399. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +65 -0
  400. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +58 -0
  401. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +144 -0
  402. data/src/core/ext/upb-generated/validate/validate.upb.c +448 -0
  403. data/src/core/ext/upb-generated/validate/validate.upb.h +2073 -0
  404. data/src/core/lib/avl/avl.cc +306 -0
  405. data/src/core/lib/avl/avl.h +94 -0
  406. data/src/core/lib/backoff/backoff.cc +78 -0
  407. data/src/core/lib/backoff/backoff.h +89 -0
  408. data/src/core/lib/channel/channel_args.cc +380 -0
  409. data/src/core/lib/channel/channel_args.h +135 -0
  410. data/src/core/lib/channel/channel_stack.cc +252 -0
  411. data/src/core/lib/channel/channel_stack.h +304 -0
  412. data/src/core/lib/channel/channel_stack_builder.cc +323 -0
  413. data/src/core/lib/channel/channel_stack_builder.h +166 -0
  414. data/src/core/lib/channel/channel_trace.cc +194 -0
  415. data/src/core/lib/channel/channel_trace.h +134 -0
  416. data/src/core/lib/channel/channelz.cc +543 -0
  417. data/src/core/lib/channel/channelz.h +334 -0
  418. data/src/core/lib/channel/channelz_registry.cc +267 -0
  419. data/src/core/lib/channel/channelz_registry.h +97 -0
  420. data/src/core/lib/channel/connected_channel.cc +246 -0
  421. data/src/core/lib/channel/connected_channel.h +34 -0
  422. data/src/core/lib/channel/context.h +49 -0
  423. data/src/core/lib/channel/handshaker.cc +262 -0
  424. data/src/core/lib/channel/handshaker.h +179 -0
  425. data/src/core/lib/channel/handshaker_factory.h +42 -0
  426. data/src/core/lib/channel/handshaker_registry.cc +105 -0
  427. data/src/core/lib/channel/handshaker_registry.h +54 -0
  428. data/src/core/lib/channel/status_util.cc +99 -0
  429. data/src/core/lib/channel/status_util.h +58 -0
  430. data/src/core/lib/compression/algorithm_metadata.h +61 -0
  431. data/src/core/lib/compression/compression.cc +179 -0
  432. data/src/core/lib/compression/compression_args.cc +134 -0
  433. data/src/core/lib/compression/compression_args.h +56 -0
  434. data/src/core/lib/compression/compression_internal.cc +280 -0
  435. data/src/core/lib/compression/compression_internal.h +96 -0
  436. data/src/core/lib/compression/message_compress.cc +192 -0
  437. data/src/core/lib/compression/message_compress.h +40 -0
  438. data/src/core/lib/compression/stream_compression.cc +80 -0
  439. data/src/core/lib/compression/stream_compression.h +116 -0
  440. data/src/core/lib/compression/stream_compression_gzip.cc +230 -0
  441. data/src/core/lib/compression/stream_compression_gzip.h +28 -0
  442. data/src/core/lib/compression/stream_compression_identity.cc +92 -0
  443. data/src/core/lib/compression/stream_compression_identity.h +29 -0
  444. data/src/core/lib/debug/stats.cc +172 -0
  445. data/src/core/lib/debug/stats.h +70 -0
  446. data/src/core/lib/debug/stats_data.cc +687 -0
  447. data/src/core/lib/debug/stats_data.h +555 -0
  448. data/src/core/lib/debug/trace.cc +154 -0
  449. data/src/core/lib/debug/trace.h +131 -0
  450. data/src/core/lib/gpr/alloc.cc +74 -0
  451. data/src/core/lib/gpr/alloc.h +28 -0
  452. data/src/core/lib/gpr/arena.h +47 -0
  453. data/src/core/lib/gpr/atm.cc +35 -0
  454. data/src/core/lib/gpr/cpu_iphone.cc +36 -0
  455. data/src/core/lib/gpr/cpu_linux.cc +82 -0
  456. data/src/core/lib/gpr/cpu_posix.cc +83 -0
  457. data/src/core/lib/gpr/cpu_windows.cc +33 -0
  458. data/src/core/lib/gpr/env.h +40 -0
  459. data/src/core/lib/gpr/env_linux.cc +76 -0
  460. data/src/core/lib/gpr/env_posix.cc +47 -0
  461. data/src/core/lib/gpr/env_windows.cc +74 -0
  462. data/src/core/lib/gpr/log.cc +98 -0
  463. data/src/core/lib/gpr/log_android.cc +76 -0
  464. data/src/core/lib/gpr/log_linux.cc +97 -0
  465. data/src/core/lib/gpr/log_posix.cc +95 -0
  466. data/src/core/lib/gpr/log_windows.cc +102 -0
  467. data/src/core/lib/gpr/murmur_hash.cc +80 -0
  468. data/src/core/lib/gpr/murmur_hash.h +29 -0
  469. data/src/core/lib/gpr/spinlock.h +45 -0
  470. data/src/core/lib/gpr/string.cc +341 -0
  471. data/src/core/lib/gpr/string.h +111 -0
  472. data/src/core/lib/gpr/string_posix.cc +72 -0
  473. data/src/core/lib/gpr/string_util_windows.cc +82 -0
  474. data/src/core/lib/gpr/string_windows.cc +69 -0
  475. data/src/core/lib/gpr/string_windows.h +32 -0
  476. data/src/core/lib/gpr/sync.cc +124 -0
  477. data/src/core/lib/gpr/sync_abseil.cc +116 -0
  478. data/src/core/lib/gpr/sync_posix.cc +176 -0
  479. data/src/core/lib/gpr/sync_windows.cc +120 -0
  480. data/src/core/lib/gpr/time.cc +263 -0
  481. data/src/core/lib/gpr/time_posix.cc +186 -0
  482. data/src/core/lib/gpr/time_precise.cc +165 -0
  483. data/src/core/lib/gpr/time_precise.h +66 -0
  484. data/src/core/lib/gpr/time_windows.cc +98 -0
  485. data/src/core/lib/gpr/tls.h +68 -0
  486. data/src/core/lib/gpr/tls_gcc.h +52 -0
  487. data/src/core/lib/gpr/tls_msvc.h +52 -0
  488. data/src/core/lib/gpr/tls_pthread.cc +30 -0
  489. data/src/core/lib/gpr/tls_pthread.h +56 -0
  490. data/src/core/lib/gpr/tmpfile.h +32 -0
  491. data/src/core/lib/gpr/tmpfile_msys.cc +58 -0
  492. data/src/core/lib/gpr/tmpfile_posix.cc +70 -0
  493. data/src/core/lib/gpr/tmpfile_windows.cc +69 -0
  494. data/src/core/lib/gpr/useful.h +65 -0
  495. data/src/core/lib/gpr/wrap_memcpy.cc +42 -0
  496. data/src/core/lib/gprpp/arena.cc +103 -0
  497. data/src/core/lib/gprpp/arena.h +120 -0
  498. data/src/core/lib/gprpp/atomic.h +104 -0
  499. data/src/core/lib/gprpp/debug_location.h +53 -0
  500. data/src/core/lib/gprpp/fork.cc +242 -0
  501. data/src/core/lib/gprpp/fork.h +103 -0
  502. data/src/core/lib/gprpp/global_config.h +96 -0
  503. data/src/core/lib/gprpp/global_config_custom.h +29 -0
  504. data/src/core/lib/gprpp/global_config_env.cc +135 -0
  505. data/src/core/lib/gprpp/global_config_env.h +131 -0
  506. data/src/core/lib/gprpp/global_config_generic.h +44 -0
  507. data/src/core/lib/gprpp/host_port.cc +112 -0
  508. data/src/core/lib/gprpp/host_port.h +56 -0
  509. data/src/core/lib/gprpp/manual_constructor.h +213 -0
  510. data/src/core/lib/gprpp/map.h +53 -0
  511. data/src/core/lib/gprpp/memory.h +51 -0
  512. data/src/core/lib/gprpp/mpscq.cc +108 -0
  513. data/src/core/lib/gprpp/mpscq.h +98 -0
  514. data/src/core/lib/gprpp/orphanable.h +129 -0
  515. data/src/core/lib/gprpp/ref_counted.h +312 -0
  516. data/src/core/lib/gprpp/ref_counted_ptr.h +192 -0
  517. data/src/core/lib/gprpp/sync.h +135 -0
  518. data/src/core/lib/gprpp/thd.h +174 -0
  519. data/src/core/lib/gprpp/thd_posix.cc +204 -0
  520. data/src/core/lib/gprpp/thd_windows.cc +176 -0
  521. data/src/core/lib/http/format_request.cc +103 -0
  522. data/src/core/lib/http/format_request.h +34 -0
  523. data/src/core/lib/http/httpcli.cc +303 -0
  524. data/src/core/lib/http/httpcli.h +126 -0
  525. data/src/core/lib/http/httpcli_security_connector.cc +214 -0
  526. data/src/core/lib/http/parser.cc +372 -0
  527. data/src/core/lib/http/parser.h +113 -0
  528. data/src/core/lib/iomgr/block_annotate.h +57 -0
  529. data/src/core/lib/iomgr/buffer_list.cc +308 -0
  530. data/src/core/lib/iomgr/buffer_list.h +165 -0
  531. data/src/core/lib/iomgr/call_combiner.cc +256 -0
  532. data/src/core/lib/iomgr/call_combiner.h +217 -0
  533. data/src/core/lib/iomgr/cfstream_handle.cc +209 -0
  534. data/src/core/lib/iomgr/cfstream_handle.h +90 -0
  535. data/src/core/lib/iomgr/closure.h +255 -0
  536. data/src/core/lib/iomgr/combiner.cc +339 -0
  537. data/src/core/lib/iomgr/combiner.h +88 -0
  538. data/src/core/lib/iomgr/dualstack_socket_posix.cc +47 -0
  539. data/src/core/lib/iomgr/dynamic_annotations.h +67 -0
  540. data/src/core/lib/iomgr/endpoint.cc +67 -0
  541. data/src/core/lib/iomgr/endpoint.h +106 -0
  542. data/src/core/lib/iomgr/endpoint_cfstream.cc +376 -0
  543. data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
  544. data/src/core/lib/iomgr/endpoint_pair.h +33 -0
  545. data/src/core/lib/iomgr/endpoint_pair_posix.cc +73 -0
  546. data/src/core/lib/iomgr/endpoint_pair_uv.cc +40 -0
  547. data/src/core/lib/iomgr/endpoint_pair_windows.cc +87 -0
  548. data/src/core/lib/iomgr/error.cc +812 -0
  549. data/src/core/lib/iomgr/error.h +276 -0
  550. data/src/core/lib/iomgr/error_cfstream.cc +52 -0
  551. data/src/core/lib/iomgr/error_cfstream.h +31 -0
  552. data/src/core/lib/iomgr/error_internal.h +61 -0
  553. data/src/core/lib/iomgr/ev_apple.cc +356 -0
  554. data/src/core/lib/iomgr/ev_apple.h +43 -0
  555. data/src/core/lib/iomgr/ev_epoll1_linux.cc +1365 -0
  556. data/src/core/lib/iomgr/ev_epoll1_linux.h +31 -0
  557. data/src/core/lib/iomgr/ev_epollex_linux.cc +1656 -0
  558. data/src/core/lib/iomgr/ev_epollex_linux.h +30 -0
  559. data/src/core/lib/iomgr/ev_poll_posix.cc +1427 -0
  560. data/src/core/lib/iomgr/ev_poll_posix.h +29 -0
  561. data/src/core/lib/iomgr/ev_posix.cc +417 -0
  562. data/src/core/lib/iomgr/ev_posix.h +207 -0
  563. data/src/core/lib/iomgr/ev_windows.cc +30 -0
  564. data/src/core/lib/iomgr/exec_ctx.cc +224 -0
  565. data/src/core/lib/iomgr/exec_ctx.h +380 -0
  566. data/src/core/lib/iomgr/executor.cc +469 -0
  567. data/src/core/lib/iomgr/executor.h +122 -0
  568. data/src/core/lib/iomgr/executor/mpmcqueue.cc +183 -0
  569. data/src/core/lib/iomgr/executor/mpmcqueue.h +175 -0
  570. data/src/core/lib/iomgr/executor/threadpool.cc +137 -0
  571. data/src/core/lib/iomgr/executor/threadpool.h +149 -0
  572. data/src/core/lib/iomgr/fork_posix.cc +119 -0
  573. data/src/core/lib/iomgr/fork_windows.cc +41 -0
  574. data/src/core/lib/iomgr/gethostname.h +26 -0
  575. data/src/core/lib/iomgr/gethostname_fallback.cc +30 -0
  576. data/src/core/lib/iomgr/gethostname_host_name_max.cc +40 -0
  577. data/src/core/lib/iomgr/gethostname_sysconf.cc +40 -0
  578. data/src/core/lib/iomgr/grpc_if_nametoindex.h +30 -0
  579. data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
  580. data/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc +38 -0
  581. data/src/core/lib/iomgr/internal_errqueue.cc +67 -0
  582. data/src/core/lib/iomgr/internal_errqueue.h +191 -0
  583. data/src/core/lib/iomgr/iocp_windows.cc +157 -0
  584. data/src/core/lib/iomgr/iocp_windows.h +48 -0
  585. data/src/core/lib/iomgr/iomgr.cc +194 -0
  586. data/src/core/lib/iomgr/iomgr.h +60 -0
  587. data/src/core/lib/iomgr/iomgr_custom.cc +79 -0
  588. data/src/core/lib/iomgr/iomgr_custom.h +49 -0
  589. data/src/core/lib/iomgr/iomgr_internal.cc +57 -0
  590. data/src/core/lib/iomgr/iomgr_internal.h +73 -0
  591. data/src/core/lib/iomgr/iomgr_posix.cc +89 -0
  592. data/src/core/lib/iomgr/iomgr_posix.h +26 -0
  593. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +171 -0
  594. data/src/core/lib/iomgr/iomgr_uv.cc +43 -0
  595. data/src/core/lib/iomgr/iomgr_windows.cc +106 -0
  596. data/src/core/lib/iomgr/is_epollexclusive_available.cc +105 -0
  597. data/src/core/lib/iomgr/is_epollexclusive_available.h +36 -0
  598. data/src/core/lib/iomgr/load_file.cc +81 -0
  599. data/src/core/lib/iomgr/load_file.h +35 -0
  600. data/src/core/lib/iomgr/lockfree_event.cc +255 -0
  601. data/src/core/lib/iomgr/lockfree_event.h +72 -0
  602. data/src/core/lib/iomgr/nameser.h +106 -0
  603. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +87 -0
  604. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +88 -0
  605. data/src/core/lib/iomgr/polling_entity.cc +96 -0
  606. data/src/core/lib/iomgr/polling_entity.h +68 -0
  607. data/src/core/lib/iomgr/pollset.cc +56 -0
  608. data/src/core/lib/iomgr/pollset.h +99 -0
  609. data/src/core/lib/iomgr/pollset_custom.cc +106 -0
  610. data/src/core/lib/iomgr/pollset_custom.h +35 -0
  611. data/src/core/lib/iomgr/pollset_set.cc +55 -0
  612. data/src/core/lib/iomgr/pollset_set.h +55 -0
  613. data/src/core/lib/iomgr/pollset_set_custom.cc +48 -0
  614. data/src/core/lib/iomgr/pollset_set_custom.h +26 -0
  615. data/src/core/lib/iomgr/pollset_set_windows.cc +51 -0
  616. data/src/core/lib/iomgr/pollset_set_windows.h +26 -0
  617. data/src/core/lib/iomgr/pollset_uv.cc +93 -0
  618. data/src/core/lib/iomgr/pollset_uv.h +32 -0
  619. data/src/core/lib/iomgr/pollset_windows.cc +243 -0
  620. data/src/core/lib/iomgr/pollset_windows.h +70 -0
  621. data/src/core/lib/iomgr/port.h +244 -0
  622. data/src/core/lib/iomgr/python_util.h +46 -0
  623. data/src/core/lib/iomgr/resolve_address.cc +50 -0
  624. data/src/core/lib/iomgr/resolve_address.h +81 -0
  625. data/src/core/lib/iomgr/resolve_address_custom.cc +173 -0
  626. data/src/core/lib/iomgr/resolve_address_custom.h +45 -0
  627. data/src/core/lib/iomgr/resolve_address_posix.cc +178 -0
  628. data/src/core/lib/iomgr/resolve_address_windows.cc +154 -0
  629. data/src/core/lib/iomgr/resource_quota.cc +1013 -0
  630. data/src/core/lib/iomgr/resource_quota.h +177 -0
  631. data/src/core/lib/iomgr/sockaddr.h +32 -0
  632. data/src/core/lib/iomgr/sockaddr_custom.h +54 -0
  633. data/src/core/lib/iomgr/sockaddr_posix.h +55 -0
  634. data/src/core/lib/iomgr/sockaddr_utils.cc +293 -0
  635. data/src/core/lib/iomgr/sockaddr_utils.h +79 -0
  636. data/src/core/lib/iomgr/sockaddr_windows.h +55 -0
  637. data/src/core/lib/iomgr/socket_factory_posix.cc +94 -0
  638. data/src/core/lib/iomgr/socket_factory_posix.h +68 -0
  639. data/src/core/lib/iomgr/socket_mutator.cc +83 -0
  640. data/src/core/lib/iomgr/socket_mutator.h +60 -0
  641. data/src/core/lib/iomgr/socket_utils.h +47 -0
  642. data/src/core/lib/iomgr/socket_utils_common_posix.cc +473 -0
  643. data/src/core/lib/iomgr/socket_utils_linux.cc +42 -0
  644. data/src/core/lib/iomgr/socket_utils_posix.cc +58 -0
  645. data/src/core/lib/iomgr/socket_utils_posix.h +163 -0
  646. data/src/core/lib/iomgr/socket_utils_uv.cc +49 -0
  647. data/src/core/lib/iomgr/socket_utils_windows.cc +47 -0
  648. data/src/core/lib/iomgr/socket_windows.cc +203 -0
  649. data/src/core/lib/iomgr/socket_windows.h +127 -0
  650. data/src/core/lib/iomgr/sys_epoll_wrapper.h +30 -0
  651. data/src/core/lib/iomgr/tcp_client.cc +36 -0
  652. data/src/core/lib/iomgr/tcp_client.h +52 -0
  653. data/src/core/lib/iomgr/tcp_client_cfstream.cc +215 -0
  654. data/src/core/lib/iomgr/tcp_client_custom.cc +163 -0
  655. data/src/core/lib/iomgr/tcp_client_posix.cc +360 -0
  656. data/src/core/lib/iomgr/tcp_client_posix.h +68 -0
  657. data/src/core/lib/iomgr/tcp_client_windows.cc +232 -0
  658. data/src/core/lib/iomgr/tcp_custom.cc +370 -0
  659. data/src/core/lib/iomgr/tcp_custom.h +84 -0
  660. data/src/core/lib/iomgr/tcp_posix.cc +1855 -0
  661. data/src/core/lib/iomgr/tcp_posix.h +60 -0
  662. data/src/core/lib/iomgr/tcp_server.cc +78 -0
  663. data/src/core/lib/iomgr/tcp_server.h +143 -0
  664. data/src/core/lib/iomgr/tcp_server_custom.cc +485 -0
  665. data/src/core/lib/iomgr/tcp_server_posix.cc +638 -0
  666. data/src/core/lib/iomgr/tcp_server_utils_posix.h +125 -0
  667. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +223 -0
  668. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +181 -0
  669. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +36 -0
  670. data/src/core/lib/iomgr/tcp_server_windows.cc +564 -0
  671. data/src/core/lib/iomgr/tcp_uv.cc +419 -0
  672. data/src/core/lib/iomgr/tcp_windows.cc +533 -0
  673. data/src/core/lib/iomgr/tcp_windows.h +53 -0
  674. data/src/core/lib/iomgr/time_averaged_stats.cc +64 -0
  675. data/src/core/lib/iomgr/time_averaged_stats.h +72 -0
  676. data/src/core/lib/iomgr/timer.cc +45 -0
  677. data/src/core/lib/iomgr/timer.h +127 -0
  678. data/src/core/lib/iomgr/timer_custom.cc +95 -0
  679. data/src/core/lib/iomgr/timer_custom.h +43 -0
  680. data/src/core/lib/iomgr/timer_generic.cc +747 -0
  681. data/src/core/lib/iomgr/timer_generic.h +39 -0
  682. data/src/core/lib/iomgr/timer_heap.cc +135 -0
  683. data/src/core/lib/iomgr/timer_heap.h +43 -0
  684. data/src/core/lib/iomgr/timer_manager.cc +363 -0
  685. data/src/core/lib/iomgr/timer_manager.h +41 -0
  686. data/src/core/lib/iomgr/timer_uv.cc +66 -0
  687. data/src/core/lib/iomgr/udp_server.cc +747 -0
  688. data/src/core/lib/iomgr/udp_server.h +101 -0
  689. data/src/core/lib/iomgr/unix_sockets_posix.cc +104 -0
  690. data/src/core/lib/iomgr/unix_sockets_posix.h +43 -0
  691. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +49 -0
  692. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +82 -0
  693. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +38 -0
  694. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +100 -0
  695. data/src/core/lib/iomgr/wakeup_fd_pipe.h +28 -0
  696. data/src/core/lib/iomgr/wakeup_fd_posix.cc +69 -0
  697. data/src/core/lib/iomgr/wakeup_fd_posix.h +96 -0
  698. data/src/core/lib/iomgr/work_serializer.cc +155 -0
  699. data/src/core/lib/iomgr/work_serializer.h +65 -0
  700. data/src/core/lib/json/json.h +240 -0
  701. data/src/core/lib/json/json_reader.cc +855 -0
  702. data/src/core/lib/json/json_writer.cc +337 -0
  703. data/src/core/lib/profiling/basic_timers.cc +293 -0
  704. data/src/core/lib/profiling/stap_timers.cc +50 -0
  705. data/src/core/lib/profiling/timers.h +94 -0
  706. data/src/core/lib/security/context/security_context.cc +321 -0
  707. data/src/core/lib/security/context/security_context.h +150 -0
  708. data/src/core/lib/security/credentials/alts/alts_credentials.cc +110 -0
  709. data/src/core/lib/security/credentials/alts/alts_credentials.h +109 -0
  710. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +72 -0
  711. data/src/core/lib/security/credentials/alts/check_gcp_environment.h +57 -0
  712. data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +68 -0
  713. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +33 -0
  714. data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +102 -0
  715. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc +127 -0
  716. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc +46 -0
  717. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +75 -0
  718. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +59 -0
  719. data/src/core/lib/security/credentials/composite/composite_credentials.cc +229 -0
  720. data/src/core/lib/security/credentials/composite/composite_credentials.h +106 -0
  721. data/src/core/lib/security/credentials/credentials.cc +162 -0
  722. data/src/core/lib/security/credentials/credentials.h +283 -0
  723. data/src/core/lib/security/credentials/credentials_metadata.cc +62 -0
  724. data/src/core/lib/security/credentials/fake/fake_credentials.cc +112 -0
  725. data/src/core/lib/security/credentials/fake/fake_credentials.h +87 -0
  726. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +41 -0
  727. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +383 -0
  728. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +87 -0
  729. data/src/core/lib/security/credentials/iam/iam_credentials.cc +80 -0
  730. data/src/core/lib/security/credentials/iam/iam_credentials.h +49 -0
  731. data/src/core/lib/security/credentials/jwt/json_token.cc +288 -0
  732. data/src/core/lib/security/credentials/jwt/json_token.h +75 -0
  733. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +172 -0
  734. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +80 -0
  735. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +925 -0
  736. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +122 -0
  737. data/src/core/lib/security/credentials/local/local_credentials.cc +64 -0
  738. data/src/core/lib/security/credentials/local/local_credentials.h +61 -0
  739. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +771 -0
  740. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +171 -0
  741. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +269 -0
  742. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +72 -0
  743. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +364 -0
  744. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +99 -0
  745. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +245 -0
  746. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +313 -0
  747. data/src/core/lib/security/credentials/tls/tls_credentials.cc +128 -0
  748. data/src/core/lib/security/credentials/tls/tls_credentials.h +62 -0
  749. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +301 -0
  750. data/src/core/lib/security/security_connector/alts/alts_security_connector.h +76 -0
  751. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +324 -0
  752. data/src/core/lib/security/security_connector/fake/fake_security_connector.h +45 -0
  753. data/src/core/lib/security/security_connector/load_system_roots.h +29 -0
  754. data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +32 -0
  755. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +171 -0
  756. data/src/core/lib/security/security_connector/load_system_roots_linux.h +44 -0
  757. data/src/core/lib/security/security_connector/local/local_security_connector.cc +281 -0
  758. data/src/core/lib/security/security_connector/local/local_security_connector.h +59 -0
  759. data/src/core/lib/security/security_connector/security_connector.cc +129 -0
  760. data/src/core/lib/security/security_connector/security_connector.h +176 -0
  761. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +439 -0
  762. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +77 -0
  763. data/src/core/lib/security/security_connector/ssl_utils.cc +563 -0
  764. data/src/core/lib/security/security_connector/ssl_utils.h +184 -0
  765. data/src/core/lib/security/security_connector/ssl_utils_config.cc +32 -0
  766. data/src/core/lib/security/security_connector/ssl_utils_config.h +30 -0
  767. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +603 -0
  768. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +183 -0
  769. data/src/core/lib/security/transport/auth_filters.h +35 -0
  770. data/src/core/lib/security/transport/client_auth_filter.cc +466 -0
  771. data/src/core/lib/security/transport/secure_endpoint.cc +446 -0
  772. data/src/core/lib/security/transport/secure_endpoint.h +41 -0
  773. data/src/core/lib/security/transport/security_handshaker.cc +574 -0
  774. data/src/core/lib/security/transport/security_handshaker.h +45 -0
  775. data/src/core/lib/security/transport/server_auth_filter.cc +326 -0
  776. data/src/core/lib/security/transport/target_authority_table.cc +75 -0
  777. data/src/core/lib/security/transport/target_authority_table.h +40 -0
  778. data/src/core/lib/security/transport/tsi_error.cc +29 -0
  779. data/src/core/lib/security/transport/tsi_error.h +29 -0
  780. data/src/core/lib/security/util/json_util.cc +73 -0
  781. data/src/core/lib/security/util/json_util.h +44 -0
  782. data/src/core/lib/slice/b64.cc +239 -0
  783. data/src/core/lib/slice/b64.h +50 -0
  784. data/src/core/lib/slice/percent_encoding.cc +169 -0
  785. data/src/core/lib/slice/percent_encoding.h +65 -0
  786. data/src/core/lib/slice/slice.cc +559 -0
  787. data/src/core/lib/slice/slice_buffer.cc +413 -0
  788. data/src/core/lib/slice/slice_hash_table.h +199 -0
  789. data/src/core/lib/slice/slice_intern.cc +375 -0
  790. data/src/core/lib/slice/slice_internal.h +364 -0
  791. data/src/core/lib/slice/slice_string_helpers.cc +127 -0
  792. data/src/core/lib/slice/slice_string_helpers.h +49 -0
  793. data/src/core/lib/slice/slice_utils.h +200 -0
  794. data/src/core/lib/slice/slice_weak_hash_table.h +102 -0
  795. data/src/core/lib/surface/api_trace.cc +24 -0
  796. data/src/core/lib/surface/api_trace.h +52 -0
  797. data/src/core/lib/surface/byte_buffer.cc +92 -0
  798. data/src/core/lib/surface/byte_buffer_reader.cc +101 -0
  799. data/src/core/lib/surface/call.cc +2044 -0
  800. data/src/core/lib/surface/call.h +125 -0
  801. data/src/core/lib/surface/call_details.cc +41 -0
  802. data/src/core/lib/surface/call_log_batch.cc +111 -0
  803. data/src/core/lib/surface/call_test_only.h +43 -0
  804. data/src/core/lib/surface/channel.cc +543 -0
  805. data/src/core/lib/surface/channel.h +158 -0
  806. data/src/core/lib/surface/channel_init.cc +109 -0
  807. data/src/core/lib/surface/channel_init.h +78 -0
  808. data/src/core/lib/surface/channel_ping.cc +64 -0
  809. data/src/core/lib/surface/channel_stack_type.cc +58 -0
  810. data/src/core/lib/surface/channel_stack_type.h +47 -0
  811. data/src/core/lib/surface/completion_queue.cc +1438 -0
  812. data/src/core/lib/surface/completion_queue.h +97 -0
  813. data/src/core/lib/surface/completion_queue_factory.cc +88 -0
  814. data/src/core/lib/surface/completion_queue_factory.h +38 -0
  815. data/src/core/lib/surface/event_string.cc +61 -0
  816. data/src/core/lib/surface/event_string.h +31 -0
  817. data/src/core/lib/surface/init.cc +250 -0
  818. data/src/core/lib/surface/init.h +27 -0
  819. data/src/core/lib/surface/init_secure.cc +81 -0
  820. data/src/core/lib/surface/lame_client.cc +191 -0
  821. data/src/core/lib/surface/lame_client.h +28 -0
  822. data/src/core/lib/surface/metadata_array.cc +36 -0
  823. data/src/core/lib/surface/server.cc +1800 -0
  824. data/src/core/lib/surface/server.h +99 -0
  825. data/src/core/lib/surface/validate_metadata.cc +105 -0
  826. data/src/core/lib/surface/validate_metadata.h +41 -0
  827. data/src/core/lib/surface/version.cc +28 -0
  828. data/src/core/lib/transport/bdp_estimator.cc +87 -0
  829. data/src/core/lib/transport/bdp_estimator.h +94 -0
  830. data/src/core/lib/transport/byte_stream.cc +158 -0
  831. data/src/core/lib/transport/byte_stream.h +165 -0
  832. data/src/core/lib/transport/connectivity_state.cc +180 -0
  833. data/src/core/lib/transport/connectivity_state.h +131 -0
  834. data/src/core/lib/transport/error_utils.cc +141 -0
  835. data/src/core/lib/transport/error_utils.h +46 -0
  836. data/src/core/lib/transport/http2_errors.h +41 -0
  837. data/src/core/lib/transport/metadata.cc +679 -0
  838. data/src/core/lib/transport/metadata.h +446 -0
  839. data/src/core/lib/transport/metadata_batch.cc +392 -0
  840. data/src/core/lib/transport/metadata_batch.h +191 -0
  841. data/src/core/lib/transport/pid_controller.cc +51 -0
  842. data/src/core/lib/transport/pid_controller.h +116 -0
  843. data/src/core/lib/transport/static_metadata.cc +1230 -0
  844. data/src/core/lib/transport/static_metadata.h +597 -0
  845. data/src/core/lib/transport/status_conversion.cc +92 -0
  846. data/src/core/lib/transport/status_conversion.h +38 -0
  847. data/src/core/lib/transport/status_metadata.cc +61 -0
  848. data/src/core/lib/transport/status_metadata.h +48 -0
  849. data/src/core/lib/transport/timeout_encoding.cc +151 -0
  850. data/src/core/lib/transport/timeout_encoding.h +38 -0
  851. data/src/core/lib/transport/transport.cc +259 -0
  852. data/src/core/lib/transport/transport.h +456 -0
  853. data/src/core/lib/transport/transport_impl.h +71 -0
  854. data/src/core/lib/transport/transport_op_string.cc +169 -0
  855. data/src/core/lib/uri/uri_parser.cc +314 -0
  856. data/src/core/lib/uri/uri_parser.h +49 -0
  857. data/src/core/plugin_registry/grpc_plugin_registry.cc +121 -0
  858. data/src/core/tsi/alts/crypt/aes_gcm.cc +687 -0
  859. data/src/core/tsi/alts/crypt/gsec.cc +189 -0
  860. data/src/core/tsi/alts/crypt/gsec.h +454 -0
  861. data/src/core/tsi/alts/frame_protector/alts_counter.cc +118 -0
  862. data/src/core/tsi/alts/frame_protector/alts_counter.h +98 -0
  863. data/src/core/tsi/alts/frame_protector/alts_crypter.cc +66 -0
  864. data/src/core/tsi/alts/frame_protector/alts_crypter.h +255 -0
  865. data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +407 -0
  866. data/src/core/tsi/alts/frame_protector/alts_frame_protector.h +55 -0
  867. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc +114 -0
  868. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h +114 -0
  869. data/src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc +105 -0
  870. data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +103 -0
  871. data/src/core/tsi/alts/frame_protector/frame_handler.cc +218 -0
  872. data/src/core/tsi/alts/frame_protector/frame_handler.h +236 -0
  873. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +899 -0
  874. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +161 -0
  875. data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +83 -0
  876. data/src/core/tsi/alts/handshaker/alts_shared_resource.h +73 -0
  877. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +674 -0
  878. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +104 -0
  879. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +88 -0
  880. data/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +64 -0
  881. data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +53 -0
  882. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +223 -0
  883. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +171 -0
  884. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +226 -0
  885. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +54 -0
  886. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc +144 -0
  887. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h +49 -0
  888. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h +91 -0
  889. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +174 -0
  890. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +99 -0
  891. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +476 -0
  892. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h +199 -0
  893. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +307 -0
  894. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +57 -0
  895. data/src/core/tsi/fake_transport_security.cc +789 -0
  896. data/src/core/tsi/fake_transport_security.h +47 -0
  897. data/src/core/tsi/local_transport_security.cc +211 -0
  898. data/src/core/tsi/local_transport_security.h +51 -0
  899. data/src/core/tsi/ssl/session_cache/ssl_session.h +71 -0
  900. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +57 -0
  901. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +214 -0
  902. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +90 -0
  903. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +75 -0
  904. data/src/core/tsi/ssl_transport_security.cc +2124 -0
  905. data/src/core/tsi/ssl_transport_security.h +353 -0
  906. data/src/core/tsi/ssl_types.h +42 -0
  907. data/src/core/tsi/transport_security.cc +370 -0
  908. data/src/core/tsi/transport_security.h +127 -0
  909. data/src/core/tsi/transport_security_grpc.cc +73 -0
  910. data/src/core/tsi/transport_security_grpc.h +79 -0
  911. data/src/core/tsi/transport_security_interface.h +476 -0
  912. data/src/ruby/bin/math_client.rb +140 -0
  913. data/src/ruby/bin/math_pb.rb +34 -0
  914. data/src/ruby/bin/math_server.rb +191 -0
  915. data/src/ruby/bin/math_services_pb.rb +51 -0
  916. data/src/ruby/bin/noproto_client.rb +93 -0
  917. data/src/ruby/bin/noproto_server.rb +97 -0
  918. data/src/ruby/ext/grpc/ext-export.clang +1 -0
  919. data/src/ruby/ext/grpc/ext-export.gcc +6 -0
  920. data/src/ruby/ext/grpc/extconf.rb +107 -0
  921. data/src/ruby/ext/grpc/rb_byte_buffer.c +64 -0
  922. data/src/ruby/ext/grpc/rb_byte_buffer.h +35 -0
  923. data/src/ruby/ext/grpc/rb_call.c +1050 -0
  924. data/src/ruby/ext/grpc/rb_call.h +53 -0
  925. data/src/ruby/ext/grpc/rb_call_credentials.c +297 -0
  926. data/src/ruby/ext/grpc/rb_call_credentials.h +31 -0
  927. data/src/ruby/ext/grpc/rb_channel.c +835 -0
  928. data/src/ruby/ext/grpc/rb_channel.h +34 -0
  929. data/src/ruby/ext/grpc/rb_channel_args.c +155 -0
  930. data/src/ruby/ext/grpc/rb_channel_args.h +38 -0
  931. data/src/ruby/ext/grpc/rb_channel_credentials.c +267 -0
  932. data/src/ruby/ext/grpc/rb_channel_credentials.h +32 -0
  933. data/src/ruby/ext/grpc/rb_completion_queue.c +100 -0
  934. data/src/ruby/ext/grpc/rb_completion_queue.h +36 -0
  935. data/src/ruby/ext/grpc/rb_compression_options.c +470 -0
  936. data/src/ruby/ext/grpc/rb_compression_options.h +29 -0
  937. data/src/ruby/ext/grpc/rb_enable_cpp.cc +22 -0
  938. data/src/ruby/ext/grpc/rb_event_thread.c +143 -0
  939. data/src/ruby/ext/grpc/rb_event_thread.h +21 -0
  940. data/src/ruby/ext/grpc/rb_grpc.c +328 -0
  941. data/src/ruby/ext/grpc/rb_grpc.h +76 -0
  942. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +573 -0
  943. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +865 -0
  944. data/src/ruby/ext/grpc/rb_loader.c +57 -0
  945. data/src/ruby/ext/grpc/rb_loader.h +25 -0
  946. data/src/ruby/ext/grpc/rb_server.c +372 -0
  947. data/src/ruby/ext/grpc/rb_server.h +32 -0
  948. data/src/ruby/ext/grpc/rb_server_credentials.c +243 -0
  949. data/src/ruby/ext/grpc/rb_server_credentials.h +32 -0
  950. data/src/ruby/lib/grpc.rb +37 -0
  951. data/src/ruby/lib/grpc/core/status_codes.rb +135 -0
  952. data/src/ruby/lib/grpc/core/time_consts.rb +56 -0
  953. data/src/ruby/lib/grpc/errors.rb +277 -0
  954. data/src/ruby/lib/grpc/generic/active_call.rb +669 -0
  955. data/src/ruby/lib/grpc/generic/bidi_call.rb +233 -0
  956. data/src/ruby/lib/grpc/generic/client_stub.rb +501 -0
  957. data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
  958. data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
  959. data/src/ruby/lib/grpc/generic/rpc_desc.rb +204 -0
  960. data/src/ruby/lib/grpc/generic/rpc_server.rb +551 -0
  961. data/src/ruby/lib/grpc/generic/service.rb +211 -0
  962. data/src/ruby/lib/grpc/google_rpc_status_utils.rb +40 -0
  963. data/src/ruby/lib/grpc/grpc.rb +24 -0
  964. data/src/ruby/lib/grpc/logconfig.rb +44 -0
  965. data/src/ruby/lib/grpc/notifier.rb +45 -0
  966. data/src/ruby/lib/grpc/structs.rb +15 -0
  967. data/src/ruby/lib/grpc/version.rb +18 -0
  968. data/src/ruby/pb/README.md +42 -0
  969. data/src/ruby/pb/generate_proto_ruby.sh +51 -0
  970. data/src/ruby/pb/grpc/health/checker.rb +75 -0
  971. data/src/ruby/pb/grpc/health/v1/health_pb.rb +31 -0
  972. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +62 -0
  973. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +44 -0
  974. data/src/ruby/pb/grpc/testing/metrics_pb.rb +28 -0
  975. data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +49 -0
  976. data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +17 -0
  977. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +105 -0
  978. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +16 -0
  979. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +118 -0
  980. data/src/ruby/spec/call_credentials_spec.rb +42 -0
  981. data/src/ruby/spec/call_spec.rb +180 -0
  982. data/src/ruby/spec/channel_connection_spec.rb +126 -0
  983. data/src/ruby/spec/channel_credentials_spec.rb +82 -0
  984. data/src/ruby/spec/channel_spec.rb +234 -0
  985. data/src/ruby/spec/client_auth_spec.rb +126 -0
  986. data/src/ruby/spec/client_server_spec.rb +664 -0
  987. data/src/ruby/spec/compression_options_spec.rb +149 -0
  988. data/src/ruby/spec/debug_message_spec.rb +134 -0
  989. data/src/ruby/spec/error_sanity_spec.rb +49 -0
  990. data/src/ruby/spec/errors_spec.rb +142 -0
  991. data/src/ruby/spec/generic/active_call_spec.rb +672 -0
  992. data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
  993. data/src/ruby/spec/generic/client_stub_spec.rb +1083 -0
  994. data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
  995. data/src/ruby/spec/generic/rpc_desc_spec.rb +374 -0
  996. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +127 -0
  997. data/src/ruby/spec/generic/rpc_server_spec.rb +748 -0
  998. data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
  999. data/src/ruby/spec/generic/service_spec.rb +263 -0
  1000. data/src/ruby/spec/google_rpc_status_utils_spec.rb +282 -0
  1001. data/src/ruby/spec/pb/codegen/grpc/testing/package_options.proto +28 -0
  1002. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto +22 -0
  1003. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
  1004. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +41 -0
  1005. data/src/ruby/spec/pb/codegen/package_option_spec.rb +82 -0
  1006. data/src/ruby/spec/pb/duplicate/codegen_spec.rb +57 -0
  1007. data/src/ruby/spec/pb/health/checker_spec.rb +236 -0
  1008. data/src/ruby/spec/server_credentials_spec.rb +79 -0
  1009. data/src/ruby/spec/server_spec.rb +209 -0
  1010. data/src/ruby/spec/spec_helper.rb +61 -0
  1011. data/src/ruby/spec/support/helpers.rb +107 -0
  1012. data/src/ruby/spec/support/services.rb +160 -0
  1013. data/src/ruby/spec/testdata/README +1 -0
  1014. data/src/ruby/spec/testdata/ca.pem +20 -0
  1015. data/src/ruby/spec/testdata/client.key +28 -0
  1016. data/src/ruby/spec/testdata/client.pem +20 -0
  1017. data/src/ruby/spec/testdata/server1.key +28 -0
  1018. data/src/ruby/spec/testdata/server1.pem +22 -0
  1019. data/src/ruby/spec/time_consts_spec.rb +74 -0
  1020. data/third_party/abseil-cpp/absl/algorithm/algorithm.h +159 -0
  1021. data/third_party/abseil-cpp/absl/base/attributes.h +621 -0
  1022. data/third_party/abseil-cpp/absl/base/call_once.h +226 -0
  1023. data/third_party/abseil-cpp/absl/base/casts.h +184 -0
  1024. data/third_party/abseil-cpp/absl/base/config.h +671 -0
  1025. data/third_party/abseil-cpp/absl/base/const_init.h +76 -0
  1026. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +129 -0
  1027. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +389 -0
  1028. data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +200 -0
  1029. data/third_party/abseil-cpp/absl/base/internal/bits.h +218 -0
  1030. data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +107 -0
  1031. data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +94 -0
  1032. data/third_party/abseil-cpp/absl/base/internal/endian.h +266 -0
  1033. data/third_party/abseil-cpp/absl/base/internal/errno_saver.h +43 -0
  1034. data/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +51 -0
  1035. data/third_party/abseil-cpp/absl/base/internal/identity.h +37 -0
  1036. data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +107 -0
  1037. data/third_party/abseil-cpp/absl/base/internal/invoke.h +187 -0
  1038. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +107 -0
  1039. data/third_party/abseil-cpp/absl/base/internal/per_thread_tls.h +52 -0
  1040. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +240 -0
  1041. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +183 -0
  1042. data/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +58 -0
  1043. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +233 -0
  1044. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +243 -0
  1045. data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +35 -0
  1046. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +66 -0
  1047. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +46 -0
  1048. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +81 -0
  1049. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +93 -0
  1050. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +37 -0
  1051. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +416 -0
  1052. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +66 -0
  1053. data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +271 -0
  1054. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +152 -0
  1055. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +259 -0
  1056. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +108 -0
  1057. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +75 -0
  1058. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +66 -0
  1059. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +158 -0
  1060. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +140 -0
  1061. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +124 -0
  1062. data/third_party/abseil-cpp/absl/base/log_severity.cc +27 -0
  1063. data/third_party/abseil-cpp/absl/base/log_severity.h +121 -0
  1064. data/third_party/abseil-cpp/absl/base/macros.h +220 -0
  1065. data/third_party/abseil-cpp/absl/base/optimization.h +181 -0
  1066. data/third_party/abseil-cpp/absl/base/options.h +211 -0
  1067. data/third_party/abseil-cpp/absl/base/policy_checks.h +111 -0
  1068. data/third_party/abseil-cpp/absl/base/port.h +26 -0
  1069. data/third_party/abseil-cpp/absl/base/thread_annotations.h +280 -0
  1070. data/third_party/abseil-cpp/absl/container/inlined_vector.h +848 -0
  1071. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +265 -0
  1072. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +892 -0
  1073. data/third_party/abseil-cpp/absl/memory/memory.h +695 -0
  1074. data/third_party/abseil-cpp/absl/meta/type_traits.h +759 -0
  1075. data/third_party/abseil-cpp/absl/numeric/int128.cc +404 -0
  1076. data/third_party/abseil-cpp/absl/numeric/int128.h +1091 -0
  1077. data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +302 -0
  1078. data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +308 -0
  1079. data/third_party/abseil-cpp/absl/strings/ascii.cc +200 -0
  1080. data/third_party/abseil-cpp/absl/strings/ascii.h +242 -0
  1081. data/third_party/abseil-cpp/absl/strings/charconv.cc +984 -0
  1082. data/third_party/abseil-cpp/absl/strings/charconv.h +119 -0
  1083. data/third_party/abseil-cpp/absl/strings/escaping.cc +949 -0
  1084. data/third_party/abseil-cpp/absl/strings/escaping.h +164 -0
  1085. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +156 -0
  1086. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +359 -0
  1087. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +423 -0
  1088. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +504 -0
  1089. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +99 -0
  1090. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +180 -0
  1091. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +58 -0
  1092. data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +112 -0
  1093. data/third_party/abseil-cpp/absl/strings/internal/memutil.h +148 -0
  1094. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +36 -0
  1095. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +89 -0
  1096. data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +73 -0
  1097. data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +248 -0
  1098. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +388 -0
  1099. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +432 -0
  1100. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +245 -0
  1101. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +209 -0
  1102. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +326 -0
  1103. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +51 -0
  1104. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +415 -0
  1105. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +493 -0
  1106. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +23 -0
  1107. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc +72 -0
  1108. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +104 -0
  1109. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +334 -0
  1110. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +333 -0
  1111. data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +314 -0
  1112. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +455 -0
  1113. data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +53 -0
  1114. data/third_party/abseil-cpp/absl/strings/internal/utf8.h +50 -0
  1115. data/third_party/abseil-cpp/absl/strings/match.cc +40 -0
  1116. data/third_party/abseil-cpp/absl/strings/match.h +90 -0
  1117. data/third_party/abseil-cpp/absl/strings/numbers.cc +965 -0
  1118. data/third_party/abseil-cpp/absl/strings/numbers.h +266 -0
  1119. data/third_party/abseil-cpp/absl/strings/str_cat.cc +246 -0
  1120. data/third_party/abseil-cpp/absl/strings/str_cat.h +408 -0
  1121. data/third_party/abseil-cpp/absl/strings/str_format.h +537 -0
  1122. data/third_party/abseil-cpp/absl/strings/str_join.h +293 -0
  1123. data/third_party/abseil-cpp/absl/strings/str_replace.cc +82 -0
  1124. data/third_party/abseil-cpp/absl/strings/str_replace.h +219 -0
  1125. data/third_party/abseil-cpp/absl/strings/str_split.cc +139 -0
  1126. data/third_party/abseil-cpp/absl/strings/str_split.h +513 -0
  1127. data/third_party/abseil-cpp/absl/strings/string_view.cc +235 -0
  1128. data/third_party/abseil-cpp/absl/strings/string_view.h +622 -0
  1129. data/third_party/abseil-cpp/absl/strings/strip.h +91 -0
  1130. data/third_party/abseil-cpp/absl/strings/substitute.cc +171 -0
  1131. data/third_party/abseil-cpp/absl/strings/substitute.h +693 -0
  1132. data/third_party/abseil-cpp/absl/time/civil_time.cc +175 -0
  1133. data/third_party/abseil-cpp/absl/time/civil_time.h +538 -0
  1134. data/third_party/abseil-cpp/absl/time/clock.cc +569 -0
  1135. data/third_party/abseil-cpp/absl/time/clock.h +74 -0
  1136. data/third_party/abseil-cpp/absl/time/duration.cc +922 -0
  1137. data/third_party/abseil-cpp/absl/time/format.cc +153 -0
  1138. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h +332 -0
  1139. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +622 -0
  1140. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +384 -0
  1141. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +102 -0
  1142. data/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc +94 -0
  1143. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +140 -0
  1144. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h +52 -0
  1145. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +922 -0
  1146. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +45 -0
  1147. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +76 -0
  1148. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +121 -0
  1149. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +93 -0
  1150. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +958 -0
  1151. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +138 -0
  1152. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +308 -0
  1153. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +55 -0
  1154. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +187 -0
  1155. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc +159 -0
  1156. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +132 -0
  1157. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +122 -0
  1158. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +115 -0
  1159. data/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc +31 -0
  1160. data/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc +24 -0
  1161. data/third_party/abseil-cpp/absl/time/time.cc +499 -0
  1162. data/third_party/abseil-cpp/absl/time/time.h +1584 -0
  1163. data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +48 -0
  1164. data/third_party/abseil-cpp/absl/types/bad_optional_access.h +78 -0
  1165. data/third_party/abseil-cpp/absl/types/internal/optional.h +396 -0
  1166. data/third_party/abseil-cpp/absl/types/internal/span.h +128 -0
  1167. data/third_party/abseil-cpp/absl/types/optional.h +776 -0
  1168. data/third_party/abseil-cpp/absl/types/span.h +713 -0
  1169. data/third_party/abseil-cpp/absl/utility/utility.h +350 -0
  1170. data/third_party/address_sorting/address_sorting.c +375 -0
  1171. data/third_party/address_sorting/address_sorting_internal.h +70 -0
  1172. data/third_party/address_sorting/address_sorting_posix.c +97 -0
  1173. data/third_party/address_sorting/address_sorting_windows.c +95 -0
  1174. data/third_party/address_sorting/include/address_sorting/address_sorting.h +113 -0
  1175. data/third_party/boringssl-with-bazel/err_data.c +1439 -0
  1176. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +271 -0
  1177. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +123 -0
  1178. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.c +93 -0
  1179. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_dup.c +87 -0
  1180. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +195 -0
  1181. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +261 -0
  1182. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_i2d_fp.c +88 -0
  1183. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +420 -0
  1184. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +305 -0
  1185. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +286 -0
  1186. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c +77 -0
  1187. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_print.c +93 -0
  1188. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +313 -0
  1189. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +212 -0
  1190. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +151 -0
  1191. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +303 -0
  1192. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utf8.c +236 -0
  1193. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +446 -0
  1194. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +104 -0
  1195. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.c +80 -0
  1196. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +105 -0
  1197. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_enum.c +93 -0
  1198. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +97 -0
  1199. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +91 -0
  1200. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +1244 -0
  1201. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +664 -0
  1202. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +244 -0
  1203. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +387 -0
  1204. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +131 -0
  1205. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +280 -0
  1206. data/third_party/boringssl-with-bazel/src/crypto/asn1/time_support.c +206 -0
  1207. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +466 -0
  1208. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +700 -0
  1209. data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +330 -0
  1210. data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +545 -0
  1211. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +279 -0
  1212. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +317 -0
  1213. data/third_party/boringssl-with-bazel/src/crypto/bio/hexdump.c +192 -0
  1214. data/third_party/boringssl-with-bazel/src/crypto/bio/internal.h +111 -0
  1215. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +488 -0
  1216. data/third_party/boringssl-with-bazel/src/crypto/bio/printf.c +115 -0
  1217. data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +206 -0
  1218. data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +118 -0
  1219. data/third_party/boringssl-with-bazel/src/crypto/bn_extra/bn_asn1.c +64 -0
  1220. data/third_party/boringssl-with-bazel/src/crypto/bn_extra/convert.c +470 -0
  1221. data/third_party/boringssl-with-bazel/src/crypto/buf/buf.c +172 -0
  1222. data/third_party/boringssl-with-bazel/src/crypto/bytestring/asn1_compat.c +52 -0
  1223. data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c +265 -0
  1224. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbb.c +719 -0
  1225. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +688 -0
  1226. data/third_party/boringssl-with-bazel/src/crypto/bytestring/internal.h +96 -0
  1227. data/third_party/boringssl-with-bazel/src/crypto/bytestring/unicode.c +155 -0
  1228. data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +184 -0
  1229. data/third_party/boringssl-with-bazel/src/crypto/chacha/internal.h +45 -0
  1230. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +143 -0
  1231. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +152 -0
  1232. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesccm.c +447 -0
  1233. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesctrhmac.c +283 -0
  1234. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesgcmsiv.c +891 -0
  1235. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_chacha20poly1305.c +418 -0
  1236. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_null.c +85 -0
  1237. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc2.c +462 -0
  1238. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc4.c +87 -0
  1239. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +688 -0
  1240. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +128 -0
  1241. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +491 -0
  1242. data/third_party/boringssl-with-bazel/src/crypto/cmac/cmac.c +278 -0
  1243. data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +810 -0
  1244. data/third_party/boringssl-with-bazel/src/crypto/conf/conf_def.h +127 -0
  1245. data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +31 -0
  1246. data/third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-fuchsia.c +55 -0
  1247. data/third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-linux.c +62 -0
  1248. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +220 -0
  1249. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.h +201 -0
  1250. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +38 -0
  1251. data/third_party/boringssl-with-bazel/src/crypto/cpu-intel.c +291 -0
  1252. data/third_party/boringssl-with-bazel/src/crypto/cpu-ppc64le.c +38 -0
  1253. data/third_party/boringssl-with-bazel/src/crypto/crypto.c +226 -0
  1254. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +2159 -0
  1255. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +7872 -0
  1256. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +146 -0
  1257. data/third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c +539 -0
  1258. data/third_party/boringssl-with-bazel/src/crypto/dh/check.c +217 -0
  1259. data/third_party/boringssl-with-bazel/src/crypto/dh/dh.c +533 -0
  1260. data/third_party/boringssl-with-bazel/src/crypto/dh/dh_asn1.c +160 -0
  1261. data/third_party/boringssl-with-bazel/src/crypto/dh/params.c +93 -0
  1262. data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +240 -0
  1263. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +980 -0
  1264. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +339 -0
  1265. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +574 -0
  1266. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_derive.c +95 -0
  1267. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +425 -0
  1268. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +78 -0
  1269. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +124 -0
  1270. data/third_party/boringssl-with-bazel/src/crypto/ecdsa_extra/ecdsa_asn1.c +267 -0
  1271. data/third_party/boringssl-with-bazel/src/crypto/engine/engine.c +99 -0
  1272. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +850 -0
  1273. data/third_party/boringssl-with-bazel/src/crypto/err/internal.h +58 -0
  1274. data/third_party/boringssl-with-bazel/src/crypto/evp/digestsign.c +231 -0
  1275. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +443 -0
  1276. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +388 -0
  1277. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_ctx.c +484 -0
  1278. data/third_party/boringssl-with-bazel/src/crypto/evp/internal.h +269 -0
  1279. data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +273 -0
  1280. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec.c +286 -0
  1281. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.c +255 -0
  1282. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519.c +104 -0
  1283. data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519_asn1.c +221 -0
  1284. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +648 -0
  1285. data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa_asn1.c +194 -0
  1286. data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519.c +110 -0
  1287. data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519_asn1.c +248 -0
  1288. data/third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.c +146 -0
  1289. data/third_party/boringssl-with-bazel/src/crypto/evp/print.c +489 -0
  1290. data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c +213 -0
  1291. data/third_party/boringssl-with-bazel/src/crypto/evp/sign.c +151 -0
  1292. data/third_party/boringssl-with-bazel/src/crypto/ex_data.c +261 -0
  1293. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes.c +108 -0
  1294. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +1282 -0
  1295. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/internal.h +238 -0
  1296. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/key_wrap.c +236 -0
  1297. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +106 -0
  1298. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +263 -0
  1299. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/add.c +316 -0
  1300. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/asm/x86_64-gcc.c +541 -0
  1301. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bn.c +445 -0
  1302. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bytes.c +230 -0
  1303. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/cmp.c +200 -0
  1304. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/ctx.c +236 -0
  1305. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +886 -0
  1306. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div_extra.c +87 -0
  1307. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.c +1288 -0
  1308. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd.c +378 -0
  1309. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd_extra.c +325 -0
  1310. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/generic.c +711 -0
  1311. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +694 -0
  1312. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/jacobi.c +146 -0
  1313. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +502 -0
  1314. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery_inv.c +186 -0
  1315. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.c +749 -0
  1316. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +1068 -0
  1317. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/random.c +341 -0
  1318. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.c +226 -0
  1319. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.h +104 -0
  1320. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/shift.c +364 -0
  1321. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.c +502 -0
  1322. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/aead.c +284 -0
  1323. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +620 -0
  1324. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +1302 -0
  1325. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_des.c +237 -0
  1326. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/internal.h +128 -0
  1327. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/delocate.h +89 -0
  1328. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/des.c +785 -0
  1329. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/internal.h +240 -0
  1330. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +271 -0
  1331. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +296 -0
  1332. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/internal.h +112 -0
  1333. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +268 -0
  1334. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +1252 -0
  1335. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +465 -0
  1336. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +524 -0
  1337. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +100 -0
  1338. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +775 -0
  1339. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +328 -0
  1340. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +1178 -0
  1341. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64-table.h +9497 -0
  1342. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.c +632 -0
  1343. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.h +153 -0
  1344. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +736 -0
  1345. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +297 -0
  1346. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +175 -0
  1347. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +357 -0
  1348. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +270 -0
  1349. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/util.c +255 -0
  1350. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +270 -0
  1351. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +122 -0
  1352. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +328 -0
  1353. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/fips_shared_support.c +32 -0
  1354. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hmac/hmac.c +228 -0
  1355. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/is_fips.c +29 -0
  1356. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +256 -0
  1357. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/internal.h +37 -0
  1358. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +301 -0
  1359. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +167 -0
  1360. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +202 -0
  1361. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +200 -0
  1362. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +729 -0
  1363. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +304 -0
  1364. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +441 -0
  1365. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +96 -0
  1366. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/polyval.c +91 -0
  1367. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/ctrdrbg.c +202 -0
  1368. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +137 -0
  1369. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.h +49 -0
  1370. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/getrandom_fillin.h +64 -0
  1371. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +163 -0
  1372. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +378 -0
  1373. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +391 -0
  1374. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c +243 -0
  1375. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +127 -0
  1376. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +695 -0
  1377. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +898 -0
  1378. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +1358 -0
  1379. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +654 -0
  1380. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/internal.h +53 -0
  1381. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1-altivec.c +361 -0
  1382. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +371 -0
  1383. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +343 -0
  1384. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +544 -0
  1385. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/internal.h +39 -0
  1386. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +165 -0
  1387. data/third_party/boringssl-with-bazel/src/crypto/hkdf/hkdf.c +112 -0
  1388. data/third_party/boringssl-with-bazel/src/crypto/hrss/hrss.c +2100 -0
  1389. data/third_party/boringssl-with-bazel/src/crypto/hrss/internal.h +61 -0
  1390. data/third_party/boringssl-with-bazel/src/crypto/internal.h +834 -0
  1391. data/third_party/boringssl-with-bazel/src/crypto/lhash/lhash.c +348 -0
  1392. data/third_party/boringssl-with-bazel/src/crypto/mem.c +359 -0
  1393. data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +549 -0
  1394. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +11585 -0
  1395. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_xref.c +122 -0
  1396. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_all.c +261 -0
  1397. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_info.c +360 -0
  1398. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +777 -0
  1399. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_oth.c +87 -0
  1400. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.c +257 -0
  1401. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.c +218 -0
  1402. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_x509.c +65 -0
  1403. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_xaux.c +65 -0
  1404. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/internal.h +49 -0
  1405. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +159 -0
  1406. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +385 -0
  1407. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +131 -0
  1408. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/p5_pbev2.c +316 -0
  1409. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +530 -0
  1410. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1305 -0
  1411. data/third_party/boringssl-with-bazel/src/crypto/poly1305/internal.h +41 -0
  1412. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +318 -0
  1413. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.c +305 -0
  1414. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.c +856 -0
  1415. data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +45 -0
  1416. data/third_party/boringssl-with-bazel/src/crypto/pool/pool.c +220 -0
  1417. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +52 -0
  1418. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/forkunsafe.c +46 -0
  1419. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/fuchsia.c +30 -0
  1420. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +70 -0
  1421. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +69 -0
  1422. data/third_party/boringssl-with-bazel/src/crypto/rc4/rc4.c +98 -0
  1423. data/third_party/boringssl-with-bazel/src/crypto/refcount_c11.c +67 -0
  1424. data/third_party/boringssl-with-bazel/src/crypto/refcount_lock.c +53 -0
  1425. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +325 -0
  1426. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_print.c +22 -0
  1427. data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c +82 -0
  1428. data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +431 -0
  1429. data/third_party/boringssl-with-bazel/src/crypto/thread.c +110 -0
  1430. data/third_party/boringssl-with-bazel/src/crypto/thread_none.c +59 -0
  1431. data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +210 -0
  1432. data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +260 -0
  1433. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +278 -0
  1434. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +1474 -0
  1435. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +720 -0
  1436. data/third_party/boringssl-with-bazel/src/crypto/x509/a_digest.c +96 -0
  1437. data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +128 -0
  1438. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +653 -0
  1439. data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c +114 -0
  1440. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +153 -0
  1441. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +842 -0
  1442. data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +458 -0
  1443. data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +275 -0
  1444. data/third_party/boringssl-with-bazel/src/crypto/x509/charmap.h +15 -0
  1445. data/third_party/boringssl-with-bazel/src/crypto/x509/i2d_pr.c +83 -0
  1446. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +66 -0
  1447. data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +385 -0
  1448. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +125 -0
  1449. data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +244 -0
  1450. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +544 -0
  1451. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +111 -0
  1452. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +71 -0
  1453. data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +157 -0
  1454. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +381 -0
  1455. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +476 -0
  1456. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c +106 -0
  1457. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_def.c +103 -0
  1458. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +206 -0
  1459. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +834 -0
  1460. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +198 -0
  1461. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_r2x.c +116 -0
  1462. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +341 -0
  1463. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +185 -0
  1464. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +326 -0
  1465. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +204 -0
  1466. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +278 -0
  1467. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +2487 -0
  1468. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +671 -0
  1469. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +210 -0
  1470. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +389 -0
  1471. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +81 -0
  1472. data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +137 -0
  1473. data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +151 -0
  1474. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +399 -0
  1475. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +111 -0
  1476. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +541 -0
  1477. data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c +75 -0
  1478. data/third_party/boringssl-with-bazel/src/crypto/x509/x_info.c +98 -0
  1479. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +554 -0
  1480. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pkey.c +106 -0
  1481. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +368 -0
  1482. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +109 -0
  1483. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +69 -0
  1484. data/third_party/boringssl-with-bazel/src/crypto/x509/x_spki.c +80 -0
  1485. data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +69 -0
  1486. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +334 -0
  1487. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +198 -0
  1488. data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +141 -0
  1489. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +56 -0
  1490. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_cache.c +286 -0
  1491. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +130 -0
  1492. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_int.h +217 -0
  1493. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_lib.c +155 -0
  1494. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_map.c +130 -0
  1495. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_node.c +189 -0
  1496. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_tree.c +842 -0
  1497. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +207 -0
  1498. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akeya.c +72 -0
  1499. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +629 -0
  1500. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bcons.c +133 -0
  1501. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +141 -0
  1502. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +463 -0
  1503. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +503 -0
  1504. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c +561 -0
  1505. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +100 -0
  1506. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_extku.c +148 -0
  1507. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +246 -0
  1508. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ia5.c +122 -0
  1509. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +218 -0
  1510. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_int.c +91 -0
  1511. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +371 -0
  1512. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ncons.c +501 -0
  1513. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ocsp.c +68 -0
  1514. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pci.c +288 -0
  1515. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcia.c +57 -0
  1516. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcons.c +139 -0
  1517. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +110 -0
  1518. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pmaps.c +154 -0
  1519. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +229 -0
  1520. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +843 -0
  1521. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +155 -0
  1522. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +274 -0
  1523. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1395 -0
  1524. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +459 -0
  1525. data/third_party/boringssl-with-bazel/src/include/openssl/aes.h +195 -0
  1526. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +121 -0
  1527. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +911 -0
  1528. data/third_party/boringssl-with-bazel/src/include/openssl/asn1_mac.h +18 -0
  1529. data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +892 -0
  1530. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +575 -0
  1531. data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +190 -0
  1532. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +933 -0
  1533. data/third_party/boringssl-with-bazel/src/include/openssl/blowfish.h +93 -0
  1534. data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +1057 -0
  1535. data/third_party/boringssl-with-bazel/src/include/openssl/buf.h +137 -0
  1536. data/third_party/boringssl-with-bazel/src/include/openssl/buffer.h +18 -0
  1537. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +561 -0
  1538. data/third_party/boringssl-with-bazel/src/include/openssl/cast.h +96 -0
  1539. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +41 -0
  1540. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +638 -0
  1541. data/third_party/boringssl-with-bazel/src/include/openssl/cmac.h +91 -0
  1542. data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +180 -0
  1543. data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +212 -0
  1544. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +149 -0
  1545. data/third_party/boringssl-with-bazel/src/include/openssl/curve25519.h +201 -0
  1546. data/third_party/boringssl-with-bazel/src/include/openssl/des.h +177 -0
  1547. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +319 -0
  1548. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +331 -0
  1549. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +457 -0
  1550. data/third_party/boringssl-with-bazel/src/include/openssl/dtls1.h +16 -0
  1551. data/third_party/boringssl-with-bazel/src/include/openssl/e_os2.h +18 -0
  1552. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +424 -0
  1553. data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +372 -0
  1554. data/third_party/boringssl-with-bazel/src/include/openssl/ecdh.h +118 -0
  1555. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +205 -0
  1556. data/third_party/boringssl-with-bazel/src/include/openssl/engine.h +109 -0
  1557. data/third_party/boringssl-with-bazel/src/include/openssl/err.h +465 -0
  1558. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +1050 -0
  1559. data/third_party/boringssl-with-bazel/src/include/openssl/ex_data.h +203 -0
  1560. data/third_party/boringssl-with-bazel/src/include/openssl/hkdf.h +64 -0
  1561. data/third_party/boringssl-with-bazel/src/include/openssl/hmac.h +186 -0
  1562. data/third_party/boringssl-with-bazel/src/include/openssl/hrss.h +100 -0
  1563. data/third_party/boringssl-with-bazel/src/include/openssl/is_boringssl.h +16 -0
  1564. data/third_party/boringssl-with-bazel/src/include/openssl/lhash.h +282 -0
  1565. data/third_party/boringssl-with-bazel/src/include/openssl/md4.h +108 -0
  1566. data/third_party/boringssl-with-bazel/src/include/openssl/md5.h +109 -0
  1567. data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +175 -0
  1568. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +4259 -0
  1569. data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +236 -0
  1570. data/third_party/boringssl-with-bazel/src/include/openssl/obj_mac.h +18 -0
  1571. data/third_party/boringssl-with-bazel/src/include/openssl/objects.h +18 -0
  1572. data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +67 -0
  1573. data/third_party/boringssl-with-bazel/src/include/openssl/opensslv.h +18 -0
  1574. data/third_party/boringssl-with-bazel/src/include/openssl/ossl_typ.h +18 -0
  1575. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +435 -0
  1576. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs12.h +18 -0
  1577. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +215 -0
  1578. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +269 -0
  1579. data/third_party/boringssl-with-bazel/src/include/openssl/poly1305.h +49 -0
  1580. data/third_party/boringssl-with-bazel/src/include/openssl/pool.h +102 -0
  1581. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +111 -0
  1582. data/third_party/boringssl-with-bazel/src/include/openssl/rc4.h +96 -0
  1583. data/third_party/boringssl-with-bazel/src/include/openssl/ripemd.h +108 -0
  1584. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +818 -0
  1585. data/third_party/boringssl-with-bazel/src/include/openssl/safestack.h +16 -0
  1586. data/third_party/boringssl-with-bazel/src/include/openssl/sha.h +294 -0
  1587. data/third_party/boringssl-with-bazel/src/include/openssl/siphash.h +37 -0
  1588. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +199 -0
  1589. data/third_party/boringssl-with-bazel/src/include/openssl/srtp.h +18 -0
  1590. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +5198 -0
  1591. data/third_party/boringssl-with-bazel/src/include/openssl/ssl3.h +333 -0
  1592. data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +542 -0
  1593. data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +191 -0
  1594. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +632 -0
  1595. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +291 -0
  1596. data/third_party/boringssl-with-bazel/src/include/openssl/type_check.h +90 -0
  1597. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +1207 -0
  1598. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +681 -0
  1599. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +831 -0
  1600. data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +179 -0
  1601. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +837 -0
  1602. data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +268 -0
  1603. data/third_party/boringssl-with-bazel/src/ssl/d1_pkt.cc +273 -0
  1604. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +232 -0
  1605. data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +200 -0
  1606. data/third_party/boringssl-with-bazel/src/ssl/dtls_record.cc +353 -0
  1607. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +675 -0
  1608. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +703 -0
  1609. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +1890 -0
  1610. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1805 -0
  1611. data/third_party/boringssl-with-bazel/src/ssl/internal.h +3572 -0
  1612. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +724 -0
  1613. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +221 -0
  1614. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +458 -0
  1615. data/third_party/boringssl-with-bazel/src/ssl/ssl_aead_ctx.cc +432 -0
  1616. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +856 -0
  1617. data/third_party/boringssl-with-bazel/src/ssl/ssl_buffer.cc +306 -0
  1618. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +1019 -0
  1619. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +1718 -0
  1620. data/third_party/boringssl-with-bazel/src/ssl/ssl_file.cc +585 -0
  1621. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +397 -0
  1622. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +3015 -0
  1623. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +835 -0
  1624. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +1333 -0
  1625. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +230 -0
  1626. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +277 -0
  1627. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +394 -0
  1628. data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +1358 -0
  1629. data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +365 -0
  1630. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +3870 -0
  1631. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +689 -0
  1632. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +1017 -0
  1633. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +513 -0
  1634. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +1096 -0
  1635. data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +317 -0
  1636. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +703 -0
  1637. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +981 -0
  1638. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +619 -0
  1639. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +3147 -0
  1640. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +1226 -0
  1641. data/third_party/cares/ares_build.h +223 -0
  1642. data/third_party/cares/cares/ares.h +670 -0
  1643. data/third_party/cares/cares/ares__close_sockets.c +61 -0
  1644. data/third_party/cares/cares/ares__get_hostent.c +261 -0
  1645. data/third_party/cares/cares/ares__read_line.c +73 -0
  1646. data/third_party/cares/cares/ares__timeval.c +111 -0
  1647. data/third_party/cares/cares/ares_cancel.c +63 -0
  1648. data/third_party/cares/cares/ares_create_query.c +206 -0
  1649. data/third_party/cares/cares/ares_data.c +222 -0
  1650. data/third_party/cares/cares/ares_data.h +72 -0
  1651. data/third_party/cares/cares/ares_destroy.c +113 -0
  1652. data/third_party/cares/cares/ares_dns.h +103 -0
  1653. data/third_party/cares/cares/ares_expand_name.c +209 -0
  1654. data/third_party/cares/cares/ares_expand_string.c +70 -0
  1655. data/third_party/cares/cares/ares_fds.c +59 -0
  1656. data/third_party/cares/cares/ares_free_hostent.c +41 -0
  1657. data/third_party/cares/cares/ares_free_string.c +25 -0
  1658. data/third_party/cares/cares/ares_getenv.c +30 -0
  1659. data/third_party/cares/cares/ares_getenv.h +26 -0
  1660. data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
  1661. data/third_party/cares/cares/ares_gethostbyname.c +529 -0
  1662. data/third_party/cares/cares/ares_getnameinfo.c +453 -0
  1663. data/third_party/cares/cares/ares_getopt.c +122 -0
  1664. data/third_party/cares/cares/ares_getopt.h +53 -0
  1665. data/third_party/cares/cares/ares_getsock.c +66 -0
  1666. data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
  1667. data/third_party/cares/cares/ares_init.c +2615 -0
  1668. data/third_party/cares/cares/ares_iphlpapi.h +221 -0
  1669. data/third_party/cares/cares/ares_ipv6.h +78 -0
  1670. data/third_party/cares/cares/ares_library_init.c +195 -0
  1671. data/third_party/cares/cares/ares_library_init.h +43 -0
  1672. data/third_party/cares/cares/ares_llist.c +63 -0
  1673. data/third_party/cares/cares/ares_llist.h +39 -0
  1674. data/third_party/cares/cares/ares_mkquery.c +24 -0
  1675. data/third_party/cares/cares/ares_nowarn.c +260 -0
  1676. data/third_party/cares/cares/ares_nowarn.h +61 -0
  1677. data/third_party/cares/cares/ares_options.c +406 -0
  1678. data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
  1679. data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
  1680. data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
  1681. data/third_party/cares/cares/ares_parse_naptr_reply.c +194 -0
  1682. data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
  1683. data/third_party/cares/cares/ares_parse_ptr_reply.c +221 -0
  1684. data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
  1685. data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
  1686. data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
  1687. data/third_party/cares/cares/ares_platform.c +11042 -0
  1688. data/third_party/cares/cares/ares_platform.h +43 -0
  1689. data/third_party/cares/cares/ares_private.h +382 -0
  1690. data/third_party/cares/cares/ares_process.c +1473 -0
  1691. data/third_party/cares/cares/ares_query.c +186 -0
  1692. data/third_party/cares/cares/ares_rules.h +125 -0
  1693. data/third_party/cares/cares/ares_search.c +323 -0
  1694. data/third_party/cares/cares/ares_send.c +137 -0
  1695. data/third_party/cares/cares/ares_setup.h +217 -0
  1696. data/third_party/cares/cares/ares_strcasecmp.c +66 -0
  1697. data/third_party/cares/cares/ares_strcasecmp.h +30 -0
  1698. data/third_party/cares/cares/ares_strdup.c +49 -0
  1699. data/third_party/cares/cares/ares_strdup.h +24 -0
  1700. data/third_party/cares/cares/ares_strerror.c +56 -0
  1701. data/third_party/cares/cares/ares_strsplit.c +174 -0
  1702. data/third_party/cares/cares/ares_strsplit.h +43 -0
  1703. data/third_party/cares/cares/ares_timeout.c +88 -0
  1704. data/third_party/cares/cares/ares_version.c +11 -0
  1705. data/third_party/cares/cares/ares_version.h +24 -0
  1706. data/third_party/cares/cares/ares_writev.c +79 -0
  1707. data/third_party/cares/cares/bitncmp.c +59 -0
  1708. data/third_party/cares/cares/bitncmp.h +26 -0
  1709. data/third_party/cares/cares/config-win32.h +351 -0
  1710. data/third_party/cares/cares/inet_net_pton.c +450 -0
  1711. data/third_party/cares/cares/inet_ntop.c +207 -0
  1712. data/third_party/cares/cares/setup_once.h +554 -0
  1713. data/third_party/cares/cares/windows_port.c +22 -0
  1714. data/third_party/cares/config_darwin/ares_config.h +428 -0
  1715. data/third_party/cares/config_freebsd/ares_config.h +505 -0
  1716. data/third_party/cares/config_linux/ares_config.h +461 -0
  1717. data/third_party/cares/config_openbsd/ares_config.h +505 -0
  1718. data/third_party/upb/upb/decode.c +609 -0
  1719. data/third_party/upb/upb/decode.h +21 -0
  1720. data/third_party/upb/upb/encode.c +378 -0
  1721. data/third_party/upb/upb/encode.h +21 -0
  1722. data/third_party/upb/upb/generated_util.h +105 -0
  1723. data/third_party/upb/upb/msg.c +111 -0
  1724. data/third_party/upb/upb/msg.h +69 -0
  1725. data/third_party/upb/upb/port.c +26 -0
  1726. data/third_party/upb/upb/port_def.inc +150 -0
  1727. data/third_party/upb/upb/port_undef.inc +21 -0
  1728. data/third_party/upb/upb/table.c +913 -0
  1729. data/third_party/upb/upb/table.int.h +507 -0
  1730. data/third_party/upb/upb/upb.c +261 -0
  1731. data/third_party/upb/upb/upb.h +364 -0
  1732. data/third_party/zlib/adler32.c +186 -0
  1733. data/third_party/zlib/compress.c +86 -0
  1734. data/third_party/zlib/crc32.c +442 -0
  1735. data/third_party/zlib/crc32.h +441 -0
  1736. data/third_party/zlib/deflate.c +2163 -0
  1737. data/third_party/zlib/deflate.h +349 -0
  1738. data/third_party/zlib/gzclose.c +25 -0
  1739. data/third_party/zlib/gzguts.h +218 -0
  1740. data/third_party/zlib/gzlib.c +637 -0
  1741. data/third_party/zlib/gzread.c +654 -0
  1742. data/third_party/zlib/gzwrite.c +665 -0
  1743. data/third_party/zlib/infback.c +640 -0
  1744. data/third_party/zlib/inffast.c +323 -0
  1745. data/third_party/zlib/inffast.h +11 -0
  1746. data/third_party/zlib/inffixed.h +94 -0
  1747. data/third_party/zlib/inflate.c +1561 -0
  1748. data/third_party/zlib/inflate.h +125 -0
  1749. data/third_party/zlib/inftrees.c +304 -0
  1750. data/third_party/zlib/inftrees.h +62 -0
  1751. data/third_party/zlib/trees.c +1203 -0
  1752. data/third_party/zlib/trees.h +128 -0
  1753. data/third_party/zlib/uncompr.c +93 -0
  1754. data/third_party/zlib/zconf.h +534 -0
  1755. data/third_party/zlib/zlib.h +1912 -0
  1756. data/third_party/zlib/zutil.c +325 -0
  1757. data/third_party/zlib/zutil.h +271 -0
  1758. metadata +2029 -0
@@ -0,0 +1,4059 @@
1
+ /*
2
+ *
3
+ * Copyright 2015 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include "src/core/ext/filters/client_channel/client_channel.h"
22
+
23
+ #include <inttypes.h>
24
+ #include <limits.h>
25
+ #include <stdbool.h>
26
+ #include <stdio.h>
27
+ #include <string.h>
28
+
29
+ #include <set>
30
+
31
+ #include "absl/strings/string_view.h"
32
+
33
+ #include <grpc/support/alloc.h>
34
+ #include <grpc/support/log.h>
35
+ #include <grpc/support/string_util.h>
36
+ #include <grpc/support/sync.h>
37
+
38
+ #include "absl/container/inlined_vector.h"
39
+ #include "absl/types/optional.h"
40
+
41
+ #include "src/core/ext/filters/client_channel/backend_metric.h"
42
+ #include "src/core/ext/filters/client_channel/backup_poller.h"
43
+ #include "src/core/ext/filters/client_channel/global_subchannel_pool.h"
44
+ #include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
45
+ #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
46
+ #include "src/core/ext/filters/client_channel/local_subchannel_pool.h"
47
+ #include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
48
+ #include "src/core/ext/filters/client_channel/resolver_registry.h"
49
+ #include "src/core/ext/filters/client_channel/resolver_result_parsing.h"
50
+ #include "src/core/ext/filters/client_channel/resolving_lb_policy.h"
51
+ #include "src/core/ext/filters/client_channel/retry_throttle.h"
52
+ #include "src/core/ext/filters/client_channel/service_config.h"
53
+ #include "src/core/ext/filters/client_channel/service_config_call_data.h"
54
+ #include "src/core/ext/filters/client_channel/subchannel.h"
55
+ #include "src/core/ext/filters/deadline/deadline_filter.h"
56
+ #include "src/core/lib/backoff/backoff.h"
57
+ #include "src/core/lib/channel/channel_args.h"
58
+ #include "src/core/lib/channel/connected_channel.h"
59
+ #include "src/core/lib/channel/status_util.h"
60
+ #include "src/core/lib/gpr/string.h"
61
+ #include "src/core/lib/gprpp/manual_constructor.h"
62
+ #include "src/core/lib/gprpp/map.h"
63
+ #include "src/core/lib/gprpp/sync.h"
64
+ #include "src/core/lib/iomgr/iomgr.h"
65
+ #include "src/core/lib/iomgr/polling_entity.h"
66
+ #include "src/core/lib/iomgr/work_serializer.h"
67
+ #include "src/core/lib/profiling/timers.h"
68
+ #include "src/core/lib/slice/slice_internal.h"
69
+ #include "src/core/lib/slice/slice_string_helpers.h"
70
+ #include "src/core/lib/surface/channel.h"
71
+ #include "src/core/lib/transport/connectivity_state.h"
72
+ #include "src/core/lib/transport/error_utils.h"
73
+ #include "src/core/lib/transport/metadata.h"
74
+ #include "src/core/lib/transport/metadata_batch.h"
75
+ #include "src/core/lib/transport/static_metadata.h"
76
+ #include "src/core/lib/transport/status_metadata.h"
77
+
78
+ using grpc_core::internal::ClientChannelMethodParsedConfig;
79
+ using grpc_core::internal::ServerRetryThrottleData;
80
+
81
+ //
82
+ // Client channel filter
83
+ //
84
+
85
+ // By default, we buffer 256 KiB per RPC for retries.
86
+ // TODO(roth): Do we have any data to suggest a better value?
87
+ #define DEFAULT_PER_RPC_RETRY_BUFFER_SIZE (256 << 10)
88
+
89
+ // This value was picked arbitrarily. It can be changed if there is
90
+ // any even moderately compelling reason to do so.
91
+ #define RETRY_BACKOFF_JITTER 0.2
92
+
93
+ // Max number of batches that can be pending on a call at any given
94
+ // time. This includes one batch for each of the following ops:
95
+ // recv_initial_metadata
96
+ // send_initial_metadata
97
+ // recv_message
98
+ // send_message
99
+ // recv_trailing_metadata
100
+ // send_trailing_metadata
101
+ #define MAX_PENDING_BATCHES 6
102
+
103
+ namespace grpc_core {
104
+
105
+ TraceFlag grpc_client_channel_call_trace(false, "client_channel_call");
106
+ TraceFlag grpc_client_channel_routing_trace(false, "client_channel_routing");
107
+
108
+ namespace {
109
+
110
+ //
111
+ // ChannelData definition
112
+ //
113
+
114
+ class ChannelData {
115
+ public:
116
+ struct QueuedPick {
117
+ grpc_call_element* elem;
118
+ QueuedPick* next = nullptr;
119
+ };
120
+
121
+ static grpc_error* Init(grpc_channel_element* elem,
122
+ grpc_channel_element_args* args);
123
+ static void Destroy(grpc_channel_element* elem);
124
+ static void StartTransportOp(grpc_channel_element* elem,
125
+ grpc_transport_op* op);
126
+ static void GetChannelInfo(grpc_channel_element* elem,
127
+ const grpc_channel_info* info);
128
+
129
+ bool deadline_checking_enabled() const { return deadline_checking_enabled_; }
130
+ bool enable_retries() const { return enable_retries_; }
131
+ size_t per_rpc_retry_buffer_size() const {
132
+ return per_rpc_retry_buffer_size_;
133
+ }
134
+ grpc_channel_stack* owning_stack() const { return owning_stack_; }
135
+
136
+ // Note: Does NOT return a new ref.
137
+ grpc_error* disconnect_error() const {
138
+ return disconnect_error_.Load(MemoryOrder::ACQUIRE);
139
+ }
140
+
141
+ Mutex* data_plane_mu() const { return &data_plane_mu_; }
142
+
143
+ LoadBalancingPolicy::SubchannelPicker* picker() const {
144
+ return picker_.get();
145
+ }
146
+ void AddQueuedPick(QueuedPick* pick, grpc_polling_entity* pollent);
147
+ void RemoveQueuedPick(QueuedPick* to_remove, grpc_polling_entity* pollent);
148
+
149
+ bool received_service_config_data() const {
150
+ return received_service_config_data_;
151
+ }
152
+ RefCountedPtr<ServerRetryThrottleData> retry_throttle_data() const {
153
+ return retry_throttle_data_;
154
+ }
155
+ RefCountedPtr<ServiceConfig> service_config() const {
156
+ return service_config_;
157
+ }
158
+ WorkSerializer* work_serializer() const { return work_serializer_.get(); }
159
+
160
+ RefCountedPtr<ConnectedSubchannel> GetConnectedSubchannelInDataPlane(
161
+ SubchannelInterface* subchannel) const;
162
+
163
+ grpc_connectivity_state CheckConnectivityState(bool try_to_connect);
164
+
165
+ void AddExternalConnectivityWatcher(grpc_polling_entity pollent,
166
+ grpc_connectivity_state* state,
167
+ grpc_closure* on_complete,
168
+ grpc_closure* watcher_timer_init) {
169
+ auto* watcher = new ExternalConnectivityWatcher(
170
+ this, pollent, state, on_complete, watcher_timer_init);
171
+ {
172
+ MutexLock lock(&external_watchers_mu_);
173
+ // Will be deleted when the watch is complete.
174
+ GPR_ASSERT(external_watchers_[on_complete] == nullptr);
175
+ external_watchers_[on_complete] = watcher;
176
+ }
177
+ watcher->Start();
178
+ }
179
+
180
+ void RemoveExternalConnectivityWatcher(grpc_closure* on_complete,
181
+ bool cancel) {
182
+ ExternalConnectivityWatcher* watcher = nullptr;
183
+ {
184
+ MutexLock lock(&external_watchers_mu_);
185
+ auto it = external_watchers_.find(on_complete);
186
+ if (it != external_watchers_.end()) {
187
+ watcher = it->second;
188
+ external_watchers_.erase(it);
189
+ }
190
+ }
191
+ if (watcher != nullptr && cancel) watcher->Cancel();
192
+ }
193
+
194
+ int NumExternalConnectivityWatchers() const {
195
+ MutexLock lock(&external_watchers_mu_);
196
+ return static_cast<int>(external_watchers_.size());
197
+ }
198
+
199
+ void AddConnectivityWatcher(
200
+ grpc_connectivity_state initial_state,
201
+ OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher);
202
+ void RemoveConnectivityWatcher(
203
+ AsyncConnectivityStateWatcherInterface* watcher);
204
+
205
+ private:
206
+ class SubchannelWrapper;
207
+ class ClientChannelControlHelper;
208
+ class ConnectivityWatcherAdder;
209
+ class ConnectivityWatcherRemover;
210
+
211
+ // Represents a pending connectivity callback from an external caller
212
+ // via grpc_client_channel_watch_connectivity_state().
213
+ class ExternalConnectivityWatcher : public ConnectivityStateWatcherInterface {
214
+ public:
215
+ ExternalConnectivityWatcher(ChannelData* chand, grpc_polling_entity pollent,
216
+ grpc_connectivity_state* state,
217
+ grpc_closure* on_complete,
218
+ grpc_closure* watcher_timer_init);
219
+
220
+ ~ExternalConnectivityWatcher();
221
+
222
+ void Start();
223
+
224
+ void Notify(grpc_connectivity_state state) override;
225
+
226
+ void Cancel();
227
+
228
+ private:
229
+ void AddWatcherLocked();
230
+ void RemoveWatcherLocked();
231
+
232
+ ChannelData* chand_;
233
+ grpc_polling_entity pollent_;
234
+ grpc_connectivity_state initial_state_;
235
+ grpc_connectivity_state* state_;
236
+ grpc_closure* on_complete_;
237
+ grpc_closure* watcher_timer_init_;
238
+ Atomic<bool> done_{false};
239
+ };
240
+
241
+ ChannelData(grpc_channel_element_args* args, grpc_error** error);
242
+ ~ChannelData();
243
+
244
+ void UpdateStateAndPickerLocked(
245
+ grpc_connectivity_state state, const char* reason,
246
+ std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker);
247
+
248
+ void UpdateServiceConfigLocked(
249
+ RefCountedPtr<ServerRetryThrottleData> retry_throttle_data,
250
+ RefCountedPtr<ServiceConfig> service_config);
251
+
252
+ void CreateResolvingLoadBalancingPolicyLocked();
253
+
254
+ void DestroyResolvingLoadBalancingPolicyLocked();
255
+
256
+ static bool ProcessResolverResultLocked(
257
+ void* arg, const Resolver::Result& result,
258
+ RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config,
259
+ grpc_error** service_config_error, bool* no_valid_service_config);
260
+
261
+ grpc_error* DoPingLocked(grpc_transport_op* op);
262
+
263
+ void StartTransportOpLocked(grpc_transport_op* op);
264
+
265
+ void TryToConnectLocked();
266
+
267
+ void ProcessLbPolicy(
268
+ const Resolver::Result& resolver_result,
269
+ const internal::ClientChannelGlobalParsedConfig* parsed_service_config,
270
+ RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config);
271
+
272
+ //
273
+ // Fields set at construction and never modified.
274
+ //
275
+ const bool deadline_checking_enabled_;
276
+ const bool enable_retries_;
277
+ const size_t per_rpc_retry_buffer_size_;
278
+ grpc_channel_stack* owning_stack_;
279
+ ClientChannelFactory* client_channel_factory_;
280
+ const grpc_channel_args* channel_args_;
281
+ RefCountedPtr<ServiceConfig> default_service_config_;
282
+ grpc_core::UniquePtr<char> server_name_;
283
+ grpc_core::UniquePtr<char> target_uri_;
284
+ channelz::ChannelNode* channelz_node_;
285
+
286
+ //
287
+ // Fields used in the data plane. Guarded by data_plane_mu.
288
+ //
289
+ mutable Mutex data_plane_mu_;
290
+ std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker_;
291
+ QueuedPick* queued_picks_ = nullptr; // Linked list of queued picks.
292
+ // Data from service config.
293
+ bool received_service_config_data_ = false;
294
+ RefCountedPtr<ServerRetryThrottleData> retry_throttle_data_;
295
+ RefCountedPtr<ServiceConfig> service_config_;
296
+
297
+ //
298
+ // Fields used in the control plane. Guarded by work_serializer.
299
+ //
300
+ std::shared_ptr<WorkSerializer> work_serializer_;
301
+ grpc_pollset_set* interested_parties_;
302
+ RefCountedPtr<SubchannelPoolInterface> subchannel_pool_;
303
+ OrphanablePtr<ResolvingLoadBalancingPolicy> resolving_lb_policy_;
304
+ ConnectivityStateTracker state_tracker_;
305
+ grpc_core::UniquePtr<char> health_check_service_name_;
306
+ RefCountedPtr<ServiceConfig> saved_service_config_;
307
+ bool received_first_resolver_result_ = false;
308
+ // The number of SubchannelWrapper instances referencing a given Subchannel.
309
+ std::map<Subchannel*, int> subchannel_refcount_map_;
310
+ // The set of SubchannelWrappers that currently exist.
311
+ // No need to hold a ref, since the map is updated in the control-plane
312
+ // work_serializer when the SubchannelWrappers are created and destroyed.
313
+ std::set<SubchannelWrapper*> subchannel_wrappers_;
314
+ // Pending ConnectedSubchannel updates for each SubchannelWrapper.
315
+ // Updates are queued here in the control plane work_serializer and then
316
+ // applied in the data plane mutex when the picker is updated.
317
+ std::map<RefCountedPtr<SubchannelWrapper>, RefCountedPtr<ConnectedSubchannel>>
318
+ pending_subchannel_updates_;
319
+
320
+ //
321
+ // Fields accessed from both data plane mutex and control plane
322
+ // work_serializer.
323
+ //
324
+ Atomic<grpc_error*> disconnect_error_;
325
+
326
+ //
327
+ // Fields guarded by a mutex, since they need to be accessed
328
+ // synchronously via get_channel_info().
329
+ //
330
+ gpr_mu info_mu_;
331
+ grpc_core::UniquePtr<char> info_lb_policy_name_;
332
+ grpc_core::UniquePtr<char> info_service_config_json_;
333
+
334
+ //
335
+ // Fields guarded by a mutex, since they need to be accessed
336
+ // synchronously via grpc_channel_num_external_connectivity_watchers().
337
+ //
338
+ mutable Mutex external_watchers_mu_;
339
+ std::map<grpc_closure*, ExternalConnectivityWatcher*> external_watchers_;
340
+ };
341
+
342
+ //
343
+ // CallData definition
344
+ //
345
+
346
+ class CallData {
347
+ public:
348
+ static grpc_error* Init(grpc_call_element* elem,
349
+ const grpc_call_element_args* args);
350
+ static void Destroy(grpc_call_element* elem,
351
+ const grpc_call_final_info* final_info,
352
+ grpc_closure* then_schedule_closure);
353
+ static void StartTransportStreamOpBatch(
354
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch);
355
+ static void SetPollent(grpc_call_element* elem, grpc_polling_entity* pollent);
356
+
357
+ RefCountedPtr<SubchannelCall> subchannel_call() { return subchannel_call_; }
358
+
359
+ // Invoked by channel for queued picks once resolver results are available.
360
+ void MaybeApplyServiceConfigToCallLocked(grpc_call_element* elem);
361
+
362
+ // Invoked by channel for queued picks when the picker is updated.
363
+ static void PickSubchannel(void* arg, grpc_error* error);
364
+
365
+ // Helper function for performing a pick while holding the data plane
366
+ // mutex. Returns true if the pick is complete, in which case the caller
367
+ // must invoke PickDone() or AsyncPickDone() with the returned error.
368
+ bool PickSubchannelLocked(grpc_call_element* elem, grpc_error** error);
369
+
370
+ // Schedules a callback to process the completed pick. The callback
371
+ // will not run until after this method returns.
372
+ void AsyncPickDone(grpc_call_element* elem, grpc_error* error);
373
+
374
+ private:
375
+ class QueuedPickCanceller;
376
+
377
+ class Metadata : public LoadBalancingPolicy::MetadataInterface {
378
+ public:
379
+ Metadata(CallData* calld, grpc_metadata_batch* batch)
380
+ : calld_(calld), batch_(batch) {}
381
+
382
+ void Add(absl::string_view key, absl::string_view value) override {
383
+ grpc_linked_mdelem* linked_mdelem = static_cast<grpc_linked_mdelem*>(
384
+ calld_->arena_->Alloc(sizeof(grpc_linked_mdelem)));
385
+ linked_mdelem->md = grpc_mdelem_from_slices(
386
+ grpc_core::ExternallyManagedSlice(key.data(), key.size()),
387
+ grpc_core::ExternallyManagedSlice(value.data(), value.size()));
388
+ GPR_ASSERT(grpc_metadata_batch_link_tail(batch_, linked_mdelem) ==
389
+ GRPC_ERROR_NONE);
390
+ }
391
+
392
+ iterator begin() const override {
393
+ static_assert(sizeof(grpc_linked_mdelem*) <= sizeof(intptr_t),
394
+ "iterator size too large");
395
+ return iterator(this, reinterpret_cast<intptr_t>(batch_->list.head));
396
+ }
397
+ iterator end() const override {
398
+ static_assert(sizeof(grpc_linked_mdelem*) <= sizeof(intptr_t),
399
+ "iterator size too large");
400
+ return iterator(this, 0);
401
+ }
402
+
403
+ iterator erase(iterator it) override {
404
+ grpc_linked_mdelem* linked_mdelem =
405
+ reinterpret_cast<grpc_linked_mdelem*>(GetIteratorHandle(it));
406
+ intptr_t handle = reinterpret_cast<intptr_t>(linked_mdelem->next);
407
+ grpc_metadata_batch_remove(batch_, linked_mdelem);
408
+ return iterator(this, handle);
409
+ }
410
+
411
+ private:
412
+ intptr_t IteratorHandleNext(intptr_t handle) const override {
413
+ grpc_linked_mdelem* linked_mdelem =
414
+ reinterpret_cast<grpc_linked_mdelem*>(handle);
415
+ return reinterpret_cast<intptr_t>(linked_mdelem->next);
416
+ }
417
+ std::pair<absl::string_view, absl::string_view> IteratorHandleGet(
418
+ intptr_t handle) const override {
419
+ grpc_linked_mdelem* linked_mdelem =
420
+ reinterpret_cast<grpc_linked_mdelem*>(handle);
421
+ return std::make_pair(
422
+ StringViewFromSlice(GRPC_MDKEY(linked_mdelem->md)),
423
+ StringViewFromSlice(GRPC_MDVALUE(linked_mdelem->md)));
424
+ }
425
+
426
+ CallData* calld_;
427
+ grpc_metadata_batch* batch_;
428
+ };
429
+
430
+ class LbCallState : public LoadBalancingPolicy::CallState {
431
+ public:
432
+ explicit LbCallState(CallData* calld) : calld_(calld) {}
433
+
434
+ void* Alloc(size_t size) override { return calld_->arena_->Alloc(size); }
435
+
436
+ const LoadBalancingPolicy::BackendMetricData* GetBackendMetricData()
437
+ override {
438
+ if (calld_->backend_metric_data_ == nullptr) {
439
+ grpc_linked_mdelem* md = calld_->recv_trailing_metadata_->idx.named
440
+ .x_endpoint_load_metrics_bin;
441
+ if (md != nullptr) {
442
+ calld_->backend_metric_data_ =
443
+ ParseBackendMetricData(GRPC_MDVALUE(md->md), calld_->arena_);
444
+ }
445
+ }
446
+ return calld_->backend_metric_data_;
447
+ }
448
+
449
+ absl::string_view ExperimentalGetCallAttribute(const char* key) override {
450
+ auto it = calld_->call_attributes_.find(key);
451
+ if (it == calld_->call_attributes_.end()) return absl::string_view();
452
+ return it->second;
453
+ }
454
+
455
+ private:
456
+ CallData* calld_;
457
+ };
458
+
459
+ // State used for starting a retryable batch on a subchannel call.
460
+ // This provides its own grpc_transport_stream_op_batch and other data
461
+ // structures needed to populate the ops in the batch.
462
+ // We allocate one struct on the arena for each attempt at starting a
463
+ // batch on a given subchannel call.
464
+ struct SubchannelCallBatchData {
465
+ // Creates a SubchannelCallBatchData object on the call's arena with the
466
+ // specified refcount. If set_on_complete is true, the batch's
467
+ // on_complete callback will be set to point to on_complete();
468
+ // otherwise, the batch's on_complete callback will be null.
469
+ static SubchannelCallBatchData* Create(grpc_call_element* elem,
470
+ int refcount, bool set_on_complete);
471
+
472
+ void Unref() {
473
+ if (gpr_unref(&refs)) Destroy();
474
+ }
475
+
476
+ SubchannelCallBatchData(grpc_call_element* elem, CallData* calld,
477
+ int refcount, bool set_on_complete);
478
+ // All dtor code must be added in `Destroy()`. This is because we may
479
+ // call closures in `SubchannelCallBatchData` after they are unrefed by
480
+ // `Unref()`, and msan would complain about accessing this class
481
+ // after calling dtor. As a result we cannot call the `dtor` in `Unref()`.
482
+ // TODO(soheil): We should try to call the dtor in `Unref()`.
483
+ ~SubchannelCallBatchData() { Destroy(); }
484
+ void Destroy();
485
+
486
+ gpr_refcount refs;
487
+ grpc_call_element* elem;
488
+ RefCountedPtr<SubchannelCall> subchannel_call;
489
+ // The batch to use in the subchannel call.
490
+ // Its payload field points to SubchannelCallRetryState::batch_payload.
491
+ grpc_transport_stream_op_batch batch;
492
+ // For intercepting on_complete.
493
+ grpc_closure on_complete;
494
+ };
495
+
496
+ // Retry state associated with a subchannel call.
497
+ // Stored in the parent_data of the subchannel call object.
498
+ struct SubchannelCallRetryState {
499
+ explicit SubchannelCallRetryState(grpc_call_context_element* context)
500
+ : batch_payload(context),
501
+ started_send_initial_metadata(false),
502
+ completed_send_initial_metadata(false),
503
+ started_send_trailing_metadata(false),
504
+ completed_send_trailing_metadata(false),
505
+ started_recv_initial_metadata(false),
506
+ completed_recv_initial_metadata(false),
507
+ started_recv_trailing_metadata(false),
508
+ completed_recv_trailing_metadata(false),
509
+ retry_dispatched(false) {}
510
+
511
+ // SubchannelCallBatchData.batch.payload points to this.
512
+ grpc_transport_stream_op_batch_payload batch_payload;
513
+ // For send_initial_metadata.
514
+ // Note that we need to make a copy of the initial metadata for each
515
+ // subchannel call instead of just referring to the copy in call_data,
516
+ // because filters in the subchannel stack will probably add entries,
517
+ // so we need to start in a pristine state for each attempt of the call.
518
+ grpc_linked_mdelem* send_initial_metadata_storage;
519
+ grpc_metadata_batch send_initial_metadata;
520
+ // For send_message.
521
+ // TODO(roth): Restructure this to eliminate use of ManualConstructor.
522
+ ManualConstructor<ByteStreamCache::CachingByteStream> send_message;
523
+ // For send_trailing_metadata.
524
+ grpc_linked_mdelem* send_trailing_metadata_storage;
525
+ grpc_metadata_batch send_trailing_metadata;
526
+ // For intercepting recv_initial_metadata.
527
+ grpc_metadata_batch recv_initial_metadata;
528
+ grpc_closure recv_initial_metadata_ready;
529
+ bool trailing_metadata_available = false;
530
+ // For intercepting recv_message.
531
+ grpc_closure recv_message_ready;
532
+ OrphanablePtr<ByteStream> recv_message;
533
+ // For intercepting recv_trailing_metadata.
534
+ grpc_metadata_batch recv_trailing_metadata;
535
+ grpc_transport_stream_stats collect_stats;
536
+ grpc_closure recv_trailing_metadata_ready;
537
+ // These fields indicate which ops have been started and completed on
538
+ // this subchannel call.
539
+ size_t started_send_message_count = 0;
540
+ size_t completed_send_message_count = 0;
541
+ size_t started_recv_message_count = 0;
542
+ size_t completed_recv_message_count = 0;
543
+ bool started_send_initial_metadata : 1;
544
+ bool completed_send_initial_metadata : 1;
545
+ bool started_send_trailing_metadata : 1;
546
+ bool completed_send_trailing_metadata : 1;
547
+ bool started_recv_initial_metadata : 1;
548
+ bool completed_recv_initial_metadata : 1;
549
+ bool started_recv_trailing_metadata : 1;
550
+ bool completed_recv_trailing_metadata : 1;
551
+ // State for callback processing.
552
+ SubchannelCallBatchData* recv_initial_metadata_ready_deferred_batch =
553
+ nullptr;
554
+ grpc_error* recv_initial_metadata_error = GRPC_ERROR_NONE;
555
+ SubchannelCallBatchData* recv_message_ready_deferred_batch = nullptr;
556
+ grpc_error* recv_message_error = GRPC_ERROR_NONE;
557
+ SubchannelCallBatchData* recv_trailing_metadata_internal_batch = nullptr;
558
+ // NOTE: Do not move this next to the metadata bitfields above. That would
559
+ // save space but will also result in a data race because compiler
560
+ // will generate a 2 byte store which overwrites the meta-data
561
+ // fields upon setting this field.
562
+ bool retry_dispatched : 1;
563
+ };
564
+
565
+ // Pending batches stored in call data.
566
+ struct PendingBatch {
567
+ // The pending batch. If nullptr, this slot is empty.
568
+ grpc_transport_stream_op_batch* batch;
569
+ // Indicates whether payload for send ops has been cached in CallData.
570
+ bool send_ops_cached;
571
+ };
572
+
573
+ CallData(grpc_call_element* elem, const ChannelData& chand,
574
+ const grpc_call_element_args& args);
575
+ ~CallData();
576
+
577
+ // Caches data for send ops so that it can be retried later, if not
578
+ // already cached.
579
+ void MaybeCacheSendOpsForBatch(PendingBatch* pending);
580
+ void FreeCachedSendInitialMetadata(ChannelData* chand);
581
+ // Frees cached send_message at index idx.
582
+ void FreeCachedSendMessage(ChannelData* chand, size_t idx);
583
+ void FreeCachedSendTrailingMetadata(ChannelData* chand);
584
+ // Frees cached send ops that have already been completed after
585
+ // committing the call.
586
+ void FreeCachedSendOpDataAfterCommit(grpc_call_element* elem,
587
+ SubchannelCallRetryState* retry_state);
588
+ // Frees cached send ops that were completed by the completed batch in
589
+ // batch_data. Used when batches are completed after the call is committed.
590
+ void FreeCachedSendOpDataForCompletedBatch(
591
+ grpc_call_element* elem, SubchannelCallBatchData* batch_data,
592
+ SubchannelCallRetryState* retry_state);
593
+
594
+ static void RecvTrailingMetadataReadyForLoadBalancingPolicy(
595
+ void* arg, grpc_error* error);
596
+ void MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(
597
+ grpc_transport_stream_op_batch* batch);
598
+
599
+ // Returns the index into pending_batches_ to be used for batch.
600
+ static size_t GetBatchIndex(grpc_transport_stream_op_batch* batch);
601
+ void PendingBatchesAdd(grpc_call_element* elem,
602
+ grpc_transport_stream_op_batch* batch);
603
+ void PendingBatchClear(PendingBatch* pending);
604
+ void MaybeClearPendingBatch(grpc_call_element* elem, PendingBatch* pending);
605
+ static void FailPendingBatchInCallCombiner(void* arg, grpc_error* error);
606
+ // A predicate type and some useful implementations for PendingBatchesFail().
607
+ typedef bool (*YieldCallCombinerPredicate)(
608
+ const CallCombinerClosureList& closures);
609
+ static bool YieldCallCombiner(const CallCombinerClosureList& /*closures*/) {
610
+ return true;
611
+ }
612
+ static bool NoYieldCallCombiner(const CallCombinerClosureList& /*closures*/) {
613
+ return false;
614
+ }
615
+ static bool YieldCallCombinerIfPendingBatchesFound(
616
+ const CallCombinerClosureList& closures) {
617
+ return closures.size() > 0;
618
+ }
619
+ // Fails all pending batches.
620
+ // If yield_call_combiner_predicate returns true, assumes responsibility for
621
+ // yielding the call combiner.
622
+ void PendingBatchesFail(
623
+ grpc_call_element* elem, grpc_error* error,
624
+ YieldCallCombinerPredicate yield_call_combiner_predicate);
625
+ static void ResumePendingBatchInCallCombiner(void* arg, grpc_error* ignored);
626
+ // Resumes all pending batches on subchannel_call_.
627
+ void PendingBatchesResume(grpc_call_element* elem);
628
+ // Returns a pointer to the first pending batch for which predicate(batch)
629
+ // returns true, or null if not found.
630
+ template <typename Predicate>
631
+ PendingBatch* PendingBatchFind(grpc_call_element* elem,
632
+ const char* log_message, Predicate predicate);
633
+
634
+ // Commits the call so that no further retry attempts will be performed.
635
+ void RetryCommit(grpc_call_element* elem,
636
+ SubchannelCallRetryState* retry_state);
637
+ // Starts a retry after appropriate back-off.
638
+ void DoRetry(grpc_call_element* elem, SubchannelCallRetryState* retry_state,
639
+ grpc_millis server_pushback_ms);
640
+ // Returns true if the call is being retried.
641
+ bool MaybeRetry(grpc_call_element* elem, SubchannelCallBatchData* batch_data,
642
+ grpc_status_code status, grpc_mdelem* server_pushback_md);
643
+
644
+ // Invokes recv_initial_metadata_ready for a subchannel batch.
645
+ static void InvokeRecvInitialMetadataCallback(void* arg, grpc_error* error);
646
+ // Intercepts recv_initial_metadata_ready callback for retries.
647
+ // Commits the call and returns the initial metadata up the stack.
648
+ static void RecvInitialMetadataReady(void* arg, grpc_error* error);
649
+
650
+ // Invokes recv_message_ready for a subchannel batch.
651
+ static void InvokeRecvMessageCallback(void* arg, grpc_error* error);
652
+ // Intercepts recv_message_ready callback for retries.
653
+ // Commits the call and returns the message up the stack.
654
+ static void RecvMessageReady(void* arg, grpc_error* error);
655
+
656
+ // Sets *status and *server_pushback_md based on md_batch and error.
657
+ // Only sets *server_pushback_md if server_pushback_md != nullptr.
658
+ void GetCallStatus(grpc_metadata_batch* md_batch, grpc_error* error,
659
+ grpc_status_code* status,
660
+ grpc_mdelem** server_pushback_md);
661
+ // Adds recv_trailing_metadata_ready closure to closures.
662
+ void AddClosureForRecvTrailingMetadataReady(
663
+ grpc_call_element* elem, SubchannelCallBatchData* batch_data,
664
+ grpc_error* error, CallCombinerClosureList* closures);
665
+ // Adds any necessary closures for deferred recv_initial_metadata and
666
+ // recv_message callbacks to closures.
667
+ static void AddClosuresForDeferredRecvCallbacks(
668
+ SubchannelCallBatchData* batch_data,
669
+ SubchannelCallRetryState* retry_state, CallCombinerClosureList* closures);
670
+ // Returns true if any op in the batch was not yet started.
671
+ // Only looks at send ops, since recv ops are always started immediately.
672
+ bool PendingBatchIsUnstarted(PendingBatch* pending,
673
+ SubchannelCallRetryState* retry_state);
674
+ // For any pending batch containing an op that has not yet been started,
675
+ // adds the pending batch's completion closures to closures.
676
+ void AddClosuresToFailUnstartedPendingBatches(
677
+ grpc_call_element* elem, SubchannelCallRetryState* retry_state,
678
+ grpc_error* error, CallCombinerClosureList* closures);
679
+ // Runs necessary closures upon completion of a call attempt.
680
+ void RunClosuresForCompletedCall(SubchannelCallBatchData* batch_data,
681
+ grpc_error* error);
682
+ // Intercepts recv_trailing_metadata_ready callback for retries.
683
+ // Commits the call and returns the trailing metadata up the stack.
684
+ static void RecvTrailingMetadataReady(void* arg, grpc_error* error);
685
+
686
+ // Adds the on_complete closure for the pending batch completed in
687
+ // batch_data to closures.
688
+ void AddClosuresForCompletedPendingBatch(grpc_call_element* elem,
689
+ SubchannelCallBatchData* batch_data,
690
+ grpc_error* error,
691
+ CallCombinerClosureList* closures);
692
+
693
+ // If there are any cached ops to replay or pending ops to start on the
694
+ // subchannel call, adds a closure to closures to invoke
695
+ // StartRetriableSubchannelBatches().
696
+ void AddClosuresForReplayOrPendingSendOps(
697
+ grpc_call_element* elem, SubchannelCallBatchData* batch_data,
698
+ SubchannelCallRetryState* retry_state, CallCombinerClosureList* closures);
699
+
700
+ // Callback used to intercept on_complete from subchannel calls.
701
+ // Called only when retries are enabled.
702
+ static void OnComplete(void* arg, grpc_error* error);
703
+
704
+ static void StartBatchInCallCombiner(void* arg, grpc_error* ignored);
705
+ // Adds a closure to closures that will execute batch in the call combiner.
706
+ void AddClosureForSubchannelBatch(grpc_call_element* elem,
707
+ grpc_transport_stream_op_batch* batch,
708
+ CallCombinerClosureList* closures);
709
+ // Adds retriable send_initial_metadata op to batch_data.
710
+ void AddRetriableSendInitialMetadataOp(SubchannelCallRetryState* retry_state,
711
+ SubchannelCallBatchData* batch_data);
712
+ // Adds retriable send_message op to batch_data.
713
+ void AddRetriableSendMessageOp(grpc_call_element* elem,
714
+ SubchannelCallRetryState* retry_state,
715
+ SubchannelCallBatchData* batch_data);
716
+ // Adds retriable send_trailing_metadata op to batch_data.
717
+ void AddRetriableSendTrailingMetadataOp(SubchannelCallRetryState* retry_state,
718
+ SubchannelCallBatchData* batch_data);
719
+ // Adds retriable recv_initial_metadata op to batch_data.
720
+ void AddRetriableRecvInitialMetadataOp(SubchannelCallRetryState* retry_state,
721
+ SubchannelCallBatchData* batch_data);
722
+ // Adds retriable recv_message op to batch_data.
723
+ void AddRetriableRecvMessageOp(SubchannelCallRetryState* retry_state,
724
+ SubchannelCallBatchData* batch_data);
725
+ // Adds retriable recv_trailing_metadata op to batch_data.
726
+ void AddRetriableRecvTrailingMetadataOp(SubchannelCallRetryState* retry_state,
727
+ SubchannelCallBatchData* batch_data);
728
+ // Helper function used to start a recv_trailing_metadata batch. This
729
+ // is used in the case where a recv_initial_metadata or recv_message
730
+ // op fails in a way that we know the call is over but when the application
731
+ // has not yet started its own recv_trailing_metadata op.
732
+ void StartInternalRecvTrailingMetadata(grpc_call_element* elem);
733
+ // If there are any cached send ops that need to be replayed on the
734
+ // current subchannel call, creates and returns a new subchannel batch
735
+ // to replay those ops. Otherwise, returns nullptr.
736
+ SubchannelCallBatchData* MaybeCreateSubchannelBatchForReplay(
737
+ grpc_call_element* elem, SubchannelCallRetryState* retry_state);
738
+ // Adds subchannel batches for pending batches to closures.
739
+ void AddSubchannelBatchesForPendingBatches(
740
+ grpc_call_element* elem, SubchannelCallRetryState* retry_state,
741
+ CallCombinerClosureList* closures);
742
+ // Constructs and starts whatever subchannel batches are needed on the
743
+ // subchannel call.
744
+ static void StartRetriableSubchannelBatches(void* arg, grpc_error* ignored);
745
+
746
+ void CreateSubchannelCall(grpc_call_element* elem);
747
+ // Invoked when a pick is completed, on both success or failure.
748
+ static void PickDone(void* arg, grpc_error* error);
749
+ // Removes the call from the channel's list of queued picks.
750
+ void RemoveCallFromQueuedPicksLocked(grpc_call_element* elem);
751
+ // Adds the call to the channel's list of queued picks.
752
+ void AddCallToQueuedPicksLocked(grpc_call_element* elem);
753
+ // Applies service config to the call. Must be invoked once we know
754
+ // that the resolver has returned results to the channel.
755
+ void ApplyServiceConfigToCallLocked(grpc_call_element* elem);
756
+
757
+ // State for handling deadlines.
758
+ // The code in deadline_filter.c requires this to be the first field.
759
+ // TODO(roth): This is slightly sub-optimal in that grpc_deadline_state
760
+ // and this struct both independently store pointers to the call stack
761
+ // and call combiner. If/when we have time, find a way to avoid this
762
+ // without breaking the grpc_deadline_state abstraction.
763
+ grpc_deadline_state deadline_state_;
764
+
765
+ grpc_slice path_; // Request path.
766
+ gpr_cycle_counter call_start_time_;
767
+ grpc_millis deadline_;
768
+ Arena* arena_;
769
+ grpc_call_stack* owning_call_;
770
+ CallCombiner* call_combiner_;
771
+ grpc_call_context_element* call_context_;
772
+
773
+ RefCountedPtr<ServerRetryThrottleData> retry_throttle_data_;
774
+ const ClientChannelMethodParsedConfig* method_params_ = nullptr;
775
+ std::map<const char*, absl::string_view> call_attributes_;
776
+
777
+ RefCountedPtr<SubchannelCall> subchannel_call_;
778
+
779
+ // Set when we get a cancel_stream op.
780
+ grpc_error* cancel_error_ = GRPC_ERROR_NONE;
781
+
782
+ ChannelData::QueuedPick pick_;
783
+ bool pick_queued_ = false;
784
+ bool service_config_applied_ = false;
785
+ QueuedPickCanceller* pick_canceller_ = nullptr;
786
+ LbCallState lb_call_state_;
787
+ const LoadBalancingPolicy::BackendMetricData* backend_metric_data_ = nullptr;
788
+ RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
789
+ std::function<void(grpc_error*, LoadBalancingPolicy::MetadataInterface*,
790
+ LoadBalancingPolicy::CallState*)>
791
+ lb_recv_trailing_metadata_ready_;
792
+ grpc_closure pick_closure_;
793
+
794
+ // For intercepting recv_trailing_metadata_ready for the LB policy.
795
+ grpc_metadata_batch* recv_trailing_metadata_ = nullptr;
796
+ grpc_closure recv_trailing_metadata_ready_;
797
+ grpc_closure* original_recv_trailing_metadata_ready_ = nullptr;
798
+
799
+ grpc_polling_entity* pollent_ = nullptr;
800
+
801
+ // Batches are added to this list when received from above.
802
+ // They are removed when we are done handling the batch (i.e., when
803
+ // either we have invoked all of the batch's callbacks or we have
804
+ // passed the batch down to the subchannel call and are not
805
+ // intercepting any of its callbacks).
806
+ PendingBatch pending_batches_[MAX_PENDING_BATCHES] = {};
807
+ bool pending_send_initial_metadata_ : 1;
808
+ bool pending_send_message_ : 1;
809
+ bool pending_send_trailing_metadata_ : 1;
810
+
811
+ // Retry state.
812
+ bool enable_retries_ : 1;
813
+ bool retry_committed_ : 1;
814
+ bool last_attempt_got_server_pushback_ : 1;
815
+ int num_attempts_completed_ = 0;
816
+ size_t bytes_buffered_for_retry_ = 0;
817
+ // TODO(roth): Restructure this to eliminate use of ManualConstructor.
818
+ ManualConstructor<BackOff> retry_backoff_;
819
+ grpc_timer retry_timer_;
820
+
821
+ // The number of pending retriable subchannel batches containing send ops.
822
+ // We hold a ref to the call stack while this is non-zero, since replay
823
+ // batches may not complete until after all callbacks have been returned
824
+ // to the surface, and we need to make sure that the call is not destroyed
825
+ // until all of these batches have completed.
826
+ // Note that we actually only need to track replay batches, but it's
827
+ // easier to track all batches with send ops.
828
+ int num_pending_retriable_subchannel_send_batches_ = 0;
829
+
830
+ // Cached data for retrying send ops.
831
+ // send_initial_metadata
832
+ bool seen_send_initial_metadata_ = false;
833
+ grpc_linked_mdelem* send_initial_metadata_storage_ = nullptr;
834
+ grpc_metadata_batch send_initial_metadata_;
835
+ uint32_t send_initial_metadata_flags_;
836
+ gpr_atm* peer_string_;
837
+ // send_message
838
+ // When we get a send_message op, we replace the original byte stream
839
+ // with a CachingByteStream that caches the slices to a local buffer for
840
+ // use in retries.
841
+ // Note: We inline the cache for the first 3 send_message ops and use
842
+ // dynamic allocation after that. This number was essentially picked
843
+ // at random; it could be changed in the future to tune performance.
844
+ absl::InlinedVector<ByteStreamCache*, 3> send_messages_;
845
+ // send_trailing_metadata
846
+ bool seen_send_trailing_metadata_ = false;
847
+ grpc_linked_mdelem* send_trailing_metadata_storage_ = nullptr;
848
+ grpc_metadata_batch send_trailing_metadata_;
849
+ };
850
+
851
+ //
852
+ // ChannelData::SubchannelWrapper
853
+ //
854
+
855
+ // This class is a wrapper for Subchannel that hides details of the
856
+ // channel's implementation (such as the health check service name and
857
+ // connected subchannel) from the LB policy API.
858
+ //
859
+ // Note that no synchronization is needed here, because even if the
860
+ // underlying subchannel is shared between channels, this wrapper will only
861
+ // be used within one channel, so it will always be synchronized by the
862
+ // control plane work_serializer.
863
+ class ChannelData::SubchannelWrapper : public SubchannelInterface {
864
+ public:
865
+ SubchannelWrapper(ChannelData* chand, Subchannel* subchannel,
866
+ grpc_core::UniquePtr<char> health_check_service_name)
867
+ : SubchannelInterface(&grpc_client_channel_routing_trace),
868
+ chand_(chand),
869
+ subchannel_(subchannel),
870
+ health_check_service_name_(std::move(health_check_service_name)) {
871
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
872
+ gpr_log(GPR_INFO,
873
+ "chand=%p: creating subchannel wrapper %p for subchannel %p",
874
+ chand, this, subchannel_);
875
+ }
876
+ GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "SubchannelWrapper");
877
+ auto* subchannel_node = subchannel_->channelz_node();
878
+ if (subchannel_node != nullptr) {
879
+ auto it = chand_->subchannel_refcount_map_.find(subchannel_);
880
+ if (it == chand_->subchannel_refcount_map_.end()) {
881
+ chand_->channelz_node_->AddChildSubchannel(subchannel_node->uuid());
882
+ it = chand_->subchannel_refcount_map_.emplace(subchannel_, 0).first;
883
+ }
884
+ ++it->second;
885
+ }
886
+ chand_->subchannel_wrappers_.insert(this);
887
+ }
888
+
889
+ ~SubchannelWrapper() {
890
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
891
+ gpr_log(GPR_INFO,
892
+ "chand=%p: destroying subchannel wrapper %p for subchannel %p",
893
+ chand_, this, subchannel_);
894
+ }
895
+ chand_->subchannel_wrappers_.erase(this);
896
+ auto* subchannel_node = subchannel_->channelz_node();
897
+ if (subchannel_node != nullptr) {
898
+ auto it = chand_->subchannel_refcount_map_.find(subchannel_);
899
+ GPR_ASSERT(it != chand_->subchannel_refcount_map_.end());
900
+ --it->second;
901
+ if (it->second == 0) {
902
+ chand_->channelz_node_->RemoveChildSubchannel(subchannel_node->uuid());
903
+ chand_->subchannel_refcount_map_.erase(it);
904
+ }
905
+ }
906
+ GRPC_SUBCHANNEL_UNREF(subchannel_, "unref from LB");
907
+ GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "SubchannelWrapper");
908
+ }
909
+
910
+ grpc_connectivity_state CheckConnectivityState() override {
911
+ RefCountedPtr<ConnectedSubchannel> connected_subchannel;
912
+ grpc_connectivity_state connectivity_state =
913
+ subchannel_->CheckConnectivityState(health_check_service_name_.get(),
914
+ &connected_subchannel);
915
+ MaybeUpdateConnectedSubchannel(std::move(connected_subchannel));
916
+ return connectivity_state;
917
+ }
918
+
919
+ void WatchConnectivityState(
920
+ grpc_connectivity_state initial_state,
921
+ std::unique_ptr<ConnectivityStateWatcherInterface> watcher) override {
922
+ auto& watcher_wrapper = watcher_map_[watcher.get()];
923
+ GPR_ASSERT(watcher_wrapper == nullptr);
924
+ watcher_wrapper = new WatcherWrapper(std::move(watcher),
925
+ Ref(DEBUG_LOCATION, "WatcherWrapper"),
926
+ initial_state);
927
+ subchannel_->WatchConnectivityState(
928
+ initial_state,
929
+ grpc_core::UniquePtr<char>(
930
+ gpr_strdup(health_check_service_name_.get())),
931
+ RefCountedPtr<Subchannel::ConnectivityStateWatcherInterface>(
932
+ watcher_wrapper));
933
+ }
934
+
935
+ void CancelConnectivityStateWatch(
936
+ ConnectivityStateWatcherInterface* watcher) override {
937
+ auto it = watcher_map_.find(watcher);
938
+ GPR_ASSERT(it != watcher_map_.end());
939
+ subchannel_->CancelConnectivityStateWatch(health_check_service_name_.get(),
940
+ it->second);
941
+ watcher_map_.erase(it);
942
+ }
943
+
944
+ void AttemptToConnect() override { subchannel_->AttemptToConnect(); }
945
+
946
+ void ResetBackoff() override { subchannel_->ResetBackoff(); }
947
+
948
+ const grpc_channel_args* channel_args() override {
949
+ return subchannel_->channel_args();
950
+ }
951
+
952
+ void UpdateHealthCheckServiceName(
953
+ grpc_core::UniquePtr<char> health_check_service_name) {
954
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
955
+ gpr_log(GPR_INFO,
956
+ "chand=%p: subchannel wrapper %p: updating health check service "
957
+ "name from \"%s\" to \"%s\"",
958
+ chand_, this, health_check_service_name_.get(),
959
+ health_check_service_name.get());
960
+ }
961
+ for (auto& p : watcher_map_) {
962
+ WatcherWrapper*& watcher_wrapper = p.second;
963
+ // Cancel the current watcher and create a new one using the new
964
+ // health check service name.
965
+ // TODO(roth): If there is not already an existing health watch
966
+ // call for the new name, then the watcher will initially report
967
+ // state CONNECTING. If the LB policy is currently reporting
968
+ // state READY, this may cause it to switch to CONNECTING before
969
+ // switching back to READY. This could cause a small delay for
970
+ // RPCs being started on the channel. If/when this becomes a
971
+ // problem, we may be able to handle it by waiting for the new
972
+ // watcher to report READY before we use it to replace the old one.
973
+ WatcherWrapper* replacement = watcher_wrapper->MakeReplacement();
974
+ subchannel_->CancelConnectivityStateWatch(
975
+ health_check_service_name_.get(), watcher_wrapper);
976
+ watcher_wrapper = replacement;
977
+ subchannel_->WatchConnectivityState(
978
+ replacement->last_seen_state(),
979
+ grpc_core::UniquePtr<char>(
980
+ gpr_strdup(health_check_service_name.get())),
981
+ RefCountedPtr<Subchannel::ConnectivityStateWatcherInterface>(
982
+ replacement));
983
+ }
984
+ // Save the new health check service name.
985
+ health_check_service_name_ = std::move(health_check_service_name);
986
+ }
987
+
988
+ // Caller must be holding the control-plane work_serializer.
989
+ ConnectedSubchannel* connected_subchannel() const {
990
+ return connected_subchannel_.get();
991
+ }
992
+
993
+ // Caller must be holding the data-plane mutex.
994
+ ConnectedSubchannel* connected_subchannel_in_data_plane() const {
995
+ return connected_subchannel_in_data_plane_.get();
996
+ }
997
+ void set_connected_subchannel_in_data_plane(
998
+ RefCountedPtr<ConnectedSubchannel> connected_subchannel) {
999
+ connected_subchannel_in_data_plane_ = std::move(connected_subchannel);
1000
+ }
1001
+
1002
+ private:
1003
+ // Subchannel and SubchannelInterface have different interfaces for
1004
+ // their respective ConnectivityStateWatcherInterface classes.
1005
+ // The one in Subchannel updates the ConnectedSubchannel along with
1006
+ // the state, whereas the one in SubchannelInterface does not expose
1007
+ // the ConnectedSubchannel.
1008
+ //
1009
+ // This wrapper provides a bridge between the two. It implements
1010
+ // Subchannel::ConnectivityStateWatcherInterface and wraps
1011
+ // the instance of SubchannelInterface::ConnectivityStateWatcherInterface
1012
+ // that was passed in by the LB policy. We pass an instance of this
1013
+ // class to the underlying Subchannel, and when we get updates from
1014
+ // the subchannel, we pass those on to the wrapped watcher to return
1015
+ // the update to the LB policy. This allows us to set the connected
1016
+ // subchannel before passing the result back to the LB policy.
1017
+ class WatcherWrapper : public Subchannel::ConnectivityStateWatcherInterface {
1018
+ public:
1019
+ WatcherWrapper(
1020
+ std::unique_ptr<SubchannelInterface::ConnectivityStateWatcherInterface>
1021
+ watcher,
1022
+ RefCountedPtr<SubchannelWrapper> parent,
1023
+ grpc_connectivity_state initial_state)
1024
+ : watcher_(std::move(watcher)),
1025
+ parent_(std::move(parent)),
1026
+ last_seen_state_(initial_state) {}
1027
+
1028
+ ~WatcherWrapper() {
1029
+ auto* parent = parent_.release(); // ref owned by lambda
1030
+ parent->chand_->work_serializer_->Run(
1031
+ [parent]() { parent->Unref(DEBUG_LOCATION, "WatcherWrapper"); },
1032
+ DEBUG_LOCATION);
1033
+ }
1034
+
1035
+ void OnConnectivityStateChange() override {
1036
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1037
+ gpr_log(GPR_INFO,
1038
+ "chand=%p: connectivity change for subchannel wrapper %p "
1039
+ "subchannel %p; hopping into work_serializer",
1040
+ parent_->chand_, parent_.get(), parent_->subchannel_);
1041
+ }
1042
+ Ref().release(); // ref owned by lambda
1043
+ parent_->chand_->work_serializer_->Run(
1044
+ [this]() {
1045
+ ApplyUpdateInControlPlaneWorkSerializer();
1046
+ Unref();
1047
+ },
1048
+ DEBUG_LOCATION);
1049
+ }
1050
+
1051
+ grpc_pollset_set* interested_parties() override {
1052
+ SubchannelInterface::ConnectivityStateWatcherInterface* watcher =
1053
+ watcher_.get();
1054
+ if (watcher_ == nullptr) watcher = replacement_->watcher_.get();
1055
+ return watcher->interested_parties();
1056
+ }
1057
+
1058
+ WatcherWrapper* MakeReplacement() {
1059
+ auto* replacement =
1060
+ new WatcherWrapper(std::move(watcher_), parent_, last_seen_state_);
1061
+ replacement_ = replacement;
1062
+ return replacement;
1063
+ }
1064
+
1065
+ grpc_connectivity_state last_seen_state() const { return last_seen_state_; }
1066
+
1067
+ private:
1068
+ void ApplyUpdateInControlPlaneWorkSerializer() {
1069
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1070
+ gpr_log(GPR_INFO,
1071
+ "chand=%p: processing connectivity change in work serializer "
1072
+ "for subchannel wrapper %p subchannel %p "
1073
+ "watcher=%p",
1074
+ parent_->chand_, parent_.get(), parent_->subchannel_,
1075
+ watcher_.get());
1076
+ }
1077
+ ConnectivityStateChange state_change = PopConnectivityStateChange();
1078
+ // Ignore update if the parent WatcherWrapper has been replaced
1079
+ // since this callback was scheduled.
1080
+ if (watcher_ != nullptr) {
1081
+ last_seen_state_ = state_change.state;
1082
+ parent_->MaybeUpdateConnectedSubchannel(
1083
+ std::move(state_change.connected_subchannel));
1084
+ watcher_->OnConnectivityStateChange(state_change.state);
1085
+ }
1086
+ }
1087
+
1088
+ std::unique_ptr<SubchannelInterface::ConnectivityStateWatcherInterface>
1089
+ watcher_;
1090
+ RefCountedPtr<SubchannelWrapper> parent_;
1091
+ grpc_connectivity_state last_seen_state_;
1092
+ WatcherWrapper* replacement_ = nullptr;
1093
+ };
1094
+
1095
+ void MaybeUpdateConnectedSubchannel(
1096
+ RefCountedPtr<ConnectedSubchannel> connected_subchannel) {
1097
+ // Update the connected subchannel only if the channel is not shutting
1098
+ // down. This is because once the channel is shutting down, we
1099
+ // ignore picker updates from the LB policy, which means that
1100
+ // UpdateStateAndPickerLocked() will never process the entries
1101
+ // in chand_->pending_subchannel_updates_. So we don't want to add
1102
+ // entries there that will never be processed, since that would
1103
+ // leave dangling refs to the channel and prevent its destruction.
1104
+ grpc_error* disconnect_error = chand_->disconnect_error();
1105
+ if (disconnect_error != GRPC_ERROR_NONE) return;
1106
+ // Not shutting down, so do the update.
1107
+ if (connected_subchannel_ != connected_subchannel) {
1108
+ connected_subchannel_ = std::move(connected_subchannel);
1109
+ // Record the new connected subchannel so that it can be updated
1110
+ // in the data plane mutex the next time the picker is updated.
1111
+ chand_->pending_subchannel_updates_[Ref(
1112
+ DEBUG_LOCATION, "ConnectedSubchannelUpdate")] = connected_subchannel_;
1113
+ }
1114
+ }
1115
+
1116
+ ChannelData* chand_;
1117
+ Subchannel* subchannel_;
1118
+ grpc_core::UniquePtr<char> health_check_service_name_;
1119
+ // Maps from the address of the watcher passed to us by the LB policy
1120
+ // to the address of the WrapperWatcher that we passed to the underlying
1121
+ // subchannel. This is needed so that when the LB policy calls
1122
+ // CancelConnectivityStateWatch() with its watcher, we know the
1123
+ // corresponding WrapperWatcher to cancel on the underlying subchannel.
1124
+ std::map<ConnectivityStateWatcherInterface*, WatcherWrapper*> watcher_map_;
1125
+ // To be accessed only in the control plane work_serializer.
1126
+ RefCountedPtr<ConnectedSubchannel> connected_subchannel_;
1127
+ // To be accessed only in the data plane mutex.
1128
+ RefCountedPtr<ConnectedSubchannel> connected_subchannel_in_data_plane_;
1129
+ };
1130
+
1131
+ //
1132
+ // ChannelData::ExternalConnectivityWatcher
1133
+ //
1134
+
1135
+ ChannelData::ExternalConnectivityWatcher::ExternalConnectivityWatcher(
1136
+ ChannelData* chand, grpc_polling_entity pollent,
1137
+ grpc_connectivity_state* state, grpc_closure* on_complete,
1138
+ grpc_closure* watcher_timer_init)
1139
+ : chand_(chand),
1140
+ pollent_(pollent),
1141
+ initial_state_(*state),
1142
+ state_(state),
1143
+ on_complete_(on_complete),
1144
+ watcher_timer_init_(watcher_timer_init) {
1145
+ grpc_polling_entity_add_to_pollset_set(&pollent_,
1146
+ chand_->interested_parties_);
1147
+ GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "ExternalConnectivityWatcher");
1148
+ }
1149
+
1150
+ ChannelData::ExternalConnectivityWatcher::~ExternalConnectivityWatcher() {
1151
+ grpc_polling_entity_del_from_pollset_set(&pollent_,
1152
+ chand_->interested_parties_);
1153
+ GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_,
1154
+ "ExternalConnectivityWatcher");
1155
+ }
1156
+
1157
+ void ChannelData::ExternalConnectivityWatcher::Start() {
1158
+ chand_->work_serializer_->Run([this]() { AddWatcherLocked(); },
1159
+ DEBUG_LOCATION);
1160
+ }
1161
+
1162
+ void ChannelData::ExternalConnectivityWatcher::Notify(
1163
+ grpc_connectivity_state state) {
1164
+ bool done = false;
1165
+ if (!done_.CompareExchangeStrong(&done, true, MemoryOrder::RELAXED,
1166
+ MemoryOrder::RELAXED)) {
1167
+ return; // Already done.
1168
+ }
1169
+ // Remove external watcher.
1170
+ chand_->RemoveExternalConnectivityWatcher(on_complete_, /*cancel=*/false);
1171
+ // Report new state to the user.
1172
+ *state_ = state;
1173
+ ExecCtx::Run(DEBUG_LOCATION, on_complete_, GRPC_ERROR_NONE);
1174
+ // Hop back into the work_serializer to clean up.
1175
+ // Not needed in state SHUTDOWN, because the tracker will
1176
+ // automatically remove all watchers in that case.
1177
+ if (state != GRPC_CHANNEL_SHUTDOWN) {
1178
+ chand_->work_serializer_->Run([this]() { RemoveWatcherLocked(); },
1179
+ DEBUG_LOCATION);
1180
+ }
1181
+ }
1182
+
1183
+ void ChannelData::ExternalConnectivityWatcher::Cancel() {
1184
+ bool done = false;
1185
+ if (!done_.CompareExchangeStrong(&done, true, MemoryOrder::RELAXED,
1186
+ MemoryOrder::RELAXED)) {
1187
+ return; // Already done.
1188
+ }
1189
+ ExecCtx::Run(DEBUG_LOCATION, on_complete_, GRPC_ERROR_CANCELLED);
1190
+ // Hop back into the work_serializer to clean up.
1191
+ chand_->work_serializer_->Run([this]() { RemoveWatcherLocked(); },
1192
+ DEBUG_LOCATION);
1193
+ }
1194
+
1195
+ void ChannelData::ExternalConnectivityWatcher::AddWatcherLocked() {
1196
+ Closure::Run(DEBUG_LOCATION, watcher_timer_init_, GRPC_ERROR_NONE);
1197
+ // Add new watcher.
1198
+ chand_->state_tracker_.AddWatcher(
1199
+ initial_state_, OrphanablePtr<ConnectivityStateWatcherInterface>(this));
1200
+ }
1201
+
1202
+ void ChannelData::ExternalConnectivityWatcher::RemoveWatcherLocked() {
1203
+ chand_->state_tracker_.RemoveWatcher(this);
1204
+ }
1205
+
1206
+ //
1207
+ // ChannelData::ConnectivityWatcherAdder
1208
+ //
1209
+
1210
+ class ChannelData::ConnectivityWatcherAdder {
1211
+ public:
1212
+ ConnectivityWatcherAdder(
1213
+ ChannelData* chand, grpc_connectivity_state initial_state,
1214
+ OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher)
1215
+ : chand_(chand),
1216
+ initial_state_(initial_state),
1217
+ watcher_(std::move(watcher)) {
1218
+ GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "ConnectivityWatcherAdder");
1219
+ chand_->work_serializer_->Run([this]() { AddWatcherLocked(); },
1220
+ DEBUG_LOCATION);
1221
+ }
1222
+
1223
+ private:
1224
+ void AddWatcherLocked() {
1225
+ chand_->state_tracker_.AddWatcher(initial_state_, std::move(watcher_));
1226
+ GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_, "ConnectivityWatcherAdder");
1227
+ delete this;
1228
+ }
1229
+
1230
+ ChannelData* chand_;
1231
+ grpc_connectivity_state initial_state_;
1232
+ OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher_;
1233
+ };
1234
+
1235
+ //
1236
+ // ChannelData::ConnectivityWatcherRemover
1237
+ //
1238
+
1239
+ class ChannelData::ConnectivityWatcherRemover {
1240
+ public:
1241
+ ConnectivityWatcherRemover(ChannelData* chand,
1242
+ AsyncConnectivityStateWatcherInterface* watcher)
1243
+ : chand_(chand), watcher_(watcher) {
1244
+ GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "ConnectivityWatcherRemover");
1245
+ chand_->work_serializer_->Run([this]() { RemoveWatcherLocked(); },
1246
+ DEBUG_LOCATION);
1247
+ }
1248
+
1249
+ private:
1250
+ void RemoveWatcherLocked() {
1251
+ chand_->state_tracker_.RemoveWatcher(watcher_);
1252
+ GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_,
1253
+ "ConnectivityWatcherRemover");
1254
+ delete this;
1255
+ }
1256
+
1257
+ ChannelData* chand_;
1258
+ AsyncConnectivityStateWatcherInterface* watcher_;
1259
+ };
1260
+
1261
+ //
1262
+ // ChannelData::ClientChannelControlHelper
1263
+ //
1264
+
1265
+ class ChannelData::ClientChannelControlHelper
1266
+ : public LoadBalancingPolicy::ChannelControlHelper {
1267
+ public:
1268
+ explicit ClientChannelControlHelper(ChannelData* chand) : chand_(chand) {
1269
+ GRPC_CHANNEL_STACK_REF(chand_->owning_stack_, "ClientChannelControlHelper");
1270
+ }
1271
+
1272
+ ~ClientChannelControlHelper() override {
1273
+ GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack_,
1274
+ "ClientChannelControlHelper");
1275
+ }
1276
+
1277
+ RefCountedPtr<SubchannelInterface> CreateSubchannel(
1278
+ const grpc_channel_args& args) override {
1279
+ bool inhibit_health_checking = grpc_channel_arg_get_bool(
1280
+ grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false);
1281
+ grpc_core::UniquePtr<char> health_check_service_name;
1282
+ if (!inhibit_health_checking) {
1283
+ health_check_service_name.reset(
1284
+ gpr_strdup(chand_->health_check_service_name_.get()));
1285
+ }
1286
+ static const char* args_to_remove[] = {
1287
+ GRPC_ARG_INHIBIT_HEALTH_CHECKING,
1288
+ GRPC_ARG_CHANNELZ_CHANNEL_NODE,
1289
+ };
1290
+ grpc_arg arg = SubchannelPoolInterface::CreateChannelArg(
1291
+ chand_->subchannel_pool_.get());
1292
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
1293
+ &args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &arg, 1);
1294
+ Subchannel* subchannel =
1295
+ chand_->client_channel_factory_->CreateSubchannel(new_args);
1296
+ grpc_channel_args_destroy(new_args);
1297
+ if (subchannel == nullptr) return nullptr;
1298
+ return MakeRefCounted<SubchannelWrapper>(
1299
+ chand_, subchannel, std::move(health_check_service_name));
1300
+ }
1301
+
1302
+ void UpdateState(
1303
+ grpc_connectivity_state state,
1304
+ std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker) override {
1305
+ grpc_error* disconnect_error = chand_->disconnect_error();
1306
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1307
+ const char* extra = disconnect_error == GRPC_ERROR_NONE
1308
+ ? ""
1309
+ : " (ignoring -- channel shutting down)";
1310
+ gpr_log(GPR_INFO, "chand=%p: update: state=%s picker=%p%s", chand_,
1311
+ ConnectivityStateName(state), picker.get(), extra);
1312
+ }
1313
+ // Do update only if not shutting down.
1314
+ if (disconnect_error == GRPC_ERROR_NONE) {
1315
+ chand_->UpdateStateAndPickerLocked(state, "helper", std::move(picker));
1316
+ }
1317
+ }
1318
+
1319
+ // No-op -- we should never get this from ResolvingLoadBalancingPolicy.
1320
+ void RequestReresolution() override {}
1321
+
1322
+ void AddTraceEvent(TraceSeverity severity,
1323
+ absl::string_view message) override {
1324
+ if (chand_->channelz_node_ != nullptr) {
1325
+ chand_->channelz_node_->AddTraceEvent(
1326
+ ConvertSeverityEnum(severity),
1327
+ grpc_slice_from_copied_buffer(message.data(), message.size()));
1328
+ }
1329
+ }
1330
+
1331
+ private:
1332
+ static channelz::ChannelTrace::Severity ConvertSeverityEnum(
1333
+ TraceSeverity severity) {
1334
+ if (severity == TRACE_INFO) return channelz::ChannelTrace::Info;
1335
+ if (severity == TRACE_WARNING) return channelz::ChannelTrace::Warning;
1336
+ return channelz::ChannelTrace::Error;
1337
+ }
1338
+
1339
+ ChannelData* chand_;
1340
+ };
1341
+
1342
+ //
1343
+ // ChannelData implementation
1344
+ //
1345
+
1346
+ grpc_error* ChannelData::Init(grpc_channel_element* elem,
1347
+ grpc_channel_element_args* args) {
1348
+ GPR_ASSERT(args->is_last);
1349
+ GPR_ASSERT(elem->filter == &grpc_client_channel_filter);
1350
+ grpc_error* error = GRPC_ERROR_NONE;
1351
+ new (elem->channel_data) ChannelData(args, &error);
1352
+ return error;
1353
+ }
1354
+
1355
+ void ChannelData::Destroy(grpc_channel_element* elem) {
1356
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
1357
+ chand->~ChannelData();
1358
+ }
1359
+
1360
+ bool GetEnableRetries(const grpc_channel_args* args) {
1361
+ return grpc_channel_arg_get_bool(
1362
+ grpc_channel_args_find(args, GRPC_ARG_ENABLE_RETRIES), true);
1363
+ }
1364
+
1365
+ size_t GetMaxPerRpcRetryBufferSize(const grpc_channel_args* args) {
1366
+ return static_cast<size_t>(grpc_channel_arg_get_integer(
1367
+ grpc_channel_args_find(args, GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE),
1368
+ {DEFAULT_PER_RPC_RETRY_BUFFER_SIZE, 0, INT_MAX}));
1369
+ }
1370
+
1371
+ RefCountedPtr<SubchannelPoolInterface> GetSubchannelPool(
1372
+ const grpc_channel_args* args) {
1373
+ const bool use_local_subchannel_pool = grpc_channel_arg_get_bool(
1374
+ grpc_channel_args_find(args, GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL), false);
1375
+ if (use_local_subchannel_pool) {
1376
+ return MakeRefCounted<LocalSubchannelPool>();
1377
+ }
1378
+ return GlobalSubchannelPool::instance();
1379
+ }
1380
+
1381
+ channelz::ChannelNode* GetChannelzNode(const grpc_channel_args* args) {
1382
+ const grpc_arg* arg =
1383
+ grpc_channel_args_find(args, GRPC_ARG_CHANNELZ_CHANNEL_NODE);
1384
+ if (arg != nullptr && arg->type == GRPC_ARG_POINTER) {
1385
+ return static_cast<channelz::ChannelNode*>(arg->value.pointer.p);
1386
+ }
1387
+ return nullptr;
1388
+ }
1389
+
1390
+ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error)
1391
+ : deadline_checking_enabled_(
1392
+ grpc_deadline_checking_enabled(args->channel_args)),
1393
+ enable_retries_(GetEnableRetries(args->channel_args)),
1394
+ per_rpc_retry_buffer_size_(
1395
+ GetMaxPerRpcRetryBufferSize(args->channel_args)),
1396
+ owning_stack_(args->channel_stack),
1397
+ client_channel_factory_(
1398
+ ClientChannelFactory::GetFromChannelArgs(args->channel_args)),
1399
+ channelz_node_(GetChannelzNode(args->channel_args)),
1400
+ work_serializer_(std::make_shared<WorkSerializer>()),
1401
+ interested_parties_(grpc_pollset_set_create()),
1402
+ subchannel_pool_(GetSubchannelPool(args->channel_args)),
1403
+ state_tracker_("client_channel", GRPC_CHANNEL_IDLE),
1404
+ disconnect_error_(GRPC_ERROR_NONE) {
1405
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1406
+ gpr_log(GPR_INFO, "chand=%p: creating client_channel for channel stack %p",
1407
+ this, owning_stack_);
1408
+ }
1409
+ // Initialize data members.
1410
+ gpr_mu_init(&info_mu_);
1411
+ // Start backup polling.
1412
+ grpc_client_channel_start_backup_polling(interested_parties_);
1413
+ // Check client channel factory.
1414
+ if (client_channel_factory_ == nullptr) {
1415
+ *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1416
+ "Missing client channel factory in args for client channel filter");
1417
+ return;
1418
+ }
1419
+ // Get server name to resolve, using proxy mapper if needed.
1420
+ const char* server_uri = grpc_channel_arg_get_string(
1421
+ grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI));
1422
+ if (server_uri == nullptr) {
1423
+ *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1424
+ "server URI channel arg missing or wrong type in client channel "
1425
+ "filter");
1426
+ return;
1427
+ }
1428
+ // Get default service config
1429
+ const char* service_config_json = grpc_channel_arg_get_string(
1430
+ grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG));
1431
+ if (service_config_json != nullptr) {
1432
+ *error = GRPC_ERROR_NONE;
1433
+ default_service_config_ = ServiceConfig::Create(service_config_json, error);
1434
+ if (*error != GRPC_ERROR_NONE) {
1435
+ default_service_config_.reset();
1436
+ return;
1437
+ }
1438
+ }
1439
+ grpc_uri* uri = grpc_uri_parse(server_uri, true);
1440
+ if (uri != nullptr && uri->path[0] != '\0') {
1441
+ server_name_.reset(
1442
+ gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path));
1443
+ }
1444
+ grpc_uri_destroy(uri);
1445
+ char* proxy_name = nullptr;
1446
+ grpc_channel_args* new_args = nullptr;
1447
+ ProxyMapperRegistry::MapName(server_uri, args->channel_args, &proxy_name,
1448
+ &new_args);
1449
+ target_uri_.reset(proxy_name != nullptr ? proxy_name
1450
+ : gpr_strdup(server_uri));
1451
+ channel_args_ = new_args != nullptr
1452
+ ? new_args
1453
+ : grpc_channel_args_copy(args->channel_args);
1454
+ if (!ResolverRegistry::IsValidTarget(target_uri_.get())) {
1455
+ *error =
1456
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("the target uri is not valid.");
1457
+ return;
1458
+ }
1459
+ *error = GRPC_ERROR_NONE;
1460
+ }
1461
+
1462
+ ChannelData::~ChannelData() {
1463
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1464
+ gpr_log(GPR_INFO, "chand=%p: destroying channel", this);
1465
+ }
1466
+ DestroyResolvingLoadBalancingPolicyLocked();
1467
+ grpc_channel_args_destroy(channel_args_);
1468
+ // Stop backup polling.
1469
+ grpc_client_channel_stop_backup_polling(interested_parties_);
1470
+ grpc_pollset_set_destroy(interested_parties_);
1471
+ GRPC_ERROR_UNREF(disconnect_error_.Load(MemoryOrder::RELAXED));
1472
+ gpr_mu_destroy(&info_mu_);
1473
+ }
1474
+
1475
+ void ChannelData::UpdateStateAndPickerLocked(
1476
+ grpc_connectivity_state state, const char* reason,
1477
+ std::unique_ptr<LoadBalancingPolicy::SubchannelPicker> picker) {
1478
+ // Clean the control plane when entering IDLE.
1479
+ if (picker_ == nullptr) {
1480
+ health_check_service_name_.reset();
1481
+ saved_service_config_.reset();
1482
+ received_first_resolver_result_ = false;
1483
+ }
1484
+ // Update connectivity state.
1485
+ state_tracker_.SetState(state, reason);
1486
+ if (channelz_node_ != nullptr) {
1487
+ channelz_node_->SetConnectivityState(state);
1488
+ channelz_node_->AddTraceEvent(
1489
+ channelz::ChannelTrace::Severity::Info,
1490
+ grpc_slice_from_static_string(
1491
+ channelz::ChannelNode::GetChannelConnectivityStateChangeString(
1492
+ state)));
1493
+ }
1494
+ // Grab data plane lock to do subchannel updates and update the picker.
1495
+ //
1496
+ // Note that we want to minimize the work done while holding the data
1497
+ // plane lock, to keep the critical section small. So, for all of the
1498
+ // objects that we might wind up unreffing here, we actually hold onto
1499
+ // the refs until after we release the lock, and then unref them at
1500
+ // that point. This includes the following:
1501
+ // - refs to subchannel wrappers in the keys of pending_subchannel_updates_
1502
+ // - ref stored in retry_throttle_data_
1503
+ // - ref stored in service_config_
1504
+ // - ownership of the existing picker in picker_
1505
+ RefCountedPtr<ServerRetryThrottleData> retry_throttle_data_to_unref;
1506
+ RefCountedPtr<ServiceConfig> service_config_to_unref;
1507
+ {
1508
+ MutexLock lock(&data_plane_mu_);
1509
+ // Handle subchannel updates.
1510
+ for (auto& p : pending_subchannel_updates_) {
1511
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1512
+ gpr_log(GPR_INFO,
1513
+ "chand=%p: updating subchannel wrapper %p data plane "
1514
+ "connected_subchannel to %p",
1515
+ this, p.first.get(), p.second.get());
1516
+ }
1517
+ // Note: We do not remove the entry from pending_subchannel_updates_
1518
+ // here, since this would unref the subchannel wrapper; instead,
1519
+ // we wait until we've released the lock to clear the map.
1520
+ p.first->set_connected_subchannel_in_data_plane(std::move(p.second));
1521
+ }
1522
+ // Swap out the picker.
1523
+ // Note: Original value will be destroyed after the lock is released.
1524
+ picker_.swap(picker);
1525
+ // Clean the data plane if the updated picker is nullptr.
1526
+ if (picker_ == nullptr) {
1527
+ received_service_config_data_ = false;
1528
+ // Note: We save the objects to unref until after the lock is released.
1529
+ retry_throttle_data_to_unref = std::move(retry_throttle_data_);
1530
+ service_config_to_unref = std::move(service_config_);
1531
+ }
1532
+ // Re-process queued picks.
1533
+ for (QueuedPick* pick = queued_picks_; pick != nullptr; pick = pick->next) {
1534
+ grpc_call_element* elem = pick->elem;
1535
+ CallData* calld = static_cast<CallData*>(elem->call_data);
1536
+ grpc_error* error = GRPC_ERROR_NONE;
1537
+ if (calld->PickSubchannelLocked(elem, &error)) {
1538
+ calld->AsyncPickDone(elem, error);
1539
+ }
1540
+ }
1541
+ }
1542
+ // Clear the pending update map after releasing the lock, to keep the
1543
+ // critical section small.
1544
+ pending_subchannel_updates_.clear();
1545
+ }
1546
+
1547
+ void ChannelData::UpdateServiceConfigLocked(
1548
+ RefCountedPtr<ServerRetryThrottleData> retry_throttle_data,
1549
+ RefCountedPtr<ServiceConfig> service_config) {
1550
+ // Grab data plane lock to update service config.
1551
+ //
1552
+ // We defer unreffing the old values (and deallocating memory) until
1553
+ // after releasing the lock to keep the critical section small.
1554
+ {
1555
+ MutexLock lock(&data_plane_mu_);
1556
+ // Update service config.
1557
+ received_service_config_data_ = true;
1558
+ // Old values will be unreffed after lock is released.
1559
+ retry_throttle_data_.swap(retry_throttle_data);
1560
+ service_config_.swap(service_config);
1561
+ // Apply service config to queued picks.
1562
+ for (QueuedPick* pick = queued_picks_; pick != nullptr; pick = pick->next) {
1563
+ CallData* calld = static_cast<CallData*>(pick->elem->call_data);
1564
+ calld->MaybeApplyServiceConfigToCallLocked(pick->elem);
1565
+ }
1566
+ }
1567
+ // Old values will be unreffed after lock is released when they go out
1568
+ // of scope.
1569
+ }
1570
+
1571
+ void ChannelData::CreateResolvingLoadBalancingPolicyLocked() {
1572
+ // Instantiate resolving LB policy.
1573
+ LoadBalancingPolicy::Args lb_args;
1574
+ lb_args.work_serializer = work_serializer_;
1575
+ lb_args.channel_control_helper =
1576
+ absl::make_unique<ClientChannelControlHelper>(this);
1577
+ lb_args.args = channel_args_;
1578
+ grpc_core::UniquePtr<char> target_uri(gpr_strdup(target_uri_.get()));
1579
+ resolving_lb_policy_.reset(new ResolvingLoadBalancingPolicy(
1580
+ std::move(lb_args), &grpc_client_channel_routing_trace,
1581
+ std::move(target_uri), ProcessResolverResultLocked, this));
1582
+ grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(),
1583
+ interested_parties_);
1584
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1585
+ gpr_log(GPR_INFO, "chand=%p: created resolving_lb_policy=%p", this,
1586
+ resolving_lb_policy_.get());
1587
+ }
1588
+ }
1589
+
1590
+ void ChannelData::DestroyResolvingLoadBalancingPolicyLocked() {
1591
+ if (resolving_lb_policy_ != nullptr) {
1592
+ grpc_pollset_set_del_pollset_set(resolving_lb_policy_->interested_parties(),
1593
+ interested_parties_);
1594
+ resolving_lb_policy_.reset();
1595
+ }
1596
+ }
1597
+
1598
+ void ChannelData::ProcessLbPolicy(
1599
+ const Resolver::Result& resolver_result,
1600
+ const internal::ClientChannelGlobalParsedConfig* parsed_service_config,
1601
+ RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config) {
1602
+ // Prefer the LB policy config found in the service config.
1603
+ if (parsed_service_config != nullptr &&
1604
+ parsed_service_config->parsed_lb_config() != nullptr) {
1605
+ *lb_policy_config = parsed_service_config->parsed_lb_config();
1606
+ return;
1607
+ }
1608
+ // Try the deprecated LB policy name from the service config.
1609
+ // If not, try the setting from channel args.
1610
+ const char* policy_name = nullptr;
1611
+ if (parsed_service_config != nullptr &&
1612
+ !parsed_service_config->parsed_deprecated_lb_policy().empty()) {
1613
+ policy_name = parsed_service_config->parsed_deprecated_lb_policy().c_str();
1614
+ } else {
1615
+ const grpc_arg* channel_arg =
1616
+ grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME);
1617
+ policy_name = grpc_channel_arg_get_string(channel_arg);
1618
+ }
1619
+ // Use pick_first if nothing was specified and we didn't select grpclb
1620
+ // above.
1621
+ if (policy_name == nullptr) policy_name = "pick_first";
1622
+ // Now that we have the policy name, construct an empty config for it.
1623
+ Json config_json = Json::Array{Json::Object{
1624
+ {policy_name, Json::Object{}},
1625
+ }};
1626
+ grpc_error* parse_error = GRPC_ERROR_NONE;
1627
+ *lb_policy_config = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(
1628
+ config_json, &parse_error);
1629
+ // The policy name came from one of three places:
1630
+ // - The deprecated loadBalancingPolicy field in the service config,
1631
+ // in which case the code in ClientChannelServiceConfigParser
1632
+ // already verified that the policy does not require a config.
1633
+ // - One of the hard-coded values here, all of which are known to not
1634
+ // require a config.
1635
+ // - A channel arg, in which case the application did something that
1636
+ // is a misuse of our API.
1637
+ // In the first two cases, these assertions will always be true. In
1638
+ // the last case, this is probably fine for now.
1639
+ // TODO(roth): If the last case becomes a problem, add better error
1640
+ // handling here.
1641
+ GPR_ASSERT(*lb_policy_config != nullptr);
1642
+ GPR_ASSERT(parse_error == GRPC_ERROR_NONE);
1643
+ }
1644
+
1645
+ // Synchronous callback from ResolvingLoadBalancingPolicy to process a
1646
+ // resolver result update.
1647
+ bool ChannelData::ProcessResolverResultLocked(
1648
+ void* arg, const Resolver::Result& result,
1649
+ RefCountedPtr<LoadBalancingPolicy::Config>* lb_policy_config,
1650
+ grpc_error** service_config_error, bool* no_valid_service_config) {
1651
+ ChannelData* chand = static_cast<ChannelData*>(arg);
1652
+ RefCountedPtr<ServiceConfig> service_config;
1653
+ // If resolver did not return a service config or returned an invalid service
1654
+ // config, we need a fallback service config.
1655
+ if (result.service_config_error != GRPC_ERROR_NONE) {
1656
+ // If the service config was invalid, then fallback to the saved service
1657
+ // config. If there is no saved config either, use the default service
1658
+ // config.
1659
+ if (chand->saved_service_config_ != nullptr) {
1660
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1661
+ gpr_log(GPR_INFO,
1662
+ "chand=%p: resolver returned invalid service config. "
1663
+ "Continuing to use previous service config.",
1664
+ chand);
1665
+ }
1666
+ service_config = chand->saved_service_config_;
1667
+ } else if (chand->default_service_config_ != nullptr) {
1668
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1669
+ gpr_log(GPR_INFO,
1670
+ "chand=%p: resolver returned invalid service config. Using "
1671
+ "default service config provided by client API.",
1672
+ chand);
1673
+ }
1674
+ service_config = chand->default_service_config_;
1675
+ }
1676
+ } else if (result.service_config == nullptr) {
1677
+ if (chand->default_service_config_ != nullptr) {
1678
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1679
+ gpr_log(GPR_INFO,
1680
+ "chand=%p: resolver returned no service config. Using default "
1681
+ "service config provided by client API.",
1682
+ chand);
1683
+ }
1684
+ service_config = chand->default_service_config_;
1685
+ }
1686
+ } else {
1687
+ service_config = result.service_config;
1688
+ }
1689
+ *service_config_error = GRPC_ERROR_REF(result.service_config_error);
1690
+ if (service_config == nullptr &&
1691
+ result.service_config_error != GRPC_ERROR_NONE) {
1692
+ *no_valid_service_config = true;
1693
+ return false;
1694
+ }
1695
+ // Process service config.
1696
+ grpc_core::UniquePtr<char> service_config_json;
1697
+ const internal::ClientChannelGlobalParsedConfig* parsed_service_config =
1698
+ nullptr;
1699
+ if (service_config != nullptr) {
1700
+ parsed_service_config =
1701
+ static_cast<const internal::ClientChannelGlobalParsedConfig*>(
1702
+ service_config->GetGlobalParsedConfig(
1703
+ internal::ClientChannelServiceConfigParser::ParserIndex()));
1704
+ }
1705
+ // Check if the config has changed.
1706
+ const bool service_config_changed =
1707
+ ((service_config == nullptr) !=
1708
+ (chand->saved_service_config_ == nullptr)) ||
1709
+ (service_config != nullptr &&
1710
+ service_config->json_string() !=
1711
+ chand->saved_service_config_->json_string());
1712
+ if (service_config_changed) {
1713
+ service_config_json.reset(gpr_strdup(
1714
+ service_config != nullptr ? service_config->json_string().c_str()
1715
+ : ""));
1716
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
1717
+ gpr_log(GPR_INFO,
1718
+ "chand=%p: resolver returned updated service config: \"%s\"",
1719
+ chand, service_config_json.get());
1720
+ }
1721
+ // Save health check service name.
1722
+ if (service_config != nullptr) {
1723
+ chand->health_check_service_name_.reset(
1724
+ gpr_strdup(parsed_service_config->health_check_service_name()));
1725
+ } else {
1726
+ chand->health_check_service_name_.reset();
1727
+ }
1728
+ // Update health check service name used by existing subchannel wrappers.
1729
+ for (auto* subchannel_wrapper : chand->subchannel_wrappers_) {
1730
+ subchannel_wrapper->UpdateHealthCheckServiceName(
1731
+ grpc_core::UniquePtr<char>(
1732
+ gpr_strdup(chand->health_check_service_name_.get())));
1733
+ }
1734
+ // Save service config.
1735
+ chand->saved_service_config_ = std::move(service_config);
1736
+ }
1737
+ // We want to set the service config at least once. This should not really be
1738
+ // needed, but we are doing it as a defensive approach. This can be removed,
1739
+ // if we feel it is unnecessary.
1740
+ if (service_config_changed || !chand->received_first_resolver_result_) {
1741
+ chand->received_first_resolver_result_ = true;
1742
+ RefCountedPtr<ServerRetryThrottleData> retry_throttle_data;
1743
+ if (parsed_service_config != nullptr) {
1744
+ absl::optional<internal::ClientChannelGlobalParsedConfig::RetryThrottling>
1745
+ retry_throttle_config = parsed_service_config->retry_throttling();
1746
+ if (retry_throttle_config.has_value()) {
1747
+ retry_throttle_data =
1748
+ internal::ServerRetryThrottleMap::GetDataForServer(
1749
+ chand->server_name_.get(),
1750
+ retry_throttle_config.value().max_milli_tokens,
1751
+ retry_throttle_config.value().milli_token_ratio);
1752
+ }
1753
+ }
1754
+ chand->UpdateServiceConfigLocked(std::move(retry_throttle_data),
1755
+ chand->saved_service_config_);
1756
+ }
1757
+ chand->ProcessLbPolicy(result, parsed_service_config, lb_policy_config);
1758
+ grpc_core::UniquePtr<char> lb_policy_name(
1759
+ gpr_strdup((*lb_policy_config)->name()));
1760
+ // Swap out the data used by GetChannelInfo().
1761
+ {
1762
+ MutexLock lock(&chand->info_mu_);
1763
+ chand->info_lb_policy_name_ = std::move(lb_policy_name);
1764
+ if (service_config_json != nullptr) {
1765
+ chand->info_service_config_json_ = std::move(service_config_json);
1766
+ }
1767
+ }
1768
+ // Return results.
1769
+ return service_config_changed;
1770
+ }
1771
+
1772
+ grpc_error* ChannelData::DoPingLocked(grpc_transport_op* op) {
1773
+ if (state_tracker_.state() != GRPC_CHANNEL_READY) {
1774
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("channel not connected");
1775
+ }
1776
+ LoadBalancingPolicy::PickResult result =
1777
+ picker_->Pick(LoadBalancingPolicy::PickArgs());
1778
+ ConnectedSubchannel* connected_subchannel = nullptr;
1779
+ if (result.subchannel != nullptr) {
1780
+ SubchannelWrapper* subchannel =
1781
+ static_cast<SubchannelWrapper*>(result.subchannel.get());
1782
+ connected_subchannel = subchannel->connected_subchannel();
1783
+ }
1784
+ if (connected_subchannel != nullptr) {
1785
+ connected_subchannel->Ping(op->send_ping.on_initiate, op->send_ping.on_ack);
1786
+ } else {
1787
+ if (result.error == GRPC_ERROR_NONE) {
1788
+ result.error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1789
+ "LB policy dropped call on ping");
1790
+ }
1791
+ }
1792
+ return result.error;
1793
+ }
1794
+
1795
+ void ChannelData::StartTransportOpLocked(grpc_transport_op* op) {
1796
+ // Connectivity watch.
1797
+ if (op->start_connectivity_watch != nullptr) {
1798
+ state_tracker_.AddWatcher(op->start_connectivity_watch_state,
1799
+ std::move(op->start_connectivity_watch));
1800
+ }
1801
+ if (op->stop_connectivity_watch != nullptr) {
1802
+ state_tracker_.RemoveWatcher(op->stop_connectivity_watch);
1803
+ }
1804
+ // Ping.
1805
+ if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) {
1806
+ grpc_error* error = DoPingLocked(op);
1807
+ if (error != GRPC_ERROR_NONE) {
1808
+ ExecCtx::Run(DEBUG_LOCATION, op->send_ping.on_initiate,
1809
+ GRPC_ERROR_REF(error));
1810
+ ExecCtx::Run(DEBUG_LOCATION, op->send_ping.on_ack, error);
1811
+ }
1812
+ op->bind_pollset = nullptr;
1813
+ op->send_ping.on_initiate = nullptr;
1814
+ op->send_ping.on_ack = nullptr;
1815
+ }
1816
+ // Reset backoff.
1817
+ if (op->reset_connect_backoff) {
1818
+ if (resolving_lb_policy_ != nullptr) {
1819
+ resolving_lb_policy_->ResetBackoffLocked();
1820
+ }
1821
+ }
1822
+ // Disconnect or enter IDLE.
1823
+ if (op->disconnect_with_error != GRPC_ERROR_NONE) {
1824
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
1825
+ gpr_log(GPR_INFO, "chand=%p: disconnect_with_error: %s", this,
1826
+ grpc_error_string(op->disconnect_with_error));
1827
+ }
1828
+ DestroyResolvingLoadBalancingPolicyLocked();
1829
+ intptr_t value;
1830
+ if (grpc_error_get_int(op->disconnect_with_error,
1831
+ GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, &value) &&
1832
+ static_cast<grpc_connectivity_state>(value) == GRPC_CHANNEL_IDLE) {
1833
+ if (disconnect_error() == GRPC_ERROR_NONE) {
1834
+ // Enter IDLE state.
1835
+ UpdateStateAndPickerLocked(GRPC_CHANNEL_IDLE, "channel entering IDLE",
1836
+ nullptr);
1837
+ }
1838
+ GRPC_ERROR_UNREF(op->disconnect_with_error);
1839
+ } else {
1840
+ // Disconnect.
1841
+ GPR_ASSERT(disconnect_error_.Load(MemoryOrder::RELAXED) ==
1842
+ GRPC_ERROR_NONE);
1843
+ disconnect_error_.Store(op->disconnect_with_error, MemoryOrder::RELEASE);
1844
+ UpdateStateAndPickerLocked(
1845
+ GRPC_CHANNEL_SHUTDOWN, "shutdown from API",
1846
+ absl::make_unique<LoadBalancingPolicy::TransientFailurePicker>(
1847
+ GRPC_ERROR_REF(op->disconnect_with_error)));
1848
+ }
1849
+ }
1850
+ GRPC_CHANNEL_STACK_UNREF(owning_stack_, "start_transport_op");
1851
+ ExecCtx::Run(DEBUG_LOCATION, op->on_consumed, GRPC_ERROR_NONE);
1852
+ }
1853
+
1854
+ void ChannelData::StartTransportOp(grpc_channel_element* elem,
1855
+ grpc_transport_op* op) {
1856
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
1857
+ GPR_ASSERT(op->set_accept_stream == false);
1858
+ // Handle bind_pollset.
1859
+ if (op->bind_pollset != nullptr) {
1860
+ grpc_pollset_set_add_pollset(chand->interested_parties_, op->bind_pollset);
1861
+ }
1862
+ // Pop into control plane work_serializer for remaining ops.
1863
+ GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "start_transport_op");
1864
+ chand->work_serializer_->Run(
1865
+ [chand, op]() { chand->StartTransportOpLocked(op); }, DEBUG_LOCATION);
1866
+ }
1867
+
1868
+ void ChannelData::GetChannelInfo(grpc_channel_element* elem,
1869
+ const grpc_channel_info* info) {
1870
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
1871
+ MutexLock lock(&chand->info_mu_);
1872
+ if (info->lb_policy_name != nullptr) {
1873
+ *info->lb_policy_name = gpr_strdup(chand->info_lb_policy_name_.get());
1874
+ }
1875
+ if (info->service_config_json != nullptr) {
1876
+ *info->service_config_json =
1877
+ gpr_strdup(chand->info_service_config_json_.get());
1878
+ }
1879
+ }
1880
+
1881
+ void ChannelData::AddQueuedPick(QueuedPick* pick,
1882
+ grpc_polling_entity* pollent) {
1883
+ // Add call to queued picks list.
1884
+ pick->next = queued_picks_;
1885
+ queued_picks_ = pick;
1886
+ // Add call's pollent to channel's interested_parties, so that I/O
1887
+ // can be done under the call's CQ.
1888
+ grpc_polling_entity_add_to_pollset_set(pollent, interested_parties_);
1889
+ }
1890
+
1891
+ void ChannelData::RemoveQueuedPick(QueuedPick* to_remove,
1892
+ grpc_polling_entity* pollent) {
1893
+ // Remove call's pollent from channel's interested_parties.
1894
+ grpc_polling_entity_del_from_pollset_set(pollent, interested_parties_);
1895
+ // Remove from queued picks list.
1896
+ for (QueuedPick** pick = &queued_picks_; *pick != nullptr;
1897
+ pick = &(*pick)->next) {
1898
+ if (*pick == to_remove) {
1899
+ *pick = to_remove->next;
1900
+ return;
1901
+ }
1902
+ }
1903
+ }
1904
+
1905
+ RefCountedPtr<ConnectedSubchannel>
1906
+ ChannelData::GetConnectedSubchannelInDataPlane(
1907
+ SubchannelInterface* subchannel) const {
1908
+ SubchannelWrapper* subchannel_wrapper =
1909
+ static_cast<SubchannelWrapper*>(subchannel);
1910
+ ConnectedSubchannel* connected_subchannel =
1911
+ subchannel_wrapper->connected_subchannel_in_data_plane();
1912
+ if (connected_subchannel == nullptr) return nullptr;
1913
+ return connected_subchannel->Ref();
1914
+ }
1915
+
1916
+ void ChannelData::TryToConnectLocked() {
1917
+ if (resolving_lb_policy_ != nullptr) {
1918
+ resolving_lb_policy_->ExitIdleLocked();
1919
+ } else {
1920
+ CreateResolvingLoadBalancingPolicyLocked();
1921
+ }
1922
+ GRPC_CHANNEL_STACK_UNREF(owning_stack_, "TryToConnect");
1923
+ }
1924
+
1925
+ grpc_connectivity_state ChannelData::CheckConnectivityState(
1926
+ bool try_to_connect) {
1927
+ grpc_connectivity_state out = state_tracker_.state();
1928
+ if (out == GRPC_CHANNEL_IDLE && try_to_connect) {
1929
+ GRPC_CHANNEL_STACK_REF(owning_stack_, "TryToConnect");
1930
+ work_serializer_->Run([this]() { TryToConnectLocked(); }, DEBUG_LOCATION);
1931
+ }
1932
+ return out;
1933
+ }
1934
+
1935
+ void ChannelData::AddConnectivityWatcher(
1936
+ grpc_connectivity_state initial_state,
1937
+ OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher) {
1938
+ new ConnectivityWatcherAdder(this, initial_state, std::move(watcher));
1939
+ }
1940
+
1941
+ void ChannelData::RemoveConnectivityWatcher(
1942
+ AsyncConnectivityStateWatcherInterface* watcher) {
1943
+ new ConnectivityWatcherRemover(this, watcher);
1944
+ }
1945
+
1946
+ //
1947
+ // CallData implementation
1948
+ //
1949
+
1950
+ // Retry support:
1951
+ //
1952
+ // In order to support retries, we act as a proxy for stream op batches.
1953
+ // When we get a batch from the surface, we add it to our list of pending
1954
+ // batches, and we then use those batches to construct separate "child"
1955
+ // batches to be started on the subchannel call. When the child batches
1956
+ // return, we then decide which pending batches have been completed and
1957
+ // schedule their callbacks accordingly. If a subchannel call fails and
1958
+ // we want to retry it, we do a new pick and start again, constructing
1959
+ // new "child" batches for the new subchannel call.
1960
+ //
1961
+ // Note that retries are committed when receiving data from the server
1962
+ // (except for Trailers-Only responses). However, there may be many
1963
+ // send ops started before receiving any data, so we may have already
1964
+ // completed some number of send ops (and returned the completions up to
1965
+ // the surface) by the time we realize that we need to retry. To deal
1966
+ // with this, we cache data for send ops, so that we can replay them on a
1967
+ // different subchannel call even after we have completed the original
1968
+ // batches.
1969
+ //
1970
+ // There are two sets of data to maintain:
1971
+ // - In call_data (in the parent channel), we maintain a list of pending
1972
+ // ops and cached data for send ops.
1973
+ // - In the subchannel call, we maintain state to indicate what ops have
1974
+ // already been sent down to that call.
1975
+ //
1976
+ // When constructing the "child" batches, we compare those two sets of
1977
+ // data to see which batches need to be sent to the subchannel call.
1978
+
1979
+ // TODO(roth): In subsequent PRs:
1980
+ // - add support for transparent retries (including initial metadata)
1981
+ // - figure out how to record stats in census for retries
1982
+ // (census filter is on top of this one)
1983
+ // - add census stats for retries
1984
+
1985
+ CallData::CallData(grpc_call_element* elem, const ChannelData& chand,
1986
+ const grpc_call_element_args& args)
1987
+ : deadline_state_(elem, args.call_stack, args.call_combiner,
1988
+ GPR_LIKELY(chand.deadline_checking_enabled())
1989
+ ? args.deadline
1990
+ : GRPC_MILLIS_INF_FUTURE),
1991
+ path_(grpc_slice_ref_internal(args.path)),
1992
+ call_start_time_(args.start_time),
1993
+ deadline_(args.deadline),
1994
+ arena_(args.arena),
1995
+ owning_call_(args.call_stack),
1996
+ call_combiner_(args.call_combiner),
1997
+ call_context_(args.context),
1998
+ lb_call_state_(this),
1999
+ pending_send_initial_metadata_(false),
2000
+ pending_send_message_(false),
2001
+ pending_send_trailing_metadata_(false),
2002
+ enable_retries_(chand.enable_retries()),
2003
+ retry_committed_(false),
2004
+ last_attempt_got_server_pushback_(false) {}
2005
+
2006
+ CallData::~CallData() {
2007
+ grpc_slice_unref_internal(path_);
2008
+ GRPC_ERROR_UNREF(cancel_error_);
2009
+ if (backend_metric_data_ != nullptr) {
2010
+ backend_metric_data_
2011
+ ->LoadBalancingPolicy::BackendMetricData::~BackendMetricData();
2012
+ }
2013
+ // Make sure there are no remaining pending batches.
2014
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
2015
+ GPR_ASSERT(pending_batches_[i].batch == nullptr);
2016
+ }
2017
+ }
2018
+
2019
+ grpc_error* CallData::Init(grpc_call_element* elem,
2020
+ const grpc_call_element_args* args) {
2021
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2022
+ new (elem->call_data) CallData(elem, *chand, *args);
2023
+ return GRPC_ERROR_NONE;
2024
+ }
2025
+
2026
+ void CallData::Destroy(grpc_call_element* elem,
2027
+ const grpc_call_final_info* /*final_info*/,
2028
+ grpc_closure* then_schedule_closure) {
2029
+ CallData* calld = static_cast<CallData*>(elem->call_data);
2030
+ if (GPR_LIKELY(calld->subchannel_call_ != nullptr)) {
2031
+ calld->subchannel_call_->SetAfterCallStackDestroy(then_schedule_closure);
2032
+ then_schedule_closure = nullptr;
2033
+ }
2034
+ calld->~CallData();
2035
+ // TODO(yashkt) : This can potentially be a Closure::Run
2036
+ ExecCtx::Run(DEBUG_LOCATION, then_schedule_closure, GRPC_ERROR_NONE);
2037
+ }
2038
+
2039
+ void CallData::StartTransportStreamOpBatch(
2040
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
2041
+ GPR_TIMER_SCOPE("cc_start_transport_stream_op_batch", 0);
2042
+ CallData* calld = static_cast<CallData*>(elem->call_data);
2043
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2044
+ if (GPR_LIKELY(chand->deadline_checking_enabled())) {
2045
+ grpc_deadline_state_client_start_transport_stream_op_batch(elem, batch);
2046
+ }
2047
+ // If we've previously been cancelled, immediately fail any new batches.
2048
+ if (GPR_UNLIKELY(calld->cancel_error_ != GRPC_ERROR_NONE)) {
2049
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2050
+ gpr_log(GPR_INFO, "chand=%p calld=%p: failing batch with error: %s",
2051
+ chand, calld, grpc_error_string(calld->cancel_error_));
2052
+ }
2053
+ // Note: This will release the call combiner.
2054
+ grpc_transport_stream_op_batch_finish_with_failure(
2055
+ batch, GRPC_ERROR_REF(calld->cancel_error_), calld->call_combiner_);
2056
+ return;
2057
+ }
2058
+ // Handle cancellation.
2059
+ if (GPR_UNLIKELY(batch->cancel_stream)) {
2060
+ // Stash a copy of cancel_error in our call data, so that we can use
2061
+ // it for subsequent operations. This ensures that if the call is
2062
+ // cancelled before any batches are passed down (e.g., if the deadline
2063
+ // is in the past when the call starts), we can return the right
2064
+ // error to the caller when the first batch does get passed down.
2065
+ GRPC_ERROR_UNREF(calld->cancel_error_);
2066
+ calld->cancel_error_ =
2067
+ GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error);
2068
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2069
+ gpr_log(GPR_INFO, "chand=%p calld=%p: recording cancel_error=%s", chand,
2070
+ calld, grpc_error_string(calld->cancel_error_));
2071
+ }
2072
+ // If we do not have a subchannel call (i.e., a pick has not yet
2073
+ // been started), fail all pending batches. Otherwise, send the
2074
+ // cancellation down to the subchannel call.
2075
+ if (calld->subchannel_call_ == nullptr) {
2076
+ // TODO(roth): If there is a pending retry callback, do we need to
2077
+ // cancel it here?
2078
+ calld->PendingBatchesFail(elem, GRPC_ERROR_REF(calld->cancel_error_),
2079
+ NoYieldCallCombiner);
2080
+ // Note: This will release the call combiner.
2081
+ grpc_transport_stream_op_batch_finish_with_failure(
2082
+ batch, GRPC_ERROR_REF(calld->cancel_error_), calld->call_combiner_);
2083
+ } else {
2084
+ // Note: This will release the call combiner.
2085
+ calld->subchannel_call_->StartTransportStreamOpBatch(batch);
2086
+ }
2087
+ return;
2088
+ }
2089
+ // Add the batch to the pending list.
2090
+ calld->PendingBatchesAdd(elem, batch);
2091
+ // Check if we've already gotten a subchannel call.
2092
+ // Note that once we have picked a subchannel, we do not need to acquire
2093
+ // the channel's data plane mutex, which is more efficient (especially for
2094
+ // streaming calls).
2095
+ if (calld->subchannel_call_ != nullptr) {
2096
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2097
+ gpr_log(GPR_INFO,
2098
+ "chand=%p calld=%p: starting batch on subchannel_call=%p", chand,
2099
+ calld, calld->subchannel_call_.get());
2100
+ }
2101
+ calld->PendingBatchesResume(elem);
2102
+ return;
2103
+ }
2104
+ // We do not yet have a subchannel call.
2105
+ // For batches containing a send_initial_metadata op, acquire the
2106
+ // channel's data plane mutex to pick a subchannel.
2107
+ if (GPR_LIKELY(batch->send_initial_metadata)) {
2108
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2109
+ gpr_log(GPR_INFO,
2110
+ "chand=%p calld=%p: grabbing data plane mutex to perform pick",
2111
+ chand, calld);
2112
+ }
2113
+ PickSubchannel(elem, GRPC_ERROR_NONE);
2114
+ } else {
2115
+ // For all other batches, release the call combiner.
2116
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2117
+ gpr_log(GPR_INFO,
2118
+ "chand=%p calld=%p: saved batch, yielding call combiner", chand,
2119
+ calld);
2120
+ }
2121
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner_,
2122
+ "batch does not include send_initial_metadata");
2123
+ }
2124
+ }
2125
+
2126
+ void CallData::SetPollent(grpc_call_element* elem,
2127
+ grpc_polling_entity* pollent) {
2128
+ CallData* calld = static_cast<CallData*>(elem->call_data);
2129
+ calld->pollent_ = pollent;
2130
+ }
2131
+
2132
+ //
2133
+ // send op data caching
2134
+ //
2135
+
2136
+ void CallData::MaybeCacheSendOpsForBatch(PendingBatch* pending) {
2137
+ if (pending->send_ops_cached) return;
2138
+ pending->send_ops_cached = true;
2139
+ grpc_transport_stream_op_batch* batch = pending->batch;
2140
+ // Save a copy of metadata for send_initial_metadata ops.
2141
+ if (batch->send_initial_metadata) {
2142
+ seen_send_initial_metadata_ = true;
2143
+ GPR_ASSERT(send_initial_metadata_storage_ == nullptr);
2144
+ grpc_metadata_batch* send_initial_metadata =
2145
+ batch->payload->send_initial_metadata.send_initial_metadata;
2146
+ send_initial_metadata_storage_ = (grpc_linked_mdelem*)arena_->Alloc(
2147
+ sizeof(grpc_linked_mdelem) * send_initial_metadata->list.count);
2148
+ grpc_metadata_batch_copy(send_initial_metadata, &send_initial_metadata_,
2149
+ send_initial_metadata_storage_);
2150
+ send_initial_metadata_flags_ =
2151
+ batch->payload->send_initial_metadata.send_initial_metadata_flags;
2152
+ peer_string_ = batch->payload->send_initial_metadata.peer_string;
2153
+ }
2154
+ // Set up cache for send_message ops.
2155
+ if (batch->send_message) {
2156
+ ByteStreamCache* cache = arena_->New<ByteStreamCache>(
2157
+ std::move(batch->payload->send_message.send_message));
2158
+ send_messages_.push_back(cache);
2159
+ }
2160
+ // Save metadata batch for send_trailing_metadata ops.
2161
+ if (batch->send_trailing_metadata) {
2162
+ seen_send_trailing_metadata_ = true;
2163
+ GPR_ASSERT(send_trailing_metadata_storage_ == nullptr);
2164
+ grpc_metadata_batch* send_trailing_metadata =
2165
+ batch->payload->send_trailing_metadata.send_trailing_metadata;
2166
+ send_trailing_metadata_storage_ = (grpc_linked_mdelem*)arena_->Alloc(
2167
+ sizeof(grpc_linked_mdelem) * send_trailing_metadata->list.count);
2168
+ grpc_metadata_batch_copy(send_trailing_metadata, &send_trailing_metadata_,
2169
+ send_trailing_metadata_storage_);
2170
+ }
2171
+ }
2172
+
2173
+ void CallData::FreeCachedSendInitialMetadata(ChannelData* chand) {
2174
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2175
+ gpr_log(GPR_INFO,
2176
+ "chand=%p calld=%p: destroying calld->send_initial_metadata", chand,
2177
+ this);
2178
+ }
2179
+ grpc_metadata_batch_destroy(&send_initial_metadata_);
2180
+ }
2181
+
2182
+ void CallData::FreeCachedSendMessage(ChannelData* chand, size_t idx) {
2183
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2184
+ gpr_log(GPR_INFO,
2185
+ "chand=%p calld=%p: destroying calld->send_messages[%" PRIuPTR "]",
2186
+ chand, this, idx);
2187
+ }
2188
+ send_messages_[idx]->Destroy();
2189
+ }
2190
+
2191
+ void CallData::FreeCachedSendTrailingMetadata(ChannelData* chand) {
2192
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2193
+ gpr_log(GPR_INFO,
2194
+ "chand=%p calld=%p: destroying calld->send_trailing_metadata",
2195
+ chand, this);
2196
+ }
2197
+ grpc_metadata_batch_destroy(&send_trailing_metadata_);
2198
+ }
2199
+
2200
+ void CallData::FreeCachedSendOpDataAfterCommit(
2201
+ grpc_call_element* elem, SubchannelCallRetryState* retry_state) {
2202
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2203
+ if (retry_state->completed_send_initial_metadata) {
2204
+ FreeCachedSendInitialMetadata(chand);
2205
+ }
2206
+ for (size_t i = 0; i < retry_state->completed_send_message_count; ++i) {
2207
+ FreeCachedSendMessage(chand, i);
2208
+ }
2209
+ if (retry_state->completed_send_trailing_metadata) {
2210
+ FreeCachedSendTrailingMetadata(chand);
2211
+ }
2212
+ }
2213
+
2214
+ void CallData::FreeCachedSendOpDataForCompletedBatch(
2215
+ grpc_call_element* elem, SubchannelCallBatchData* batch_data,
2216
+ SubchannelCallRetryState* retry_state) {
2217
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2218
+ if (batch_data->batch.send_initial_metadata) {
2219
+ FreeCachedSendInitialMetadata(chand);
2220
+ }
2221
+ if (batch_data->batch.send_message) {
2222
+ FreeCachedSendMessage(chand, retry_state->completed_send_message_count - 1);
2223
+ }
2224
+ if (batch_data->batch.send_trailing_metadata) {
2225
+ FreeCachedSendTrailingMetadata(chand);
2226
+ }
2227
+ }
2228
+
2229
+ //
2230
+ // LB recv_trailing_metadata_ready handling
2231
+ //
2232
+
2233
+ void CallData::RecvTrailingMetadataReadyForLoadBalancingPolicy(
2234
+ void* arg, grpc_error* error) {
2235
+ CallData* calld = static_cast<CallData*>(arg);
2236
+ // Set error if call did not succeed.
2237
+ grpc_error* error_for_lb = GRPC_ERROR_NONE;
2238
+ if (error != GRPC_ERROR_NONE) {
2239
+ error_for_lb = error;
2240
+ } else {
2241
+ const auto& fields = calld->recv_trailing_metadata_->idx.named;
2242
+ GPR_ASSERT(fields.grpc_status != nullptr);
2243
+ grpc_status_code status =
2244
+ grpc_get_status_code_from_metadata(fields.grpc_status->md);
2245
+ std::string msg;
2246
+ if (status != GRPC_STATUS_OK) {
2247
+ error_for_lb = grpc_error_set_int(
2248
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("call failed"),
2249
+ GRPC_ERROR_INT_GRPC_STATUS, status);
2250
+ if (fields.grpc_message != nullptr) {
2251
+ error_for_lb = grpc_error_set_str(
2252
+ error_for_lb, GRPC_ERROR_STR_GRPC_MESSAGE,
2253
+ grpc_slice_ref_internal(GRPC_MDVALUE(fields.grpc_message->md)));
2254
+ }
2255
+ }
2256
+ }
2257
+ // Invoke callback to LB policy.
2258
+ Metadata trailing_metadata(calld, calld->recv_trailing_metadata_);
2259
+ calld->lb_recv_trailing_metadata_ready_(error_for_lb, &trailing_metadata,
2260
+ &calld->lb_call_state_);
2261
+ if (error == GRPC_ERROR_NONE) GRPC_ERROR_UNREF(error_for_lb);
2262
+ // Chain to original callback.
2263
+ Closure::Run(DEBUG_LOCATION, calld->original_recv_trailing_metadata_ready_,
2264
+ GRPC_ERROR_REF(error));
2265
+ }
2266
+
2267
+ void CallData::MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(
2268
+ grpc_transport_stream_op_batch* batch) {
2269
+ if (lb_recv_trailing_metadata_ready_ != nullptr) {
2270
+ recv_trailing_metadata_ =
2271
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata;
2272
+ original_recv_trailing_metadata_ready_ =
2273
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready;
2274
+ GRPC_CLOSURE_INIT(&recv_trailing_metadata_ready_,
2275
+ RecvTrailingMetadataReadyForLoadBalancingPolicy, this,
2276
+ grpc_schedule_on_exec_ctx);
2277
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready =
2278
+ &recv_trailing_metadata_ready_;
2279
+ }
2280
+ }
2281
+
2282
+ //
2283
+ // pending_batches management
2284
+ //
2285
+
2286
+ size_t CallData::GetBatchIndex(grpc_transport_stream_op_batch* batch) {
2287
+ // Note: It is important the send_initial_metadata be the first entry
2288
+ // here, since the code in pick_subchannel_locked() assumes it will be.
2289
+ if (batch->send_initial_metadata) return 0;
2290
+ if (batch->send_message) return 1;
2291
+ if (batch->send_trailing_metadata) return 2;
2292
+ if (batch->recv_initial_metadata) return 3;
2293
+ if (batch->recv_message) return 4;
2294
+ if (batch->recv_trailing_metadata) return 5;
2295
+ GPR_UNREACHABLE_CODE(return (size_t)-1);
2296
+ }
2297
+
2298
+ // This is called via the call combiner, so access to calld is synchronized.
2299
+ void CallData::PendingBatchesAdd(grpc_call_element* elem,
2300
+ grpc_transport_stream_op_batch* batch) {
2301
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2302
+ const size_t idx = GetBatchIndex(batch);
2303
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2304
+ gpr_log(GPR_INFO,
2305
+ "chand=%p calld=%p: adding pending batch at index %" PRIuPTR, chand,
2306
+ this, idx);
2307
+ }
2308
+ PendingBatch* pending = &pending_batches_[idx];
2309
+ GPR_ASSERT(pending->batch == nullptr);
2310
+ pending->batch = batch;
2311
+ pending->send_ops_cached = false;
2312
+ if (enable_retries_) {
2313
+ // Update state in calld about pending batches.
2314
+ // Also check if the batch takes us over the retry buffer limit.
2315
+ // Note: We don't check the size of trailing metadata here, because
2316
+ // gRPC clients do not send trailing metadata.
2317
+ if (batch->send_initial_metadata) {
2318
+ pending_send_initial_metadata_ = true;
2319
+ bytes_buffered_for_retry_ += grpc_metadata_batch_size(
2320
+ batch->payload->send_initial_metadata.send_initial_metadata);
2321
+ }
2322
+ if (batch->send_message) {
2323
+ pending_send_message_ = true;
2324
+ bytes_buffered_for_retry_ +=
2325
+ batch->payload->send_message.send_message->length();
2326
+ }
2327
+ if (batch->send_trailing_metadata) {
2328
+ pending_send_trailing_metadata_ = true;
2329
+ }
2330
+ if (GPR_UNLIKELY(bytes_buffered_for_retry_ >
2331
+ chand->per_rpc_retry_buffer_size())) {
2332
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2333
+ gpr_log(GPR_INFO,
2334
+ "chand=%p calld=%p: exceeded retry buffer size, committing",
2335
+ chand, this);
2336
+ }
2337
+ SubchannelCallRetryState* retry_state =
2338
+ subchannel_call_ == nullptr ? nullptr
2339
+ : static_cast<SubchannelCallRetryState*>(
2340
+ subchannel_call_->GetParentData());
2341
+ RetryCommit(elem, retry_state);
2342
+ // If we are not going to retry and have not yet started, pretend
2343
+ // retries are disabled so that we don't bother with retry overhead.
2344
+ if (num_attempts_completed_ == 0) {
2345
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2346
+ gpr_log(GPR_INFO,
2347
+ "chand=%p calld=%p: disabling retries before first attempt",
2348
+ chand, this);
2349
+ }
2350
+ enable_retries_ = false;
2351
+ }
2352
+ }
2353
+ }
2354
+ }
2355
+
2356
+ void CallData::PendingBatchClear(PendingBatch* pending) {
2357
+ if (enable_retries_) {
2358
+ if (pending->batch->send_initial_metadata) {
2359
+ pending_send_initial_metadata_ = false;
2360
+ }
2361
+ if (pending->batch->send_message) {
2362
+ pending_send_message_ = false;
2363
+ }
2364
+ if (pending->batch->send_trailing_metadata) {
2365
+ pending_send_trailing_metadata_ = false;
2366
+ }
2367
+ }
2368
+ pending->batch = nullptr;
2369
+ }
2370
+
2371
+ void CallData::MaybeClearPendingBatch(grpc_call_element* elem,
2372
+ PendingBatch* pending) {
2373
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2374
+ grpc_transport_stream_op_batch* batch = pending->batch;
2375
+ // We clear the pending batch if all of its callbacks have been
2376
+ // scheduled and reset to nullptr.
2377
+ if (batch->on_complete == nullptr &&
2378
+ (!batch->recv_initial_metadata ||
2379
+ batch->payload->recv_initial_metadata.recv_initial_metadata_ready ==
2380
+ nullptr) &&
2381
+ (!batch->recv_message ||
2382
+ batch->payload->recv_message.recv_message_ready == nullptr) &&
2383
+ (!batch->recv_trailing_metadata ||
2384
+ batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready ==
2385
+ nullptr)) {
2386
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2387
+ gpr_log(GPR_INFO, "chand=%p calld=%p: clearing pending batch", chand,
2388
+ this);
2389
+ }
2390
+ PendingBatchClear(pending);
2391
+ }
2392
+ }
2393
+
2394
+ // This is called via the call combiner, so access to calld is synchronized.
2395
+ void CallData::FailPendingBatchInCallCombiner(void* arg, grpc_error* error) {
2396
+ grpc_transport_stream_op_batch* batch =
2397
+ static_cast<grpc_transport_stream_op_batch*>(arg);
2398
+ CallData* calld = static_cast<CallData*>(batch->handler_private.extra_arg);
2399
+ // Note: This will release the call combiner.
2400
+ grpc_transport_stream_op_batch_finish_with_failure(
2401
+ batch, GRPC_ERROR_REF(error), calld->call_combiner_);
2402
+ }
2403
+
2404
+ // This is called via the call combiner, so access to calld is synchronized.
2405
+ void CallData::PendingBatchesFail(
2406
+ grpc_call_element* elem, grpc_error* error,
2407
+ YieldCallCombinerPredicate yield_call_combiner_predicate) {
2408
+ GPR_ASSERT(error != GRPC_ERROR_NONE);
2409
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2410
+ size_t num_batches = 0;
2411
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
2412
+ if (pending_batches_[i].batch != nullptr) ++num_batches;
2413
+ }
2414
+ gpr_log(GPR_INFO,
2415
+ "chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s",
2416
+ elem->channel_data, this, num_batches, grpc_error_string(error));
2417
+ }
2418
+ CallCombinerClosureList closures;
2419
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
2420
+ PendingBatch* pending = &pending_batches_[i];
2421
+ grpc_transport_stream_op_batch* batch = pending->batch;
2422
+ if (batch != nullptr) {
2423
+ if (batch->recv_trailing_metadata) {
2424
+ MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(batch);
2425
+ }
2426
+ batch->handler_private.extra_arg = this;
2427
+ GRPC_CLOSURE_INIT(&batch->handler_private.closure,
2428
+ FailPendingBatchInCallCombiner, batch,
2429
+ grpc_schedule_on_exec_ctx);
2430
+ closures.Add(&batch->handler_private.closure, GRPC_ERROR_REF(error),
2431
+ "PendingBatchesFail");
2432
+ PendingBatchClear(pending);
2433
+ }
2434
+ }
2435
+ if (yield_call_combiner_predicate(closures)) {
2436
+ closures.RunClosures(call_combiner_);
2437
+ } else {
2438
+ closures.RunClosuresWithoutYielding(call_combiner_);
2439
+ }
2440
+ GRPC_ERROR_UNREF(error);
2441
+ }
2442
+
2443
+ // This is called via the call combiner, so access to calld is synchronized.
2444
+ void CallData::ResumePendingBatchInCallCombiner(void* arg,
2445
+ grpc_error* /*ignored*/) {
2446
+ grpc_transport_stream_op_batch* batch =
2447
+ static_cast<grpc_transport_stream_op_batch*>(arg);
2448
+ SubchannelCall* subchannel_call =
2449
+ static_cast<SubchannelCall*>(batch->handler_private.extra_arg);
2450
+ // Note: This will release the call combiner.
2451
+ subchannel_call->StartTransportStreamOpBatch(batch);
2452
+ }
2453
+
2454
+ // This is called via the call combiner, so access to calld is synchronized.
2455
+ void CallData::PendingBatchesResume(grpc_call_element* elem) {
2456
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2457
+ if (enable_retries_) {
2458
+ StartRetriableSubchannelBatches(elem, GRPC_ERROR_NONE);
2459
+ return;
2460
+ }
2461
+ // Retries not enabled; send down batches as-is.
2462
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2463
+ size_t num_batches = 0;
2464
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
2465
+ if (pending_batches_[i].batch != nullptr) ++num_batches;
2466
+ }
2467
+ gpr_log(GPR_INFO,
2468
+ "chand=%p calld=%p: starting %" PRIuPTR
2469
+ " pending batches on subchannel_call=%p",
2470
+ chand, this, num_batches, subchannel_call_.get());
2471
+ }
2472
+ CallCombinerClosureList closures;
2473
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
2474
+ PendingBatch* pending = &pending_batches_[i];
2475
+ grpc_transport_stream_op_batch* batch = pending->batch;
2476
+ if (batch != nullptr) {
2477
+ if (batch->recv_trailing_metadata) {
2478
+ MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(batch);
2479
+ }
2480
+ batch->handler_private.extra_arg = subchannel_call_.get();
2481
+ GRPC_CLOSURE_INIT(&batch->handler_private.closure,
2482
+ ResumePendingBatchInCallCombiner, batch,
2483
+ grpc_schedule_on_exec_ctx);
2484
+ closures.Add(&batch->handler_private.closure, GRPC_ERROR_NONE,
2485
+ "PendingBatchesResume");
2486
+ PendingBatchClear(pending);
2487
+ }
2488
+ }
2489
+ // Note: This will release the call combiner.
2490
+ closures.RunClosures(call_combiner_);
2491
+ }
2492
+
2493
+ template <typename Predicate>
2494
+ CallData::PendingBatch* CallData::PendingBatchFind(grpc_call_element* elem,
2495
+ const char* log_message,
2496
+ Predicate predicate) {
2497
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2498
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
2499
+ PendingBatch* pending = &pending_batches_[i];
2500
+ grpc_transport_stream_op_batch* batch = pending->batch;
2501
+ if (batch != nullptr && predicate(batch)) {
2502
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2503
+ gpr_log(GPR_INFO,
2504
+ "chand=%p calld=%p: %s pending batch at index %" PRIuPTR, chand,
2505
+ this, log_message, i);
2506
+ }
2507
+ return pending;
2508
+ }
2509
+ }
2510
+ return nullptr;
2511
+ }
2512
+
2513
+ //
2514
+ // retry code
2515
+ //
2516
+
2517
+ void CallData::RetryCommit(grpc_call_element* elem,
2518
+ SubchannelCallRetryState* retry_state) {
2519
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2520
+ if (retry_committed_) return;
2521
+ retry_committed_ = true;
2522
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2523
+ gpr_log(GPR_INFO, "chand=%p calld=%p: committing retries", chand, this);
2524
+ }
2525
+ if (retry_state != nullptr) {
2526
+ FreeCachedSendOpDataAfterCommit(elem, retry_state);
2527
+ }
2528
+ }
2529
+
2530
+ void CallData::DoRetry(grpc_call_element* elem,
2531
+ SubchannelCallRetryState* retry_state,
2532
+ grpc_millis server_pushback_ms) {
2533
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2534
+ GPR_ASSERT(method_params_ != nullptr);
2535
+ const auto* retry_policy = method_params_->retry_policy();
2536
+ GPR_ASSERT(retry_policy != nullptr);
2537
+ // Reset subchannel call.
2538
+ subchannel_call_.reset();
2539
+ // Compute backoff delay.
2540
+ grpc_millis next_attempt_time;
2541
+ if (server_pushback_ms >= 0) {
2542
+ next_attempt_time = ExecCtx::Get()->Now() + server_pushback_ms;
2543
+ last_attempt_got_server_pushback_ = true;
2544
+ } else {
2545
+ if (num_attempts_completed_ == 1 || last_attempt_got_server_pushback_) {
2546
+ retry_backoff_.Init(
2547
+ BackOff::Options()
2548
+ .set_initial_backoff(retry_policy->initial_backoff)
2549
+ .set_multiplier(retry_policy->backoff_multiplier)
2550
+ .set_jitter(RETRY_BACKOFF_JITTER)
2551
+ .set_max_backoff(retry_policy->max_backoff));
2552
+ last_attempt_got_server_pushback_ = false;
2553
+ }
2554
+ next_attempt_time = retry_backoff_->NextAttemptTime();
2555
+ }
2556
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2557
+ gpr_log(GPR_INFO,
2558
+ "chand=%p calld=%p: retrying failed call in %" PRId64 " ms", chand,
2559
+ this, next_attempt_time - ExecCtx::Get()->Now());
2560
+ }
2561
+ // Schedule retry after computed delay.
2562
+ GRPC_CLOSURE_INIT(&pick_closure_, PickSubchannel, elem,
2563
+ grpc_schedule_on_exec_ctx);
2564
+ grpc_timer_init(&retry_timer_, next_attempt_time, &pick_closure_);
2565
+ // Update bookkeeping.
2566
+ if (retry_state != nullptr) retry_state->retry_dispatched = true;
2567
+ }
2568
+
2569
+ bool CallData::MaybeRetry(grpc_call_element* elem,
2570
+ SubchannelCallBatchData* batch_data,
2571
+ grpc_status_code status,
2572
+ grpc_mdelem* server_pushback_md) {
2573
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2574
+ // Get retry policy.
2575
+ if (method_params_ == nullptr) return false;
2576
+ const auto* retry_policy = method_params_->retry_policy();
2577
+ if (retry_policy == nullptr) return false;
2578
+ // If we've already dispatched a retry from this call, return true.
2579
+ // This catches the case where the batch has multiple callbacks
2580
+ // (i.e., it includes either recv_message or recv_initial_metadata).
2581
+ SubchannelCallRetryState* retry_state = nullptr;
2582
+ if (batch_data != nullptr) {
2583
+ retry_state = static_cast<SubchannelCallRetryState*>(
2584
+ batch_data->subchannel_call->GetParentData());
2585
+ if (retry_state->retry_dispatched) {
2586
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2587
+ gpr_log(GPR_INFO, "chand=%p calld=%p: retry already dispatched", chand,
2588
+ this);
2589
+ }
2590
+ return true;
2591
+ }
2592
+ }
2593
+ // Check status.
2594
+ if (GPR_LIKELY(status == GRPC_STATUS_OK)) {
2595
+ if (retry_throttle_data_ != nullptr) {
2596
+ retry_throttle_data_->RecordSuccess();
2597
+ }
2598
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2599
+ gpr_log(GPR_INFO, "chand=%p calld=%p: call succeeded", chand, this);
2600
+ }
2601
+ return false;
2602
+ }
2603
+ // Status is not OK. Check whether the status is retryable.
2604
+ if (!retry_policy->retryable_status_codes.Contains(status)) {
2605
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2606
+ gpr_log(GPR_INFO,
2607
+ "chand=%p calld=%p: status %s not configured as retryable", chand,
2608
+ this, grpc_status_code_to_string(status));
2609
+ }
2610
+ return false;
2611
+ }
2612
+ // Record the failure and check whether retries are throttled.
2613
+ // Note that it's important for this check to come after the status
2614
+ // code check above, since we should only record failures whose statuses
2615
+ // match the configured retryable status codes, so that we don't count
2616
+ // things like failures due to malformed requests (INVALID_ARGUMENT).
2617
+ // Conversely, it's important for this to come before the remaining
2618
+ // checks, so that we don't fail to record failures due to other factors.
2619
+ if (retry_throttle_data_ != nullptr &&
2620
+ !retry_throttle_data_->RecordFailure()) {
2621
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2622
+ gpr_log(GPR_INFO, "chand=%p calld=%p: retries throttled", chand, this);
2623
+ }
2624
+ return false;
2625
+ }
2626
+ // Check whether the call is committed.
2627
+ if (retry_committed_) {
2628
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2629
+ gpr_log(GPR_INFO, "chand=%p calld=%p: retries already committed", chand,
2630
+ this);
2631
+ }
2632
+ return false;
2633
+ }
2634
+ // Check whether we have retries remaining.
2635
+ ++num_attempts_completed_;
2636
+ if (num_attempts_completed_ >= retry_policy->max_attempts) {
2637
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2638
+ gpr_log(GPR_INFO, "chand=%p calld=%p: exceeded %d retry attempts", chand,
2639
+ this, retry_policy->max_attempts);
2640
+ }
2641
+ return false;
2642
+ }
2643
+ // If the call was cancelled from the surface, don't retry.
2644
+ if (cancel_error_ != GRPC_ERROR_NONE) {
2645
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2646
+ gpr_log(GPR_INFO,
2647
+ "chand=%p calld=%p: call cancelled from surface, not retrying",
2648
+ chand, this);
2649
+ }
2650
+ return false;
2651
+ }
2652
+ // Check server push-back.
2653
+ grpc_millis server_pushback_ms = -1;
2654
+ if (server_pushback_md != nullptr) {
2655
+ // If the value is "-1" or any other unparseable string, we do not retry.
2656
+ uint32_t ms;
2657
+ if (!grpc_parse_slice_to_uint32(GRPC_MDVALUE(*server_pushback_md), &ms)) {
2658
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2659
+ gpr_log(GPR_INFO,
2660
+ "chand=%p calld=%p: not retrying due to server push-back",
2661
+ chand, this);
2662
+ }
2663
+ return false;
2664
+ } else {
2665
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2666
+ gpr_log(GPR_INFO, "chand=%p calld=%p: server push-back: retry in %u ms",
2667
+ chand, this, ms);
2668
+ }
2669
+ server_pushback_ms = (grpc_millis)ms;
2670
+ }
2671
+ }
2672
+ DoRetry(elem, retry_state, server_pushback_ms);
2673
+ return true;
2674
+ }
2675
+
2676
+ //
2677
+ // CallData::SubchannelCallBatchData
2678
+ //
2679
+
2680
+ CallData::SubchannelCallBatchData* CallData::SubchannelCallBatchData::Create(
2681
+ grpc_call_element* elem, int refcount, bool set_on_complete) {
2682
+ CallData* calld = static_cast<CallData*>(elem->call_data);
2683
+ return calld->arena_->New<SubchannelCallBatchData>(elem, calld, refcount,
2684
+ set_on_complete);
2685
+ }
2686
+
2687
+ CallData::SubchannelCallBatchData::SubchannelCallBatchData(
2688
+ grpc_call_element* elem, CallData* calld, int refcount,
2689
+ bool set_on_complete)
2690
+ : elem(elem), subchannel_call(calld->subchannel_call_) {
2691
+ SubchannelCallRetryState* retry_state =
2692
+ static_cast<SubchannelCallRetryState*>(
2693
+ calld->subchannel_call_->GetParentData());
2694
+ batch.payload = &retry_state->batch_payload;
2695
+ gpr_ref_init(&refs, refcount);
2696
+ if (set_on_complete) {
2697
+ GRPC_CLOSURE_INIT(&on_complete, CallData::OnComplete, this,
2698
+ grpc_schedule_on_exec_ctx);
2699
+ batch.on_complete = &on_complete;
2700
+ }
2701
+ GRPC_CALL_STACK_REF(calld->owning_call_, "batch_data");
2702
+ }
2703
+
2704
+ void CallData::SubchannelCallBatchData::Destroy() {
2705
+ SubchannelCallRetryState* retry_state =
2706
+ static_cast<SubchannelCallRetryState*>(subchannel_call->GetParentData());
2707
+ if (batch.send_initial_metadata) {
2708
+ grpc_metadata_batch_destroy(&retry_state->send_initial_metadata);
2709
+ }
2710
+ if (batch.send_trailing_metadata) {
2711
+ grpc_metadata_batch_destroy(&retry_state->send_trailing_metadata);
2712
+ }
2713
+ if (batch.recv_initial_metadata) {
2714
+ grpc_metadata_batch_destroy(&retry_state->recv_initial_metadata);
2715
+ }
2716
+ if (batch.recv_trailing_metadata) {
2717
+ grpc_metadata_batch_destroy(&retry_state->recv_trailing_metadata);
2718
+ }
2719
+ subchannel_call.reset();
2720
+ CallData* calld = static_cast<CallData*>(elem->call_data);
2721
+ GRPC_CALL_STACK_UNREF(calld->owning_call_, "batch_data");
2722
+ }
2723
+
2724
+ //
2725
+ // recv_initial_metadata callback handling
2726
+ //
2727
+
2728
+ void CallData::InvokeRecvInitialMetadataCallback(void* arg, grpc_error* error) {
2729
+ SubchannelCallBatchData* batch_data =
2730
+ static_cast<SubchannelCallBatchData*>(arg);
2731
+ CallData* calld = static_cast<CallData*>(batch_data->elem->call_data);
2732
+ // Find pending batch.
2733
+ PendingBatch* pending = calld->PendingBatchFind(
2734
+ batch_data->elem, "invoking recv_initial_metadata_ready for",
2735
+ [](grpc_transport_stream_op_batch* batch) {
2736
+ return batch->recv_initial_metadata &&
2737
+ batch->payload->recv_initial_metadata
2738
+ .recv_initial_metadata_ready != nullptr;
2739
+ });
2740
+ GPR_ASSERT(pending != nullptr);
2741
+ // Return metadata.
2742
+ SubchannelCallRetryState* retry_state =
2743
+ static_cast<SubchannelCallRetryState*>(
2744
+ batch_data->subchannel_call->GetParentData());
2745
+ grpc_metadata_batch_move(
2746
+ &retry_state->recv_initial_metadata,
2747
+ pending->batch->payload->recv_initial_metadata.recv_initial_metadata);
2748
+ // Update bookkeeping.
2749
+ // Note: Need to do this before invoking the callback, since invoking
2750
+ // the callback will result in yielding the call combiner.
2751
+ grpc_closure* recv_initial_metadata_ready =
2752
+ pending->batch->payload->recv_initial_metadata
2753
+ .recv_initial_metadata_ready;
2754
+ pending->batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
2755
+ nullptr;
2756
+ calld->MaybeClearPendingBatch(batch_data->elem, pending);
2757
+ batch_data->Unref();
2758
+ // Invoke callback.
2759
+ Closure::Run(DEBUG_LOCATION, recv_initial_metadata_ready,
2760
+ GRPC_ERROR_REF(error));
2761
+ }
2762
+
2763
+ void CallData::RecvInitialMetadataReady(void* arg, grpc_error* error) {
2764
+ SubchannelCallBatchData* batch_data =
2765
+ static_cast<SubchannelCallBatchData*>(arg);
2766
+ grpc_call_element* elem = batch_data->elem;
2767
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2768
+ CallData* calld = static_cast<CallData*>(elem->call_data);
2769
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2770
+ gpr_log(GPR_INFO,
2771
+ "chand=%p calld=%p: got recv_initial_metadata_ready, error=%s",
2772
+ chand, calld, grpc_error_string(error));
2773
+ }
2774
+ SubchannelCallRetryState* retry_state =
2775
+ static_cast<SubchannelCallRetryState*>(
2776
+ batch_data->subchannel_call->GetParentData());
2777
+ retry_state->completed_recv_initial_metadata = true;
2778
+ // If a retry was already dispatched, then we're not going to use the
2779
+ // result of this recv_initial_metadata op, so do nothing.
2780
+ if (retry_state->retry_dispatched) {
2781
+ GRPC_CALL_COMBINER_STOP(
2782
+ calld->call_combiner_,
2783
+ "recv_initial_metadata_ready after retry dispatched");
2784
+ return;
2785
+ }
2786
+ // If we got an error or a Trailers-Only response and have not yet gotten
2787
+ // the recv_trailing_metadata_ready callback, then defer propagating this
2788
+ // callback back to the surface. We can evaluate whether to retry when
2789
+ // recv_trailing_metadata comes back.
2790
+ if (GPR_UNLIKELY((retry_state->trailing_metadata_available ||
2791
+ error != GRPC_ERROR_NONE) &&
2792
+ !retry_state->completed_recv_trailing_metadata)) {
2793
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2794
+ gpr_log(GPR_INFO,
2795
+ "chand=%p calld=%p: deferring recv_initial_metadata_ready "
2796
+ "(Trailers-Only)",
2797
+ chand, calld);
2798
+ }
2799
+ retry_state->recv_initial_metadata_ready_deferred_batch = batch_data;
2800
+ retry_state->recv_initial_metadata_error = GRPC_ERROR_REF(error);
2801
+ if (!retry_state->started_recv_trailing_metadata) {
2802
+ // recv_trailing_metadata not yet started by application; start it
2803
+ // ourselves to get status.
2804
+ calld->StartInternalRecvTrailingMetadata(elem);
2805
+ } else {
2806
+ GRPC_CALL_COMBINER_STOP(
2807
+ calld->call_combiner_,
2808
+ "recv_initial_metadata_ready trailers-only or error");
2809
+ }
2810
+ return;
2811
+ }
2812
+ // Received valid initial metadata, so commit the call.
2813
+ calld->RetryCommit(elem, retry_state);
2814
+ // Invoke the callback to return the result to the surface.
2815
+ // Manually invoking a callback function; it does not take ownership of error.
2816
+ calld->InvokeRecvInitialMetadataCallback(batch_data, error);
2817
+ }
2818
+
2819
+ //
2820
+ // recv_message callback handling
2821
+ //
2822
+
2823
+ void CallData::InvokeRecvMessageCallback(void* arg, grpc_error* error) {
2824
+ SubchannelCallBatchData* batch_data =
2825
+ static_cast<SubchannelCallBatchData*>(arg);
2826
+ CallData* calld = static_cast<CallData*>(batch_data->elem->call_data);
2827
+ // Find pending op.
2828
+ PendingBatch* pending = calld->PendingBatchFind(
2829
+ batch_data->elem, "invoking recv_message_ready for",
2830
+ [](grpc_transport_stream_op_batch* batch) {
2831
+ return batch->recv_message &&
2832
+ batch->payload->recv_message.recv_message_ready != nullptr;
2833
+ });
2834
+ GPR_ASSERT(pending != nullptr);
2835
+ // Return payload.
2836
+ SubchannelCallRetryState* retry_state =
2837
+ static_cast<SubchannelCallRetryState*>(
2838
+ batch_data->subchannel_call->GetParentData());
2839
+ *pending->batch->payload->recv_message.recv_message =
2840
+ std::move(retry_state->recv_message);
2841
+ // Update bookkeeping.
2842
+ // Note: Need to do this before invoking the callback, since invoking
2843
+ // the callback will result in yielding the call combiner.
2844
+ grpc_closure* recv_message_ready =
2845
+ pending->batch->payload->recv_message.recv_message_ready;
2846
+ pending->batch->payload->recv_message.recv_message_ready = nullptr;
2847
+ calld->MaybeClearPendingBatch(batch_data->elem, pending);
2848
+ batch_data->Unref();
2849
+ // Invoke callback.
2850
+ Closure::Run(DEBUG_LOCATION, recv_message_ready, GRPC_ERROR_REF(error));
2851
+ }
2852
+
2853
+ void CallData::RecvMessageReady(void* arg, grpc_error* error) {
2854
+ SubchannelCallBatchData* batch_data =
2855
+ static_cast<SubchannelCallBatchData*>(arg);
2856
+ grpc_call_element* elem = batch_data->elem;
2857
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
2858
+ CallData* calld = static_cast<CallData*>(elem->call_data);
2859
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2860
+ gpr_log(GPR_INFO, "chand=%p calld=%p: got recv_message_ready, error=%s",
2861
+ chand, calld, grpc_error_string(error));
2862
+ }
2863
+ SubchannelCallRetryState* retry_state =
2864
+ static_cast<SubchannelCallRetryState*>(
2865
+ batch_data->subchannel_call->GetParentData());
2866
+ ++retry_state->completed_recv_message_count;
2867
+ // If a retry was already dispatched, then we're not going to use the
2868
+ // result of this recv_message op, so do nothing.
2869
+ if (retry_state->retry_dispatched) {
2870
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner_,
2871
+ "recv_message_ready after retry dispatched");
2872
+ return;
2873
+ }
2874
+ // If we got an error or the payload was nullptr and we have not yet gotten
2875
+ // the recv_trailing_metadata_ready callback, then defer propagating this
2876
+ // callback back to the surface. We can evaluate whether to retry when
2877
+ // recv_trailing_metadata comes back.
2878
+ if (GPR_UNLIKELY(
2879
+ (retry_state->recv_message == nullptr || error != GRPC_ERROR_NONE) &&
2880
+ !retry_state->completed_recv_trailing_metadata)) {
2881
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
2882
+ gpr_log(GPR_INFO,
2883
+ "chand=%p calld=%p: deferring recv_message_ready (nullptr "
2884
+ "message and recv_trailing_metadata pending)",
2885
+ chand, calld);
2886
+ }
2887
+ retry_state->recv_message_ready_deferred_batch = batch_data;
2888
+ retry_state->recv_message_error = GRPC_ERROR_REF(error);
2889
+ if (!retry_state->started_recv_trailing_metadata) {
2890
+ // recv_trailing_metadata not yet started by application; start it
2891
+ // ourselves to get status.
2892
+ calld->StartInternalRecvTrailingMetadata(elem);
2893
+ } else {
2894
+ GRPC_CALL_COMBINER_STOP(calld->call_combiner_, "recv_message_ready null");
2895
+ }
2896
+ return;
2897
+ }
2898
+ // Received a valid message, so commit the call.
2899
+ calld->RetryCommit(elem, retry_state);
2900
+ // Invoke the callback to return the result to the surface.
2901
+ // Manually invoking a callback function; it does not take ownership of error.
2902
+ calld->InvokeRecvMessageCallback(batch_data, error);
2903
+ }
2904
+
2905
+ //
2906
+ // recv_trailing_metadata handling
2907
+ //
2908
+
2909
+ void CallData::GetCallStatus(grpc_metadata_batch* md_batch, grpc_error* error,
2910
+ grpc_status_code* status,
2911
+ grpc_mdelem** server_pushback_md) {
2912
+ if (error != GRPC_ERROR_NONE) {
2913
+ grpc_error_get_status(error, deadline_, status, nullptr, nullptr, nullptr);
2914
+ } else {
2915
+ GPR_ASSERT(md_batch->idx.named.grpc_status != nullptr);
2916
+ *status =
2917
+ grpc_get_status_code_from_metadata(md_batch->idx.named.grpc_status->md);
2918
+ if (server_pushback_md != nullptr &&
2919
+ md_batch->idx.named.grpc_retry_pushback_ms != nullptr) {
2920
+ *server_pushback_md = &md_batch->idx.named.grpc_retry_pushback_ms->md;
2921
+ }
2922
+ }
2923
+ GRPC_ERROR_UNREF(error);
2924
+ }
2925
+
2926
+ void CallData::AddClosureForRecvTrailingMetadataReady(
2927
+ grpc_call_element* elem, SubchannelCallBatchData* batch_data,
2928
+ grpc_error* error, CallCombinerClosureList* closures) {
2929
+ // Find pending batch.
2930
+ PendingBatch* pending = PendingBatchFind(
2931
+ elem, "invoking recv_trailing_metadata for",
2932
+ [](grpc_transport_stream_op_batch* batch) {
2933
+ return batch->recv_trailing_metadata &&
2934
+ batch->payload->recv_trailing_metadata
2935
+ .recv_trailing_metadata_ready != nullptr;
2936
+ });
2937
+ // If we generated the recv_trailing_metadata op internally via
2938
+ // StartInternalRecvTrailingMetadata(), then there will be no pending batch.
2939
+ if (pending == nullptr) {
2940
+ GRPC_ERROR_UNREF(error);
2941
+ return;
2942
+ }
2943
+ // Return metadata.
2944
+ SubchannelCallRetryState* retry_state =
2945
+ static_cast<SubchannelCallRetryState*>(
2946
+ batch_data->subchannel_call->GetParentData());
2947
+ grpc_metadata_batch_move(
2948
+ &retry_state->recv_trailing_metadata,
2949
+ pending->batch->payload->recv_trailing_metadata.recv_trailing_metadata);
2950
+ // Add closure.
2951
+ closures->Add(pending->batch->payload->recv_trailing_metadata
2952
+ .recv_trailing_metadata_ready,
2953
+ error, "recv_trailing_metadata_ready for pending batch");
2954
+ // Update bookkeeping.
2955
+ pending->batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready =
2956
+ nullptr;
2957
+ MaybeClearPendingBatch(elem, pending);
2958
+ }
2959
+
2960
+ void CallData::AddClosuresForDeferredRecvCallbacks(
2961
+ SubchannelCallBatchData* batch_data, SubchannelCallRetryState* retry_state,
2962
+ CallCombinerClosureList* closures) {
2963
+ if (batch_data->batch.recv_trailing_metadata) {
2964
+ // Add closure for deferred recv_initial_metadata_ready.
2965
+ if (GPR_UNLIKELY(retry_state->recv_initial_metadata_ready_deferred_batch !=
2966
+ nullptr)) {
2967
+ GRPC_CLOSURE_INIT(&retry_state->recv_initial_metadata_ready,
2968
+ InvokeRecvInitialMetadataCallback,
2969
+ retry_state->recv_initial_metadata_ready_deferred_batch,
2970
+ grpc_schedule_on_exec_ctx);
2971
+ closures->Add(&retry_state->recv_initial_metadata_ready,
2972
+ retry_state->recv_initial_metadata_error,
2973
+ "resuming recv_initial_metadata_ready");
2974
+ retry_state->recv_initial_metadata_ready_deferred_batch = nullptr;
2975
+ }
2976
+ // Add closure for deferred recv_message_ready.
2977
+ if (GPR_UNLIKELY(retry_state->recv_message_ready_deferred_batch !=
2978
+ nullptr)) {
2979
+ GRPC_CLOSURE_INIT(&retry_state->recv_message_ready,
2980
+ InvokeRecvMessageCallback,
2981
+ retry_state->recv_message_ready_deferred_batch,
2982
+ grpc_schedule_on_exec_ctx);
2983
+ closures->Add(&retry_state->recv_message_ready,
2984
+ retry_state->recv_message_error,
2985
+ "resuming recv_message_ready");
2986
+ retry_state->recv_message_ready_deferred_batch = nullptr;
2987
+ }
2988
+ }
2989
+ }
2990
+
2991
+ bool CallData::PendingBatchIsUnstarted(PendingBatch* pending,
2992
+ SubchannelCallRetryState* retry_state) {
2993
+ if (pending->batch == nullptr || pending->batch->on_complete == nullptr) {
2994
+ return false;
2995
+ }
2996
+ if (pending->batch->send_initial_metadata &&
2997
+ !retry_state->started_send_initial_metadata) {
2998
+ return true;
2999
+ }
3000
+ if (pending->batch->send_message &&
3001
+ retry_state->started_send_message_count < send_messages_.size()) {
3002
+ return true;
3003
+ }
3004
+ if (pending->batch->send_trailing_metadata &&
3005
+ !retry_state->started_send_trailing_metadata) {
3006
+ return true;
3007
+ }
3008
+ return false;
3009
+ }
3010
+
3011
+ void CallData::AddClosuresToFailUnstartedPendingBatches(
3012
+ grpc_call_element* elem, SubchannelCallRetryState* retry_state,
3013
+ grpc_error* error, CallCombinerClosureList* closures) {
3014
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3015
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
3016
+ PendingBatch* pending = &pending_batches_[i];
3017
+ if (PendingBatchIsUnstarted(pending, retry_state)) {
3018
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3019
+ gpr_log(GPR_INFO,
3020
+ "chand=%p calld=%p: failing unstarted pending batch at index "
3021
+ "%" PRIuPTR,
3022
+ chand, this, i);
3023
+ }
3024
+ closures->Add(pending->batch->on_complete, GRPC_ERROR_REF(error),
3025
+ "failing on_complete for pending batch");
3026
+ pending->batch->on_complete = nullptr;
3027
+ MaybeClearPendingBatch(elem, pending);
3028
+ }
3029
+ }
3030
+ GRPC_ERROR_UNREF(error);
3031
+ }
3032
+
3033
+ void CallData::RunClosuresForCompletedCall(SubchannelCallBatchData* batch_data,
3034
+ grpc_error* error) {
3035
+ grpc_call_element* elem = batch_data->elem;
3036
+ SubchannelCallRetryState* retry_state =
3037
+ static_cast<SubchannelCallRetryState*>(
3038
+ batch_data->subchannel_call->GetParentData());
3039
+ // Construct list of closures to execute.
3040
+ CallCombinerClosureList closures;
3041
+ // First, add closure for recv_trailing_metadata_ready.
3042
+ AddClosureForRecvTrailingMetadataReady(elem, batch_data,
3043
+ GRPC_ERROR_REF(error), &closures);
3044
+ // If there are deferred recv_initial_metadata_ready or recv_message_ready
3045
+ // callbacks, add them to closures.
3046
+ AddClosuresForDeferredRecvCallbacks(batch_data, retry_state, &closures);
3047
+ // Add closures to fail any pending batches that have not yet been started.
3048
+ AddClosuresToFailUnstartedPendingBatches(elem, retry_state,
3049
+ GRPC_ERROR_REF(error), &closures);
3050
+ // Don't need batch_data anymore.
3051
+ batch_data->Unref();
3052
+ // Schedule all of the closures identified above.
3053
+ // Note: This will release the call combiner.
3054
+ closures.RunClosures(call_combiner_);
3055
+ GRPC_ERROR_UNREF(error);
3056
+ }
3057
+
3058
+ void CallData::RecvTrailingMetadataReady(void* arg, grpc_error* error) {
3059
+ SubchannelCallBatchData* batch_data =
3060
+ static_cast<SubchannelCallBatchData*>(arg);
3061
+ grpc_call_element* elem = batch_data->elem;
3062
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3063
+ CallData* calld = static_cast<CallData*>(elem->call_data);
3064
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3065
+ gpr_log(GPR_INFO,
3066
+ "chand=%p calld=%p: got recv_trailing_metadata_ready, error=%s",
3067
+ chand, calld, grpc_error_string(error));
3068
+ }
3069
+ SubchannelCallRetryState* retry_state =
3070
+ static_cast<SubchannelCallRetryState*>(
3071
+ batch_data->subchannel_call->GetParentData());
3072
+ retry_state->completed_recv_trailing_metadata = true;
3073
+ // Get the call's status and check for server pushback metadata.
3074
+ grpc_status_code status = GRPC_STATUS_OK;
3075
+ grpc_mdelem* server_pushback_md = nullptr;
3076
+ grpc_metadata_batch* md_batch =
3077
+ batch_data->batch.payload->recv_trailing_metadata.recv_trailing_metadata;
3078
+ calld->GetCallStatus(md_batch, GRPC_ERROR_REF(error), &status,
3079
+ &server_pushback_md);
3080
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3081
+ gpr_log(GPR_INFO, "chand=%p calld=%p: call finished, status=%s", chand,
3082
+ calld, grpc_status_code_to_string(status));
3083
+ }
3084
+ // Check if we should retry.
3085
+ if (calld->MaybeRetry(elem, batch_data, status, server_pushback_md)) {
3086
+ // Unref batch_data for deferred recv_initial_metadata_ready or
3087
+ // recv_message_ready callbacks, if any.
3088
+ if (retry_state->recv_initial_metadata_ready_deferred_batch != nullptr) {
3089
+ batch_data->Unref();
3090
+ GRPC_ERROR_UNREF(retry_state->recv_initial_metadata_error);
3091
+ }
3092
+ if (retry_state->recv_message_ready_deferred_batch != nullptr) {
3093
+ batch_data->Unref();
3094
+ GRPC_ERROR_UNREF(retry_state->recv_message_error);
3095
+ }
3096
+ batch_data->Unref();
3097
+ return;
3098
+ }
3099
+ // Not retrying, so commit the call.
3100
+ calld->RetryCommit(elem, retry_state);
3101
+ // Run any necessary closures.
3102
+ calld->RunClosuresForCompletedCall(batch_data, GRPC_ERROR_REF(error));
3103
+ }
3104
+
3105
+ //
3106
+ // on_complete callback handling
3107
+ //
3108
+
3109
+ void CallData::AddClosuresForCompletedPendingBatch(
3110
+ grpc_call_element* elem, SubchannelCallBatchData* batch_data,
3111
+ grpc_error* error, CallCombinerClosureList* closures) {
3112
+ PendingBatch* pending = PendingBatchFind(
3113
+ elem, "completed", [batch_data](grpc_transport_stream_op_batch* batch) {
3114
+ // Match the pending batch with the same set of send ops as the
3115
+ // subchannel batch we've just completed.
3116
+ return batch->on_complete != nullptr &&
3117
+ batch_data->batch.send_initial_metadata ==
3118
+ batch->send_initial_metadata &&
3119
+ batch_data->batch.send_message == batch->send_message &&
3120
+ batch_data->batch.send_trailing_metadata ==
3121
+ batch->send_trailing_metadata;
3122
+ });
3123
+ // If batch_data is a replay batch, then there will be no pending
3124
+ // batch to complete.
3125
+ if (pending == nullptr) {
3126
+ GRPC_ERROR_UNREF(error);
3127
+ return;
3128
+ }
3129
+ // Add closure.
3130
+ closures->Add(pending->batch->on_complete, error,
3131
+ "on_complete for pending batch");
3132
+ pending->batch->on_complete = nullptr;
3133
+ MaybeClearPendingBatch(elem, pending);
3134
+ }
3135
+
3136
+ void CallData::AddClosuresForReplayOrPendingSendOps(
3137
+ grpc_call_element* elem, SubchannelCallBatchData* batch_data,
3138
+ SubchannelCallRetryState* retry_state, CallCombinerClosureList* closures) {
3139
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3140
+ bool have_pending_send_message_ops =
3141
+ retry_state->started_send_message_count < send_messages_.size();
3142
+ bool have_pending_send_trailing_metadata_op =
3143
+ seen_send_trailing_metadata_ &&
3144
+ !retry_state->started_send_trailing_metadata;
3145
+ if (!have_pending_send_message_ops &&
3146
+ !have_pending_send_trailing_metadata_op) {
3147
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
3148
+ PendingBatch* pending = &pending_batches_[i];
3149
+ grpc_transport_stream_op_batch* batch = pending->batch;
3150
+ if (batch == nullptr || pending->send_ops_cached) continue;
3151
+ if (batch->send_message) have_pending_send_message_ops = true;
3152
+ if (batch->send_trailing_metadata) {
3153
+ have_pending_send_trailing_metadata_op = true;
3154
+ }
3155
+ }
3156
+ }
3157
+ if (have_pending_send_message_ops || have_pending_send_trailing_metadata_op) {
3158
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3159
+ gpr_log(GPR_INFO,
3160
+ "chand=%p calld=%p: starting next batch for pending send op(s)",
3161
+ chand, this);
3162
+ }
3163
+ GRPC_CLOSURE_INIT(&batch_data->batch.handler_private.closure,
3164
+ StartRetriableSubchannelBatches, elem,
3165
+ grpc_schedule_on_exec_ctx);
3166
+ closures->Add(&batch_data->batch.handler_private.closure, GRPC_ERROR_NONE,
3167
+ "starting next batch for send_* op(s)");
3168
+ }
3169
+ }
3170
+
3171
+ void CallData::OnComplete(void* arg, grpc_error* error) {
3172
+ SubchannelCallBatchData* batch_data =
3173
+ static_cast<SubchannelCallBatchData*>(arg);
3174
+ grpc_call_element* elem = batch_data->elem;
3175
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3176
+ CallData* calld = static_cast<CallData*>(elem->call_data);
3177
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3178
+ gpr_log(GPR_INFO, "chand=%p calld=%p: got on_complete, error=%s, batch=%s",
3179
+ chand, calld, grpc_error_string(error),
3180
+ grpc_transport_stream_op_batch_string(&batch_data->batch).c_str());
3181
+ }
3182
+ SubchannelCallRetryState* retry_state =
3183
+ static_cast<SubchannelCallRetryState*>(
3184
+ batch_data->subchannel_call->GetParentData());
3185
+ // Update bookkeeping in retry_state.
3186
+ if (batch_data->batch.send_initial_metadata) {
3187
+ retry_state->completed_send_initial_metadata = true;
3188
+ }
3189
+ if (batch_data->batch.send_message) {
3190
+ ++retry_state->completed_send_message_count;
3191
+ }
3192
+ if (batch_data->batch.send_trailing_metadata) {
3193
+ retry_state->completed_send_trailing_metadata = true;
3194
+ }
3195
+ // If the call is committed, free cached data for send ops that we've just
3196
+ // completed.
3197
+ if (calld->retry_committed_) {
3198
+ calld->FreeCachedSendOpDataForCompletedBatch(elem, batch_data, retry_state);
3199
+ }
3200
+ // Construct list of closures to execute.
3201
+ CallCombinerClosureList closures;
3202
+ // If a retry was already dispatched, that means we saw
3203
+ // recv_trailing_metadata before this, so we do nothing here.
3204
+ // Otherwise, invoke the callback to return the result to the surface.
3205
+ if (!retry_state->retry_dispatched) {
3206
+ // Add closure for the completed pending batch, if any.
3207
+ calld->AddClosuresForCompletedPendingBatch(
3208
+ elem, batch_data, GRPC_ERROR_REF(error), &closures);
3209
+ // If needed, add a callback to start any replay or pending send ops on
3210
+ // the subchannel call.
3211
+ if (!retry_state->completed_recv_trailing_metadata) {
3212
+ calld->AddClosuresForReplayOrPendingSendOps(elem, batch_data, retry_state,
3213
+ &closures);
3214
+ }
3215
+ }
3216
+ // Track number of pending subchannel send batches and determine if this
3217
+ // was the last one.
3218
+ --calld->num_pending_retriable_subchannel_send_batches_;
3219
+ const bool last_send_batch_complete =
3220
+ calld->num_pending_retriable_subchannel_send_batches_ == 0;
3221
+ // Don't need batch_data anymore.
3222
+ batch_data->Unref();
3223
+ // Schedule all of the closures identified above.
3224
+ // Note: This yeilds the call combiner.
3225
+ closures.RunClosures(calld->call_combiner_);
3226
+ // If this was the last subchannel send batch, unref the call stack.
3227
+ if (last_send_batch_complete) {
3228
+ GRPC_CALL_STACK_UNREF(calld->owning_call_, "subchannel_send_batches");
3229
+ }
3230
+ }
3231
+
3232
+ //
3233
+ // subchannel batch construction
3234
+ //
3235
+
3236
+ void CallData::StartBatchInCallCombiner(void* arg, grpc_error* /*ignored*/) {
3237
+ grpc_transport_stream_op_batch* batch =
3238
+ static_cast<grpc_transport_stream_op_batch*>(arg);
3239
+ SubchannelCall* subchannel_call =
3240
+ static_cast<SubchannelCall*>(batch->handler_private.extra_arg);
3241
+ // Note: This will release the call combiner.
3242
+ subchannel_call->StartTransportStreamOpBatch(batch);
3243
+ }
3244
+
3245
+ void CallData::AddClosureForSubchannelBatch(
3246
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch,
3247
+ CallCombinerClosureList* closures) {
3248
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3249
+ batch->handler_private.extra_arg = subchannel_call_.get();
3250
+ GRPC_CLOSURE_INIT(&batch->handler_private.closure, StartBatchInCallCombiner,
3251
+ batch, grpc_schedule_on_exec_ctx);
3252
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3253
+ gpr_log(GPR_INFO, "chand=%p calld=%p: starting subchannel batch: %s", chand,
3254
+ this, grpc_transport_stream_op_batch_string(batch).c_str());
3255
+ }
3256
+ closures->Add(&batch->handler_private.closure, GRPC_ERROR_NONE,
3257
+ "start_subchannel_batch");
3258
+ }
3259
+
3260
+ void CallData::AddRetriableSendInitialMetadataOp(
3261
+ SubchannelCallRetryState* retry_state,
3262
+ SubchannelCallBatchData* batch_data) {
3263
+ // Maps the number of retries to the corresponding metadata value slice.
3264
+ const grpc_slice* retry_count_strings[] = {&GRPC_MDSTR_1, &GRPC_MDSTR_2,
3265
+ &GRPC_MDSTR_3, &GRPC_MDSTR_4};
3266
+ // We need to make a copy of the metadata batch for each attempt, since
3267
+ // the filters in the subchannel stack may modify this batch, and we don't
3268
+ // want those modifications to be passed forward to subsequent attempts.
3269
+ //
3270
+ // If we've already completed one or more attempts, add the
3271
+ // grpc-retry-attempts header.
3272
+ retry_state->send_initial_metadata_storage =
3273
+ static_cast<grpc_linked_mdelem*>(arena_->Alloc(
3274
+ sizeof(grpc_linked_mdelem) *
3275
+ (send_initial_metadata_.list.count + (num_attempts_completed_ > 0))));
3276
+ grpc_metadata_batch_copy(&send_initial_metadata_,
3277
+ &retry_state->send_initial_metadata,
3278
+ retry_state->send_initial_metadata_storage);
3279
+ if (GPR_UNLIKELY(retry_state->send_initial_metadata.idx.named
3280
+ .grpc_previous_rpc_attempts != nullptr)) {
3281
+ grpc_metadata_batch_remove(&retry_state->send_initial_metadata,
3282
+ GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS);
3283
+ }
3284
+ if (GPR_UNLIKELY(num_attempts_completed_ > 0)) {
3285
+ grpc_mdelem retry_md = grpc_mdelem_create(
3286
+ GRPC_MDSTR_GRPC_PREVIOUS_RPC_ATTEMPTS,
3287
+ *retry_count_strings[num_attempts_completed_ - 1], nullptr);
3288
+ grpc_error* error = grpc_metadata_batch_add_tail(
3289
+ &retry_state->send_initial_metadata,
3290
+ &retry_state
3291
+ ->send_initial_metadata_storage[send_initial_metadata_.list.count],
3292
+ retry_md, GRPC_BATCH_GRPC_PREVIOUS_RPC_ATTEMPTS);
3293
+ if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) {
3294
+ gpr_log(GPR_ERROR, "error adding retry metadata: %s",
3295
+ grpc_error_string(error));
3296
+ GPR_ASSERT(false);
3297
+ }
3298
+ }
3299
+ retry_state->started_send_initial_metadata = true;
3300
+ batch_data->batch.send_initial_metadata = true;
3301
+ batch_data->batch.payload->send_initial_metadata.send_initial_metadata =
3302
+ &retry_state->send_initial_metadata;
3303
+ batch_data->batch.payload->send_initial_metadata.send_initial_metadata_flags =
3304
+ send_initial_metadata_flags_;
3305
+ batch_data->batch.payload->send_initial_metadata.peer_string = peer_string_;
3306
+ }
3307
+
3308
+ void CallData::AddRetriableSendMessageOp(grpc_call_element* elem,
3309
+ SubchannelCallRetryState* retry_state,
3310
+ SubchannelCallBatchData* batch_data) {
3311
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3312
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3313
+ gpr_log(GPR_INFO,
3314
+ "chand=%p calld=%p: starting calld->send_messages[%" PRIuPTR "]",
3315
+ chand, this, retry_state->started_send_message_count);
3316
+ }
3317
+ ByteStreamCache* cache =
3318
+ send_messages_[retry_state->started_send_message_count];
3319
+ ++retry_state->started_send_message_count;
3320
+ retry_state->send_message.Init(cache);
3321
+ batch_data->batch.send_message = true;
3322
+ batch_data->batch.payload->send_message.send_message.reset(
3323
+ retry_state->send_message.get());
3324
+ }
3325
+
3326
+ void CallData::AddRetriableSendTrailingMetadataOp(
3327
+ SubchannelCallRetryState* retry_state,
3328
+ SubchannelCallBatchData* batch_data) {
3329
+ // We need to make a copy of the metadata batch for each attempt, since
3330
+ // the filters in the subchannel stack may modify this batch, and we don't
3331
+ // want those modifications to be passed forward to subsequent attempts.
3332
+ retry_state->send_trailing_metadata_storage =
3333
+ static_cast<grpc_linked_mdelem*>(arena_->Alloc(
3334
+ sizeof(grpc_linked_mdelem) * send_trailing_metadata_.list.count));
3335
+ grpc_metadata_batch_copy(&send_trailing_metadata_,
3336
+ &retry_state->send_trailing_metadata,
3337
+ retry_state->send_trailing_metadata_storage);
3338
+ retry_state->started_send_trailing_metadata = true;
3339
+ batch_data->batch.send_trailing_metadata = true;
3340
+ batch_data->batch.payload->send_trailing_metadata.send_trailing_metadata =
3341
+ &retry_state->send_trailing_metadata;
3342
+ }
3343
+
3344
+ void CallData::AddRetriableRecvInitialMetadataOp(
3345
+ SubchannelCallRetryState* retry_state,
3346
+ SubchannelCallBatchData* batch_data) {
3347
+ retry_state->started_recv_initial_metadata = true;
3348
+ batch_data->batch.recv_initial_metadata = true;
3349
+ grpc_metadata_batch_init(&retry_state->recv_initial_metadata);
3350
+ batch_data->batch.payload->recv_initial_metadata.recv_initial_metadata =
3351
+ &retry_state->recv_initial_metadata;
3352
+ batch_data->batch.payload->recv_initial_metadata.trailing_metadata_available =
3353
+ &retry_state->trailing_metadata_available;
3354
+ GRPC_CLOSURE_INIT(&retry_state->recv_initial_metadata_ready,
3355
+ RecvInitialMetadataReady, batch_data,
3356
+ grpc_schedule_on_exec_ctx);
3357
+ batch_data->batch.payload->recv_initial_metadata.recv_initial_metadata_ready =
3358
+ &retry_state->recv_initial_metadata_ready;
3359
+ }
3360
+
3361
+ void CallData::AddRetriableRecvMessageOp(SubchannelCallRetryState* retry_state,
3362
+ SubchannelCallBatchData* batch_data) {
3363
+ ++retry_state->started_recv_message_count;
3364
+ batch_data->batch.recv_message = true;
3365
+ batch_data->batch.payload->recv_message.recv_message =
3366
+ &retry_state->recv_message;
3367
+ GRPC_CLOSURE_INIT(&retry_state->recv_message_ready, RecvMessageReady,
3368
+ batch_data, grpc_schedule_on_exec_ctx);
3369
+ batch_data->batch.payload->recv_message.recv_message_ready =
3370
+ &retry_state->recv_message_ready;
3371
+ }
3372
+
3373
+ void CallData::AddRetriableRecvTrailingMetadataOp(
3374
+ SubchannelCallRetryState* retry_state,
3375
+ SubchannelCallBatchData* batch_data) {
3376
+ retry_state->started_recv_trailing_metadata = true;
3377
+ batch_data->batch.recv_trailing_metadata = true;
3378
+ grpc_metadata_batch_init(&retry_state->recv_trailing_metadata);
3379
+ batch_data->batch.payload->recv_trailing_metadata.recv_trailing_metadata =
3380
+ &retry_state->recv_trailing_metadata;
3381
+ batch_data->batch.payload->recv_trailing_metadata.collect_stats =
3382
+ &retry_state->collect_stats;
3383
+ GRPC_CLOSURE_INIT(&retry_state->recv_trailing_metadata_ready,
3384
+ RecvTrailingMetadataReady, batch_data,
3385
+ grpc_schedule_on_exec_ctx);
3386
+ batch_data->batch.payload->recv_trailing_metadata
3387
+ .recv_trailing_metadata_ready =
3388
+ &retry_state->recv_trailing_metadata_ready;
3389
+ MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy(
3390
+ &batch_data->batch);
3391
+ }
3392
+
3393
+ void CallData::StartInternalRecvTrailingMetadata(grpc_call_element* elem) {
3394
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3395
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3396
+ gpr_log(GPR_INFO,
3397
+ "chand=%p calld=%p: call failed but recv_trailing_metadata not "
3398
+ "started; starting it internally",
3399
+ chand, this);
3400
+ }
3401
+ SubchannelCallRetryState* retry_state =
3402
+ static_cast<SubchannelCallRetryState*>(subchannel_call_->GetParentData());
3403
+ // Create batch_data with 2 refs, since this batch will be unreffed twice:
3404
+ // once for the recv_trailing_metadata_ready callback when the subchannel
3405
+ // batch returns, and again when we actually get a recv_trailing_metadata
3406
+ // op from the surface.
3407
+ SubchannelCallBatchData* batch_data =
3408
+ SubchannelCallBatchData::Create(elem, 2, false /* set_on_complete */);
3409
+ AddRetriableRecvTrailingMetadataOp(retry_state, batch_data);
3410
+ retry_state->recv_trailing_metadata_internal_batch = batch_data;
3411
+ // Note: This will release the call combiner.
3412
+ subchannel_call_->StartTransportStreamOpBatch(&batch_data->batch);
3413
+ }
3414
+
3415
+ // If there are any cached send ops that need to be replayed on the
3416
+ // current subchannel call, creates and returns a new subchannel batch
3417
+ // to replay those ops. Otherwise, returns nullptr.
3418
+ CallData::SubchannelCallBatchData*
3419
+ CallData::MaybeCreateSubchannelBatchForReplay(
3420
+ grpc_call_element* elem, SubchannelCallRetryState* retry_state) {
3421
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3422
+ SubchannelCallBatchData* replay_batch_data = nullptr;
3423
+ // send_initial_metadata.
3424
+ if (seen_send_initial_metadata_ &&
3425
+ !retry_state->started_send_initial_metadata &&
3426
+ !pending_send_initial_metadata_) {
3427
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3428
+ gpr_log(GPR_INFO,
3429
+ "chand=%p calld=%p: replaying previously completed "
3430
+ "send_initial_metadata op",
3431
+ chand, this);
3432
+ }
3433
+ replay_batch_data =
3434
+ SubchannelCallBatchData::Create(elem, 1, true /* set_on_complete */);
3435
+ AddRetriableSendInitialMetadataOp(retry_state, replay_batch_data);
3436
+ }
3437
+ // send_message.
3438
+ // Note that we can only have one send_message op in flight at a time.
3439
+ if (retry_state->started_send_message_count < send_messages_.size() &&
3440
+ retry_state->started_send_message_count ==
3441
+ retry_state->completed_send_message_count &&
3442
+ !pending_send_message_) {
3443
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3444
+ gpr_log(GPR_INFO,
3445
+ "chand=%p calld=%p: replaying previously completed "
3446
+ "send_message op",
3447
+ chand, this);
3448
+ }
3449
+ if (replay_batch_data == nullptr) {
3450
+ replay_batch_data =
3451
+ SubchannelCallBatchData::Create(elem, 1, true /* set_on_complete */);
3452
+ }
3453
+ AddRetriableSendMessageOp(elem, retry_state, replay_batch_data);
3454
+ }
3455
+ // send_trailing_metadata.
3456
+ // Note that we only add this op if we have no more send_message ops
3457
+ // to start, since we can't send down any more send_message ops after
3458
+ // send_trailing_metadata.
3459
+ if (seen_send_trailing_metadata_ &&
3460
+ retry_state->started_send_message_count == send_messages_.size() &&
3461
+ !retry_state->started_send_trailing_metadata &&
3462
+ !pending_send_trailing_metadata_) {
3463
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3464
+ gpr_log(GPR_INFO,
3465
+ "chand=%p calld=%p: replaying previously completed "
3466
+ "send_trailing_metadata op",
3467
+ chand, this);
3468
+ }
3469
+ if (replay_batch_data == nullptr) {
3470
+ replay_batch_data =
3471
+ SubchannelCallBatchData::Create(elem, 1, true /* set_on_complete */);
3472
+ }
3473
+ AddRetriableSendTrailingMetadataOp(retry_state, replay_batch_data);
3474
+ }
3475
+ return replay_batch_data;
3476
+ }
3477
+
3478
+ void CallData::AddSubchannelBatchesForPendingBatches(
3479
+ grpc_call_element* elem, SubchannelCallRetryState* retry_state,
3480
+ CallCombinerClosureList* closures) {
3481
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
3482
+ PendingBatch* pending = &pending_batches_[i];
3483
+ grpc_transport_stream_op_batch* batch = pending->batch;
3484
+ if (batch == nullptr) continue;
3485
+ // Skip any batch that either (a) has already been started on this
3486
+ // subchannel call or (b) we can't start yet because we're still
3487
+ // replaying send ops that need to be completed first.
3488
+ // TODO(roth): Note that if any one op in the batch can't be sent
3489
+ // yet due to ops that we're replaying, we don't start any of the ops
3490
+ // in the batch. This is probably okay, but it could conceivably
3491
+ // lead to increased latency in some cases -- e.g., we could delay
3492
+ // starting a recv op due to it being in the same batch with a send
3493
+ // op. If/when we revamp the callback protocol in
3494
+ // transport_stream_op_batch, we may be able to fix this.
3495
+ if (batch->send_initial_metadata &&
3496
+ retry_state->started_send_initial_metadata) {
3497
+ continue;
3498
+ }
3499
+ if (batch->send_message && retry_state->completed_send_message_count <
3500
+ retry_state->started_send_message_count) {
3501
+ continue;
3502
+ }
3503
+ // Note that we only start send_trailing_metadata if we have no more
3504
+ // send_message ops to start, since we can't send down any more
3505
+ // send_message ops after send_trailing_metadata.
3506
+ if (batch->send_trailing_metadata &&
3507
+ (retry_state->started_send_message_count + batch->send_message <
3508
+ send_messages_.size() ||
3509
+ retry_state->started_send_trailing_metadata)) {
3510
+ continue;
3511
+ }
3512
+ if (batch->recv_initial_metadata &&
3513
+ retry_state->started_recv_initial_metadata) {
3514
+ continue;
3515
+ }
3516
+ if (batch->recv_message && retry_state->completed_recv_message_count <
3517
+ retry_state->started_recv_message_count) {
3518
+ continue;
3519
+ }
3520
+ if (batch->recv_trailing_metadata &&
3521
+ retry_state->started_recv_trailing_metadata) {
3522
+ // If we previously completed a recv_trailing_metadata op
3523
+ // initiated by StartInternalRecvTrailingMetadata(), use the
3524
+ // result of that instead of trying to re-start this op.
3525
+ if (GPR_UNLIKELY((retry_state->recv_trailing_metadata_internal_batch !=
3526
+ nullptr))) {
3527
+ // If the batch completed, then trigger the completion callback
3528
+ // directly, so that we return the previously returned results to
3529
+ // the application. Otherwise, just unref the internally
3530
+ // started subchannel batch, since we'll propagate the
3531
+ // completion when it completes.
3532
+ if (retry_state->completed_recv_trailing_metadata) {
3533
+ // Batches containing recv_trailing_metadata always succeed.
3534
+ closures->Add(
3535
+ &retry_state->recv_trailing_metadata_ready, GRPC_ERROR_NONE,
3536
+ "re-executing recv_trailing_metadata_ready to propagate "
3537
+ "internally triggered result");
3538
+ } else {
3539
+ retry_state->recv_trailing_metadata_internal_batch->Unref();
3540
+ }
3541
+ retry_state->recv_trailing_metadata_internal_batch = nullptr;
3542
+ }
3543
+ continue;
3544
+ }
3545
+ // If we're not retrying, just send the batch as-is.
3546
+ if (method_params_ == nullptr ||
3547
+ method_params_->retry_policy() == nullptr || retry_committed_) {
3548
+ // TODO(roth) : We should probably call
3549
+ // MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy here.
3550
+ AddClosureForSubchannelBatch(elem, batch, closures);
3551
+ PendingBatchClear(pending);
3552
+ continue;
3553
+ }
3554
+ // Create batch with the right number of callbacks.
3555
+ const bool has_send_ops = batch->send_initial_metadata ||
3556
+ batch->send_message ||
3557
+ batch->send_trailing_metadata;
3558
+ const int num_callbacks = has_send_ops + batch->recv_initial_metadata +
3559
+ batch->recv_message +
3560
+ batch->recv_trailing_metadata;
3561
+ SubchannelCallBatchData* batch_data = SubchannelCallBatchData::Create(
3562
+ elem, num_callbacks, has_send_ops /* set_on_complete */);
3563
+ // Cache send ops if needed.
3564
+ MaybeCacheSendOpsForBatch(pending);
3565
+ // send_initial_metadata.
3566
+ if (batch->send_initial_metadata) {
3567
+ AddRetriableSendInitialMetadataOp(retry_state, batch_data);
3568
+ }
3569
+ // send_message.
3570
+ if (batch->send_message) {
3571
+ AddRetriableSendMessageOp(elem, retry_state, batch_data);
3572
+ }
3573
+ // send_trailing_metadata.
3574
+ if (batch->send_trailing_metadata) {
3575
+ AddRetriableSendTrailingMetadataOp(retry_state, batch_data);
3576
+ }
3577
+ // recv_initial_metadata.
3578
+ if (batch->recv_initial_metadata) {
3579
+ // recv_flags is only used on the server side.
3580
+ GPR_ASSERT(batch->payload->recv_initial_metadata.recv_flags == nullptr);
3581
+ AddRetriableRecvInitialMetadataOp(retry_state, batch_data);
3582
+ }
3583
+ // recv_message.
3584
+ if (batch->recv_message) {
3585
+ AddRetriableRecvMessageOp(retry_state, batch_data);
3586
+ }
3587
+ // recv_trailing_metadata.
3588
+ if (batch->recv_trailing_metadata) {
3589
+ AddRetriableRecvTrailingMetadataOp(retry_state, batch_data);
3590
+ }
3591
+ AddClosureForSubchannelBatch(elem, &batch_data->batch, closures);
3592
+ // Track number of pending subchannel send batches.
3593
+ // If this is the first one, take a ref to the call stack.
3594
+ if (batch->send_initial_metadata || batch->send_message ||
3595
+ batch->send_trailing_metadata) {
3596
+ if (num_pending_retriable_subchannel_send_batches_ == 0) {
3597
+ GRPC_CALL_STACK_REF(owning_call_, "subchannel_send_batches");
3598
+ }
3599
+ ++num_pending_retriable_subchannel_send_batches_;
3600
+ }
3601
+ }
3602
+ }
3603
+
3604
+ void CallData::StartRetriableSubchannelBatches(void* arg,
3605
+ grpc_error* /*ignored*/) {
3606
+ grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
3607
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3608
+ CallData* calld = static_cast<CallData*>(elem->call_data);
3609
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3610
+ gpr_log(GPR_INFO, "chand=%p calld=%p: constructing retriable batches",
3611
+ chand, calld);
3612
+ }
3613
+ SubchannelCallRetryState* retry_state =
3614
+ static_cast<SubchannelCallRetryState*>(
3615
+ calld->subchannel_call_->GetParentData());
3616
+ // Construct list of closures to execute, one for each pending batch.
3617
+ CallCombinerClosureList closures;
3618
+ // Replay previously-returned send_* ops if needed.
3619
+ SubchannelCallBatchData* replay_batch_data =
3620
+ calld->MaybeCreateSubchannelBatchForReplay(elem, retry_state);
3621
+ if (replay_batch_data != nullptr) {
3622
+ calld->AddClosureForSubchannelBatch(elem, &replay_batch_data->batch,
3623
+ &closures);
3624
+ // Track number of pending subchannel send batches.
3625
+ // If this is the first one, take a ref to the call stack.
3626
+ if (calld->num_pending_retriable_subchannel_send_batches_ == 0) {
3627
+ GRPC_CALL_STACK_REF(calld->owning_call_, "subchannel_send_batches");
3628
+ }
3629
+ ++calld->num_pending_retriable_subchannel_send_batches_;
3630
+ }
3631
+ // Now add pending batches.
3632
+ calld->AddSubchannelBatchesForPendingBatches(elem, retry_state, &closures);
3633
+ // Start batches on subchannel call.
3634
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
3635
+ gpr_log(GPR_INFO,
3636
+ "chand=%p calld=%p: starting %" PRIuPTR
3637
+ " retriable batches on subchannel_call=%p",
3638
+ chand, calld, closures.size(), calld->subchannel_call_.get());
3639
+ }
3640
+ // Note: This will yield the call combiner.
3641
+ closures.RunClosures(calld->call_combiner_);
3642
+ }
3643
+
3644
+ //
3645
+ // LB pick
3646
+ //
3647
+
3648
+ void CallData::CreateSubchannelCall(grpc_call_element* elem) {
3649
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3650
+ const size_t parent_data_size =
3651
+ enable_retries_ ? sizeof(SubchannelCallRetryState) : 0;
3652
+ SubchannelCall::Args call_args = {
3653
+ std::move(connected_subchannel_), pollent_, path_, call_start_time_,
3654
+ deadline_, arena_,
3655
+ // TODO(roth): When we implement hedging support, we will probably
3656
+ // need to use a separate call context for each subchannel call.
3657
+ call_context_, call_combiner_, parent_data_size};
3658
+ grpc_error* error = GRPC_ERROR_NONE;
3659
+ subchannel_call_ = SubchannelCall::Create(std::move(call_args), &error);
3660
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
3661
+ gpr_log(GPR_INFO, "chand=%p calld=%p: create subchannel_call=%p: error=%s",
3662
+ chand, this, subchannel_call_.get(), grpc_error_string(error));
3663
+ }
3664
+ if (GPR_UNLIKELY(error != GRPC_ERROR_NONE)) {
3665
+ PendingBatchesFail(elem, error, YieldCallCombiner);
3666
+ } else {
3667
+ if (parent_data_size > 0) {
3668
+ new (subchannel_call_->GetParentData())
3669
+ SubchannelCallRetryState(call_context_);
3670
+ }
3671
+ PendingBatchesResume(elem);
3672
+ }
3673
+ }
3674
+
3675
+ void CallData::AsyncPickDone(grpc_call_element* elem, grpc_error* error) {
3676
+ GRPC_CLOSURE_INIT(&pick_closure_, PickDone, elem, grpc_schedule_on_exec_ctx);
3677
+ ExecCtx::Run(DEBUG_LOCATION, &pick_closure_, error);
3678
+ }
3679
+
3680
+ void CallData::PickDone(void* arg, grpc_error* error) {
3681
+ grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
3682
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3683
+ CallData* calld = static_cast<CallData*>(elem->call_data);
3684
+ if (error != GRPC_ERROR_NONE) {
3685
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
3686
+ gpr_log(GPR_INFO,
3687
+ "chand=%p calld=%p: failed to pick subchannel: error=%s", chand,
3688
+ calld, grpc_error_string(error));
3689
+ }
3690
+ calld->PendingBatchesFail(elem, GRPC_ERROR_REF(error), YieldCallCombiner);
3691
+ return;
3692
+ }
3693
+ calld->CreateSubchannelCall(elem);
3694
+ }
3695
+
3696
+ // A class to handle the call combiner cancellation callback for a
3697
+ // queued pick.
3698
+ class CallData::QueuedPickCanceller {
3699
+ public:
3700
+ explicit QueuedPickCanceller(grpc_call_element* elem) : elem_(elem) {
3701
+ auto* calld = static_cast<CallData*>(elem->call_data);
3702
+ GRPC_CALL_STACK_REF(calld->owning_call_, "QueuedPickCanceller");
3703
+ GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this,
3704
+ grpc_schedule_on_exec_ctx);
3705
+ calld->call_combiner_->SetNotifyOnCancel(&closure_);
3706
+ }
3707
+
3708
+ private:
3709
+ static void CancelLocked(void* arg, grpc_error* error) {
3710
+ auto* self = static_cast<QueuedPickCanceller*>(arg);
3711
+ auto* chand = static_cast<ChannelData*>(self->elem_->channel_data);
3712
+ auto* calld = static_cast<CallData*>(self->elem_->call_data);
3713
+ MutexLock lock(chand->data_plane_mu());
3714
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
3715
+ gpr_log(GPR_INFO,
3716
+ "chand=%p calld=%p: cancelling queued pick: "
3717
+ "error=%s self=%p calld->pick_canceller=%p",
3718
+ chand, calld, grpc_error_string(error), self,
3719
+ calld->pick_canceller_);
3720
+ }
3721
+ if (calld->pick_canceller_ == self && error != GRPC_ERROR_NONE) {
3722
+ // Remove pick from list of queued picks.
3723
+ calld->RemoveCallFromQueuedPicksLocked(self->elem_);
3724
+ // Fail pending batches on the call.
3725
+ calld->PendingBatchesFail(self->elem_, GRPC_ERROR_REF(error),
3726
+ YieldCallCombinerIfPendingBatchesFound);
3727
+ }
3728
+ GRPC_CALL_STACK_UNREF(calld->owning_call_, "QueuedPickCanceller");
3729
+ delete self;
3730
+ }
3731
+
3732
+ grpc_call_element* elem_;
3733
+ grpc_closure closure_;
3734
+ };
3735
+
3736
+ void CallData::RemoveCallFromQueuedPicksLocked(grpc_call_element* elem) {
3737
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
3738
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
3739
+ gpr_log(GPR_INFO, "chand=%p calld=%p: removing from queued picks list",
3740
+ chand, this);
3741
+ }
3742
+ chand->RemoveQueuedPick(&pick_, pollent_);
3743
+ pick_queued_ = false;
3744
+ // Lame the call combiner canceller.
3745
+ pick_canceller_ = nullptr;
3746
+ }
3747
+
3748
+ void CallData::AddCallToQueuedPicksLocked(grpc_call_element* elem) {
3749
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
3750
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
3751
+ gpr_log(GPR_INFO, "chand=%p calld=%p: adding to queued picks list", chand,
3752
+ this);
3753
+ }
3754
+ pick_queued_ = true;
3755
+ pick_.elem = elem;
3756
+ chand->AddQueuedPick(&pick_, pollent_);
3757
+ // Register call combiner cancellation callback.
3758
+ pick_canceller_ = new QueuedPickCanceller(elem);
3759
+ }
3760
+
3761
+ void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) {
3762
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3763
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
3764
+ gpr_log(GPR_INFO, "chand=%p calld=%p: applying service config to call",
3765
+ chand, this);
3766
+ }
3767
+ auto service_config = chand->service_config();
3768
+ if (service_config != nullptr) {
3769
+ // Create a ServiceConfigCallData for the call. This stores a ref to the
3770
+ // ServiceConfig and caches the right set of parsed configs to use for
3771
+ // the call. The MethodConfig will store itself in the call context,
3772
+ // so that it can be accessed by filters in the subchannel, and it
3773
+ // will be cleaned up when the call ends.
3774
+ const auto* method_params_vector =
3775
+ service_config->GetMethodParsedConfigVector(path_);
3776
+ auto* service_config_call_data = arena_->New<ServiceConfigCallData>(
3777
+ std::move(service_config), method_params_vector, call_context_);
3778
+ // Apply our own method params to the call.
3779
+ method_params_ = static_cast<ClientChannelMethodParsedConfig*>(
3780
+ service_config_call_data->GetMethodParsedConfig(
3781
+ internal::ClientChannelServiceConfigParser::ParserIndex()));
3782
+ if (method_params_ != nullptr) {
3783
+ // If the deadline from the service config is shorter than the one
3784
+ // from the client API, reset the deadline timer.
3785
+ if (chand->deadline_checking_enabled() &&
3786
+ method_params_->timeout() != 0) {
3787
+ const grpc_millis per_method_deadline =
3788
+ grpc_cycle_counter_to_millis_round_up(call_start_time_) +
3789
+ method_params_->timeout();
3790
+ if (per_method_deadline < deadline_) {
3791
+ deadline_ = per_method_deadline;
3792
+ grpc_deadline_state_reset(elem, deadline_);
3793
+ }
3794
+ }
3795
+ // If the service config set wait_for_ready and the application
3796
+ // did not explicitly set it, use the value from the service config.
3797
+ uint32_t* send_initial_metadata_flags =
3798
+ &pending_batches_[0]
3799
+ .batch->payload->send_initial_metadata
3800
+ .send_initial_metadata_flags;
3801
+ if (method_params_->wait_for_ready().has_value() &&
3802
+ !(*send_initial_metadata_flags &
3803
+ GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET)) {
3804
+ if (method_params_->wait_for_ready().value()) {
3805
+ *send_initial_metadata_flags |= GRPC_INITIAL_METADATA_WAIT_FOR_READY;
3806
+ } else {
3807
+ *send_initial_metadata_flags &= ~GRPC_INITIAL_METADATA_WAIT_FOR_READY;
3808
+ }
3809
+ }
3810
+ }
3811
+ // Set retry throttle data for call.
3812
+ retry_throttle_data_ = chand->retry_throttle_data();
3813
+ }
3814
+ // If no retry policy, disable retries.
3815
+ // TODO(roth): Remove this when adding support for transparent retries.
3816
+ if (method_params_ == nullptr || method_params_->retry_policy() == nullptr) {
3817
+ enable_retries_ = false;
3818
+ }
3819
+ }
3820
+
3821
+ void CallData::MaybeApplyServiceConfigToCallLocked(grpc_call_element* elem) {
3822
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3823
+ // Apply service config data to the call only once, and only if the
3824
+ // channel has the data available.
3825
+ if (GPR_LIKELY(chand->received_service_config_data() &&
3826
+ !service_config_applied_)) {
3827
+ service_config_applied_ = true;
3828
+ ApplyServiceConfigToCallLocked(elem);
3829
+ }
3830
+ }
3831
+
3832
+ const char* PickResultTypeName(
3833
+ LoadBalancingPolicy::PickResult::ResultType type) {
3834
+ switch (type) {
3835
+ case LoadBalancingPolicy::PickResult::PICK_COMPLETE:
3836
+ return "COMPLETE";
3837
+ case LoadBalancingPolicy::PickResult::PICK_QUEUE:
3838
+ return "QUEUE";
3839
+ case LoadBalancingPolicy::PickResult::PICK_FAILED:
3840
+ return "FAILED";
3841
+ }
3842
+ GPR_UNREACHABLE_CODE(return "UNKNOWN");
3843
+ }
3844
+
3845
+ void CallData::PickSubchannel(void* arg, grpc_error* error) {
3846
+ grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
3847
+ CallData* calld = static_cast<CallData*>(elem->call_data);
3848
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3849
+ bool pick_complete;
3850
+ {
3851
+ MutexLock lock(chand->data_plane_mu());
3852
+ pick_complete = calld->PickSubchannelLocked(elem, &error);
3853
+ }
3854
+ if (pick_complete) {
3855
+ PickDone(elem, error);
3856
+ GRPC_ERROR_UNREF(error);
3857
+ }
3858
+ }
3859
+
3860
+ bool CallData::PickSubchannelLocked(grpc_call_element* elem,
3861
+ grpc_error** error) {
3862
+ ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
3863
+ GPR_ASSERT(connected_subchannel_ == nullptr);
3864
+ GPR_ASSERT(subchannel_call_ == nullptr);
3865
+ // The picker being null means that the channel is currently in IDLE state.
3866
+ // The incoming call will make the channel exit IDLE.
3867
+ if (chand->picker() == nullptr) {
3868
+ GRPC_CHANNEL_STACK_REF(chand->owning_stack(), "PickSubchannelLocked");
3869
+ // Bounce into the control plane work serializer to exit IDLE. Since we are
3870
+ // holding on to the data plane mutex here, we offload it on the ExecCtx so
3871
+ // that we don't deadlock with ourselves.
3872
+ ExecCtx::Run(
3873
+ DEBUG_LOCATION,
3874
+ GRPC_CLOSURE_CREATE(
3875
+ [](void* arg, grpc_error* /*error*/) {
3876
+ auto* chand = static_cast<ChannelData*>(arg);
3877
+ chand->work_serializer()->Run(
3878
+ [chand]() {
3879
+ chand->CheckConnectivityState(/*try_to_connect=*/true);
3880
+ GRPC_CHANNEL_STACK_UNREF(chand->owning_stack(),
3881
+ "PickSubchannelLocked");
3882
+ },
3883
+ DEBUG_LOCATION);
3884
+ },
3885
+ chand, nullptr),
3886
+ GRPC_ERROR_NONE);
3887
+ // Queue the pick, so that it will be attempted once the channel
3888
+ // becomes connected.
3889
+ AddCallToQueuedPicksLocked(elem);
3890
+ return false;
3891
+ }
3892
+ // Apply service config to call if needed.
3893
+ MaybeApplyServiceConfigToCallLocked(elem);
3894
+ // If this is a retry, use the send_initial_metadata payload that
3895
+ // we've cached; otherwise, use the pending batch. The
3896
+ // send_initial_metadata batch will be the first pending batch in the
3897
+ // list, as set by GetBatchIndex() above.
3898
+ // TODO(roth): What if the LB policy needs to add something to the
3899
+ // call's initial metadata, and then there's a retry? We don't want
3900
+ // the new metadata to be added twice. We might need to somehow
3901
+ // allocate the subchannel batch earlier so that we can give the
3902
+ // subchannel's copy of the metadata batch (which is copied for each
3903
+ // attempt) to the LB policy instead the one from the parent channel.
3904
+ LoadBalancingPolicy::PickArgs pick_args;
3905
+ pick_args.call_state = &lb_call_state_;
3906
+ Metadata initial_metadata(
3907
+ this,
3908
+ seen_send_initial_metadata_
3909
+ ? &send_initial_metadata_
3910
+ : pending_batches_[0]
3911
+ .batch->payload->send_initial_metadata.send_initial_metadata);
3912
+ pick_args.initial_metadata = &initial_metadata;
3913
+ // Grab initial metadata flags so that we can check later if the call has
3914
+ // wait_for_ready enabled.
3915
+ const uint32_t send_initial_metadata_flags =
3916
+ seen_send_initial_metadata_ ? send_initial_metadata_flags_
3917
+ : pending_batches_[0]
3918
+ .batch->payload->send_initial_metadata
3919
+ .send_initial_metadata_flags;
3920
+ // Attempt pick.
3921
+ auto result = chand->picker()->Pick(pick_args);
3922
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
3923
+ gpr_log(GPR_INFO,
3924
+ "chand=%p calld=%p: LB pick returned %s (subchannel=%p, error=%s)",
3925
+ chand, this, PickResultTypeName(result.type),
3926
+ result.subchannel.get(), grpc_error_string(result.error));
3927
+ }
3928
+ switch (result.type) {
3929
+ case LoadBalancingPolicy::PickResult::PICK_FAILED: {
3930
+ // If we're shutting down, fail all RPCs.
3931
+ grpc_error* disconnect_error = chand->disconnect_error();
3932
+ if (disconnect_error != GRPC_ERROR_NONE) {
3933
+ GRPC_ERROR_UNREF(result.error);
3934
+ if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem);
3935
+ *error = GRPC_ERROR_REF(disconnect_error);
3936
+ return true;
3937
+ }
3938
+ // If wait_for_ready is false, then the error indicates the RPC
3939
+ // attempt's final status.
3940
+ if ((send_initial_metadata_flags &
3941
+ GRPC_INITIAL_METADATA_WAIT_FOR_READY) == 0) {
3942
+ // Retry if appropriate; otherwise, fail.
3943
+ grpc_status_code status = GRPC_STATUS_OK;
3944
+ grpc_error_get_status(result.error, deadline_, &status, nullptr,
3945
+ nullptr, nullptr);
3946
+ const bool retried = enable_retries_ &&
3947
+ MaybeRetry(elem, nullptr /* batch_data */, status,
3948
+ nullptr /* server_pushback_md */);
3949
+ if (!retried) {
3950
+ grpc_error* new_error =
3951
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
3952
+ "Failed to pick subchannel", &result.error, 1);
3953
+ GRPC_ERROR_UNREF(result.error);
3954
+ *error = new_error;
3955
+ }
3956
+ if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem);
3957
+ return !retried;
3958
+ }
3959
+ // If wait_for_ready is true, then queue to retry when we get a new
3960
+ // picker.
3961
+ GRPC_ERROR_UNREF(result.error);
3962
+ }
3963
+ // Fallthrough
3964
+ case LoadBalancingPolicy::PickResult::PICK_QUEUE:
3965
+ if (!pick_queued_) AddCallToQueuedPicksLocked(elem);
3966
+ return false;
3967
+ default: // PICK_COMPLETE
3968
+ if (pick_queued_) RemoveCallFromQueuedPicksLocked(elem);
3969
+ // Handle drops.
3970
+ if (GPR_UNLIKELY(result.subchannel == nullptr)) {
3971
+ result.error = grpc_error_set_int(
3972
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3973
+ "Call dropped by load balancing policy"),
3974
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
3975
+ } else {
3976
+ // Grab a ref to the connected subchannel while we're still
3977
+ // holding the data plane mutex.
3978
+ connected_subchannel_ =
3979
+ chand->GetConnectedSubchannelInDataPlane(result.subchannel.get());
3980
+ GPR_ASSERT(connected_subchannel_ != nullptr);
3981
+ }
3982
+ lb_recv_trailing_metadata_ready_ = result.recv_trailing_metadata_ready;
3983
+ *error = result.error;
3984
+ return true;
3985
+ }
3986
+ }
3987
+
3988
+ } // namespace
3989
+ } // namespace grpc_core
3990
+
3991
+ /*************************************************************************
3992
+ * EXPORTED SYMBOLS
3993
+ */
3994
+
3995
+ using grpc_core::CallData;
3996
+ using grpc_core::ChannelData;
3997
+
3998
+ const grpc_channel_filter grpc_client_channel_filter = {
3999
+ CallData::StartTransportStreamOpBatch,
4000
+ ChannelData::StartTransportOp,
4001
+ sizeof(CallData),
4002
+ CallData::Init,
4003
+ CallData::SetPollent,
4004
+ CallData::Destroy,
4005
+ sizeof(ChannelData),
4006
+ ChannelData::Init,
4007
+ ChannelData::Destroy,
4008
+ ChannelData::GetChannelInfo,
4009
+ "client-channel",
4010
+ };
4011
+
4012
+ grpc_connectivity_state grpc_client_channel_check_connectivity_state(
4013
+ grpc_channel_element* elem, int try_to_connect) {
4014
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
4015
+ return chand->CheckConnectivityState(try_to_connect);
4016
+ }
4017
+
4018
+ int grpc_client_channel_num_external_connectivity_watchers(
4019
+ grpc_channel_element* elem) {
4020
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
4021
+ return chand->NumExternalConnectivityWatchers();
4022
+ }
4023
+
4024
+ void grpc_client_channel_watch_connectivity_state(
4025
+ grpc_channel_element* elem, grpc_polling_entity pollent,
4026
+ grpc_connectivity_state* state, grpc_closure* closure,
4027
+ grpc_closure* watcher_timer_init) {
4028
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
4029
+ if (state == nullptr) {
4030
+ // Handle cancellation.
4031
+ GPR_ASSERT(watcher_timer_init == nullptr);
4032
+ chand->RemoveExternalConnectivityWatcher(closure, /*cancel=*/true);
4033
+ return;
4034
+ }
4035
+ // Handle addition.
4036
+ return chand->AddExternalConnectivityWatcher(pollent, state, closure,
4037
+ watcher_timer_init);
4038
+ }
4039
+
4040
+ void grpc_client_channel_start_connectivity_watch(
4041
+ grpc_channel_element* elem, grpc_connectivity_state initial_state,
4042
+ grpc_core::OrphanablePtr<grpc_core::AsyncConnectivityStateWatcherInterface>
4043
+ watcher) {
4044
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
4045
+ chand->AddConnectivityWatcher(initial_state, std::move(watcher));
4046
+ }
4047
+
4048
+ void grpc_client_channel_stop_connectivity_watch(
4049
+ grpc_channel_element* elem,
4050
+ grpc_core::AsyncConnectivityStateWatcherInterface* watcher) {
4051
+ auto* chand = static_cast<ChannelData*>(elem->channel_data);
4052
+ chand->RemoveConnectivityWatcher(watcher);
4053
+ }
4054
+
4055
+ grpc_core::RefCountedPtr<grpc_core::SubchannelCall>
4056
+ grpc_client_channel_get_subchannel_call(grpc_call_element* elem) {
4057
+ auto* calld = static_cast<CallData*>(elem->call_data);
4058
+ return calld->subchannel_call();
4059
+ }