grpc 1.45.0 → 1.47.0

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

Potentially problematic release.


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

Files changed (859) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +69 -110
  3. data/include/grpc/event_engine/event_engine.h +42 -7
  4. data/include/grpc/event_engine/memory_allocator.h +0 -15
  5. data/include/grpc/event_engine/port.h +1 -1
  6. data/include/grpc/event_engine/slice.h +286 -0
  7. data/include/grpc/event_engine/slice_buffer.h +112 -0
  8. data/include/grpc/grpc_security.h +11 -0
  9. data/include/grpc/impl/codegen/grpc_types.h +7 -13
  10. data/include/grpc/impl/codegen/port_platform.h +100 -36
  11. data/include/grpc/impl/codegen/slice.h +1 -1
  12. data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +297 -0
  13. data/src/core/ext/filters/channel_idle/channel_idle_filter.h +125 -0
  14. data/src/core/ext/filters/{client_idle → channel_idle}/idle_filter_state.cc +1 -1
  15. data/src/core/ext/filters/{client_idle → channel_idle}/idle_filter_state.h +3 -3
  16. data/src/core/ext/filters/client_channel/backend_metric.cc +17 -12
  17. data/src/core/ext/filters/client_channel/backend_metric.h +19 -9
  18. data/src/core/ext/filters/client_channel/backup_poller.cc +5 -5
  19. data/src/core/ext/filters/client_channel/backup_poller.h +2 -4
  20. data/src/core/ext/filters/client_channel/channel_connectivity.cc +42 -20
  21. data/src/core/ext/filters/client_channel/client_channel.cc +223 -113
  22. data/src/core/ext/filters/client_channel/client_channel.h +28 -6
  23. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +3 -5
  24. data/src/core/ext/filters/client_channel/client_channel_channelz.h +12 -2
  25. data/src/core/ext/filters/client_channel/client_channel_factory.cc +5 -0
  26. data/src/core/ext/filters/client_channel/client_channel_factory.h +8 -0
  27. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -13
  28. data/src/core/ext/filters/client_channel/config_selector.cc +1 -0
  29. data/src/core/ext/filters/client_channel/config_selector.h +7 -5
  30. data/src/core/ext/filters/client_channel/connector.h +8 -2
  31. data/src/core/ext/filters/client_channel/dynamic_filters.cc +13 -2
  32. data/src/core/ext/filters/client_channel/dynamic_filters.h +11 -1
  33. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +2 -0
  34. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +3 -0
  35. data/src/core/ext/filters/client_channel/health/health_check_client.cc +138 -582
  36. data/src/core/ext/filters/client_channel/health/health_check_client.h +26 -160
  37. data/src/core/ext/filters/client_channel/http_proxy.cc +98 -112
  38. data/src/core/ext/filters/client_channel/http_proxy.h +20 -0
  39. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +6 -2
  40. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +1 -0
  41. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +49 -0
  42. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +12 -0
  43. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -0
  44. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +9 -3
  45. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +59 -19
  46. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +4 -0
  47. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +6 -0
  48. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +10 -1
  49. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +6 -3
  50. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +408 -0
  51. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.h +57 -0
  52. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +1038 -0
  53. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +54 -0
  54. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +60 -52
  55. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +277 -195
  56. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +158 -101
  57. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +2 -0
  58. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +46 -20
  59. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +182 -171
  60. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +39 -36
  61. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +117 -63
  62. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +142 -63
  63. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +6 -0
  64. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +30 -4
  65. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +37 -10
  66. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +300 -291
  67. data/src/core/ext/filters/client_channel/lb_policy.cc +4 -2
  68. data/src/core/ext/filters/client_channel/lb_policy.h +18 -24
  69. data/src/core/ext/filters/client_channel/lb_policy_factory.h +2 -0
  70. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +8 -1
  71. data/src/core/ext/filters/client_channel/lb_policy_registry.h +6 -1
  72. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +4 -0
  73. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +1 -0
  74. data/src/core/ext/filters/client_channel/proxy_mapper.h +1 -1
  75. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +2 -0
  76. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +5 -0
  77. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +23 -5
  78. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +226 -300
  79. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +8 -1
  80. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +10 -8
  81. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +1 -1
  82. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +26 -9
  83. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +13 -4
  84. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +2 -1
  85. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +2 -0
  86. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +2 -1
  87. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +73 -220
  88. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +13 -14
  89. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +5 -2
  90. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +59 -13
  91. data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +213 -0
  92. data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +113 -0
  93. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +15 -11
  94. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +182 -79
  95. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -11
  96. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +11 -5
  97. data/src/core/ext/filters/client_channel/retry_filter.cc +60 -5
  98. data/src/core/ext/filters/client_channel/retry_service_config.cc +8 -9
  99. data/src/core/ext/filters/client_channel/retry_service_config.h +10 -1
  100. data/src/core/ext/filters/client_channel/retry_throttle.cc +1 -8
  101. data/src/core/ext/filters/client_channel/retry_throttle.h +7 -1
  102. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +22 -5
  103. data/src/core/ext/filters/client_channel/subchannel.cc +161 -165
  104. data/src/core/ext/filters/client_channel/subchannel.h +80 -20
  105. data/src/core/ext/filters/client_channel/subchannel_interface.h +41 -23
  106. data/src/core/ext/filters/client_channel/subchannel_interface_internal.h +38 -0
  107. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +12 -2
  108. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +6 -3
  109. data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +558 -0
  110. data/src/core/ext/filters/client_channel/subchannel_stream_client.h +226 -0
  111. data/src/core/ext/filters/deadline/deadline_filter.cc +6 -2
  112. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +123 -366
  113. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +24 -1
  114. data/src/core/ext/filters/http/client/http_client_filter.cc +87 -458
  115. data/src/core/ext/filters/http/client/http_client_filter.h +27 -4
  116. data/src/core/ext/filters/http/client_authority_filter.cc +21 -31
  117. data/src/core/ext/filters/http/client_authority_filter.h +6 -5
  118. data/src/core/ext/filters/http/http_filters_plugin.cc +16 -14
  119. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +1 -0
  120. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +3 -1
  121. data/src/core/ext/filters/http/server/http_server_filter.cc +80 -361
  122. data/src/core/ext/filters/http/server/http_server_filter.h +31 -2
  123. data/src/core/ext/filters/message_size/message_size_filter.cc +20 -26
  124. data/src/core/ext/filters/message_size/message_size_filter.h +2 -2
  125. data/src/core/ext/filters/rbac/rbac_filter.cc +1 -0
  126. data/src/core/ext/filters/server_config_selector/server_config_selector.cc +2 -8
  127. data/src/core/ext/filters/server_config_selector/server_config_selector.h +2 -2
  128. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +73 -201
  129. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +102 -135
  130. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +9 -7
  131. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +49 -19
  132. data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -0
  133. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +3 -3
  134. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -1
  135. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -0
  136. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +205 -45
  137. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +5 -0
  138. data/src/core/ext/transport/chttp2/transport/context_list.cc +4 -0
  139. data/src/core/ext/transport/chttp2/transport/context_list.h +4 -1
  140. data/src/core/ext/transport/chttp2/transport/flow_control.cc +6 -2
  141. data/src/core/ext/transport/chttp2/transport/flow_control.h +6 -2
  142. data/src/core/ext/transport/chttp2/transport/frame.h +0 -4
  143. data/src/core/ext/transport/chttp2/transport/frame_data.cc +7 -1
  144. data/src/core/ext/transport/chttp2/transport/frame_data.h +4 -1
  145. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +3 -0
  146. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +3 -1
  147. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -0
  148. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
  149. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +6 -2
  150. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +3 -0
  151. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +14 -3
  152. data/src/core/ext/transport/chttp2/transport/frame_settings.h +4 -0
  153. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -1
  154. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +3 -0
  155. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +13 -15
  156. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +15 -2
  157. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +3 -0
  158. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +3 -0
  159. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +25 -7
  160. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -1
  161. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +55 -37
  162. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +38 -21
  163. data/src/core/ext/transport/chttp2/transport/http2_settings.h +0 -1
  164. data/src/core/ext/transport/chttp2/transport/internal.h +28 -5
  165. data/src/core/ext/transport/chttp2/transport/parsing.cc +35 -6
  166. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +13 -9
  167. data/src/core/ext/transport/chttp2/transport/stream_map.cc +1 -1
  168. data/src/core/ext/transport/chttp2/transport/stream_map.h +1 -0
  169. data/src/core/ext/transport/chttp2/transport/varint.h +2 -0
  170. data/src/core/ext/transport/chttp2/transport/writing.cc +62 -15
  171. data/src/core/ext/transport/inproc/inproc_transport.cc +8 -5
  172. data/src/core/ext/upb-generated/envoy/admin/v3/certs.upb.c +27 -24
  173. data/src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h +143 -63
  174. data/src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.c +37 -35
  175. data/src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.h +177 -77
  176. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +115 -111
  177. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +547 -207
  178. data/src/core/ext/upb-generated/envoy/admin/v3/init_dump.upb.c +5 -5
  179. data/src/core/ext/upb-generated/envoy/admin/v3/init_dump.upb.h +26 -13
  180. data/src/core/ext/upb-generated/envoy/admin/v3/listeners.upb.c +5 -5
  181. data/src/core/ext/upb-generated/envoy/admin/v3/listeners.upb.h +23 -9
  182. data/src/core/ext/upb-generated/envoy/admin/v3/memory.upb.c +7 -7
  183. data/src/core/ext/upb-generated/envoy/admin/v3/memory.upb.h +18 -0
  184. data/src/core/ext/upb-generated/envoy/admin/v3/metrics.upb.c +4 -4
  185. data/src/core/ext/upb-generated/envoy/admin/v3/metrics.upb.h +13 -4
  186. data/src/core/ext/upb-generated/envoy/admin/v3/mutex_stats.upb.c +4 -4
  187. data/src/core/ext/upb-generated/envoy/admin/v3/mutex_stats.upb.h +9 -0
  188. data/src/core/ext/upb-generated/envoy/admin/v3/server_info.upb.c +49 -46
  189. data/src/core/ext/upb-generated/envoy/admin/v3/server_info.upb.h +217 -78
  190. data/src/core/ext/upb-generated/envoy/admin/v3/tap.upb.c +3 -3
  191. data/src/core/ext/upb-generated/envoy/admin/v3/tap.upb.h +10 -2
  192. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +12 -12
  193. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +40 -8
  194. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +5 -5
  195. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +20 -2
  196. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +55 -55
  197. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +289 -110
  198. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +133 -125
  199. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +656 -267
  200. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +24 -18
  201. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +96 -23
  202. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +185 -173
  203. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +860 -309
  204. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +3 -3
  205. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +10 -2
  206. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +44 -24
  207. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +165 -40
  208. data/src/core/ext/upb-generated/envoy/config/common/matcher/v3/matcher.upb.c +72 -63
  209. data/src/core/ext/upb-generated/envoy/config/common/matcher/v3/matcher.upb.h +433 -174
  210. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +33 -31
  211. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +154 -52
  212. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +5 -4
  213. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +14 -4
  214. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +89 -89
  215. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +460 -166
  216. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +76 -33
  217. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +379 -69
  218. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +2 -2
  219. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +14 -6
  220. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +5 -25
  221. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +10 -91
  222. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_method_list.upb.c +5 -5
  223. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_method_list.upb.h +26 -13
  224. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +70 -68
  225. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +369 -131
  226. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +94 -65
  227. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +447 -161
  228. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +4 -4
  229. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +27 -11
  230. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +104 -85
  231. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +378 -113
  232. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +2 -2
  233. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +3 -0
  234. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +6 -6
  235. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +30 -13
  236. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +7 -7
  237. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +43 -16
  238. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +8 -8
  239. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +58 -24
  240. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +4 -4
  241. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +14 -4
  242. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +18 -18
  243. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +100 -43
  244. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +31 -30
  245. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +171 -71
  246. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +32 -32
  247. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +196 -95
  248. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +2 -2
  249. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +7 -2
  250. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +53 -46
  251. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +284 -129
  252. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +56 -50
  253. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +337 -146
  254. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +13 -11
  255. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +49 -14
  256. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +4 -4
  257. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +14 -4
  258. data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.c +5 -5
  259. data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.h +20 -4
  260. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +33 -32
  261. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +205 -86
  262. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +34 -34
  263. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +175 -74
  264. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +56 -52
  265. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +370 -146
  266. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +27 -23
  267. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +173 -74
  268. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +362 -341
  269. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +2056 -845
  270. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +11 -11
  271. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +49 -16
  272. data/src/core/ext/upb-generated/envoy/config/tap/v3/common.upb.c +56 -50
  273. data/src/core/ext/upb-generated/envoy/config/tap/v3/common.upb.h +293 -111
  274. data/src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.c +3 -3
  275. data/src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.h +6 -0
  276. data/src/core/ext/upb-generated/envoy/config/trace/v3/dynamic_ot.upb.c +3 -3
  277. data/src/core/ext/upb-generated/envoy/config/trace/v3/dynamic_ot.upb.h +10 -2
  278. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +5 -5
  279. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +26 -10
  280. data/src/core/ext/upb-generated/envoy/config/trace/v3/lightstep.upb.c +5 -5
  281. data/src/core/ext/upb-generated/envoy/config/trace/v3/lightstep.upb.h +27 -12
  282. data/src/core/ext/upb-generated/envoy/config/trace/v3/opencensus.upb.c +17 -16
  283. data/src/core/ext/upb-generated/envoy/config/trace/v3/opencensus.upb.h +83 -36
  284. data/src/core/ext/upb-generated/envoy/config/trace/v3/service.upb.c +2 -2
  285. data/src/core/ext/upb-generated/envoy/config/trace/v3/service.upb.h +7 -2
  286. data/src/core/ext/upb-generated/envoy/config/trace/v3/skywalking.upb.c +8 -8
  287. data/src/core/ext/upb-generated/envoy/config/trace/v3/skywalking.upb.h +46 -17
  288. data/src/core/ext/upb-generated/envoy/config/trace/v3/xray.upb.c +9 -9
  289. data/src/core/ext/upb-generated/envoy/config/trace/v3/xray.upb.h +38 -12
  290. data/src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.c +7 -7
  291. data/src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.h +30 -10
  292. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +2 -2
  293. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +10 -6
  294. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +15 -15
  295. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +71 -28
  296. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +25 -25
  297. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +149 -65
  298. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +8 -7
  299. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +30 -12
  300. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +9 -9
  301. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +42 -15
  302. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +173 -144
  303. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +898 -323
  304. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +51 -45
  305. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +261 -116
  306. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +13 -13
  307. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +70 -25
  308. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +80 -55
  309. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +410 -124
  310. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.c +5 -5
  311. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.h +23 -9
  312. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +1 -1
  313. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +44 -44
  314. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +261 -122
  315. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +8 -8
  316. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +47 -21
  317. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +32 -32
  318. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +175 -66
  319. data/src/core/ext/upb-generated/envoy/type/http/v3/cookie.upb.c +4 -4
  320. data/src/core/ext/upb-generated/envoy/type/http/v3/cookie.upb.h +17 -6
  321. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +8 -8
  322. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +38 -17
  323. data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.c +8 -8
  324. data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.h +12 -0
  325. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +7 -7
  326. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +43 -18
  327. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +3 -3
  328. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +20 -9
  329. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +3 -3
  330. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +24 -9
  331. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +2 -2
  332. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +14 -6
  333. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +8 -8
  334. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +40 -16
  335. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +9 -9
  336. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +70 -25
  337. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +5 -5
  338. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +37 -18
  339. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +12 -12
  340. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +81 -30
  341. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +16 -16
  342. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +76 -30
  343. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +20 -20
  344. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +90 -30
  345. data/src/core/ext/upb-generated/envoy/type/v3/hash_policy.upb.c +7 -7
  346. data/src/core/ext/upb-generated/envoy/type/v3/hash_policy.upb.h +28 -10
  347. data/src/core/ext/upb-generated/envoy/type/v3/http_status.upb.c +2 -2
  348. data/src/core/ext/upb-generated/envoy/type/v3/http_status.upb.h +3 -0
  349. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +5 -5
  350. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +13 -4
  351. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +9 -9
  352. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +18 -0
  353. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +4 -4
  354. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +9 -0
  355. data/src/core/ext/upb-generated/envoy/type/v3/token_bucket.upb.c +5 -5
  356. data/src/core/ext/upb-generated/envoy/type/v3/token_bucket.upb.h +17 -4
  357. data/src/core/ext/upb-generated/google/api/annotations.upb.c +3 -3
  358. data/src/core/ext/upb-generated/google/api/annotations.upb.h +17 -2
  359. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +70 -66
  360. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +410 -162
  361. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +80 -74
  362. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +440 -158
  363. data/src/core/ext/upb-generated/google/api/http.upb.c +17 -17
  364. data/src/core/ext/upb-generated/google/api/http.upb.h +116 -43
  365. data/src/core/ext/upb-generated/google/api/httpbody.upb.c +4 -4
  366. data/src/core/ext/upb-generated/google/api/httpbody.upb.h +19 -7
  367. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +3 -3
  368. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +6 -0
  369. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +163 -162
  370. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +1157 -435
  371. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +3 -3
  372. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +10 -4
  373. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +1 -1
  374. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +15 -15
  375. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +108 -40
  376. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +3 -3
  377. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +10 -4
  378. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +18 -18
  379. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +27 -0
  380. data/src/core/ext/upb-generated/google/rpc/status.upb.c +4 -4
  381. data/src/core/ext/upb-generated/google/rpc/status.upb.h +19 -7
  382. data/src/core/ext/upb-generated/opencensus/proto/trace/v1/trace_config.upb.c +15 -15
  383. data/src/core/ext/upb-generated/opencensus/proto/trace/v1/trace_config.upb.h +65 -22
  384. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +12 -12
  385. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +49 -12
  386. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +69 -65
  387. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +364 -149
  388. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +8 -7
  389. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +20 -4
  390. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +4 -4
  391. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +6 -0
  392. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +31 -31
  393. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +150 -58
  394. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c +11 -11
  395. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.h +51 -18
  396. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls_config.upb.c +175 -0
  397. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls_config.upb.h +764 -0
  398. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +22 -22
  399. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +97 -10
  400. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +6 -6
  401. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +23 -2
  402. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +3 -3
  403. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +10 -2
  404. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +6 -6
  405. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +27 -6
  406. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +5 -5
  407. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +20 -2
  408. data/src/core/ext/upb-generated/validate/validate.upb.c +261 -250
  409. data/src/core/ext/upb-generated/validate/validate.upb.h +1836 -663
  410. data/src/core/ext/upb-generated/xds/annotations/v3/migrate.upb.c +22 -22
  411. data/src/core/ext/upb-generated/xds/annotations/v3/migrate.upb.h +97 -10
  412. data/src/core/ext/upb-generated/xds/annotations/v3/security.upb.c +6 -6
  413. data/src/core/ext/upb-generated/xds/annotations/v3/security.upb.h +23 -2
  414. data/src/core/ext/upb-generated/xds/annotations/v3/sensitive.upb.c +3 -3
  415. data/src/core/ext/upb-generated/xds/annotations/v3/sensitive.upb.h +10 -2
  416. data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.c +18 -18
  417. data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.h +70 -10
  418. data/src/core/ext/upb-generated/xds/annotations/v3/versioning.upb.c +5 -5
  419. data/src/core/ext/upb-generated/xds/annotations/v3/versioning.upb.h +20 -2
  420. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +2 -2
  421. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +3 -0
  422. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +8 -8
  423. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +38 -12
  424. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +5 -5
  425. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +27 -10
  426. data/src/core/ext/upb-generated/xds/core/v3/extension.upb.c +3 -3
  427. data/src/core/ext/upb-generated/xds/core/v3/extension.upb.h +10 -2
  428. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +5 -5
  429. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +21 -8
  430. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +10 -10
  431. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +71 -30
  432. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +5 -5
  433. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +16 -2
  434. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +12 -12
  435. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +69 -26
  436. data/src/core/ext/upb-generated/xds/service/orca/v3/orca.upb.c +47 -0
  437. data/src/core/ext/upb-generated/xds/service/orca/v3/orca.upb.h +109 -0
  438. data/src/core/ext/upb-generated/xds/type/matcher/v3/matcher.upb.c +43 -39
  439. data/src/core/ext/upb-generated/xds/type/matcher/v3/matcher.upb.h +255 -103
  440. data/src/core/ext/upb-generated/xds/type/matcher/v3/regex.upb.c +4 -4
  441. data/src/core/ext/upb-generated/xds/type/matcher/v3/regex.upb.h +19 -8
  442. data/src/core/ext/upb-generated/xds/type/matcher/v3/string.upb.c +9 -9
  443. data/src/core/ext/upb-generated/xds/type/matcher/v3/string.upb.h +70 -25
  444. data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.c +3 -3
  445. data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.h +10 -2
  446. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +50 -46
  447. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +195 -185
  448. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +16 -12
  449. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +129 -94
  450. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +10 -0
  451. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c +18 -33
  452. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.h +0 -5
  453. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +163 -155
  454. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.h +5 -0
  455. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +141 -138
  456. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +26 -20
  457. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +738 -730
  458. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +271 -251
  459. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
  460. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +207 -193
  461. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h +5 -0
  462. data/src/core/ext/upbdefs-generated/src/proto/grpc/lookup/v1/rls_config.upbdefs.c +99 -0
  463. data/src/core/ext/upbdefs-generated/src/proto/grpc/lookup/v1/rls_config.upbdefs.h +75 -0
  464. data/src/core/ext/xds/certificate_provider_store.cc +10 -0
  465. data/src/core/ext/xds/certificate_provider_store.h +9 -0
  466. data/src/core/ext/xds/xds_api.cc +20 -0
  467. data/src/core/ext/xds/xds_bootstrap.cc +2 -2
  468. data/src/core/ext/xds/xds_bootstrap.h +2 -0
  469. data/src/core/ext/xds/xds_certificate_provider.cc +5 -0
  470. data/src/core/ext/xds/xds_certificate_provider.h +8 -0
  471. data/src/core/ext/xds/xds_channel_stack_modifier.cc +5 -5
  472. data/src/core/ext/xds/xds_client.cc +125 -109
  473. data/src/core/ext/xds/xds_client.h +13 -5
  474. data/src/core/ext/xds/xds_cluster.cc +106 -16
  475. data/src/core/ext/xds/xds_cluster.h +3 -0
  476. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +142 -0
  477. data/src/core/ext/xds/xds_cluster_specifier_plugin.h +79 -0
  478. data/src/core/ext/xds/xds_common_types.cc +9 -9
  479. data/src/core/ext/xds/xds_common_types.h +3 -3
  480. data/src/core/ext/xds/xds_endpoint.cc +12 -5
  481. data/src/core/ext/xds/xds_http_fault_filter.cc +4 -4
  482. data/src/core/ext/xds/xds_listener.cc +20 -10
  483. data/src/core/ext/xds/xds_route_config.cc +162 -25
  484. data/src/core/ext/xds/xds_route_config.h +13 -10
  485. data/src/core/ext/xds/xds_server_config_fetcher.cc +19 -23
  486. data/src/core/lib/address_utils/sockaddr_utils.cc +56 -23
  487. data/src/core/lib/address_utils/sockaddr_utils.h +7 -4
  488. data/src/core/lib/avl/avl.h +71 -6
  489. data/src/core/lib/channel/call_finalization.h +4 -0
  490. data/src/core/lib/channel/call_tracer.h +12 -3
  491. data/src/core/lib/channel/channel_args.cc +179 -81
  492. data/src/core/lib/channel/channel_args.h +242 -11
  493. data/src/core/lib/channel/channel_args_preconditioning.cc +5 -11
  494. data/src/core/lib/channel/channel_args_preconditioning.h +4 -4
  495. data/src/core/lib/channel/channel_stack.cc +41 -3
  496. data/src/core/lib/channel/channel_stack.h +51 -8
  497. data/src/core/lib/channel/channel_stack_builder.cc +9 -84
  498. data/src/core/lib/channel/channel_stack_builder.h +35 -26
  499. data/src/core/lib/channel/channel_stack_builder_impl.cc +97 -0
  500. data/src/core/lib/channel/channel_stack_builder_impl.h +45 -0
  501. data/src/core/lib/channel/channel_trace.cc +8 -13
  502. data/src/core/lib/channel/channel_trace.h +6 -3
  503. data/src/core/lib/channel/channelz.cc +8 -13
  504. data/src/core/lib/channel/channelz.h +13 -4
  505. data/src/core/lib/channel/channelz_registry.cc +7 -14
  506. data/src/core/lib/channel/channelz_registry.h +10 -9
  507. data/src/core/lib/channel/connected_channel.cc +21 -31
  508. data/src/core/lib/channel/connected_channel.h +2 -0
  509. data/src/core/lib/channel/promise_based_filter.cc +848 -260
  510. data/src/core/lib/channel/promise_based_filter.h +215 -68
  511. data/src/core/lib/channel/status_util.cc +2 -0
  512. data/src/core/lib/channel/status_util.h +0 -3
  513. data/src/core/lib/compression/compression_internal.cc +46 -17
  514. data/src/core/lib/compression/compression_internal.h +1 -1
  515. data/src/core/lib/config/core_configuration.cc +3 -0
  516. data/src/core/lib/config/core_configuration.h +2 -1
  517. data/src/core/lib/debug/stats_data.cc +2 -6
  518. data/src/core/lib/debug/stats_data.h +18 -21
  519. data/src/core/lib/event_engine/channel_args_endpoint_config.cc +4 -2
  520. data/src/core/lib/event_engine/channel_args_endpoint_config.h +3 -2
  521. data/src/core/lib/event_engine/default_event_engine_factory.cc +8 -2
  522. data/src/core/lib/event_engine/event_engine.cc +12 -2
  523. data/src/core/lib/event_engine/event_engine_factory.h +5 -0
  524. data/src/core/lib/event_engine/handle_containers.h +67 -0
  525. data/src/core/lib/event_engine/iomgr_engine.cc +206 -0
  526. data/src/core/lib/event_engine/iomgr_engine.h +118 -0
  527. data/src/core/lib/event_engine/memory_allocator.cc +12 -4
  528. data/src/core/lib/event_engine/resolved_address.cc +4 -2
  529. data/src/core/lib/event_engine/slice.cc +102 -0
  530. data/src/core/lib/event_engine/slice_buffer.cc +50 -0
  531. data/src/core/{ext/filters/max_age/max_age_filter.h → lib/event_engine/trace.cc} +3 -11
  532. data/src/core/lib/{iomgr/endpoint_pair_event_engine.cc → event_engine/trace.h} +12 -14
  533. data/src/core/lib/gpr/log.cc +5 -0
  534. data/src/core/lib/gpr/tls.h +4 -5
  535. data/src/core/lib/gprpp/bitset.h +17 -1
  536. data/src/core/lib/gprpp/chunked_vector.h +4 -0
  537. data/src/core/lib/gprpp/construct_destruct.h +1 -0
  538. data/src/core/lib/gprpp/cpp_impl_of.h +4 -0
  539. data/src/core/lib/gprpp/dual_ref_counted.h +1 -4
  540. data/src/core/lib/gprpp/examine_stack.h +0 -1
  541. data/src/core/lib/gprpp/fork.cc +3 -6
  542. data/src/core/lib/gprpp/global_config.h +2 -4
  543. data/src/core/lib/gprpp/global_config_env.cc +3 -2
  544. data/src/core/lib/gprpp/global_config_env.h +3 -1
  545. data/src/core/lib/gprpp/global_config_generic.h +0 -4
  546. data/src/core/lib/gprpp/host_port.cc +2 -0
  547. data/src/core/lib/gprpp/manual_constructor.h +0 -1
  548. data/src/core/lib/gprpp/match.h +75 -0
  549. data/src/core/lib/gprpp/memory.h +1 -5
  550. data/src/core/lib/gprpp/orphanable.h +1 -4
  551. data/src/core/lib/gprpp/overload.h +59 -0
  552. data/src/core/lib/gprpp/ref_counted.h +3 -3
  553. data/src/core/lib/gprpp/ref_counted_ptr.h +1 -1
  554. data/src/core/lib/gprpp/single_set_ptr.h +87 -0
  555. data/src/core/lib/gprpp/stat.h +0 -2
  556. data/src/core/lib/gprpp/stat_posix.cc +7 -2
  557. data/src/core/lib/gprpp/status_helper.cc +25 -5
  558. data/src/core/lib/gprpp/status_helper.h +4 -0
  559. data/src/core/lib/gprpp/sync.h +3 -1
  560. data/src/core/lib/gprpp/table.h +10 -0
  561. data/src/core/lib/gprpp/thd.h +2 -5
  562. data/src/core/lib/gprpp/thd_posix.cc +4 -2
  563. data/src/core/lib/gprpp/thd_windows.cc +2 -0
  564. data/src/core/lib/gprpp/time.cc +20 -0
  565. data/src/core/lib/gprpp/time.h +7 -2
  566. data/src/core/lib/gprpp/time_util.cc +4 -0
  567. data/src/core/lib/gprpp/time_util.h +1 -1
  568. data/src/core/lib/gprpp/unique_type_name.h +104 -0
  569. data/src/core/lib/http/format_request.cc +30 -2
  570. data/src/core/lib/http/format_request.h +2 -0
  571. data/src/core/lib/http/httpcli.cc +88 -81
  572. data/src/core/lib/http/httpcli.h +39 -7
  573. data/src/core/lib/http/httpcli_security_connector.cc +6 -7
  574. data/src/core/lib/http/parser.cc +80 -9
  575. data/src/core/lib/http/parser.h +14 -1
  576. data/src/core/lib/iomgr/endpoint.cc +4 -4
  577. data/src/core/lib/iomgr/endpoint.h +6 -4
  578. data/src/core/lib/iomgr/endpoint_cfstream.cc +7 -4
  579. data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -1
  580. data/src/core/lib/iomgr/ev_posix.cc +7 -11
  581. data/src/core/lib/iomgr/exec_ctx.h +1 -2
  582. data/src/core/lib/iomgr/fork_posix.cc +1 -1
  583. data/src/core/lib/iomgr/internal_errqueue.cc +38 -47
  584. data/src/core/lib/iomgr/internal_errqueue.h +1 -6
  585. data/src/core/lib/iomgr/iomgr.cc +0 -1
  586. data/src/core/lib/iomgr/{event_engine/pollset.h → iomgr_fwd.h} +9 -9
  587. data/src/core/lib/iomgr/pollset_set.h +1 -2
  588. data/src/core/lib/iomgr/port.h +25 -8
  589. data/src/core/lib/iomgr/resolve_address.cc +8 -0
  590. data/src/core/lib/iomgr/resolve_address.h +21 -14
  591. data/src/core/lib/iomgr/resolve_address_impl.h +2 -3
  592. data/src/core/lib/iomgr/resolve_address_posix.cc +8 -14
  593. data/src/core/lib/iomgr/resolve_address_posix.h +5 -2
  594. data/src/core/lib/iomgr/resolve_address_windows.cc +7 -14
  595. data/src/core/lib/iomgr/resolve_address_windows.h +5 -2
  596. data/src/core/lib/iomgr/sockaddr.h +2 -3
  597. data/src/core/lib/iomgr/sockaddr_posix.h +2 -0
  598. data/src/core/lib/iomgr/sockaddr_windows.h +2 -0
  599. data/src/core/lib/iomgr/socket_utils_common_posix.cc +3 -2
  600. data/src/core/lib/iomgr/tcp_client_cfstream.cc +10 -2
  601. data/src/core/lib/iomgr/tcp_client_posix.cc +14 -7
  602. data/src/core/lib/iomgr/tcp_client_windows.cc +13 -6
  603. data/src/core/lib/iomgr/tcp_posix.cc +77 -37
  604. data/src/core/lib/iomgr/tcp_server_posix.cc +50 -27
  605. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +30 -27
  606. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +7 -4
  607. data/src/core/lib/iomgr/tcp_server_windows.cc +13 -5
  608. data/src/core/lib/iomgr/tcp_windows.cc +7 -4
  609. data/src/core/lib/json/json.h +1 -2
  610. data/src/core/lib/json/json_reader.cc +9 -1
  611. data/src/core/lib/json/json_util.cc +7 -0
  612. data/src/core/lib/json/json_util.h +13 -4
  613. data/src/core/lib/json/json_writer.cc +6 -1
  614. data/src/core/lib/promise/activity.cc +1 -1
  615. data/src/core/lib/promise/activity.h +6 -6
  616. data/src/core/lib/promise/arena_promise.h +11 -1
  617. data/src/core/lib/promise/call_push_pull.h +148 -0
  618. data/src/core/lib/promise/context.h +1 -1
  619. data/src/core/lib/promise/detail/basic_seq.h +2 -2
  620. data/src/core/lib/promise/detail/promise_factory.h +0 -1
  621. data/src/core/lib/promise/detail/status.h +2 -1
  622. data/src/core/lib/promise/intra_activity_waiter.h +49 -0
  623. data/src/core/lib/promise/latch.h +103 -0
  624. data/src/core/lib/promise/loop.h +1 -0
  625. data/src/core/lib/promise/race.h +0 -1
  626. data/src/core/lib/promise/seq.h +0 -2
  627. data/src/core/lib/promise/sleep.cc +2 -0
  628. data/src/core/lib/promise/sleep.h +10 -0
  629. data/src/core/lib/promise/try_seq.h +2 -2
  630. data/src/core/lib/resolver/resolver_factory.h +1 -2
  631. data/src/core/lib/resolver/server_address.cc +9 -3
  632. data/src/core/lib/resolver/server_address.h +4 -4
  633. data/src/core/lib/resource_quota/api.cc +19 -31
  634. data/src/core/lib/resource_quota/api.h +5 -2
  635. data/src/core/lib/resource_quota/arena.cc +0 -6
  636. data/src/core/lib/resource_quota/arena.h +1 -2
  637. data/src/core/lib/resource_quota/memory_quota.cc +47 -5
  638. data/src/core/lib/resource_quota/memory_quota.h +24 -5
  639. data/src/core/lib/resource_quota/resource_quota.h +16 -0
  640. data/src/core/lib/resource_quota/thread_quota.cc +2 -0
  641. data/src/core/lib/resource_quota/thread_quota.h +4 -0
  642. data/src/core/lib/security/authorization/authorization_policy_provider.h +7 -0
  643. data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +12 -12
  644. data/src/core/lib/security/authorization/grpc_server_authz_filter.h +5 -6
  645. data/src/core/lib/security/context/security_context.h +8 -1
  646. data/src/core/lib/security/credentials/alts/alts_credentials.cc +12 -5
  647. data/src/core/lib/security/credentials/alts/alts_credentials.h +4 -0
  648. data/src/core/lib/security/credentials/call_creds_util.cc +5 -3
  649. data/src/core/lib/security/credentials/call_creds_util.h +2 -2
  650. data/src/core/lib/security/credentials/channel_creds_registry.h +1 -0
  651. data/src/core/lib/security/credentials/composite/composite_credentials.cc +19 -10
  652. data/src/core/lib/security/credentials/composite/composite_credentials.h +11 -9
  653. data/src/core/lib/security/credentials/credentials.h +29 -39
  654. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +81 -0
  655. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +8 -0
  656. data/src/core/lib/security/credentials/external/external_account_credentials.cc +3 -0
  657. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -0
  658. data/src/core/lib/security/credentials/fake/fake_credentials.cc +18 -12
  659. data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -5
  660. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +27 -13
  661. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +4 -4
  662. data/src/core/lib/security/credentials/iam/iam_credentials.cc +8 -4
  663. data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -2
  664. data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +28 -29
  665. data/src/core/lib/security/credentials/insecure/insecure_credentials.h +57 -0
  666. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +8 -3
  667. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +6 -2
  668. data/src/core/lib/security/credentials/local/local_credentials.cc +12 -6
  669. data/src/core/lib/security/credentials/local/local_credentials.h +4 -0
  670. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +22 -10
  671. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +14 -6
  672. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +11 -6
  673. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +8 -6
  674. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +12 -4
  675. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +8 -0
  676. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +10 -0
  677. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +47 -0
  678. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc +34 -1
  679. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h +66 -3
  680. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +66 -95
  681. data/src/core/lib/security/credentials/tls/tls_credentials.cc +19 -6
  682. data/src/core/lib/security/credentials/tls/tls_credentials.h +5 -5
  683. data/src/core/lib/security/credentials/xds/xds_credentials.cc +57 -50
  684. data/src/core/lib/security/credentials/xds/xds_credentials.h +31 -5
  685. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +1 -1
  686. data/src/core/lib/security/security_connector/fake/fake_security_connector.h +1 -1
  687. data/src/core/lib/security/security_connector/local/local_security_connector.cc +2 -2
  688. data/src/core/lib/security/security_connector/security_connector.cc +1 -1
  689. data/src/core/lib/security/security_connector/security_connector.h +10 -1
  690. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +5 -3
  691. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +4 -2
  692. data/src/core/lib/security/transport/auth_filters.h +7 -7
  693. data/src/core/lib/security/transport/client_auth_filter.cc +26 -20
  694. data/src/core/lib/security/transport/secure_endpoint.cc +213 -133
  695. data/src/core/lib/security/transport/secure_endpoint.h +1 -1
  696. data/src/core/lib/security/transport/security_handshaker.cc +11 -9
  697. data/src/core/lib/security/transport/security_handshaker.h +1 -1
  698. data/src/core/lib/security/transport/server_auth_filter.cc +3 -2
  699. data/src/core/lib/service_config/service_config.h +4 -8
  700. data/src/core/lib/service_config/service_config_call_data.h +4 -1
  701. data/src/core/lib/service_config/service_config_impl.cc +7 -0
  702. data/src/core/lib/service_config/service_config_impl.h +9 -2
  703. data/src/core/lib/service_config/service_config_parser.cc +8 -0
  704. data/src/core/lib/service_config/service_config_parser.h +7 -0
  705. data/src/core/lib/slice/b64.cc +1 -1
  706. data/src/core/lib/slice/b64.h +2 -0
  707. data/src/core/lib/slice/percent_encoding.cc +4 -1
  708. data/src/core/lib/slice/percent_encoding.h +0 -6
  709. data/src/core/lib/slice/slice.cc +2 -1
  710. data/src/core/lib/slice/slice.h +10 -5
  711. data/src/core/lib/slice/slice_api.cc +1 -1
  712. data/src/core/lib/slice/slice_buffer.cc +50 -23
  713. data/src/core/lib/slice/slice_buffer.h +106 -0
  714. data/src/core/lib/{iomgr/is_epollexclusive_available.h → slice/slice_buffer_api.cc} +11 -12
  715. data/src/core/lib/slice/slice_internal.h +4 -3
  716. data/src/core/lib/slice/slice_refcount.h +2 -3
  717. data/src/core/lib/slice/slice_refcount_base.h +2 -3
  718. data/src/core/lib/slice/slice_split.cc +3 -0
  719. data/src/core/lib/slice/slice_split.h +0 -4
  720. data/src/core/lib/slice/slice_string_helpers.cc +4 -0
  721. data/src/core/lib/slice/slice_string_helpers.h +1 -4
  722. data/src/core/lib/surface/builtins.cc +7 -2
  723. data/src/core/lib/surface/byte_buffer.cc +7 -1
  724. data/src/core/lib/surface/byte_buffer_reader.cc +4 -4
  725. data/src/core/lib/surface/call.cc +1052 -917
  726. data/src/core/lib/surface/call.h +16 -16
  727. data/src/core/lib/surface/call_details.cc +4 -4
  728. data/src/core/lib/surface/call_log_batch.cc +7 -1
  729. data/src/core/lib/surface/call_test_only.h +4 -1
  730. data/src/core/lib/surface/channel.cc +181 -243
  731. data/src/core/lib/surface/channel.h +94 -57
  732. data/src/core/lib/surface/channel_init.cc +2 -3
  733. data/src/core/lib/surface/channel_init.h +3 -5
  734. data/src/core/lib/surface/channel_ping.cc +8 -2
  735. data/src/core/lib/surface/channel_stack_type.cc +0 -2
  736. data/src/core/lib/surface/channel_stack_type.h +0 -2
  737. data/src/core/lib/surface/completion_queue.cc +14 -6
  738. data/src/core/lib/surface/completion_queue.h +5 -1
  739. data/src/core/lib/surface/completion_queue_factory.cc +1 -0
  740. data/src/core/lib/surface/completion_queue_factory.h +1 -3
  741. data/src/core/lib/surface/event_string.cc +1 -7
  742. data/src/core/lib/surface/event_string.h +1 -1
  743. data/src/core/lib/surface/init.cc +17 -45
  744. data/src/core/lib/surface/init.h +0 -8
  745. data/src/core/lib/surface/lame_client.cc +64 -110
  746. data/src/core/lib/surface/lame_client.h +40 -2
  747. data/src/core/lib/surface/metadata_array.cc +2 -0
  748. data/src/core/lib/surface/server.cc +72 -70
  749. data/src/core/lib/surface/server.h +40 -11
  750. data/src/core/lib/surface/validate_metadata.cc +2 -5
  751. data/src/core/lib/surface/validate_metadata.h +3 -0
  752. data/src/core/lib/surface/version.cc +2 -2
  753. data/src/core/lib/transport/bdp_estimator.cc +3 -1
  754. data/src/core/lib/transport/bdp_estimator.h +2 -3
  755. data/src/core/lib/transport/byte_stream.cc +6 -3
  756. data/src/core/lib/transport/byte_stream.h +5 -1
  757. data/src/core/lib/transport/connectivity_state.cc +6 -4
  758. data/src/core/lib/transport/connectivity_state.h +2 -3
  759. data/src/core/lib/transport/error_utils.cc +4 -2
  760. data/src/core/lib/transport/error_utils.h +5 -1
  761. data/src/core/lib/{channel → transport}/handshaker.cc +9 -4
  762. data/src/core/lib/{channel → transport}/handshaker.h +13 -6
  763. data/src/core/lib/{channel → transport}/handshaker_factory.h +9 -10
  764. data/src/core/lib/{channel → transport}/handshaker_registry.cc +5 -1
  765. data/src/core/lib/{channel → transport}/handshaker_registry.h +5 -4
  766. data/src/core/{ext/filters/client_channel → lib/transport}/http_connect_handshaker.cc +24 -10
  767. data/src/core/{ext/filters/client_channel → lib/transport}/http_connect_handshaker.h +3 -3
  768. data/src/core/lib/transport/metadata_batch.cc +287 -0
  769. data/src/core/lib/transport/metadata_batch.h +142 -269
  770. data/src/core/lib/transport/parsed_metadata.cc +2 -0
  771. data/src/core/lib/transport/parsed_metadata.h +10 -3
  772. data/src/core/lib/transport/status_conversion.cc +2 -0
  773. data/src/core/lib/transport/status_conversion.h +2 -2
  774. data/src/core/lib/transport/tcp_connect_handshaker.cc +253 -0
  775. data/src/core/lib/transport/tcp_connect_handshaker.h +39 -0
  776. data/src/core/lib/transport/timeout_encoding.cc +2 -6
  777. data/src/core/lib/transport/timeout_encoding.h +5 -1
  778. data/src/core/lib/transport/transport.cc +18 -17
  779. data/src/core/lib/transport/transport.h +48 -7
  780. data/src/core/lib/transport/transport_impl.h +14 -3
  781. data/src/core/lib/transport/transport_op_string.cc +9 -10
  782. data/src/core/lib/uri/uri_parser.cc +11 -3
  783. data/src/core/lib/uri/uri_parser.h +0 -2
  784. data/src/core/plugin_registry/grpc_plugin_registry.cc +13 -4
  785. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -2
  786. data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -0
  787. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +2 -0
  788. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +2 -0
  789. data/src/core/tsi/ssl_transport_security.cc +75 -38
  790. data/src/core/tsi/ssl_transport_security.h +8 -2
  791. data/src/core/tsi/transport_security_interface.h +2 -0
  792. data/src/ruby/ext/grpc/extconf.rb +2 -2
  793. data/src/ruby/lib/grpc/generic/active_call.rb +7 -1
  794. data/src/ruby/lib/grpc/grpc.rb +1 -1
  795. data/src/ruby/lib/grpc/version.rb +1 -1
  796. data/src/ruby/pb/generate_proto_ruby.sh +1 -0
  797. data/src/ruby/pb/test/client.rb +769 -0
  798. data/src/ruby/pb/test/server.rb +252 -0
  799. data/src/ruby/pb/test/xds_client.rb +415 -0
  800. data/third_party/abseil-cpp/absl/cleanup/cleanup.h +140 -0
  801. data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +100 -0
  802. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +504 -0
  803. data/third_party/upb/third_party/utf8_range/utf8_range.h +1 -1
  804. data/third_party/upb/upb/decode.c +32 -16
  805. data/third_party/upb/upb/def.c +118 -55
  806. data/third_party/upb/upb/def.h +12 -3
  807. data/third_party/upb/upb/encode.c +14 -8
  808. data/third_party/upb/upb/json_encode.c +776 -0
  809. data/third_party/upb/upb/json_encode.h +62 -0
  810. data/third_party/upb/upb/msg.c +5 -7
  811. data/third_party/upb/upb/msg.h +1 -2
  812. data/third_party/upb/upb/msg_internal.h +49 -36
  813. data/third_party/upb/upb/port_def.inc +8 -0
  814. data/third_party/upb/upb/port_undef.inc +1 -0
  815. data/third_party/upb/upb/table.c +10 -6
  816. data/third_party/upb/upb/table_internal.h +2 -0
  817. data/third_party/upb/upb/upb.h +41 -11
  818. data/third_party/zlib/crc32.c +966 -292
  819. data/third_party/zlib/crc32.h +9441 -436
  820. data/third_party/zlib/deflate.c +78 -30
  821. data/third_party/zlib/deflate.h +12 -15
  822. data/third_party/zlib/gzguts.h +3 -2
  823. data/third_party/zlib/gzlib.c +5 -3
  824. data/third_party/zlib/gzread.c +5 -7
  825. data/third_party/zlib/gzwrite.c +25 -13
  826. data/third_party/zlib/infback.c +2 -1
  827. data/third_party/zlib/inffast.c +14 -14
  828. data/third_party/zlib/inflate.c +39 -8
  829. data/third_party/zlib/inflate.h +3 -2
  830. data/third_party/zlib/inftrees.c +3 -3
  831. data/third_party/zlib/trees.c +27 -48
  832. data/third_party/zlib/zlib.h +123 -100
  833. data/third_party/zlib/zutil.c +2 -2
  834. data/third_party/zlib/zutil.h +12 -9
  835. metadata +100 -72
  836. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +0 -31
  837. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +0 -28
  838. data/src/core/ext/filters/client_idle/client_idle_filter.cc +0 -201
  839. data/src/core/ext/filters/max_age/max_age_filter.cc +0 -566
  840. data/src/core/lib/event_engine/sockaddr.cc +0 -40
  841. data/src/core/lib/event_engine/sockaddr.h +0 -44
  842. data/src/core/lib/gprpp/capture.h +0 -76
  843. data/src/core/lib/iomgr/ev_epollex_linux.cc +0 -1657
  844. data/src/core/lib/iomgr/ev_epollex_linux.h +0 -30
  845. data/src/core/lib/iomgr/event_engine/closure.cc +0 -77
  846. data/src/core/lib/iomgr/event_engine/closure.h +0 -42
  847. data/src/core/lib/iomgr/event_engine/endpoint.cc +0 -172
  848. data/src/core/lib/iomgr/event_engine/endpoint.h +0 -52
  849. data/src/core/lib/iomgr/event_engine/iomgr.cc +0 -85
  850. data/src/core/lib/iomgr/event_engine/pollset.cc +0 -87
  851. data/src/core/lib/iomgr/event_engine/promise.h +0 -51
  852. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +0 -47
  853. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +0 -37
  854. data/src/core/lib/iomgr/event_engine/resolver.cc +0 -133
  855. data/src/core/lib/iomgr/event_engine/resolver.h +0 -56
  856. data/src/core/lib/iomgr/event_engine/tcp.cc +0 -296
  857. data/src/core/lib/iomgr/event_engine/timer.cc +0 -62
  858. data/src/core/lib/iomgr/is_epollexclusive_available.cc +0 -119
  859. data/src/core/lib/iomgr/sys_epoll_wrapper.h +0 -30
@@ -20,212 +20,395 @@
20
20
 
21
21
  #include "src/core/lib/surface/call.h"
22
22
 
23
- #include <assert.h>
24
23
  #include <limits.h>
25
- #include <stdio.h>
26
24
  #include <stdlib.h>
27
- #include <string.h>
28
25
 
26
+ #include <algorithm>
27
+ #include <atomic>
28
+ #include <memory>
29
+ #include <new>
29
30
  #include <string>
31
+ #include <utility>
30
32
 
33
+ #include "absl/base/thread_annotations.h"
34
+ #include "absl/meta/type_traits.h"
35
+ #include "absl/status/status.h"
31
36
  #include "absl/strings/str_cat.h"
32
37
  #include "absl/strings/str_format.h"
38
+ #include "absl/strings/string_view.h"
33
39
 
40
+ #include <grpc/byte_buffer.h>
34
41
  #include <grpc/compression.h>
35
42
  #include <grpc/grpc.h>
43
+ #include <grpc/impl/codegen/gpr_types.h>
44
+ #include <grpc/impl/codegen/propagation_bits.h>
36
45
  #include <grpc/slice.h>
46
+ #include <grpc/slice_buffer.h>
47
+ #include <grpc/status.h>
37
48
  #include <grpc/support/alloc.h>
49
+ #include <grpc/support/atm.h>
38
50
  #include <grpc/support/log.h>
39
51
  #include <grpc/support/string_util.h>
40
52
 
41
53
  #include "src/core/lib/channel/channel_stack.h"
54
+ #include "src/core/lib/channel/channel_stack_builder.h"
55
+ #include "src/core/lib/channel/channelz.h"
56
+ #include "src/core/lib/channel/context.h"
42
57
  #include "src/core/lib/compression/compression_internal.h"
43
58
  #include "src/core/lib/debug/stats.h"
44
59
  #include "src/core/lib/gpr/alloc.h"
45
- #include "src/core/lib/gpr/string.h"
46
60
  #include "src/core/lib/gpr/time_precise.h"
47
- #include "src/core/lib/gpr/useful.h"
61
+ #include "src/core/lib/gprpp/cpp_impl_of.h"
62
+ #include "src/core/lib/gprpp/debug_location.h"
48
63
  #include "src/core/lib/gprpp/manual_constructor.h"
64
+ #include "src/core/lib/gprpp/orphanable.h"
49
65
  #include "src/core/lib/gprpp/ref_counted.h"
50
- #include "src/core/lib/iomgr/timer.h"
66
+ #include "src/core/lib/gprpp/sync.h"
67
+ #include "src/core/lib/iomgr/call_combiner.h"
68
+ #include "src/core/lib/iomgr/exec_ctx.h"
69
+ #include "src/core/lib/iomgr/polling_entity.h"
51
70
  #include "src/core/lib/profiling/timers.h"
52
71
  #include "src/core/lib/resource_quota/arena.h"
53
72
  #include "src/core/lib/slice/slice_internal.h"
54
- #include "src/core/lib/slice/slice_split.h"
55
- #include "src/core/lib/slice/slice_string_helpers.h"
73
+ #include "src/core/lib/slice/slice_refcount.h"
56
74
  #include "src/core/lib/surface/api_trace.h"
57
75
  #include "src/core/lib/surface/call_test_only.h"
58
76
  #include "src/core/lib/surface/channel.h"
59
77
  #include "src/core/lib/surface/completion_queue.h"
60
78
  #include "src/core/lib/surface/server.h"
61
79
  #include "src/core/lib/surface/validate_metadata.h"
80
+ #include "src/core/lib/transport/byte_stream.h"
62
81
  #include "src/core/lib/transport/error_utils.h"
82
+ #include "src/core/lib/transport/metadata_batch.h"
63
83
  #include "src/core/lib/transport/transport.h"
64
84
 
65
- /** The maximum number of concurrent batches possible.
66
- Based upon the maximum number of individually queueable ops in the batch
67
- api:
68
- - initial metadata send
69
- - message send
70
- - status/close send (depending on client/server)
71
- - initial metadata recv
72
- - message recv
73
- - status/close recv (depending on client/server) */
74
- #define MAX_CONCURRENT_BATCHES 6
75
-
76
- struct batch_control {
77
- batch_control() = default;
78
-
79
- grpc_call* call = nullptr;
80
- grpc_transport_stream_op_batch op;
81
- /* Share memory for cq_completion and notify_tag as they are never needed
82
- simultaneously. Each byte used in this data structure count as six bytes
83
- per call, so any savings we can make are worthwhile,
84
-
85
- We use notify_tag to determine whether or not to send notification to the
86
- completion queue. Once we've made that determination, we can reuse the
87
- memory for cq_completion. */
88
- union {
89
- grpc_cq_completion cq_completion;
90
- struct {
91
- /* Any given op indicates completion by either (a) calling a closure or
92
- (b) sending a notification on the call's completion queue. If
93
- \a is_closure is true, \a tag indicates a closure to be invoked;
94
- otherwise, \a tag indicates the tag to be used in the notification to
95
- be sent to the completion queue. */
96
- void* tag;
97
- bool is_closure;
98
- } notify_tag;
99
- } completion_data;
100
- grpc_closure start_batch;
101
- grpc_closure finish_batch;
102
- std::atomic<intptr_t> steps_to_complete{0};
103
- AtomicError batch_error;
104
- void set_num_steps_to_complete(uintptr_t steps) {
105
- steps_to_complete.store(steps, std::memory_order_release);
106
- }
107
- bool completed_batch_step() {
108
- return steps_to_complete.fetch_sub(1, std::memory_order_acq_rel) == 1;
109
- }
110
- };
85
+ grpc_core::TraceFlag grpc_call_error_trace(false, "call_error");
86
+ grpc_core::TraceFlag grpc_compression_trace(false, "compression");
111
87
 
112
- struct parent_call {
113
- parent_call() { gpr_mu_init(&child_list_mu); }
114
- ~parent_call() { gpr_mu_destroy(&child_list_mu); }
88
+ namespace grpc_core {
115
89
 
116
- gpr_mu child_list_mu;
117
- grpc_call* first_child = nullptr;
118
- };
90
+ class Call : public CppImplOf<Call, grpc_call> {
91
+ public:
92
+ Arena* arena() { return arena_; }
93
+ bool is_client() const { return is_client_; }
94
+
95
+ virtual void ContextSet(grpc_context_index elem, void* value,
96
+ void (*destroy)(void* value)) = 0;
97
+ virtual void* ContextGet(grpc_context_index elem) const = 0;
98
+ virtual bool Completed() = 0;
99
+ void CancelWithStatus(grpc_status_code status, const char* description);
100
+ virtual void CancelWithError(grpc_error_handle error) = 0;
101
+ virtual void SetCompletionQueue(grpc_completion_queue* cq) = 0;
102
+ virtual char* GetPeer() = 0;
103
+ virtual grpc_call_error StartBatch(const grpc_op* ops, size_t nops,
104
+ void* notify_tag,
105
+ bool is_notify_tag_closure) = 0;
106
+ virtual bool failed_before_recv_message() const = 0;
107
+ virtual bool is_trailers_only() const = 0;
108
+ virtual void ExternalRef() = 0;
109
+ virtual void ExternalUnref() = 0;
110
+ virtual void InternalRef(const char* reason) = 0;
111
+ virtual void InternalUnref(const char* reason) = 0;
112
+
113
+ virtual grpc_compression_algorithm test_only_compression_algorithm() = 0;
114
+ virtual uint32_t test_only_message_flags() = 0;
115
+ virtual uint32_t test_only_encodings_accepted_by_peer() = 0;
116
+ virtual grpc_compression_algorithm compression_for_level(
117
+ grpc_compression_level level) = 0;
118
+
119
+ // This should return nullptr for the promise stack (and alternative means
120
+ // for that functionality be invented)
121
+ virtual grpc_call_stack* call_stack() = 0;
122
+
123
+ protected:
124
+ Call(Arena* arena, bool is_client, Timestamp send_deadline)
125
+ : arena_(arena), send_deadline_(send_deadline), is_client_(is_client) {
126
+ GPR_DEBUG_ASSERT(arena_ != nullptr);
127
+ }
128
+ ~Call() = default;
129
+
130
+ struct ParentCall {
131
+ Mutex child_list_mu;
132
+ Call* first_child ABSL_GUARDED_BY(child_list_mu) = nullptr;
133
+ };
134
+
135
+ struct ChildCall {
136
+ explicit ChildCall(Call* parent) : parent(parent) {}
137
+ Call* parent;
138
+ /** siblings: children of the same parent form a list, and this list is
139
+ protected under
140
+ parent->mu */
141
+ Call* sibling_next = nullptr;
142
+ Call* sibling_prev = nullptr;
143
+ };
144
+
145
+ ParentCall* GetOrCreateParentCall();
146
+ ParentCall* parent_call();
147
+
148
+ absl::Status InitParent(Call* parent, uint32_t propagation_mask);
149
+ void PublishToParent(Call* parent);
150
+ void MaybeUnpublishFromParent();
151
+ void PropagateCancellationToChildren();
152
+
153
+ Timestamp send_deadline() const { return send_deadline_; }
154
+ void set_send_deadline(Timestamp send_deadline) {
155
+ send_deadline_ = send_deadline;
156
+ }
119
157
 
120
- struct child_call {
121
- explicit child_call(grpc_call* parent) : parent(parent) {}
122
- grpc_call* parent;
123
- /** siblings: children of the same parent form a list, and this list is
124
- protected under
125
- parent->mu */
126
- grpc_call* sibling_next = nullptr;
127
- grpc_call* sibling_prev = nullptr;
158
+ private:
159
+ Arena* const arena_;
160
+ std::atomic<ParentCall*> parent_call_{nullptr};
161
+ ChildCall* child_ = nullptr;
162
+ Timestamp send_deadline_;
163
+ const bool is_client_;
164
+ // flag indicating that cancellation is inherited
165
+ bool cancellation_is_inherited_ = false;
128
166
  };
129
167
 
130
- #define RECV_NONE ((gpr_atm)0)
131
- #define RECV_INITIAL_METADATA_FIRST ((gpr_atm)1)
132
-
133
- struct grpc_call {
134
- grpc_call(grpc_core::Arena* arena, const grpc_call_create_args& args)
135
- : arena(arena),
136
- cq(args.cq),
137
- channel(args.channel),
138
- is_client(args.server_transport_data == nullptr),
139
- stream_op_payload(context) {}
140
-
141
- ~grpc_call() {
168
+ class FilterStackCall final : public Call {
169
+ public:
170
+ ~FilterStackCall() {
142
171
  for (int i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
143
- if (context[i].destroy) {
144
- context[i].destroy(context[i].value);
172
+ if (context_[i].destroy) {
173
+ context_[i].destroy(context_[i].value);
145
174
  }
146
175
  }
147
- gpr_free(static_cast<void*>(const_cast<char*>(final_info.error_string)));
176
+ gpr_free(static_cast<void*>(const_cast<char*>(final_info_.error_string)));
177
+ }
178
+
179
+ bool Completed() override {
180
+ return gpr_atm_acq_load(&received_final_op_atm_) != 0;
181
+ }
182
+
183
+ // TODO(ctiller): return absl::StatusOr<SomeSmartPointer<Call>>?
184
+ static grpc_error_handle Create(grpc_call_create_args* args,
185
+ grpc_call** out_call);
186
+
187
+ static Call* FromTopElem(grpc_call_element* elem) {
188
+ return FromCallStack(grpc_call_stack_from_top_element(elem));
189
+ }
190
+
191
+ grpc_call_stack* call_stack() override {
192
+ return reinterpret_cast<grpc_call_stack*>(
193
+ reinterpret_cast<char*>(this) +
194
+ GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(*this)));
195
+ }
196
+
197
+ grpc_call_element* call_elem(size_t idx) {
198
+ return grpc_call_stack_element(call_stack(), idx);
199
+ }
200
+
201
+ CallCombiner* call_combiner() { return &call_combiner_; }
202
+
203
+ void CancelWithError(grpc_error_handle error) override;
204
+ void SetCompletionQueue(grpc_completion_queue* cq) override;
205
+ char* GetPeer() override;
206
+ grpc_call_error StartBatch(const grpc_op* ops, size_t nops, void* notify_tag,
207
+ bool is_notify_tag_closure) override;
208
+ void ExternalRef() override { ext_ref_.Ref(); }
209
+ void ExternalUnref() override;
210
+ void InternalRef(const char* reason) override {
211
+ GRPC_CALL_STACK_REF(call_stack(), reason);
212
+ }
213
+ void InternalUnref(const char* reason) override {
214
+ GRPC_CALL_STACK_UNREF(call_stack(), reason);
215
+ }
216
+
217
+ void ContextSet(grpc_context_index elem, void* value,
218
+ void (*destroy)(void* value)) override;
219
+ void* ContextGet(grpc_context_index elem) const override {
220
+ return context_[elem].value;
221
+ }
222
+
223
+ grpc_compression_algorithm compression_for_level(
224
+ grpc_compression_level level) override {
225
+ return encodings_accepted_by_peer_.CompressionAlgorithmForLevel(level);
148
226
  }
149
227
 
150
- grpc_core::RefCount ext_ref;
151
- grpc_core::Arena* arena;
152
- grpc_core::CallCombiner call_combiner;
153
- grpc_completion_queue* cq;
154
- grpc_polling_entity pollent;
155
- grpc_channel* channel;
156
- gpr_cycle_counter start_time = gpr_get_cycle_counter();
157
- /* parent_call* */ gpr_atm parent_call_atm = 0;
158
- child_call* child = nullptr;
228
+ bool is_trailers_only() const override {
229
+ bool result = is_trailers_only_;
230
+ GPR_DEBUG_ASSERT(!result || recv_initial_metadata_.TransportSize() == 0);
231
+ return result;
232
+ }
233
+
234
+ bool failed_before_recv_message() const override {
235
+ return call_failed_before_recv_message_;
236
+ }
237
+
238
+ grpc_compression_algorithm test_only_compression_algorithm() override {
239
+ return incoming_compression_algorithm_;
240
+ }
241
+
242
+ uint32_t test_only_message_flags() override {
243
+ return test_only_last_message_flags_;
244
+ }
245
+
246
+ uint32_t test_only_encodings_accepted_by_peer() override {
247
+ return encodings_accepted_by_peer_.ToLegacyBitmask();
248
+ }
249
+
250
+ static size_t InitialSizeEstimate() {
251
+ return sizeof(FilterStackCall) +
252
+ sizeof(BatchControl) * kMaxConcurrentBatches;
253
+ }
254
+
255
+ private:
256
+ // The maximum number of concurrent batches possible.
257
+ // Based upon the maximum number of individually queueable ops in the batch
258
+ // api:
259
+ // - initial metadata send
260
+ // - message send
261
+ // - status/close send (depending on client/server)
262
+ // - initial metadata recv
263
+ // - message recv
264
+ // - status/close recv (depending on client/server)
265
+ static constexpr size_t kMaxConcurrentBatches = 6;
266
+
267
+ static constexpr gpr_atm kRecvNone = 0;
268
+ static constexpr gpr_atm kRecvInitialMetadataFirst = 1;
269
+
270
+ struct BatchControl {
271
+ FilterStackCall* call_ = nullptr;
272
+ grpc_transport_stream_op_batch op_;
273
+ /* Share memory for cq_completion and notify_tag as they are never needed
274
+ simultaneously. Each byte used in this data structure count as six bytes
275
+ per call, so any savings we can make are worthwhile,
276
+
277
+ We use notify_tag to determine whether or not to send notification to the
278
+ completion queue. Once we've made that determination, we can reuse the
279
+ memory for cq_completion. */
280
+ union {
281
+ grpc_cq_completion cq_completion;
282
+ struct {
283
+ /* Any given op indicates completion by either (a) calling a closure or
284
+ (b) sending a notification on the call's completion queue. If
285
+ \a is_closure is true, \a tag indicates a closure to be invoked;
286
+ otherwise, \a tag indicates the tag to be used in the notification to
287
+ be sent to the completion queue. */
288
+ void* tag;
289
+ bool is_closure;
290
+ } notify_tag;
291
+ } completion_data_;
292
+ grpc_closure start_batch_;
293
+ grpc_closure finish_batch_;
294
+ std::atomic<intptr_t> steps_to_complete_{0};
295
+ AtomicError batch_error_;
296
+ void set_num_steps_to_complete(uintptr_t steps) {
297
+ steps_to_complete_.store(steps, std::memory_order_release);
298
+ }
299
+ bool completed_batch_step() {
300
+ return steps_to_complete_.fetch_sub(1, std::memory_order_acq_rel) == 1;
301
+ }
302
+
303
+ void PostCompletion();
304
+ void FinishStep();
305
+ void ContinueReceivingSlices();
306
+ void ReceivingSliceReady(grpc_error_handle error);
307
+ void ProcessDataAfterMetadata();
308
+ void ReceivingStreamReady(grpc_error_handle error);
309
+ void ValidateFilteredMetadata();
310
+ void ReceivingInitialMetadataReady(grpc_error_handle error);
311
+ void ReceivingTrailingMetadataReady(grpc_error_handle error);
312
+ void FinishBatch(grpc_error_handle error);
313
+ };
314
+
315
+ FilterStackCall(Arena* arena, const grpc_call_create_args& args)
316
+ : Call(arena, args.server_transport_data == nullptr, args.send_deadline),
317
+ cq_(args.cq),
318
+ channel_(args.channel->Ref()),
319
+ stream_op_payload_(context_) {}
320
+
321
+ static void ReleaseCall(void* call, grpc_error_handle);
322
+ static void DestroyCall(void* call, grpc_error_handle);
323
+
324
+ static FilterStackCall* FromCallStack(grpc_call_stack* call_stack) {
325
+ return reinterpret_cast<FilterStackCall*>(
326
+ reinterpret_cast<char*>(call_stack) -
327
+ GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(FilterStackCall)));
328
+ }
329
+
330
+ void ExecuteBatch(grpc_transport_stream_op_batch* batch,
331
+ grpc_closure* start_batch_closure);
332
+ void SetFinalStatus(grpc_error_handle error);
333
+ BatchControl* ReuseOrAllocateBatchControl(const grpc_op* ops);
334
+ void HandleCompressionAlgorithmDisabled(
335
+ grpc_compression_algorithm compression_algorithm) GPR_ATTRIBUTE_NOINLINE;
336
+ void HandleCompressionAlgorithmNotAccepted(
337
+ grpc_compression_algorithm compression_algorithm) GPR_ATTRIBUTE_NOINLINE;
338
+ bool PrepareApplicationMetadata(size_t count, grpc_metadata* metadata,
339
+ bool is_trailing);
340
+ void PublishAppMetadata(grpc_metadata_batch* b, bool is_trailing);
341
+ void RecvInitialFilter(grpc_metadata_batch* b);
342
+ void RecvTrailingFilter(grpc_metadata_batch* b,
343
+ grpc_error_handle batch_error);
344
+
345
+ RefCount ext_ref_;
346
+ CallCombiner call_combiner_;
347
+ grpc_completion_queue* cq_;
348
+ grpc_polling_entity pollent_;
349
+ RefCountedPtr<Channel> channel_;
350
+ gpr_cycle_counter start_time_ = gpr_get_cycle_counter();
159
351
 
160
- /* client or server call */
161
- bool is_client;
162
352
  /** has grpc_call_unref been called */
163
- bool destroy_called = false;
164
- /** flag indicating that cancellation is inherited */
165
- bool cancellation_is_inherited = false;
353
+ bool destroy_called_ = false;
166
354
  // Trailers-only response status
167
- bool is_trailers_only = false;
355
+ bool is_trailers_only_ = false;
168
356
  /** which ops are in-flight */
169
- bool sent_initial_metadata = false;
170
- bool sending_message = false;
171
- bool sent_final_op = false;
172
- bool received_initial_metadata = false;
173
- bool receiving_message = false;
174
- bool requested_final_op = false;
175
- gpr_atm any_ops_sent_atm = 0;
176
- gpr_atm received_final_op_atm = 0;
177
-
178
- batch_control* active_batches[MAX_CONCURRENT_BATCHES] = {};
179
- grpc_transport_stream_op_batch_payload stream_op_payload;
357
+ bool sent_initial_metadata_ = false;
358
+ bool sending_message_ = false;
359
+ bool sent_final_op_ = false;
360
+ bool received_initial_metadata_ = false;
361
+ bool receiving_message_ = false;
362
+ bool requested_final_op_ = false;
363
+ gpr_atm any_ops_sent_atm_ = 0;
364
+ gpr_atm received_final_op_atm_ = 0;
365
+
366
+ BatchControl* active_batches_[kMaxConcurrentBatches] = {};
367
+ grpc_transport_stream_op_batch_payload stream_op_payload_;
180
368
 
181
369
  /* first idx: is_receiving, second idx: is_trailing */
182
- grpc_metadata_batch send_initial_metadata{arena};
183
- grpc_metadata_batch send_trailing_metadata{arena};
184
- grpc_metadata_batch recv_initial_metadata{arena};
185
- grpc_metadata_batch recv_trailing_metadata{arena};
370
+ grpc_metadata_batch send_initial_metadata_{arena()};
371
+ grpc_metadata_batch send_trailing_metadata_{arena()};
372
+ grpc_metadata_batch recv_initial_metadata_{arena()};
373
+ grpc_metadata_batch recv_trailing_metadata_{arena()};
186
374
 
187
375
  /* Buffered read metadata waiting to be returned to the application.
188
376
  Element 0 is initial metadata, element 1 is trailing metadata. */
189
- grpc_metadata_array* buffered_metadata[2] = {};
377
+ grpc_metadata_array* buffered_metadata_[2] = {};
190
378
 
191
379
  // A char* indicating the peer name.
192
- gpr_atm peer_string = 0;
380
+ gpr_atm peer_string_ = 0;
193
381
 
194
382
  /* Call data useful used for reporting. Only valid after the call has
195
383
  * completed */
196
- grpc_call_final_info final_info;
384
+ grpc_call_final_info final_info_;
197
385
 
198
386
  /* Compression algorithm for *incoming* data */
199
- grpc_compression_algorithm incoming_compression_algorithm =
387
+ grpc_compression_algorithm incoming_compression_algorithm_ =
200
388
  GRPC_COMPRESS_NONE;
201
389
  /* Supported encodings (compression algorithms), a bitset.
202
390
  * Always support no compression. */
203
- grpc_core::CompressionAlgorithmSet encodings_accepted_by_peer{
204
- GRPC_COMPRESS_NONE};
205
- /* Supported stream encodings (stream compression algorithms), a bitset */
206
- uint32_t stream_encodings_accepted_by_peer = 0;
391
+ CompressionAlgorithmSet encodings_accepted_by_peer_{GRPC_COMPRESS_NONE};
207
392
 
208
393
  /* Contexts for various subsystems (security, tracing, ...). */
209
- grpc_call_context_element context[GRPC_CONTEXT_COUNT] = {};
210
-
211
- grpc_core::Timestamp send_deadline;
212
-
213
- grpc_core::ManualConstructor<grpc_core::SliceBufferByteStream> sending_stream;
214
-
215
- grpc_core::OrphanablePtr<grpc_core::ByteStream> receiving_stream;
216
- bool call_failed_before_recv_message = false;
217
- grpc_byte_buffer** receiving_buffer = nullptr;
218
- grpc_slice receiving_slice = grpc_empty_slice();
219
- grpc_closure receiving_slice_ready;
220
- grpc_closure receiving_stream_ready;
221
- grpc_closure receiving_initial_metadata_ready;
222
- grpc_closure receiving_trailing_metadata_ready;
223
- uint32_t test_only_last_message_flags = 0;
394
+ grpc_call_context_element context_[GRPC_CONTEXT_COUNT] = {};
395
+
396
+ ManualConstructor<SliceBufferByteStream> sending_stream_;
397
+
398
+ OrphanablePtr<ByteStream> receiving_stream_;
399
+ bool call_failed_before_recv_message_ = false;
400
+ grpc_byte_buffer** receiving_buffer_ = nullptr;
401
+ grpc_slice receiving_slice_ = grpc_empty_slice();
402
+ grpc_closure receiving_slice_ready_;
403
+ grpc_closure receiving_stream_ready_;
404
+ grpc_closure receiving_initial_metadata_ready_;
405
+ grpc_closure receiving_trailing_metadata_ready_;
406
+ uint32_t test_only_last_message_flags_ = 0;
224
407
  // Status about operation of call
225
- bool sent_server_trailing_metadata = false;
226
- gpr_atm cancelled_with_error = 0;
408
+ bool sent_server_trailing_metadata_ = false;
409
+ gpr_atm cancelled_with_error_ = 0;
227
410
 
228
- grpc_closure release_call;
411
+ grpc_closure release_call_;
229
412
 
230
413
  union {
231
414
  struct {
@@ -236,10 +419,10 @@ struct grpc_call {
236
419
  struct {
237
420
  int* cancelled;
238
421
  // backpointer to owning server if this is a server side call.
239
- grpc_core::Server* core_server;
422
+ Server* core_server;
240
423
  } server;
241
- } final_op;
242
- AtomicError status_error;
424
+ } final_op_;
425
+ AtomicError status_error_;
243
426
 
244
427
  /* recv_state can contain one of the following values:
245
428
  RECV_NONE : : no initial metadata and messages received
@@ -257,220 +440,176 @@ struct grpc_call {
257
440
 
258
441
  For 1, 4: See receiving_initial_metadata_ready() function
259
442
  For 2, 3: See receiving_stream_ready() function */
260
- gpr_atm recv_state = 0;
443
+ gpr_atm recv_state_ = 0;
261
444
  };
262
445
 
263
- grpc_core::TraceFlag grpc_call_error_trace(false, "call_error");
264
- grpc_core::TraceFlag grpc_compression_trace(false, "compression");
265
-
266
- #define CALL_STACK_FROM_CALL(call) \
267
- (grpc_call_stack*)((char*)(call) + \
268
- GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)))
269
- #define CALL_FROM_CALL_STACK(call_stack) \
270
- (grpc_call*)(((char*)(call_stack)) - \
271
- GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)))
272
-
273
- #define CALL_ELEM_FROM_CALL(call, idx) \
274
- grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx)
275
- #define CALL_FROM_TOP_ELEM(top_elem) \
276
- CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem))
277
-
278
- static void execute_batch(grpc_call* call,
279
- grpc_transport_stream_op_batch* batch,
280
- grpc_closure* start_batch_closure);
281
-
282
- static void cancel_with_status(grpc_call* c, grpc_status_code status,
283
- const char* description);
284
- static void cancel_with_error(grpc_call* c, grpc_error_handle error);
285
- static void destroy_call(void* call_stack, grpc_error_handle error);
286
- static void receiving_slice_ready(void* bctlp, grpc_error_handle error);
287
- static void set_final_status(grpc_call* call, grpc_error_handle error);
288
- static void process_data_after_md(batch_control* bctl);
289
- static void post_batch_completion(batch_control* bctl);
290
-
291
- static void add_init_error(grpc_error_handle* composite,
292
- grpc_error_handle new_err) {
293
- if (new_err == GRPC_ERROR_NONE) return;
294
- if (*composite == GRPC_ERROR_NONE) {
295
- *composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Call creation failed");
446
+ Call::ParentCall* Call::GetOrCreateParentCall() {
447
+ ParentCall* p = parent_call_.load(std::memory_order_acquire);
448
+ if (p == nullptr) {
449
+ p = arena_->New<ParentCall>();
450
+ ParentCall* expected = nullptr;
451
+ if (!parent_call_.compare_exchange_strong(expected, p,
452
+ std::memory_order_release,
453
+ std::memory_order_relaxed)) {
454
+ p->~ParentCall();
455
+ p = expected;
456
+ }
296
457
  }
297
- *composite = grpc_error_add_child(*composite, new_err);
458
+ return p;
298
459
  }
299
460
 
300
- void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
301
- grpc_core::ExecCtx exec_ctx;
302
- return call->arena->Alloc(size);
461
+ Call::ParentCall* Call::parent_call() {
462
+ return parent_call_.load(std::memory_order_acquire);
303
463
  }
304
464
 
305
- static parent_call* get_or_create_parent_call(grpc_call* call) {
306
- parent_call* p =
307
- reinterpret_cast<parent_call*>(gpr_atm_acq_load(&call->parent_call_atm));
308
- if (p == nullptr) {
309
- p = call->arena->New<parent_call>();
310
- if (!gpr_atm_rel_cas(&call->parent_call_atm,
311
- reinterpret_cast<gpr_atm>(nullptr),
312
- reinterpret_cast<gpr_atm>(p))) {
313
- p->~parent_call();
314
- p = reinterpret_cast<parent_call*>(
315
- gpr_atm_acq_load(&call->parent_call_atm));
465
+ absl::Status Call::InitParent(Call* parent, uint32_t propagation_mask) {
466
+ child_ = arena()->New<ChildCall>(parent);
467
+
468
+ parent->InternalRef("child");
469
+ GPR_ASSERT(is_client_);
470
+ GPR_ASSERT(!parent->is_client_);
471
+
472
+ if (propagation_mask & GRPC_PROPAGATE_DEADLINE) {
473
+ send_deadline_ = std::min(send_deadline_, parent->send_deadline_);
474
+ }
475
+ /* for now GRPC_PROPAGATE_TRACING_CONTEXT *MUST* be passed with
476
+ * GRPC_PROPAGATE_STATS_CONTEXT */
477
+ /* TODO(ctiller): This should change to use the appropriate census start_op
478
+ * call. */
479
+ if (propagation_mask & GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT) {
480
+ if (0 == (propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT)) {
481
+ return absl::UnknownError(
482
+ "Census tracing propagation requested without Census context "
483
+ "propagation");
316
484
  }
485
+ ContextSet(GRPC_CONTEXT_TRACING, parent->ContextGet(GRPC_CONTEXT_TRACING),
486
+ nullptr);
487
+ } else if (propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT) {
488
+ return absl::UnknownError(
489
+ "Census context propagation requested without Census tracing "
490
+ "propagation");
317
491
  }
318
- return p;
319
- }
320
-
321
- static parent_call* get_parent_call(grpc_call* call) {
322
- return reinterpret_cast<parent_call*>(
323
- gpr_atm_acq_load(&call->parent_call_atm));
492
+ if (propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
493
+ cancellation_is_inherited_ = true;
494
+ }
495
+ return absl::OkStatus();
324
496
  }
325
497
 
326
- size_t grpc_call_get_initial_size_estimate() {
327
- return sizeof(grpc_call) + sizeof(batch_control) * MAX_CONCURRENT_BATCHES;
498
+ void Call::PublishToParent(Call* parent) {
499
+ ChildCall* cc = child_;
500
+ ParentCall* pc = parent->GetOrCreateParentCall();
501
+ MutexLock lock(&pc->child_list_mu);
502
+ if (pc->first_child == nullptr) {
503
+ pc->first_child = this;
504
+ cc->sibling_next = cc->sibling_prev = this;
505
+ } else {
506
+ cc->sibling_next = pc->first_child;
507
+ cc->sibling_prev = pc->first_child->child_->sibling_prev;
508
+ cc->sibling_next->child_->sibling_prev =
509
+ cc->sibling_prev->child_->sibling_next = this;
510
+ }
511
+ if (parent->Completed()) {
512
+ CancelWithError(GRPC_ERROR_CANCELLED);
513
+ }
328
514
  }
329
515
 
330
- grpc_error_handle grpc_call_create(grpc_call_create_args* args,
331
- grpc_call** out_call) {
516
+ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
517
+ grpc_call** out_call) {
332
518
  GPR_TIMER_SCOPE("grpc_call_create", 0);
333
519
 
334
- GRPC_CHANNEL_INTERNAL_REF(args->channel, "call");
520
+ Channel* channel = args->channel.get();
521
+
522
+ auto add_init_error = [](grpc_error_handle* composite,
523
+ grpc_error_handle new_err) {
524
+ if (new_err == GRPC_ERROR_NONE) return;
525
+ if (*composite == GRPC_ERROR_NONE) {
526
+ *composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Call creation failed");
527
+ }
528
+ *composite = grpc_error_add_child(*composite, new_err);
529
+ };
335
530
 
336
- grpc_core::Arena* arena;
337
- grpc_call* call;
531
+ Arena* arena;
532
+ FilterStackCall* call;
338
533
  grpc_error_handle error = GRPC_ERROR_NONE;
339
- grpc_channel_stack* channel_stack =
340
- grpc_channel_get_channel_stack(args->channel);
341
- size_t initial_size = grpc_channel_get_call_size_estimate(args->channel);
534
+ grpc_channel_stack* channel_stack = channel->channel_stack();
535
+ size_t initial_size = channel->CallSizeEstimate();
342
536
  GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
343
- size_t call_and_stack_size =
344
- GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)) +
345
- channel_stack->call_stack_size;
346
537
  size_t call_alloc_size =
347
- call_and_stack_size + (args->parent ? sizeof(child_call) : 0);
538
+ GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(FilterStackCall)) +
539
+ channel_stack->call_stack_size;
348
540
 
349
- std::pair<grpc_core::Arena*, void*> arena_with_call =
350
- grpc_core::Arena::CreateWithAlloc(initial_size, call_alloc_size,
351
- &*args->channel->allocator);
541
+ std::pair<Arena*, void*> arena_with_call = Arena::CreateWithAlloc(
542
+ initial_size, call_alloc_size, channel->allocator());
352
543
  arena = arena_with_call.first;
353
- call = new (arena_with_call.second) grpc_call(arena, *args);
354
- *out_call = call;
544
+ call = new (arena_with_call.second) FilterStackCall(arena, *args);
545
+ GPR_DEBUG_ASSERT(FromC(call->c_ptr()) == call);
546
+ GPR_DEBUG_ASSERT(FromCallStack(call->call_stack()) == call);
547
+ *out_call = call->c_ptr();
355
548
  grpc_slice path = grpc_empty_slice();
356
- if (call->is_client) {
357
- call->final_op.client.status_details = nullptr;
358
- call->final_op.client.status = nullptr;
359
- call->final_op.client.error_string = nullptr;
549
+ if (call->is_client()) {
550
+ call->final_op_.client.status_details = nullptr;
551
+ call->final_op_.client.status = nullptr;
552
+ call->final_op_.client.error_string = nullptr;
360
553
  GRPC_STATS_INC_CLIENT_CALLS_CREATED();
361
554
  path = grpc_slice_ref_internal(args->path->c_slice());
362
- call->send_initial_metadata.Set(grpc_core::HttpPathMetadata(),
363
- std::move(*args->path));
555
+ call->send_initial_metadata_.Set(HttpPathMetadata(),
556
+ std::move(*args->path));
364
557
  if (args->authority.has_value()) {
365
- call->send_initial_metadata.Set(grpc_core::HttpAuthorityMetadata(),
366
- std::move(*args->authority));
558
+ call->send_initial_metadata_.Set(HttpAuthorityMetadata(),
559
+ std::move(*args->authority));
367
560
  }
368
561
  } else {
369
562
  GRPC_STATS_INC_SERVER_CALLS_CREATED();
370
- call->final_op.server.cancelled = nullptr;
371
- call->final_op.server.core_server = args->server;
563
+ call->final_op_.server.cancelled = nullptr;
564
+ call->final_op_.server.core_server = args->server;
372
565
  }
373
566
 
374
- grpc_core::Timestamp send_deadline = args->send_deadline;
375
- bool immediately_cancel = false;
376
-
377
- if (args->parent != nullptr) {
378
- call->child = new (reinterpret_cast<char*>(arena_with_call.second) +
379
- call_and_stack_size) child_call(args->parent);
380
-
381
- GRPC_CALL_INTERNAL_REF(args->parent, "child");
382
- GPR_ASSERT(call->is_client);
383
- GPR_ASSERT(!args->parent->is_client);
384
-
385
- if (args->propagation_mask & GRPC_PROPAGATE_DEADLINE) {
386
- send_deadline = std::min(send_deadline, args->parent->send_deadline);
387
- }
388
- /* for now GRPC_PROPAGATE_TRACING_CONTEXT *MUST* be passed with
389
- * GRPC_PROPAGATE_STATS_CONTEXT */
390
- /* TODO(ctiller): This should change to use the appropriate census start_op
391
- * call. */
392
- if (args->propagation_mask & GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT) {
393
- if (0 == (args->propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT)) {
394
- add_init_error(&error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
395
- "Census tracing propagation requested "
396
- "without Census context propagation"));
397
- }
398
- grpc_call_context_set(call, GRPC_CONTEXT_TRACING,
399
- args->parent->context[GRPC_CONTEXT_TRACING].value,
400
- nullptr);
401
- } else if (args->propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT) {
402
- add_init_error(&error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
403
- "Census context propagation requested "
404
- "without Census tracing propagation"));
405
- }
406
- if (args->propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
407
- call->cancellation_is_inherited = true;
408
- if (gpr_atm_acq_load(&args->parent->received_final_op_atm)) {
409
- immediately_cancel = true;
410
- }
411
- }
567
+ Call* parent = Call::FromC(args->parent);
568
+ if (parent != nullptr) {
569
+ add_init_error(&error, absl_status_to_grpc_error(call->InitParent(
570
+ parent, args->propagation_mask)));
412
571
  }
413
- call->send_deadline = send_deadline;
414
572
  /* initial refcount dropped by grpc_call_unref */
415
- grpc_call_element_args call_args = {CALL_STACK_FROM_CALL(call),
416
- args->server_transport_data,
417
- call->context,
418
- path,
419
- call->start_time,
420
- send_deadline,
421
- call->arena,
422
- &call->call_combiner};
423
- add_init_error(&error, grpc_call_stack_init(channel_stack, 1, destroy_call,
573
+ grpc_call_element_args call_args = {
574
+ call->call_stack(), args->server_transport_data,
575
+ call->context_, path,
576
+ call->start_time_, call->send_deadline(),
577
+ call->arena(), &call->call_combiner_};
578
+ add_init_error(&error, grpc_call_stack_init(channel_stack, 1, DestroyCall,
424
579
  call, &call_args));
425
580
  // Publish this call to parent only after the call stack has been initialized.
426
- if (args->parent != nullptr) {
427
- child_call* cc = call->child;
428
- parent_call* pc = get_or_create_parent_call(args->parent);
429
- gpr_mu_lock(&pc->child_list_mu);
430
- if (pc->first_child == nullptr) {
431
- pc->first_child = call;
432
- cc->sibling_next = cc->sibling_prev = call;
433
- } else {
434
- cc->sibling_next = pc->first_child;
435
- cc->sibling_prev = pc->first_child->child->sibling_prev;
436
- cc->sibling_next->child->sibling_prev =
437
- cc->sibling_prev->child->sibling_next = call;
438
- }
439
- gpr_mu_unlock(&pc->child_list_mu);
581
+ if (parent != nullptr) {
582
+ call->PublishToParent(parent);
440
583
  }
441
584
 
442
585
  if (error != GRPC_ERROR_NONE) {
443
- cancel_with_error(call, GRPC_ERROR_REF(error));
444
- }
445
- if (immediately_cancel) {
446
- cancel_with_error(call, GRPC_ERROR_CANCELLED);
586
+ call->CancelWithError(GRPC_ERROR_REF(error));
447
587
  }
448
588
  if (args->cq != nullptr) {
449
589
  GPR_ASSERT(args->pollset_set_alternative == nullptr &&
450
590
  "Only one of 'cq' and 'pollset_set_alternative' should be "
451
591
  "non-nullptr.");
452
592
  GRPC_CQ_INTERNAL_REF(args->cq, "bind");
453
- call->pollent =
593
+ call->pollent_ =
454
594
  grpc_polling_entity_create_from_pollset(grpc_cq_pollset(args->cq));
455
595
  }
456
596
  if (args->pollset_set_alternative != nullptr) {
457
- call->pollent = grpc_polling_entity_create_from_pollset_set(
597
+ call->pollent_ = grpc_polling_entity_create_from_pollset_set(
458
598
  args->pollset_set_alternative);
459
599
  }
460
- if (!grpc_polling_entity_is_empty(&call->pollent)) {
461
- grpc_call_stack_set_pollset_or_pollset_set(CALL_STACK_FROM_CALL(call),
462
- &call->pollent);
600
+ if (!grpc_polling_entity_is_empty(&call->pollent_)) {
601
+ grpc_call_stack_set_pollset_or_pollset_set(call->call_stack(),
602
+ &call->pollent_);
463
603
  }
464
604
 
465
- if (call->is_client) {
466
- grpc_core::channelz::ChannelNode* channelz_channel =
467
- grpc_channel_get_channelz_node(call->channel);
605
+ if (call->is_client()) {
606
+ channelz::ChannelNode* channelz_channel = channel->channelz_node();
468
607
  if (channelz_channel != nullptr) {
469
608
  channelz_channel->RecordCallStarted();
470
609
  }
471
- } else if (call->final_op.server.core_server != nullptr) {
472
- grpc_core::channelz::ServerNode* channelz_node =
473
- call->final_op.server.core_server->channelz_node();
610
+ } else if (call->final_op_.server.core_server != nullptr) {
611
+ channelz::ServerNode* channelz_node =
612
+ call->final_op_.server.core_server->channelz_node();
474
613
  if (channelz_node != nullptr) {
475
614
  channelz_node->RecordCallStarted();
476
615
  }
@@ -481,266 +620,209 @@ grpc_error_handle grpc_call_create(grpc_call_create_args* args,
481
620
  return error;
482
621
  }
483
622
 
484
- void grpc_call_set_completion_queue(grpc_call* call,
485
- grpc_completion_queue* cq) {
623
+ void FilterStackCall::SetCompletionQueue(grpc_completion_queue* cq) {
486
624
  GPR_ASSERT(cq);
487
625
 
488
- if (grpc_polling_entity_pollset_set(&call->pollent) != nullptr) {
626
+ if (grpc_polling_entity_pollset_set(&pollent_) != nullptr) {
489
627
  gpr_log(GPR_ERROR, "A pollset_set is already registered for this call.");
490
628
  abort();
491
629
  }
492
- call->cq = cq;
630
+ cq_ = cq;
493
631
  GRPC_CQ_INTERNAL_REF(cq, "bind");
494
- call->pollent = grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq));
495
- grpc_call_stack_set_pollset_or_pollset_set(CALL_STACK_FROM_CALL(call),
496
- &call->pollent);
497
- }
498
-
499
- #ifndef NDEBUG
500
- #define REF_REASON reason
501
- #define REF_ARG , const char* reason
502
- #else
503
- #define REF_REASON ""
504
- #define REF_ARG
505
- #endif
506
- void grpc_call_internal_ref(grpc_call* c REF_ARG) {
507
- GRPC_CALL_STACK_REF(CALL_STACK_FROM_CALL(c), REF_REASON);
508
- }
509
- void grpc_call_internal_unref(grpc_call* c REF_ARG) {
510
- GRPC_CALL_STACK_UNREF(CALL_STACK_FROM_CALL(c), REF_REASON);
632
+ pollent_ = grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq));
633
+ grpc_call_stack_set_pollset_or_pollset_set(call_stack(), &pollent_);
511
634
  }
512
635
 
513
- static void release_call(void* call, grpc_error_handle /*error*/) {
514
- grpc_call* c = static_cast<grpc_call*>(call);
515
- grpc_channel* channel = c->channel;
516
- grpc_core::Arena* arena = c->arena;
517
- c->~grpc_call();
518
- grpc_channel_update_call_size_estimate(channel, arena->Destroy());
519
- GRPC_CHANNEL_INTERNAL_UNREF(channel, "call");
636
+ void FilterStackCall::ReleaseCall(void* call, grpc_error_handle /*error*/) {
637
+ auto* c = static_cast<FilterStackCall*>(call);
638
+ RefCountedPtr<Channel> channel = std::move(c->channel_);
639
+ Arena* arena = c->arena();
640
+ c->~FilterStackCall();
641
+ channel->UpdateCallSizeEstimate(arena->Destroy());
520
642
  }
521
643
 
522
- static void destroy_call(void* call, grpc_error_handle /*error*/) {
644
+ void FilterStackCall::DestroyCall(void* call, grpc_error_handle /*error*/) {
523
645
  GPR_TIMER_SCOPE("destroy_call", 0);
524
- grpc_call* c = static_cast<grpc_call*>(call);
525
- c->recv_initial_metadata.Clear();
526
- c->recv_trailing_metadata.Clear();
527
- c->receiving_stream.reset();
528
- parent_call* pc = get_parent_call(c);
646
+ auto* c = static_cast<FilterStackCall*>(call);
647
+ c->recv_initial_metadata_.Clear();
648
+ c->recv_trailing_metadata_.Clear();
649
+ c->receiving_stream_.reset();
650
+ ParentCall* pc = c->parent_call();
529
651
  if (pc != nullptr) {
530
- pc->~parent_call();
652
+ pc->~ParentCall();
531
653
  }
532
- if (c->cq) {
533
- GRPC_CQ_INTERNAL_UNREF(c->cq, "bind");
654
+ if (c->cq_) {
655
+ GRPC_CQ_INTERNAL_UNREF(c->cq_, "bind");
534
656
  }
535
657
 
536
- grpc_error_handle status_error = c->status_error.get();
537
- grpc_error_get_status(status_error, c->send_deadline,
538
- &c->final_info.final_status, nullptr, nullptr,
539
- &(c->final_info.error_string));
540
- c->status_error.set(GRPC_ERROR_NONE);
541
- c->final_info.stats.latency =
542
- gpr_cycle_counter_sub(gpr_get_cycle_counter(), c->start_time);
543
- grpc_call_stack_destroy(CALL_STACK_FROM_CALL(c), &c->final_info,
544
- GRPC_CLOSURE_INIT(&c->release_call, release_call, c,
658
+ grpc_error_handle status_error = c->status_error_.get();
659
+ grpc_error_get_status(status_error, c->send_deadline(),
660
+ &c->final_info_.final_status, nullptr, nullptr,
661
+ &(c->final_info_.error_string));
662
+ c->status_error_.set(GRPC_ERROR_NONE);
663
+ c->final_info_.stats.latency =
664
+ gpr_cycle_counter_sub(gpr_get_cycle_counter(), c->start_time_);
665
+ grpc_call_stack_destroy(c->call_stack(), &c->final_info_,
666
+ GRPC_CLOSURE_INIT(&c->release_call_, ReleaseCall, c,
545
667
  grpc_schedule_on_exec_ctx));
546
668
  }
547
669
 
548
- void grpc_call_ref(grpc_call* c) { c->ext_ref.Ref(); }
549
-
550
- void grpc_call_unref(grpc_call* c) {
551
- if (GPR_LIKELY(!c->ext_ref.Unref())) return;
552
-
553
- GPR_TIMER_SCOPE("grpc_call_unref", 0);
670
+ void Call::MaybeUnpublishFromParent() {
671
+ ChildCall* cc = child_;
672
+ if (cc == nullptr) return;
554
673
 
555
- child_call* cc = c->child;
556
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
557
- grpc_core::ExecCtx exec_ctx;
558
-
559
- GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (c));
560
-
561
- if (cc) {
562
- parent_call* pc = get_parent_call(cc->parent);
563
- gpr_mu_lock(&pc->child_list_mu);
564
- if (c == pc->first_child) {
674
+ ParentCall* pc = cc->parent->parent_call();
675
+ {
676
+ MutexLock lock(&pc->child_list_mu);
677
+ if (this == pc->first_child) {
565
678
  pc->first_child = cc->sibling_next;
566
- if (c == pc->first_child) {
679
+ if (this == pc->first_child) {
567
680
  pc->first_child = nullptr;
568
681
  }
569
682
  }
570
- cc->sibling_prev->child->sibling_next = cc->sibling_next;
571
- cc->sibling_next->child->sibling_prev = cc->sibling_prev;
572
- gpr_mu_unlock(&pc->child_list_mu);
573
- GRPC_CALL_INTERNAL_UNREF(cc->parent, "child");
683
+ cc->sibling_prev->child_->sibling_next = cc->sibling_next;
684
+ cc->sibling_next->child_->sibling_prev = cc->sibling_prev;
574
685
  }
686
+ cc->parent->InternalUnref("child");
687
+ }
688
+
689
+ void FilterStackCall::ExternalUnref() {
690
+ if (GPR_LIKELY(!ext_ref_.Unref())) return;
691
+
692
+ GPR_TIMER_SCOPE("grpc_call_unref", 0);
693
+
694
+ ApplicationCallbackExecCtx callback_exec_ctx;
695
+ ExecCtx exec_ctx;
696
+
697
+ GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (this));
575
698
 
576
- GPR_ASSERT(!c->destroy_called);
577
- c->destroy_called = true;
578
- bool cancel = gpr_atm_acq_load(&c->any_ops_sent_atm) != 0 &&
579
- gpr_atm_acq_load(&c->received_final_op_atm) == 0;
699
+ MaybeUnpublishFromParent();
700
+
701
+ GPR_ASSERT(!destroy_called_);
702
+ destroy_called_ = true;
703
+ bool cancel = gpr_atm_acq_load(&any_ops_sent_atm_) != 0 &&
704
+ gpr_atm_acq_load(&received_final_op_atm_) == 0;
580
705
  if (cancel) {
581
- cancel_with_error(c, GRPC_ERROR_CANCELLED);
706
+ CancelWithError(GRPC_ERROR_CANCELLED);
582
707
  } else {
583
708
  // Unset the call combiner cancellation closure. This has the
584
709
  // effect of scheduling the previously set cancellation closure, if
585
710
  // any, so that it can release any internal references it may be
586
711
  // holding to the call stack.
587
- c->call_combiner.SetNotifyOnCancel(nullptr);
712
+ call_combiner_.SetNotifyOnCancel(nullptr);
588
713
  }
589
- GRPC_CALL_INTERNAL_UNREF(c, "destroy");
590
- }
591
-
592
- grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
593
- GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
594
- GPR_ASSERT(!reserved);
595
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
596
- grpc_core::ExecCtx exec_ctx;
597
- cancel_with_error(call, GRPC_ERROR_CANCELLED);
598
- return GRPC_CALL_OK;
714
+ InternalUnref("destroy");
599
715
  }
600
716
 
601
- // This is called via the call combiner to start sending a batch down
602
- // the filter stack.
603
- static void execute_batch_in_call_combiner(void* arg,
604
- grpc_error_handle /*ignored*/) {
605
- GPR_TIMER_SCOPE("execute_batch_in_call_combiner", 0);
606
- grpc_transport_stream_op_batch* batch =
607
- static_cast<grpc_transport_stream_op_batch*>(arg);
608
- grpc_call* call = static_cast<grpc_call*>(batch->handler_private.extra_arg);
609
- grpc_call_element* elem = CALL_ELEM_FROM_CALL(call, 0);
610
- GRPC_CALL_LOG_OP(GPR_INFO, elem, batch);
611
- elem->filter->start_transport_stream_op_batch(elem, batch);
717
+ char* FilterStackCall::GetPeer() {
718
+ char* peer_string = reinterpret_cast<char*>(gpr_atm_acq_load(&peer_string_));
719
+ if (peer_string != nullptr) return gpr_strdup(peer_string);
720
+ peer_string = grpc_channel_get_target(channel_->c_ptr());
721
+ if (peer_string != nullptr) return peer_string;
722
+ return gpr_strdup("unknown");
612
723
  }
613
724
 
614
725
  // start_batch_closure points to a caller-allocated closure to be used
615
726
  // for entering the call combiner.
616
- static void execute_batch(grpc_call* call,
617
- grpc_transport_stream_op_batch* batch,
618
- grpc_closure* start_batch_closure) {
619
- batch->handler_private.extra_arg = call;
727
+ void FilterStackCall::ExecuteBatch(grpc_transport_stream_op_batch* batch,
728
+ grpc_closure* start_batch_closure) {
729
+ // This is called via the call combiner to start sending a batch down
730
+ // the filter stack.
731
+ auto execute_batch_in_call_combiner = [](void* arg, grpc_error_handle) {
732
+ GPR_TIMER_SCOPE("execute_batch_in_call_combiner", 0);
733
+ grpc_transport_stream_op_batch* batch =
734
+ static_cast<grpc_transport_stream_op_batch*>(arg);
735
+ auto* call =
736
+ static_cast<FilterStackCall*>(batch->handler_private.extra_arg);
737
+ grpc_call_element* elem = call->call_elem(0);
738
+ GRPC_CALL_LOG_OP(GPR_INFO, elem, batch);
739
+ elem->filter->start_transport_stream_op_batch(elem, batch);
740
+ };
741
+ batch->handler_private.extra_arg = this;
620
742
  GRPC_CLOSURE_INIT(start_batch_closure, execute_batch_in_call_combiner, batch,
621
743
  grpc_schedule_on_exec_ctx);
622
- GRPC_CALL_COMBINER_START(&call->call_combiner, start_batch_closure,
744
+ GRPC_CALL_COMBINER_START(call_combiner(), start_batch_closure,
623
745
  GRPC_ERROR_NONE, "executing batch");
624
746
  }
625
747
 
626
- char* grpc_call_get_peer(grpc_call* call) {
627
- char* peer_string =
628
- reinterpret_cast<char*>(gpr_atm_acq_load(&call->peer_string));
629
- if (peer_string != nullptr) return gpr_strdup(peer_string);
630
- peer_string = grpc_channel_get_target(call->channel);
631
- if (peer_string != nullptr) return peer_string;
632
- return gpr_strdup("unknown");
633
- }
634
-
635
- grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element) {
636
- return CALL_FROM_TOP_ELEM(surface_element);
637
- }
638
-
639
- /*******************************************************************************
640
- * CANCELLATION
641
- */
642
-
643
- grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
644
- grpc_status_code status,
645
- const char* description,
646
- void* reserved) {
647
- grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
648
- grpc_core::ExecCtx exec_ctx;
649
- GRPC_API_TRACE(
650
- "grpc_call_cancel_with_status("
651
- "c=%p, status=%d, description=%s, reserved=%p)",
652
- 4, (c, (int)status, description, reserved));
653
- GPR_ASSERT(reserved == nullptr);
654
- cancel_with_status(c, status, description);
655
- return GRPC_CALL_OK;
656
- }
657
-
658
- struct cancel_state {
659
- grpc_call* call;
748
+ namespace {
749
+ struct CancelState {
750
+ FilterStackCall* call;
660
751
  grpc_closure start_batch;
661
752
  grpc_closure finish_batch;
662
753
  };
754
+ } // namespace
755
+
663
756
  // The on_complete callback used when sending a cancel_stream batch down
664
757
  // the filter stack. Yields the call combiner when the batch is done.
665
758
  static void done_termination(void* arg, grpc_error_handle /*error*/) {
666
- cancel_state* state = static_cast<cancel_state*>(arg);
667
- GRPC_CALL_COMBINER_STOP(&state->call->call_combiner,
759
+ CancelState* state = static_cast<CancelState*>(arg);
760
+ GRPC_CALL_COMBINER_STOP(state->call->call_combiner(),
668
761
  "on_complete for cancel_stream op");
669
- GRPC_CALL_INTERNAL_UNREF(state->call, "termination");
670
- gpr_free(state);
762
+ state->call->InternalUnref("termination");
763
+ delete state;
671
764
  }
672
765
 
673
- static void cancel_with_error(grpc_call* c, grpc_error_handle error) {
674
- if (!gpr_atm_rel_cas(&c->cancelled_with_error, 0, 1)) {
766
+ void FilterStackCall::CancelWithError(grpc_error_handle error) {
767
+ if (!gpr_atm_rel_cas(&cancelled_with_error_, 0, 1)) {
675
768
  GRPC_ERROR_UNREF(error);
676
769
  return;
677
770
  }
678
- GRPC_CALL_INTERNAL_REF(c, "termination");
771
+ InternalRef("termination");
679
772
  // Inform the call combiner of the cancellation, so that it can cancel
680
773
  // any in-flight asynchronous actions that may be holding the call
681
774
  // combiner. This ensures that the cancel_stream batch can be sent
682
775
  // down the filter stack in a timely manner.
683
- c->call_combiner.Cancel(GRPC_ERROR_REF(error));
684
- cancel_state* state = static_cast<cancel_state*>(gpr_malloc(sizeof(*state)));
685
- state->call = c;
776
+ call_combiner_.Cancel(GRPC_ERROR_REF(error));
777
+ CancelState* state = new CancelState;
778
+ state->call = this;
686
779
  GRPC_CLOSURE_INIT(&state->finish_batch, done_termination, state,
687
780
  grpc_schedule_on_exec_ctx);
688
781
  grpc_transport_stream_op_batch* op =
689
782
  grpc_make_transport_stream_op(&state->finish_batch);
690
783
  op->cancel_stream = true;
691
784
  op->payload->cancel_stream.cancel_error = error;
692
- execute_batch(c, op, &state->start_batch);
785
+ ExecuteBatch(op, &state->start_batch);
693
786
  }
694
787
 
695
- void grpc_call_cancel_internal(grpc_call* call) {
696
- cancel_with_error(call, GRPC_ERROR_CANCELLED);
697
- }
698
-
699
- static grpc_error_handle error_from_status(grpc_status_code status,
700
- const char* description) {
788
+ void Call::CancelWithStatus(grpc_status_code status, const char* description) {
701
789
  // copying 'description' is needed to ensure the grpc_call_cancel_with_status
702
790
  // guarantee that can be short-lived.
703
- return grpc_error_set_int(
791
+ CancelWithError(grpc_error_set_int(
704
792
  grpc_error_set_str(GRPC_ERROR_CREATE_FROM_COPIED_STRING(description),
705
793
  GRPC_ERROR_STR_GRPC_MESSAGE, description),
706
- GRPC_ERROR_INT_GRPC_STATUS, status);
707
- }
708
-
709
- static void cancel_with_status(grpc_call* c, grpc_status_code status,
710
- const char* description) {
711
- cancel_with_error(c, error_from_status(status, description));
794
+ GRPC_ERROR_INT_GRPC_STATUS, status));
712
795
  }
713
796
 
714
- static void set_final_status(grpc_call* call, grpc_error_handle error) {
797
+ void FilterStackCall::SetFinalStatus(grpc_error_handle error) {
715
798
  if (GRPC_TRACE_FLAG_ENABLED(grpc_call_error_trace)) {
716
- gpr_log(GPR_DEBUG, "set_final_status %s", call->is_client ? "CLI" : "SVR");
799
+ gpr_log(GPR_DEBUG, "set_final_status %s", is_client() ? "CLI" : "SVR");
717
800
  gpr_log(GPR_DEBUG, "%s", grpc_error_std_string(error).c_str());
718
801
  }
719
- if (call->is_client) {
802
+ if (is_client()) {
720
803
  std::string status_details;
721
- grpc_error_get_status(error, call->send_deadline,
722
- call->final_op.client.status, &status_details,
723
- nullptr, call->final_op.client.error_string);
724
- *call->final_op.client.status_details =
804
+ grpc_error_get_status(error, send_deadline(), final_op_.client.status,
805
+ &status_details, nullptr,
806
+ final_op_.client.error_string);
807
+ *final_op_.client.status_details =
725
808
  grpc_slice_from_cpp_string(std::move(status_details));
726
- call->status_error.set(error);
809
+ status_error_.set(error);
727
810
  GRPC_ERROR_UNREF(error);
728
- grpc_core::channelz::ChannelNode* channelz_channel =
729
- grpc_channel_get_channelz_node(call->channel);
811
+ channelz::ChannelNode* channelz_channel = channel_->channelz_node();
730
812
  if (channelz_channel != nullptr) {
731
- if (*call->final_op.client.status != GRPC_STATUS_OK) {
813
+ if (*final_op_.client.status != GRPC_STATUS_OK) {
732
814
  channelz_channel->RecordCallFailed();
733
815
  } else {
734
816
  channelz_channel->RecordCallSucceeded();
735
817
  }
736
818
  }
737
819
  } else {
738
- *call->final_op.server.cancelled =
739
- error != GRPC_ERROR_NONE || !call->sent_server_trailing_metadata;
740
- grpc_core::channelz::ServerNode* channelz_node =
741
- call->final_op.server.core_server->channelz_node();
820
+ *final_op_.server.cancelled =
821
+ error != GRPC_ERROR_NONE || !sent_server_trailing_metadata_;
822
+ channelz::ServerNode* channelz_node =
823
+ final_op_.server.core_server->channelz_node();
742
824
  if (channelz_node != nullptr) {
743
- if (*call->final_op.server.cancelled || !call->status_error.ok()) {
825
+ if (*final_op_.server.cancelled || !status_error_.ok()) {
744
826
  channelz_node->RecordCallFailed();
745
827
  } else {
746
828
  channelz_node->RecordCallSucceeded();
@@ -750,58 +832,40 @@ static void set_final_status(grpc_call* call, grpc_error_handle error) {
750
832
  }
751
833
  }
752
834
 
753
- /*******************************************************************************
754
- * COMPRESSION
755
- */
756
-
757
- grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
758
- grpc_call* call) {
759
- return call->incoming_compression_algorithm;
760
- }
761
-
762
- uint32_t grpc_call_test_only_get_message_flags(grpc_call* call) {
763
- uint32_t flags;
764
- flags = call->test_only_last_message_flags;
765
- return flags;
766
- }
767
-
768
- uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call) {
769
- return call->encodings_accepted_by_peer.ToLegacyBitmask();
770
- }
771
-
772
- static int prepare_application_metadata(grpc_call* call, int count,
773
- grpc_metadata* metadata,
774
- int is_trailing) {
775
- int i;
776
- grpc_metadata_batch* batch = is_trailing ? &call->send_trailing_metadata
777
- : &call->send_initial_metadata;
778
- for (i = 0; i < count; i++) {
835
+ bool FilterStackCall::PrepareApplicationMetadata(size_t count,
836
+ grpc_metadata* metadata,
837
+ bool is_trailing) {
838
+ grpc_metadata_batch* batch =
839
+ is_trailing ? &send_trailing_metadata_ : &send_initial_metadata_;
840
+ for (size_t i = 0; i < count; i++) {
779
841
  grpc_metadata* md = &metadata[i];
780
842
  if (!GRPC_LOG_IF_ERROR("validate_metadata",
781
843
  grpc_validate_header_key_is_legal(md->key))) {
782
- return 0;
844
+ return false;
783
845
  } else if (!grpc_is_binary_header_internal(md->key) &&
784
846
  !GRPC_LOG_IF_ERROR(
785
847
  "validate_metadata",
786
848
  grpc_validate_header_nonbin_value_is_legal(md->value))) {
787
- return 0;
849
+ return false;
788
850
  } else if (GRPC_SLICE_LENGTH(md->value) >= UINT32_MAX) {
789
851
  // HTTP2 hpack encoding has a maximum limit.
790
- return 0;
852
+ return false;
853
+ } else if (grpc_slice_str_cmp(md->key, "content-length") == 0) {
854
+ // Filter "content-length metadata"
855
+ continue;
791
856
  }
792
- batch->Append(
793
- grpc_core::StringViewFromSlice(md->key),
794
- grpc_core::Slice(grpc_slice_ref_internal(md->value)),
795
- [md](absl::string_view error, const grpc_core::Slice& value) {
796
- gpr_log(
797
- GPR_DEBUG, "Append error: %s",
798
- absl::StrCat("key=", grpc_core::StringViewFromSlice(md->key),
799
- " error=", error, " value=", value.as_string_view())
800
- .c_str());
801
- });
802
- }
803
-
804
- return 1;
857
+ batch->Append(StringViewFromSlice(md->key),
858
+ Slice(grpc_slice_ref_internal(md->value)),
859
+ [md](absl::string_view error, const Slice& value) {
860
+ gpr_log(GPR_DEBUG, "Append error: %s",
861
+ absl::StrCat("key=", StringViewFromSlice(md->key),
862
+ " error=", error,
863
+ " value=", value.as_string_view())
864
+ .c_str());
865
+ });
866
+ }
867
+
868
+ return true;
805
869
  }
806
870
 
807
871
  namespace {
@@ -809,7 +873,7 @@ class PublishToAppEncoder {
809
873
  public:
810
874
  explicit PublishToAppEncoder(grpc_metadata_array* dest) : dest_(dest) {}
811
875
 
812
- void Encode(const grpc_core::Slice& key, const grpc_core::Slice& value) {
876
+ void Encode(const Slice& key, const Slice& value) {
813
877
  Append(key.c_slice(), value.c_slice());
814
878
  }
815
879
 
@@ -819,36 +883,34 @@ class PublishToAppEncoder {
819
883
  template <typename Which>
820
884
  void Encode(Which, const typename Which::ValueType&) {}
821
885
 
822
- void Encode(grpc_core::UserAgentMetadata, const grpc_core::Slice& slice) {
823
- Append(grpc_core::UserAgentMetadata::key(), slice);
886
+ void Encode(UserAgentMetadata, const Slice& slice) {
887
+ Append(UserAgentMetadata::key(), slice);
824
888
  }
825
889
 
826
- void Encode(grpc_core::HostMetadata, const grpc_core::Slice& slice) {
827
- Append(grpc_core::HostMetadata::key(), slice);
890
+ void Encode(HostMetadata, const Slice& slice) {
891
+ Append(HostMetadata::key(), slice);
828
892
  }
829
893
 
830
- void Encode(grpc_core::GrpcPreviousRpcAttemptsMetadata, uint32_t count) {
831
- Append(grpc_core::GrpcPreviousRpcAttemptsMetadata::key(), count);
894
+ void Encode(GrpcPreviousRpcAttemptsMetadata, uint32_t count) {
895
+ Append(GrpcPreviousRpcAttemptsMetadata::key(), count);
832
896
  }
833
897
 
834
- void Encode(grpc_core::GrpcRetryPushbackMsMetadata,
835
- grpc_core::Duration count) {
836
- Append(grpc_core::GrpcRetryPushbackMsMetadata::key(), count.millis());
898
+ void Encode(GrpcRetryPushbackMsMetadata, Duration count) {
899
+ Append(GrpcRetryPushbackMsMetadata::key(), count.millis());
837
900
  }
838
901
 
839
- void Encode(grpc_core::LbTokenMetadata, const grpc_core::Slice& slice) {
840
- Append(grpc_core::LbTokenMetadata::key(), slice);
902
+ void Encode(LbTokenMetadata, const Slice& slice) {
903
+ Append(LbTokenMetadata::key(), slice);
841
904
  }
842
905
 
843
906
  private:
844
907
  void Append(absl::string_view key, int64_t value) {
845
- Append(grpc_core::StaticSlice::FromStaticString(key).c_slice(),
846
- grpc_core::Slice::FromInt64(value).c_slice());
908
+ Append(StaticSlice::FromStaticString(key).c_slice(),
909
+ Slice::FromInt64(value).c_slice());
847
910
  }
848
911
 
849
- void Append(absl::string_view key, const grpc_core::Slice& value) {
850
- Append(grpc_core::StaticSlice::FromStaticString(key).c_slice(),
851
- value.c_slice());
912
+ void Append(absl::string_view key, const Slice& value) {
913
+ Append(StaticSlice::FromStaticString(key).c_slice(), value.c_slice());
852
914
  }
853
915
 
854
916
  void Append(grpc_slice key, grpc_slice value) {
@@ -861,14 +923,14 @@ class PublishToAppEncoder {
861
923
  };
862
924
  } // namespace
863
925
 
864
- static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
865
- int is_trailing) {
926
+ void FilterStackCall::PublishAppMetadata(grpc_metadata_batch* b,
927
+ bool is_trailing) {
866
928
  if (b->count() == 0) return;
867
- if (!call->is_client && is_trailing) return;
868
- if (is_trailing && call->buffered_metadata[1] == nullptr) return;
929
+ if (!is_client() && is_trailing) return;
930
+ if (is_trailing && buffered_metadata_[1] == nullptr) return;
869
931
  GPR_TIMER_SCOPE("publish_app_metadata", 0);
870
932
  grpc_metadata_array* dest;
871
- dest = call->buffered_metadata[is_trailing];
933
+ dest = buffered_metadata_[is_trailing];
872
934
  if (dest->count + b->count() > dest->capacity) {
873
935
  dest->capacity =
874
936
  std::max(dest->capacity + b->count(), dest->capacity * 3 / 2);
@@ -879,68 +941,57 @@ static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
879
941
  b->Encode(&encoder);
880
942
  }
881
943
 
882
- static void recv_initial_filter(grpc_call* call, grpc_metadata_batch* b) {
883
- call->incoming_compression_algorithm =
884
- b->Take(grpc_core::GrpcEncodingMetadata()).value_or(GRPC_COMPRESS_NONE);
885
- call->encodings_accepted_by_peer =
886
- b->Take(grpc_core::GrpcAcceptEncodingMetadata())
887
- .value_or(grpc_core::CompressionAlgorithmSet{GRPC_COMPRESS_NONE});
888
- publish_app_metadata(call, b, false);
944
+ void FilterStackCall::RecvInitialFilter(grpc_metadata_batch* b) {
945
+ incoming_compression_algorithm_ =
946
+ b->Take(GrpcEncodingMetadata()).value_or(GRPC_COMPRESS_NONE);
947
+ encodings_accepted_by_peer_ =
948
+ b->Take(GrpcAcceptEncodingMetadata())
949
+ .value_or(CompressionAlgorithmSet{GRPC_COMPRESS_NONE});
950
+ PublishAppMetadata(b, false);
889
951
  }
890
952
 
891
- static void recv_trailing_filter(void* args, grpc_metadata_batch* b,
892
- grpc_error_handle batch_error) {
893
- grpc_call* call = static_cast<grpc_call*>(args);
953
+ void FilterStackCall::RecvTrailingFilter(grpc_metadata_batch* b,
954
+ grpc_error_handle batch_error) {
894
955
  if (batch_error != GRPC_ERROR_NONE) {
895
- set_final_status(call, batch_error);
956
+ SetFinalStatus(batch_error);
896
957
  } else {
897
958
  absl::optional<grpc_status_code> grpc_status =
898
- b->Take(grpc_core::GrpcStatusMetadata());
959
+ b->Take(GrpcStatusMetadata());
899
960
  if (grpc_status.has_value()) {
900
961
  grpc_status_code status_code = *grpc_status;
901
962
  grpc_error_handle error = GRPC_ERROR_NONE;
902
963
  if (status_code != GRPC_STATUS_OK) {
903
- char* peer = grpc_call_get_peer(call);
964
+ char* peer = GetPeer();
904
965
  error = grpc_error_set_int(
905
966
  GRPC_ERROR_CREATE_FROM_CPP_STRING(
906
967
  absl::StrCat("Error received from peer ", peer)),
907
968
  GRPC_ERROR_INT_GRPC_STATUS, static_cast<intptr_t>(status_code));
908
969
  gpr_free(peer);
909
970
  }
910
- auto grpc_message = b->Take(grpc_core::GrpcMessageMetadata());
971
+ auto grpc_message = b->Take(GrpcMessageMetadata());
911
972
  if (grpc_message.has_value()) {
912
973
  error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
913
974
  grpc_message->as_string_view());
914
975
  } else if (error != GRPC_ERROR_NONE) {
915
976
  error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "");
916
977
  }
917
- set_final_status(call, GRPC_ERROR_REF(error));
978
+ SetFinalStatus(GRPC_ERROR_REF(error));
918
979
  GRPC_ERROR_UNREF(error);
919
- } else if (!call->is_client) {
920
- set_final_status(call, GRPC_ERROR_NONE);
980
+ } else if (!is_client()) {
981
+ SetFinalStatus(GRPC_ERROR_NONE);
921
982
  } else {
922
983
  gpr_log(GPR_DEBUG,
923
984
  "Received trailing metadata with no error and no status");
924
- set_final_status(
925
- call, grpc_error_set_int(
926
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("No status received"),
927
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNKNOWN));
985
+ SetFinalStatus(grpc_error_set_int(
986
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("No status received"),
987
+ GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNKNOWN));
928
988
  }
929
989
  }
930
- publish_app_metadata(call, b, true);
931
- }
932
-
933
- grpc_core::Arena* grpc_call_get_arena(grpc_call* call) { return call->arena; }
934
-
935
- grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
936
- return CALL_STACK_FROM_CALL(call);
990
+ PublishAppMetadata(b, true);
937
991
  }
938
992
 
939
- /*******************************************************************************
940
- * BATCH API IMPLEMENTATION
941
- */
942
-
943
- static bool are_write_flags_valid(uint32_t flags) {
993
+ namespace {
994
+ bool AreWriteFlagsValid(uint32_t flags) {
944
995
  /* check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set */
945
996
  const uint32_t allowed_write_positions =
946
997
  (GRPC_WRITE_USED_MASK | GRPC_WRITE_INTERNAL_USED_MASK);
@@ -948,16 +999,13 @@ static bool are_write_flags_valid(uint32_t flags) {
948
999
  return !(flags & invalid_positions);
949
1000
  }
950
1001
 
951
- static bool are_initial_metadata_flags_valid(uint32_t flags, bool is_client) {
1002
+ bool AreInitialMetadataFlagsValid(uint32_t flags) {
952
1003
  /* check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set */
953
1004
  uint32_t invalid_positions = ~GRPC_INITIAL_METADATA_USED_MASK;
954
- if (!is_client) {
955
- invalid_positions |= GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
956
- }
957
1005
  return !(flags & invalid_positions);
958
1006
  }
959
1007
 
960
- static size_t batch_slot_for_op(grpc_op_type type) {
1008
+ size_t BatchSlotForOp(grpc_op_type type) {
961
1009
  switch (type) {
962
1010
  case GRPC_OP_SEND_INITIAL_METADATA:
963
1011
  return 0;
@@ -976,137 +1024,135 @@ static size_t batch_slot_for_op(grpc_op_type type) {
976
1024
  }
977
1025
  GPR_UNREACHABLE_CODE(return 123456789);
978
1026
  }
1027
+ } // namespace
979
1028
 
980
- static batch_control* reuse_or_allocate_batch_control(grpc_call* call,
981
- const grpc_op* ops) {
982
- size_t slot_idx = batch_slot_for_op(ops[0].op);
983
- batch_control** pslot = &call->active_batches[slot_idx];
984
- batch_control* bctl;
1029
+ FilterStackCall::BatchControl* FilterStackCall::ReuseOrAllocateBatchControl(
1030
+ const grpc_op* ops) {
1031
+ size_t slot_idx = BatchSlotForOp(ops[0].op);
1032
+ BatchControl** pslot = &active_batches_[slot_idx];
1033
+ BatchControl* bctl;
985
1034
  if (*pslot != nullptr) {
986
1035
  bctl = *pslot;
987
- if (bctl->call != nullptr) {
1036
+ if (bctl->call_ != nullptr) {
988
1037
  return nullptr;
989
1038
  }
990
- bctl->~batch_control();
991
- bctl->op = {};
992
- new (&bctl->batch_error) AtomicError();
1039
+ bctl->~BatchControl();
1040
+ bctl->op_ = {};
1041
+ new (&bctl->batch_error_) AtomicError();
993
1042
  } else {
994
- bctl = call->arena->New<batch_control>();
1043
+ bctl = arena()->New<BatchControl>();
995
1044
  *pslot = bctl;
996
1045
  }
997
- bctl->call = call;
998
- bctl->op.payload = &call->stream_op_payload;
1046
+ bctl->call_ = this;
1047
+ bctl->op_.payload = &stream_op_payload_;
999
1048
  return bctl;
1000
1049
  }
1001
1050
 
1002
- static void finish_batch_completion(void* user_data,
1003
- grpc_cq_completion* /*storage*/) {
1004
- batch_control* bctl = static_cast<batch_control*>(user_data);
1005
- grpc_call* call = bctl->call;
1006
- bctl->call = nullptr;
1007
- GRPC_CALL_INTERNAL_UNREF(call, "completion");
1008
- }
1009
-
1010
- static void reset_batch_errors(batch_control* bctl) {
1011
- bctl->batch_error.set(GRPC_ERROR_NONE);
1051
+ void Call::PropagateCancellationToChildren() {
1052
+ ParentCall* pc = parent_call();
1053
+ if (pc != nullptr) {
1054
+ Call* child;
1055
+ MutexLock lock(&pc->child_list_mu);
1056
+ child = pc->first_child;
1057
+ if (child != nullptr) {
1058
+ do {
1059
+ Call* next_child_call = child->child_->sibling_next;
1060
+ if (child->cancellation_is_inherited_) {
1061
+ child->InternalRef("propagate_cancel");
1062
+ child->CancelWithError(GRPC_ERROR_CANCELLED);
1063
+ child->InternalUnref("propagate_cancel");
1064
+ }
1065
+ child = next_child_call;
1066
+ } while (child != pc->first_child);
1067
+ }
1068
+ }
1012
1069
  }
1013
1070
 
1014
- static void post_batch_completion(batch_control* bctl) {
1015
- grpc_call* next_child_call;
1016
- grpc_call* call = bctl->call;
1017
- grpc_error_handle error = GRPC_ERROR_REF(bctl->batch_error.get());
1071
+ void FilterStackCall::BatchControl::PostCompletion() {
1072
+ FilterStackCall* call = call_;
1073
+ grpc_error_handle error = GRPC_ERROR_REF(batch_error_.get());
1018
1074
 
1019
- if (bctl->op.send_initial_metadata) {
1020
- call->send_initial_metadata.Clear();
1075
+ if (op_.send_initial_metadata) {
1076
+ call->send_initial_metadata_.Clear();
1021
1077
  }
1022
- if (bctl->op.send_message) {
1023
- if (bctl->op.payload->send_message.stream_write_closed &&
1078
+ if (op_.send_message) {
1079
+ if (op_.payload->send_message.stream_write_closed &&
1024
1080
  error == GRPC_ERROR_NONE) {
1025
1081
  error = grpc_error_add_child(
1026
1082
  error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1027
1083
  "Attempt to send message after stream was closed."));
1028
1084
  }
1029
- call->sending_message = false;
1085
+ call->sending_message_ = false;
1030
1086
  }
1031
- if (bctl->op.send_trailing_metadata) {
1032
- call->send_trailing_metadata.Clear();
1087
+ if (op_.send_trailing_metadata) {
1088
+ call->send_trailing_metadata_.Clear();
1033
1089
  }
1034
- if (bctl->op.recv_trailing_metadata) {
1090
+ if (op_.recv_trailing_metadata) {
1035
1091
  /* propagate cancellation to any interested children */
1036
- gpr_atm_rel_store(&call->received_final_op_atm, 1);
1037
- parent_call* pc = get_parent_call(call);
1038
- if (pc != nullptr) {
1039
- grpc_call* child;
1040
- gpr_mu_lock(&pc->child_list_mu);
1041
- child = pc->first_child;
1042
- if (child != nullptr) {
1043
- do {
1044
- next_child_call = child->child->sibling_next;
1045
- if (child->cancellation_is_inherited) {
1046
- GRPC_CALL_INTERNAL_REF(child, "propagate_cancel");
1047
- cancel_with_error(child, GRPC_ERROR_CANCELLED);
1048
- GRPC_CALL_INTERNAL_UNREF(child, "propagate_cancel");
1049
- }
1050
- child = next_child_call;
1051
- } while (child != pc->first_child);
1052
- }
1053
- gpr_mu_unlock(&pc->child_list_mu);
1054
- }
1092
+ gpr_atm_rel_store(&call->received_final_op_atm_, 1);
1093
+ call->PropagateCancellationToChildren();
1055
1094
  GRPC_ERROR_UNREF(error);
1056
1095
  error = GRPC_ERROR_NONE;
1057
1096
  }
1058
- if (error != GRPC_ERROR_NONE && bctl->op.recv_message &&
1059
- *call->receiving_buffer != nullptr) {
1060
- grpc_byte_buffer_destroy(*call->receiving_buffer);
1061
- *call->receiving_buffer = nullptr;
1097
+ if (error != GRPC_ERROR_NONE && op_.recv_message &&
1098
+ *call->receiving_buffer_ != nullptr) {
1099
+ grpc_byte_buffer_destroy(*call->receiving_buffer_);
1100
+ *call->receiving_buffer_ = nullptr;
1062
1101
  }
1063
- reset_batch_errors(bctl);
1102
+ batch_error_.set(GRPC_ERROR_NONE);
1064
1103
 
1065
- if (bctl->completion_data.notify_tag.is_closure) {
1104
+ if (completion_data_.notify_tag.is_closure) {
1066
1105
  /* unrefs error */
1067
- bctl->call = nullptr;
1068
- grpc_core::Closure::Run(
1069
- DEBUG_LOCATION,
1070
- static_cast<grpc_closure*>(bctl->completion_data.notify_tag.tag),
1071
- error);
1072
- GRPC_CALL_INTERNAL_UNREF(call, "completion");
1106
+ call_ = nullptr;
1107
+ Closure::Run(DEBUG_LOCATION,
1108
+ static_cast<grpc_closure*>(completion_data_.notify_tag.tag),
1109
+ error);
1110
+ call->InternalUnref("completion");
1073
1111
  } else {
1074
1112
  /* unrefs error */
1075
- grpc_cq_end_op(bctl->call->cq, bctl->completion_data.notify_tag.tag, error,
1076
- finish_batch_completion, bctl,
1077
- &bctl->completion_data.cq_completion);
1113
+ grpc_cq_end_op(
1114
+ call->cq_, completion_data_.notify_tag.tag, error,
1115
+ [](void* user_data, grpc_cq_completion* /*storage*/) {
1116
+ BatchControl* bctl = static_cast<BatchControl*>(user_data);
1117
+ Call* call = bctl->call_;
1118
+ bctl->call_ = nullptr;
1119
+ call->InternalUnref("completion");
1120
+ },
1121
+ this, &completion_data_.cq_completion);
1078
1122
  }
1079
1123
  }
1080
1124
 
1081
- static void finish_batch_step(batch_control* bctl) {
1082
- if (GPR_UNLIKELY(bctl->completed_batch_step())) {
1083
- post_batch_completion(bctl);
1125
+ void FilterStackCall::BatchControl::FinishStep() {
1126
+ if (GPR_UNLIKELY(completed_batch_step())) {
1127
+ PostCompletion();
1084
1128
  }
1085
1129
  }
1086
1130
 
1087
- static void continue_receiving_slices(batch_control* bctl) {
1131
+ void FilterStackCall::BatchControl::ContinueReceivingSlices() {
1088
1132
  grpc_error_handle error;
1089
- grpc_call* call = bctl->call;
1133
+ FilterStackCall* call = call_;
1090
1134
  for (;;) {
1091
- size_t remaining = call->receiving_stream->length() -
1092
- (*call->receiving_buffer)->data.raw.slice_buffer.length;
1135
+ size_t remaining = call->receiving_stream_->length() -
1136
+ (*call->receiving_buffer_)->data.raw.slice_buffer.length;
1093
1137
  if (remaining == 0) {
1094
- call->receiving_message = false;
1095
- call->receiving_stream.reset();
1096
- finish_batch_step(bctl);
1138
+ call->receiving_message_ = false;
1139
+ call->receiving_stream_.reset();
1140
+ FinishStep();
1097
1141
  return;
1098
1142
  }
1099
- if (call->receiving_stream->Next(remaining, &call->receiving_slice_ready)) {
1100
- error = call->receiving_stream->Pull(&call->receiving_slice);
1143
+ if (call->receiving_stream_->Next(remaining,
1144
+ &call->receiving_slice_ready_)) {
1145
+ error = call->receiving_stream_->Pull(&call->receiving_slice_);
1101
1146
  if (error == GRPC_ERROR_NONE) {
1102
- grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer,
1103
- call->receiving_slice);
1147
+ grpc_slice_buffer_add(
1148
+ &(*call->receiving_buffer_)->data.raw.slice_buffer,
1149
+ call->receiving_slice_);
1104
1150
  } else {
1105
- call->receiving_stream.reset();
1106
- grpc_byte_buffer_destroy(*call->receiving_buffer);
1107
- *call->receiving_buffer = nullptr;
1108
- call->receiving_message = false;
1109
- finish_batch_step(bctl);
1151
+ call->receiving_stream_.reset();
1152
+ grpc_byte_buffer_destroy(*call->receiving_buffer_);
1153
+ *call->receiving_buffer_ = nullptr;
1154
+ call->receiving_message_ = false;
1155
+ FinishStep();
1110
1156
  GRPC_ERROR_UNREF(error);
1111
1157
  return;
1112
1158
  }
@@ -1116,18 +1162,18 @@ static void continue_receiving_slices(batch_control* bctl) {
1116
1162
  }
1117
1163
  }
1118
1164
 
1119
- static void receiving_slice_ready(void* bctlp, grpc_error_handle error) {
1120
- batch_control* bctl = static_cast<batch_control*>(bctlp);
1121
- grpc_call* call = bctl->call;
1165
+ void FilterStackCall::BatchControl::ReceivingSliceReady(
1166
+ grpc_error_handle error) {
1167
+ FilterStackCall* call = call_;
1122
1168
  bool release_error = false;
1123
1169
 
1124
1170
  if (error == GRPC_ERROR_NONE) {
1125
1171
  grpc_slice slice;
1126
- error = call->receiving_stream->Pull(&slice);
1172
+ error = call->receiving_stream_->Pull(&slice);
1127
1173
  if (error == GRPC_ERROR_NONE) {
1128
- grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer,
1174
+ grpc_slice_buffer_add(&(*call->receiving_buffer_)->data.raw.slice_buffer,
1129
1175
  slice);
1130
- continue_receiving_slices(bctl);
1176
+ ContinueReceivingSlices();
1131
1177
  } else {
1132
1178
  /* Error returned by ByteStream::Pull() needs to be released manually */
1133
1179
  release_error = true;
@@ -1138,142 +1184,134 @@ static void receiving_slice_ready(void* bctlp, grpc_error_handle error) {
1138
1184
  if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures)) {
1139
1185
  GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error));
1140
1186
  }
1141
- call->receiving_stream.reset();
1142
- grpc_byte_buffer_destroy(*call->receiving_buffer);
1143
- *call->receiving_buffer = nullptr;
1144
- call->receiving_message = false;
1145
- finish_batch_step(bctl);
1187
+ call->receiving_stream_.reset();
1188
+ grpc_byte_buffer_destroy(*call->receiving_buffer_);
1189
+ *call->receiving_buffer_ = nullptr;
1190
+ call->receiving_message_ = false;
1191
+ FinishStep();
1146
1192
  if (release_error) {
1147
1193
  GRPC_ERROR_UNREF(error);
1148
1194
  }
1149
1195
  }
1150
1196
  }
1151
1197
 
1152
- static void process_data_after_md(batch_control* bctl) {
1153
- grpc_call* call = bctl->call;
1154
- if (call->receiving_stream == nullptr) {
1155
- *call->receiving_buffer = nullptr;
1156
- call->receiving_message = false;
1157
- finish_batch_step(bctl);
1198
+ void FilterStackCall::BatchControl::ProcessDataAfterMetadata() {
1199
+ FilterStackCall* call = call_;
1200
+ if (call->receiving_stream_ == nullptr) {
1201
+ *call->receiving_buffer_ = nullptr;
1202
+ call->receiving_message_ = false;
1203
+ FinishStep();
1158
1204
  } else {
1159
- call->test_only_last_message_flags = call->receiving_stream->flags();
1160
- if ((call->receiving_stream->flags() & GRPC_WRITE_INTERNAL_COMPRESS) &&
1161
- (call->incoming_compression_algorithm != GRPC_COMPRESS_NONE)) {
1162
- *call->receiving_buffer = grpc_raw_compressed_byte_buffer_create(
1163
- nullptr, 0, call->incoming_compression_algorithm);
1205
+ call->test_only_last_message_flags_ = call->receiving_stream_->flags();
1206
+ if ((call->receiving_stream_->flags() & GRPC_WRITE_INTERNAL_COMPRESS) &&
1207
+ (call->incoming_compression_algorithm_ != GRPC_COMPRESS_NONE)) {
1208
+ *call->receiving_buffer_ = grpc_raw_compressed_byte_buffer_create(
1209
+ nullptr, 0, call->incoming_compression_algorithm_);
1164
1210
  } else {
1165
- *call->receiving_buffer = grpc_raw_byte_buffer_create(nullptr, 0);
1211
+ *call->receiving_buffer_ = grpc_raw_byte_buffer_create(nullptr, 0);
1166
1212
  }
1167
- GRPC_CLOSURE_INIT(&call->receiving_slice_ready, receiving_slice_ready, bctl,
1168
- grpc_schedule_on_exec_ctx);
1169
- continue_receiving_slices(bctl);
1213
+ GRPC_CLOSURE_INIT(
1214
+ &call->receiving_slice_ready_,
1215
+ [](void* bctl, grpc_error_handle error) {
1216
+ static_cast<BatchControl*>(bctl)->ReceivingSliceReady(error);
1217
+ },
1218
+ this, grpc_schedule_on_exec_ctx);
1219
+ ContinueReceivingSlices();
1170
1220
  }
1171
1221
  }
1172
1222
 
1173
- static void receiving_stream_ready(void* bctlp, grpc_error_handle error) {
1174
- batch_control* bctl = static_cast<batch_control*>(bctlp);
1175
- grpc_call* call = bctl->call;
1223
+ void FilterStackCall::BatchControl::ReceivingStreamReady(
1224
+ grpc_error_handle error) {
1225
+ FilterStackCall* call = call_;
1176
1226
  if (error != GRPC_ERROR_NONE) {
1177
- call->receiving_stream.reset();
1178
- if (bctl->batch_error.ok()) {
1179
- bctl->batch_error.set(error);
1227
+ call->receiving_stream_.reset();
1228
+ if (batch_error_.ok()) {
1229
+ batch_error_.set(error);
1180
1230
  }
1181
- cancel_with_error(call, GRPC_ERROR_REF(error));
1231
+ call->CancelWithError(GRPC_ERROR_REF(error));
1182
1232
  }
1183
- /* If recv_state is RECV_NONE, we will save the batch_control
1233
+ /* If recv_state is kRecvNone, we will save the batch_control
1184
1234
  * object with rel_cas, and will not use it after the cas. Its corresponding
1185
1235
  * acq_load is in receiving_initial_metadata_ready() */
1186
- if (error != GRPC_ERROR_NONE || call->receiving_stream == nullptr ||
1187
- !gpr_atm_rel_cas(&call->recv_state, RECV_NONE,
1188
- reinterpret_cast<gpr_atm>(bctlp))) {
1189
- process_data_after_md(bctl);
1236
+ if (error != GRPC_ERROR_NONE || call->receiving_stream_ == nullptr ||
1237
+ !gpr_atm_rel_cas(&call->recv_state_, kRecvNone,
1238
+ reinterpret_cast<gpr_atm>(this))) {
1239
+ ProcessDataAfterMetadata();
1190
1240
  }
1191
1241
  }
1192
1242
 
1193
- // The recv_message_ready callback used when sending a batch containing
1194
- // a recv_message op down the filter stack. Yields the call combiner
1195
- // before processing the received message.
1196
- static void receiving_stream_ready_in_call_combiner(void* bctlp,
1197
- grpc_error_handle error) {
1198
- batch_control* bctl = static_cast<batch_control*>(bctlp);
1199
- grpc_call* call = bctl->call;
1200
- GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_message_ready");
1201
- receiving_stream_ready(bctlp, error);
1202
- }
1203
-
1204
- static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_disabled(
1205
- grpc_call* call, grpc_compression_algorithm compression_algorithm) {
1243
+ void FilterStackCall::HandleCompressionAlgorithmDisabled(
1244
+ grpc_compression_algorithm compression_algorithm) {
1206
1245
  const char* algo_name = nullptr;
1207
1246
  grpc_compression_algorithm_name(compression_algorithm, &algo_name);
1208
1247
  std::string error_msg =
1209
1248
  absl::StrFormat("Compression algorithm '%s' is disabled.", algo_name);
1210
1249
  gpr_log(GPR_ERROR, "%s", error_msg.c_str());
1211
- cancel_with_status(call, GRPC_STATUS_UNIMPLEMENTED, error_msg.c_str());
1250
+ CancelWithStatus(GRPC_STATUS_UNIMPLEMENTED, error_msg.c_str());
1212
1251
  }
1213
1252
 
1214
- static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_not_accepted(
1215
- grpc_call* call, grpc_compression_algorithm compression_algorithm) {
1253
+ void FilterStackCall::HandleCompressionAlgorithmNotAccepted(
1254
+ grpc_compression_algorithm compression_algorithm) {
1216
1255
  const char* algo_name = nullptr;
1217
1256
  grpc_compression_algorithm_name(compression_algorithm, &algo_name);
1218
1257
  gpr_log(GPR_ERROR,
1219
1258
  "Compression algorithm ('%s') not present in the "
1220
1259
  "accepted encodings (%s)",
1221
- algo_name, call->encodings_accepted_by_peer.ToString().c_str());
1260
+ algo_name,
1261
+ std::string(encodings_accepted_by_peer_.ToString()).c_str());
1222
1262
  }
1223
1263
 
1224
- static void validate_filtered_metadata(batch_control* bctl) {
1225
- grpc_call* call = bctl->call;
1264
+ void FilterStackCall::BatchControl::ValidateFilteredMetadata() {
1265
+ FilterStackCall* call = call_;
1226
1266
 
1227
1267
  const grpc_compression_options compression_options =
1228
- grpc_channel_compression_options(call->channel);
1268
+ call->channel_->compression_options();
1229
1269
  const grpc_compression_algorithm compression_algorithm =
1230
- call->incoming_compression_algorithm;
1231
- if (GPR_UNLIKELY(!grpc_core::CompressionAlgorithmSet::FromUint32(
1270
+ call->incoming_compression_algorithm_;
1271
+ if (GPR_UNLIKELY(!CompressionAlgorithmSet::FromUint32(
1232
1272
  compression_options.enabled_algorithms_bitset)
1233
1273
  .IsSet(compression_algorithm))) {
1234
1274
  /* check if algorithm is supported by current channel config */
1235
- handle_compression_algorithm_disabled(call, compression_algorithm);
1275
+ call->HandleCompressionAlgorithmDisabled(compression_algorithm);
1236
1276
  }
1237
1277
  /* GRPC_COMPRESS_NONE is always set. */
1238
- GPR_DEBUG_ASSERT(call->encodings_accepted_by_peer.IsSet(GRPC_COMPRESS_NONE));
1278
+ GPR_DEBUG_ASSERT(call->encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE));
1239
1279
  if (GPR_UNLIKELY(
1240
- !call->encodings_accepted_by_peer.IsSet(compression_algorithm))) {
1280
+ !call->encodings_accepted_by_peer_.IsSet(compression_algorithm))) {
1241
1281
  if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
1242
- handle_compression_algorithm_not_accepted(call, compression_algorithm);
1282
+ call->HandleCompressionAlgorithmNotAccepted(compression_algorithm);
1243
1283
  }
1244
1284
  }
1245
1285
  }
1246
1286
 
1247
- static void receiving_initial_metadata_ready(void* bctlp,
1248
- grpc_error_handle error) {
1249
- batch_control* bctl = static_cast<batch_control*>(bctlp);
1250
- grpc_call* call = bctl->call;
1287
+ void FilterStackCall::BatchControl::ReceivingInitialMetadataReady(
1288
+ grpc_error_handle error) {
1289
+ FilterStackCall* call = call_;
1251
1290
 
1252
- GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_initial_metadata_ready");
1291
+ GRPC_CALL_COMBINER_STOP(call->call_combiner(), "recv_initial_metadata_ready");
1253
1292
 
1254
1293
  if (error == GRPC_ERROR_NONE) {
1255
- grpc_metadata_batch* md = &call->recv_initial_metadata;
1256
- recv_initial_filter(call, md);
1294
+ grpc_metadata_batch* md = &call->recv_initial_metadata_;
1295
+ call->RecvInitialFilter(md);
1257
1296
 
1258
1297
  /* TODO(ctiller): this could be moved into recv_initial_filter now */
1259
1298
  GPR_TIMER_SCOPE("validate_filtered_metadata", 0);
1260
- validate_filtered_metadata(bctl);
1299
+ ValidateFilteredMetadata();
1261
1300
 
1262
- absl::optional<grpc_core::Timestamp> deadline =
1263
- md->get(grpc_core::GrpcTimeoutMetadata());
1264
- if (deadline.has_value() && !call->is_client) {
1265
- call->send_deadline = *deadline;
1301
+ absl::optional<Timestamp> deadline = md->get(GrpcTimeoutMetadata());
1302
+ if (deadline.has_value() && !call->is_client()) {
1303
+ call_->set_send_deadline(*deadline);
1266
1304
  }
1267
1305
  } else {
1268
- if (bctl->batch_error.ok()) {
1269
- bctl->batch_error.set(error);
1306
+ if (batch_error_.ok()) {
1307
+ batch_error_.set(error);
1270
1308
  }
1271
- cancel_with_error(call, GRPC_ERROR_REF(error));
1309
+ call->CancelWithError(GRPC_ERROR_REF(error));
1272
1310
  }
1273
1311
 
1274
1312
  grpc_closure* saved_rsr_closure = nullptr;
1275
1313
  while (true) {
1276
- gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state);
1314
+ gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state_);
1277
1315
  /* Should only receive initial metadata once */
1278
1316
  GPR_ASSERT(rsr_bctlp != 1);
1279
1317
  if (rsr_bctlp == 0) {
@@ -1282,62 +1320,57 @@ static void receiving_initial_metadata_ready(void* bctlp,
1282
1320
  * no_barrier_cas is used, as this function won't access the batch_control
1283
1321
  * object saved by receiving_stream_ready() if the initial metadata is
1284
1322
  * received first. */
1285
- if (gpr_atm_no_barrier_cas(&call->recv_state, RECV_NONE,
1286
- RECV_INITIAL_METADATA_FIRST)) {
1323
+ if (gpr_atm_no_barrier_cas(&call->recv_state_, kRecvNone,
1324
+ kRecvInitialMetadataFirst)) {
1287
1325
  break;
1288
1326
  }
1289
1327
  } else {
1290
1328
  /* Already received messages */
1291
- saved_rsr_closure =
1292
- GRPC_CLOSURE_CREATE(receiving_stream_ready, (batch_control*)rsr_bctlp,
1293
- grpc_schedule_on_exec_ctx);
1329
+ saved_rsr_closure = GRPC_CLOSURE_CREATE(
1330
+ [](void* bctl, grpc_error_handle error) {
1331
+ static_cast<BatchControl*>(bctl)->ReceivingStreamReady(error);
1332
+ },
1333
+ reinterpret_cast<BatchControl*>(rsr_bctlp),
1334
+ grpc_schedule_on_exec_ctx);
1294
1335
  /* No need to modify recv_state */
1295
1336
  break;
1296
1337
  }
1297
1338
  }
1298
1339
  if (saved_rsr_closure != nullptr) {
1299
- grpc_core::Closure::Run(DEBUG_LOCATION, saved_rsr_closure,
1300
- GRPC_ERROR_REF(error));
1340
+ Closure::Run(DEBUG_LOCATION, saved_rsr_closure, GRPC_ERROR_REF(error));
1301
1341
  }
1302
1342
 
1303
- finish_batch_step(bctl);
1343
+ FinishStep();
1304
1344
  }
1305
1345
 
1306
- static void receiving_trailing_metadata_ready(void* bctlp,
1307
- grpc_error_handle error) {
1308
- batch_control* bctl = static_cast<batch_control*>(bctlp);
1309
- grpc_call* call = bctl->call;
1310
- GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_trailing_metadata_ready");
1311
- grpc_metadata_batch* md = &call->recv_trailing_metadata;
1312
- recv_trailing_filter(call, md, GRPC_ERROR_REF(error));
1313
- finish_batch_step(bctl);
1346
+ void FilterStackCall::BatchControl::ReceivingTrailingMetadataReady(
1347
+ grpc_error_handle error) {
1348
+ GRPC_CALL_COMBINER_STOP(call_->call_combiner(),
1349
+ "recv_trailing_metadata_ready");
1350
+ grpc_metadata_batch* md = &call_->recv_trailing_metadata_;
1351
+ call_->RecvTrailingFilter(md, GRPC_ERROR_REF(error));
1352
+ FinishStep();
1314
1353
  }
1315
1354
 
1316
- static void finish_batch(void* bctlp, grpc_error_handle error) {
1317
- batch_control* bctl = static_cast<batch_control*>(bctlp);
1318
- grpc_call* call = bctl->call;
1319
- GRPC_CALL_COMBINER_STOP(&call->call_combiner, "on_complete");
1320
- if (bctl->batch_error.ok()) {
1321
- bctl->batch_error.set(error);
1355
+ void FilterStackCall::BatchControl::FinishBatch(grpc_error_handle error) {
1356
+ GRPC_CALL_COMBINER_STOP(call_->call_combiner(), "on_complete");
1357
+ if (batch_error_.ok()) {
1358
+ batch_error_.set(error);
1322
1359
  }
1323
1360
  if (error != GRPC_ERROR_NONE) {
1324
- cancel_with_error(call, GRPC_ERROR_REF(error));
1361
+ call_->CancelWithError(GRPC_ERROR_REF(error));
1325
1362
  }
1326
- finish_batch_step(bctl);
1327
- }
1328
-
1329
- static void free_no_op_completion(void* /*p*/, grpc_cq_completion* completion) {
1330
- gpr_free(completion);
1363
+ FinishStep();
1331
1364
  }
1332
1365
 
1333
- static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1334
- size_t nops, void* notify_tag,
1335
- int is_notify_tag_closure) {
1366
+ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1367
+ void* notify_tag,
1368
+ bool is_notify_tag_closure) {
1336
1369
  GPR_TIMER_SCOPE("call_start_batch", 0);
1337
1370
 
1338
1371
  size_t i;
1339
1372
  const grpc_op* op;
1340
- batch_control* bctl;
1373
+ BatchControl* bctl;
1341
1374
  bool has_send_ops = false;
1342
1375
  int num_recv_ops = 0;
1343
1376
  grpc_call_error error = GRPC_CALL_OK;
@@ -1356,30 +1389,31 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1356
1389
 
1357
1390
  if (nops == 0) {
1358
1391
  if (!is_notify_tag_closure) {
1359
- GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag));
1360
- grpc_cq_end_op(call->cq, notify_tag, GRPC_ERROR_NONE,
1361
- free_no_op_completion, nullptr,
1362
- static_cast<grpc_cq_completion*>(
1363
- gpr_malloc(sizeof(grpc_cq_completion))));
1392
+ GPR_ASSERT(grpc_cq_begin_op(cq_, notify_tag));
1393
+ grpc_cq_end_op(
1394
+ cq_, notify_tag, GRPC_ERROR_NONE,
1395
+ [](void*, grpc_cq_completion* completion) { gpr_free(completion); },
1396
+ nullptr,
1397
+ static_cast<grpc_cq_completion*>(
1398
+ gpr_malloc(sizeof(grpc_cq_completion))));
1364
1399
  } else {
1365
- grpc_core::Closure::Run(DEBUG_LOCATION,
1366
- static_cast<grpc_closure*>(notify_tag),
1367
- GRPC_ERROR_NONE);
1400
+ Closure::Run(DEBUG_LOCATION, static_cast<grpc_closure*>(notify_tag),
1401
+ GRPC_ERROR_NONE);
1368
1402
  }
1369
1403
  error = GRPC_CALL_OK;
1370
1404
  goto done;
1371
1405
  }
1372
1406
 
1373
- bctl = reuse_or_allocate_batch_control(call, ops);
1407
+ bctl = ReuseOrAllocateBatchControl(ops);
1374
1408
  if (bctl == nullptr) {
1375
1409
  return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1376
1410
  }
1377
- bctl->completion_data.notify_tag.tag = notify_tag;
1378
- bctl->completion_data.notify_tag.is_closure =
1411
+ bctl->completion_data_.notify_tag.tag = notify_tag;
1412
+ bctl->completion_data_.notify_tag.is_closure =
1379
1413
  static_cast<uint8_t>(is_notify_tag_closure != 0);
1380
1414
 
1381
- stream_op = &bctl->op;
1382
- stream_op_payload = &call->stream_op_payload;
1415
+ stream_op = &bctl->op_;
1416
+ stream_op_payload = &stream_op_payload_;
1383
1417
 
1384
1418
  /* rewrite batch ops into a transport op */
1385
1419
  for (i = 0; i < nops; i++) {
@@ -1391,11 +1425,11 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1391
1425
  switch (op->op) {
1392
1426
  case GRPC_OP_SEND_INITIAL_METADATA: {
1393
1427
  /* Flag validation: currently allow no flags */
1394
- if (!are_initial_metadata_flags_valid(op->flags, call->is_client)) {
1428
+ if (!AreInitialMetadataFlagsValid(op->flags)) {
1395
1429
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1396
1430
  goto done_with_error;
1397
1431
  }
1398
- if (call->sent_initial_metadata) {
1432
+ if (sent_initial_metadata_) {
1399
1433
  error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1400
1434
  goto done_with_error;
1401
1435
  }
@@ -1413,56 +1447,52 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1413
1447
  level_set = true;
1414
1448
  } else {
1415
1449
  const grpc_compression_options copts =
1416
- grpc_channel_compression_options(call->channel);
1450
+ channel_->compression_options();
1417
1451
  if (copts.default_level.is_set) {
1418
1452
  level_set = true;
1419
1453
  effective_compression_level = copts.default_level.level;
1420
1454
  }
1421
1455
  }
1422
1456
  // Currently, only server side supports compression level setting.
1423
- if (level_set && !call->is_client) {
1457
+ if (level_set && !is_client()) {
1424
1458
  const grpc_compression_algorithm calgo =
1425
- call->encodings_accepted_by_peer.CompressionAlgorithmForLevel(
1459
+ encodings_accepted_by_peer_.CompressionAlgorithmForLevel(
1426
1460
  effective_compression_level);
1427
1461
  // The following metadata will be checked and removed by the message
1428
1462
  // compression filter. It will be used as the call's compression
1429
1463
  // algorithm.
1430
- call->send_initial_metadata.Set(
1431
- grpc_core::GrpcInternalEncodingRequest(), calgo);
1464
+ send_initial_metadata_.Set(GrpcInternalEncodingRequest(), calgo);
1432
1465
  }
1433
1466
  if (op->data.send_initial_metadata.count > INT_MAX) {
1434
1467
  error = GRPC_CALL_ERROR_INVALID_METADATA;
1435
1468
  goto done_with_error;
1436
1469
  }
1437
1470
  stream_op->send_initial_metadata = true;
1438
- call->sent_initial_metadata = true;
1439
- if (!prepare_application_metadata(
1440
- call, static_cast<int>(op->data.send_initial_metadata.count),
1441
- op->data.send_initial_metadata.metadata, 0)) {
1471
+ sent_initial_metadata_ = true;
1472
+ if (!PrepareApplicationMetadata(op->data.send_initial_metadata.count,
1473
+ op->data.send_initial_metadata.metadata,
1474
+ false)) {
1442
1475
  error = GRPC_CALL_ERROR_INVALID_METADATA;
1443
1476
  goto done_with_error;
1444
1477
  }
1445
1478
  // Ignore any te metadata key value pairs specified.
1446
- call->send_initial_metadata.Remove(grpc_core::TeMetadata());
1479
+ send_initial_metadata_.Remove(TeMetadata());
1447
1480
  /* TODO(ctiller): just make these the same variable? */
1448
- if (call->is_client &&
1449
- call->send_deadline != grpc_core::Timestamp::InfFuture()) {
1450
- call->send_initial_metadata.Set(grpc_core::GrpcTimeoutMetadata(),
1451
- call->send_deadline);
1481
+ if (is_client() && send_deadline() != Timestamp::InfFuture()) {
1482
+ send_initial_metadata_.Set(GrpcTimeoutMetadata(), send_deadline());
1452
1483
  }
1453
1484
  stream_op_payload->send_initial_metadata.send_initial_metadata =
1454
- &call->send_initial_metadata;
1485
+ &send_initial_metadata_;
1455
1486
  stream_op_payload->send_initial_metadata.send_initial_metadata_flags =
1456
1487
  op->flags;
1457
- if (call->is_client) {
1458
- stream_op_payload->send_initial_metadata.peer_string =
1459
- &call->peer_string;
1488
+ if (is_client()) {
1489
+ stream_op_payload->send_initial_metadata.peer_string = &peer_string_;
1460
1490
  }
1461
1491
  has_send_ops = true;
1462
1492
  break;
1463
1493
  }
1464
1494
  case GRPC_OP_SEND_MESSAGE: {
1465
- if (!are_write_flags_valid(op->flags)) {
1495
+ if (!AreWriteFlagsValid(op->flags)) {
1466
1496
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1467
1497
  goto done_with_error;
1468
1498
  }
@@ -1470,7 +1500,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1470
1500
  error = GRPC_CALL_ERROR_INVALID_MESSAGE;
1471
1501
  goto done_with_error;
1472
1502
  }
1473
- if (call->sending_message) {
1503
+ if (sending_message_) {
1474
1504
  error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1475
1505
  goto done_with_error;
1476
1506
  }
@@ -1483,11 +1513,11 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1483
1513
  flags |= GRPC_WRITE_INTERNAL_COMPRESS;
1484
1514
  }
1485
1515
  stream_op->send_message = true;
1486
- call->sending_message = true;
1487
- call->sending_stream.Init(
1516
+ sending_message_ = true;
1517
+ sending_stream_.Init(
1488
1518
  &op->data.send_message.send_message->data.raw.slice_buffer, flags);
1489
1519
  stream_op_payload->send_message.send_message.reset(
1490
- call->sending_stream.get());
1520
+ sending_stream_.get());
1491
1521
  has_send_ops = true;
1492
1522
  break;
1493
1523
  }
@@ -1497,18 +1527,18 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1497
1527
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1498
1528
  goto done_with_error;
1499
1529
  }
1500
- if (!call->is_client) {
1530
+ if (!is_client()) {
1501
1531
  error = GRPC_CALL_ERROR_NOT_ON_SERVER;
1502
1532
  goto done_with_error;
1503
1533
  }
1504
- if (call->sent_final_op) {
1534
+ if (sent_final_op_) {
1505
1535
  error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1506
1536
  goto done_with_error;
1507
1537
  }
1508
1538
  stream_op->send_trailing_metadata = true;
1509
- call->sent_final_op = true;
1539
+ sent_final_op_ = true;
1510
1540
  stream_op_payload->send_trailing_metadata.send_trailing_metadata =
1511
- &call->send_trailing_metadata;
1541
+ &send_trailing_metadata_;
1512
1542
  has_send_ops = true;
1513
1543
  break;
1514
1544
  }
@@ -1518,11 +1548,11 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1518
1548
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1519
1549
  goto done_with_error;
1520
1550
  }
1521
- if (call->is_client) {
1551
+ if (is_client()) {
1522
1552
  error = GRPC_CALL_ERROR_NOT_ON_CLIENT;
1523
1553
  goto done_with_error;
1524
1554
  }
1525
- if (call->sent_final_op) {
1555
+ if (sent_final_op_) {
1526
1556
  error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1527
1557
  goto done_with_error;
1528
1558
  }
@@ -1532,13 +1562,11 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1532
1562
  goto done_with_error;
1533
1563
  }
1534
1564
  stream_op->send_trailing_metadata = true;
1535
- call->sent_final_op = true;
1565
+ sent_final_op_ = true;
1536
1566
 
1537
- if (!prepare_application_metadata(
1538
- call,
1539
- static_cast<int>(
1540
- op->data.send_status_from_server.trailing_metadata_count),
1541
- op->data.send_status_from_server.trailing_metadata, 1)) {
1567
+ if (!PrepareApplicationMetadata(
1568
+ op->data.send_status_from_server.trailing_metadata_count,
1569
+ op->data.send_status_from_server.trailing_metadata, true)) {
1542
1570
  error = GRPC_CALL_ERROR_INVALID_METADATA;
1543
1571
  goto done_with_error;
1544
1572
  }
@@ -1553,31 +1581,30 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1553
1581
  static_cast<intptr_t>(
1554
1582
  op->data.send_status_from_server.status));
1555
1583
  if (op->data.send_status_from_server.status_details != nullptr) {
1556
- call->send_trailing_metadata.Set(
1557
- grpc_core::GrpcMessageMetadata(),
1558
- grpc_core::Slice(grpc_slice_copy(
1584
+ send_trailing_metadata_.Set(
1585
+ GrpcMessageMetadata(),
1586
+ Slice(grpc_slice_copy(
1559
1587
  *op->data.send_status_from_server.status_details)));
1560
1588
  if (status_error != GRPC_ERROR_NONE) {
1561
1589
  status_error = grpc_error_set_str(
1562
1590
  status_error, GRPC_ERROR_STR_GRPC_MESSAGE,
1563
- grpc_core::StringViewFromSlice(
1591
+ StringViewFromSlice(
1564
1592
  *op->data.send_status_from_server.status_details));
1565
1593
  }
1566
1594
  }
1567
1595
 
1568
- call->status_error.set(status_error);
1596
+ status_error_.set(status_error);
1569
1597
  GRPC_ERROR_UNREF(status_error);
1570
1598
 
1571
- call->send_trailing_metadata.Set(
1572
- grpc_core::GrpcStatusMetadata(),
1573
- op->data.send_status_from_server.status);
1599
+ send_trailing_metadata_.Set(GrpcStatusMetadata(),
1600
+ op->data.send_status_from_server.status);
1574
1601
 
1575
1602
  // Ignore any te metadata key value pairs specified.
1576
- call->send_trailing_metadata.Remove(grpc_core::TeMetadata());
1603
+ send_trailing_metadata_.Remove(TeMetadata());
1577
1604
  stream_op_payload->send_trailing_metadata.send_trailing_metadata =
1578
- &call->send_trailing_metadata;
1605
+ &send_trailing_metadata_;
1579
1606
  stream_op_payload->send_trailing_metadata.sent =
1580
- &call->sent_server_trailing_metadata;
1607
+ &sent_server_trailing_metadata_;
1581
1608
  has_send_ops = true;
1582
1609
  break;
1583
1610
  }
@@ -1587,27 +1614,30 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1587
1614
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1588
1615
  goto done_with_error;
1589
1616
  }
1590
- if (call->received_initial_metadata) {
1617
+ if (received_initial_metadata_) {
1591
1618
  error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1592
1619
  goto done_with_error;
1593
1620
  }
1594
- call->received_initial_metadata = true;
1595
- call->buffered_metadata[0] =
1621
+ received_initial_metadata_ = true;
1622
+ buffered_metadata_[0] =
1596
1623
  op->data.recv_initial_metadata.recv_initial_metadata;
1597
- GRPC_CLOSURE_INIT(&call->receiving_initial_metadata_ready,
1598
- receiving_initial_metadata_ready, bctl,
1599
- grpc_schedule_on_exec_ctx);
1624
+ GRPC_CLOSURE_INIT(
1625
+ &receiving_initial_metadata_ready_,
1626
+ [](void* bctl, grpc_error_handle error) {
1627
+ static_cast<BatchControl*>(bctl)->ReceivingInitialMetadataReady(
1628
+ error);
1629
+ },
1630
+ bctl, grpc_schedule_on_exec_ctx);
1600
1631
  stream_op->recv_initial_metadata = true;
1601
1632
  stream_op_payload->recv_initial_metadata.recv_initial_metadata =
1602
- &call->recv_initial_metadata;
1633
+ &recv_initial_metadata_;
1603
1634
  stream_op_payload->recv_initial_metadata.recv_initial_metadata_ready =
1604
- &call->receiving_initial_metadata_ready;
1605
- if (call->is_client) {
1635
+ &receiving_initial_metadata_ready_;
1636
+ if (is_client()) {
1606
1637
  stream_op_payload->recv_initial_metadata.trailing_metadata_available =
1607
- &call->is_trailers_only;
1638
+ &is_trailers_only_;
1608
1639
  } else {
1609
- stream_op_payload->recv_initial_metadata.peer_string =
1610
- &call->peer_string;
1640
+ stream_op_payload->recv_initial_metadata.peer_string = &peer_string_;
1611
1641
  }
1612
1642
  ++num_recv_ops;
1613
1643
  break;
@@ -1618,21 +1648,30 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1618
1648
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1619
1649
  goto done_with_error;
1620
1650
  }
1621
- if (call->receiving_message) {
1651
+ if (receiving_message_) {
1622
1652
  error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1623
1653
  goto done_with_error;
1624
1654
  }
1625
- call->receiving_message = true;
1655
+ receiving_message_ = true;
1626
1656
  stream_op->recv_message = true;
1627
- call->receiving_buffer = op->data.recv_message.recv_message;
1628
- stream_op_payload->recv_message.recv_message = &call->receiving_stream;
1657
+ receiving_buffer_ = op->data.recv_message.recv_message;
1658
+ stream_op_payload->recv_message.recv_message = &receiving_stream_;
1629
1659
  stream_op_payload->recv_message.call_failed_before_recv_message =
1630
- &call->call_failed_before_recv_message;
1631
- GRPC_CLOSURE_INIT(&call->receiving_stream_ready,
1632
- receiving_stream_ready_in_call_combiner, bctl,
1633
- grpc_schedule_on_exec_ctx);
1660
+ &call_failed_before_recv_message_;
1661
+ GRPC_CLOSURE_INIT(
1662
+ &receiving_stream_ready_,
1663
+ [](void* bctlp, grpc_error_handle error) {
1664
+ auto* bctl = static_cast<BatchControl*>(bctlp);
1665
+ auto* call = bctl->call_;
1666
+ // Yields the call combiner before processing the received
1667
+ // message.
1668
+ GRPC_CALL_COMBINER_STOP(call->call_combiner(),
1669
+ "recv_message_ready");
1670
+ bctl->ReceivingStreamReady(error);
1671
+ },
1672
+ bctl, grpc_schedule_on_exec_ctx);
1634
1673
  stream_op_payload->recv_message.recv_message_ready =
1635
- &call->receiving_stream_ready;
1674
+ &receiving_stream_ready_;
1636
1675
  ++num_recv_ops;
1637
1676
  break;
1638
1677
  }
@@ -1642,32 +1681,36 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1642
1681
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1643
1682
  goto done_with_error;
1644
1683
  }
1645
- if (!call->is_client) {
1684
+ if (!is_client()) {
1646
1685
  error = GRPC_CALL_ERROR_NOT_ON_SERVER;
1647
1686
  goto done_with_error;
1648
1687
  }
1649
- if (call->requested_final_op) {
1688
+ if (requested_final_op_) {
1650
1689
  error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1651
1690
  goto done_with_error;
1652
1691
  }
1653
- call->requested_final_op = true;
1654
- call->buffered_metadata[1] =
1692
+ requested_final_op_ = true;
1693
+ buffered_metadata_[1] =
1655
1694
  op->data.recv_status_on_client.trailing_metadata;
1656
- call->final_op.client.status = op->data.recv_status_on_client.status;
1657
- call->final_op.client.status_details =
1695
+ final_op_.client.status = op->data.recv_status_on_client.status;
1696
+ final_op_.client.status_details =
1658
1697
  op->data.recv_status_on_client.status_details;
1659
- call->final_op.client.error_string =
1698
+ final_op_.client.error_string =
1660
1699
  op->data.recv_status_on_client.error_string;
1661
1700
  stream_op->recv_trailing_metadata = true;
1662
1701
  stream_op_payload->recv_trailing_metadata.recv_trailing_metadata =
1663
- &call->recv_trailing_metadata;
1702
+ &recv_trailing_metadata_;
1664
1703
  stream_op_payload->recv_trailing_metadata.collect_stats =
1665
- &call->final_info.stats.transport_stream_stats;
1666
- GRPC_CLOSURE_INIT(&call->receiving_trailing_metadata_ready,
1667
- receiving_trailing_metadata_ready, bctl,
1668
- grpc_schedule_on_exec_ctx);
1704
+ &final_info_.stats.transport_stream_stats;
1705
+ GRPC_CLOSURE_INIT(
1706
+ &receiving_trailing_metadata_ready_,
1707
+ [](void* bctl, grpc_error_handle error) {
1708
+ static_cast<BatchControl*>(bctl)->ReceivingTrailingMetadataReady(
1709
+ error);
1710
+ },
1711
+ bctl, grpc_schedule_on_exec_ctx);
1669
1712
  stream_op_payload->recv_trailing_metadata.recv_trailing_metadata_ready =
1670
- &call->receiving_trailing_metadata_ready;
1713
+ &receiving_trailing_metadata_ready_;
1671
1714
  ++num_recv_ops;
1672
1715
  break;
1673
1716
  }
@@ -1677,47 +1720,54 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
1677
1720
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1678
1721
  goto done_with_error;
1679
1722
  }
1680
- if (call->is_client) {
1723
+ if (is_client()) {
1681
1724
  error = GRPC_CALL_ERROR_NOT_ON_CLIENT;
1682
1725
  goto done_with_error;
1683
1726
  }
1684
- if (call->requested_final_op) {
1727
+ if (requested_final_op_) {
1685
1728
  error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
1686
1729
  goto done_with_error;
1687
1730
  }
1688
- call->requested_final_op = true;
1689
- call->final_op.server.cancelled =
1690
- op->data.recv_close_on_server.cancelled;
1731
+ requested_final_op_ = true;
1732
+ final_op_.server.cancelled = op->data.recv_close_on_server.cancelled;
1691
1733
  stream_op->recv_trailing_metadata = true;
1692
1734
  stream_op_payload->recv_trailing_metadata.recv_trailing_metadata =
1693
- &call->recv_trailing_metadata;
1735
+ &recv_trailing_metadata_;
1694
1736
  stream_op_payload->recv_trailing_metadata.collect_stats =
1695
- &call->final_info.stats.transport_stream_stats;
1696
- GRPC_CLOSURE_INIT(&call->receiving_trailing_metadata_ready,
1697
- receiving_trailing_metadata_ready, bctl,
1698
- grpc_schedule_on_exec_ctx);
1737
+ &final_info_.stats.transport_stream_stats;
1738
+ GRPC_CLOSURE_INIT(
1739
+ &receiving_trailing_metadata_ready_,
1740
+ [](void* bctl, grpc_error_handle error) {
1741
+ static_cast<BatchControl*>(bctl)->ReceivingTrailingMetadataReady(
1742
+ error);
1743
+ },
1744
+ bctl, grpc_schedule_on_exec_ctx);
1699
1745
  stream_op_payload->recv_trailing_metadata.recv_trailing_metadata_ready =
1700
- &call->receiving_trailing_metadata_ready;
1746
+ &receiving_trailing_metadata_ready_;
1701
1747
  ++num_recv_ops;
1702
1748
  break;
1703
1749
  }
1704
1750
  }
1705
1751
  }
1706
1752
 
1707
- GRPC_CALL_INTERNAL_REF(call, "completion");
1753
+ InternalRef("completion");
1708
1754
  if (!is_notify_tag_closure) {
1709
- GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag));
1755
+ GPR_ASSERT(grpc_cq_begin_op(cq_, notify_tag));
1710
1756
  }
1711
1757
  bctl->set_num_steps_to_complete((has_send_ops ? 1 : 0) + num_recv_ops);
1712
1758
 
1713
1759
  if (has_send_ops) {
1714
- GRPC_CLOSURE_INIT(&bctl->finish_batch, finish_batch, bctl,
1715
- grpc_schedule_on_exec_ctx);
1716
- stream_op->on_complete = &bctl->finish_batch;
1760
+ GRPC_CLOSURE_INIT(
1761
+ &bctl->finish_batch_,
1762
+ [](void* bctl, grpc_error_handle error) {
1763
+ static_cast<BatchControl*>(bctl)->FinishBatch(error);
1764
+ },
1765
+ bctl, grpc_schedule_on_exec_ctx);
1766
+ stream_op->on_complete = &bctl->finish_batch_;
1717
1767
  }
1718
1768
 
1719
- gpr_atm_rel_store(&call->any_ops_sent_atm, 1);
1720
- execute_batch(call, stream_op, &bctl->start_batch);
1769
+ gpr_atm_rel_store(&any_ops_sent_atm_, 1);
1770
+ ExecuteBatch(stream_op, &bctl->start_batch_);
1721
1771
 
1722
1772
  done:
1723
1773
  return error;
@@ -1725,87 +1775,172 @@ done:
1725
1775
  done_with_error:
1726
1776
  /* reverse any mutations that occurred */
1727
1777
  if (stream_op->send_initial_metadata) {
1728
- call->sent_initial_metadata = false;
1729
- call->send_initial_metadata.Clear();
1778
+ sent_initial_metadata_ = false;
1779
+ send_initial_metadata_.Clear();
1730
1780
  }
1731
1781
  if (stream_op->send_message) {
1732
- call->sending_message = false;
1782
+ sending_message_ = false;
1733
1783
  // No need to invoke call->sending_stream->Orphan() explicitly.
1734
1784
  // stream_op_payload->send_message.send_message.reset() calls Deletor
1735
1785
  // of call->sending_stream which in-turn invokes the Orphan() method.
1736
1786
  stream_op_payload->send_message.send_message.reset();
1737
1787
  }
1738
1788
  if (stream_op->send_trailing_metadata) {
1739
- call->sent_final_op = false;
1740
- call->send_trailing_metadata.Clear();
1789
+ sent_final_op_ = false;
1790
+ send_trailing_metadata_.Clear();
1741
1791
  }
1742
1792
  if (stream_op->recv_initial_metadata) {
1743
- call->received_initial_metadata = false;
1793
+ received_initial_metadata_ = false;
1744
1794
  }
1745
1795
  if (stream_op->recv_message) {
1746
- call->receiving_message = false;
1796
+ receiving_message_ = false;
1747
1797
  }
1748
1798
  if (stream_op->recv_trailing_metadata) {
1749
- call->requested_final_op = false;
1799
+ requested_final_op_ = false;
1750
1800
  }
1751
1801
  goto done;
1752
1802
  }
1753
1803
 
1804
+ void FilterStackCall::ContextSet(grpc_context_index elem, void* value,
1805
+ void (*destroy)(void*)) {
1806
+ if (context_[elem].destroy) {
1807
+ context_[elem].destroy(context_[elem].value);
1808
+ }
1809
+ context_[elem].value = value;
1810
+ context_[elem].destroy = destroy;
1811
+ }
1812
+
1813
+ } // namespace grpc_core
1814
+
1815
+ void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
1816
+ grpc_core::ExecCtx exec_ctx;
1817
+ return grpc_core::Call::FromC(call)->arena()->Alloc(size);
1818
+ }
1819
+
1820
+ size_t grpc_call_get_initial_size_estimate() {
1821
+ return grpc_core::FilterStackCall::InitialSizeEstimate();
1822
+ }
1823
+
1824
+ grpc_error_handle grpc_call_create(grpc_call_create_args* args,
1825
+ grpc_call** out_call) {
1826
+ return grpc_core::FilterStackCall::Create(args, out_call);
1827
+ }
1828
+
1829
+ void grpc_call_set_completion_queue(grpc_call* call,
1830
+ grpc_completion_queue* cq) {
1831
+ grpc_core::Call::FromC(call)->SetCompletionQueue(cq);
1832
+ }
1833
+
1834
+ void grpc_call_ref(grpc_call* c) { grpc_core::Call::FromC(c)->ExternalRef(); }
1835
+
1836
+ void grpc_call_unref(grpc_call* c) {
1837
+ grpc_core::Call::FromC(c)->ExternalUnref();
1838
+ }
1839
+
1840
+ char* grpc_call_get_peer(grpc_call* call) {
1841
+ return grpc_core::Call::FromC(call)->GetPeer();
1842
+ }
1843
+
1844
+ grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element) {
1845
+ return grpc_core::FilterStackCall::FromTopElem(surface_element)->c_ptr();
1846
+ }
1847
+
1848
+ grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
1849
+ GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
1850
+ GPR_ASSERT(reserved == nullptr);
1851
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
1852
+ grpc_core::ExecCtx exec_ctx;
1853
+ grpc_core::Call::FromC(call)->CancelWithError(GRPC_ERROR_CANCELLED);
1854
+ return GRPC_CALL_OK;
1855
+ }
1856
+
1857
+ grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
1858
+ grpc_status_code status,
1859
+ const char* description,
1860
+ void* reserved) {
1861
+ GRPC_API_TRACE(
1862
+ "grpc_call_cancel_with_status("
1863
+ "c=%p, status=%d, description=%s, reserved=%p)",
1864
+ 4, (c, (int)status, description, reserved));
1865
+ GPR_ASSERT(reserved == nullptr);
1866
+ grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
1867
+ grpc_core::ExecCtx exec_ctx;
1868
+ grpc_core::Call::FromC(c)->CancelWithStatus(status, description);
1869
+ return GRPC_CALL_OK;
1870
+ }
1871
+
1872
+ void grpc_call_cancel_internal(grpc_call* call) {
1873
+ grpc_core::Call::FromC(call)->CancelWithError(GRPC_ERROR_CANCELLED);
1874
+ }
1875
+
1876
+ grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
1877
+ grpc_call* call) {
1878
+ return grpc_core::Call::FromC(call)->test_only_compression_algorithm();
1879
+ }
1880
+
1881
+ uint32_t grpc_call_test_only_get_message_flags(grpc_call* call) {
1882
+ return grpc_core::Call::FromC(call)->test_only_message_flags();
1883
+ }
1884
+
1885
+ uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call) {
1886
+ return grpc_core::Call::FromC(call)->test_only_encodings_accepted_by_peer();
1887
+ }
1888
+
1889
+ grpc_core::Arena* grpc_call_get_arena(grpc_call* call) {
1890
+ return grpc_core::Call::FromC(call)->arena();
1891
+ }
1892
+
1893
+ grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
1894
+ return grpc_core::Call::FromC(call)->call_stack();
1895
+ }
1896
+
1754
1897
  grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
1755
1898
  size_t nops, void* tag, void* reserved) {
1756
- grpc_call_error err;
1757
-
1758
1899
  GRPC_API_TRACE(
1759
1900
  "grpc_call_start_batch(call=%p, ops=%p, nops=%lu, tag=%p, "
1760
1901
  "reserved=%p)",
1761
1902
  5, (call, ops, (unsigned long)nops, tag, reserved));
1762
1903
 
1763
1904
  if (reserved != nullptr) {
1764
- err = GRPC_CALL_ERROR;
1905
+ return GRPC_CALL_ERROR;
1765
1906
  } else {
1766
1907
  grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
1767
1908
  grpc_core::ExecCtx exec_ctx;
1768
- err = call_start_batch(call, ops, nops, tag, 0);
1909
+ return grpc_core::Call::FromC(call)->StartBatch(ops, nops, tag, false);
1769
1910
  }
1770
-
1771
- return err;
1772
1911
  }
1773
1912
 
1774
1913
  grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call,
1775
1914
  const grpc_op* ops,
1776
1915
  size_t nops,
1777
1916
  grpc_closure* closure) {
1778
- return call_start_batch(call, ops, nops, closure, 1);
1917
+ return grpc_core::Call::FromC(call)->StartBatch(ops, nops, closure, true);
1779
1918
  }
1780
1919
 
1781
1920
  void grpc_call_context_set(grpc_call* call, grpc_context_index elem,
1782
1921
  void* value, void (*destroy)(void* value)) {
1783
- if (call->context[elem].destroy) {
1784
- call->context[elem].destroy(call->context[elem].value);
1785
- }
1786
- call->context[elem].value = value;
1787
- call->context[elem].destroy = destroy;
1922
+ return grpc_core::Call::FromC(call)->ContextSet(elem, value, destroy);
1788
1923
  }
1789
1924
 
1790
1925
  void* grpc_call_context_get(grpc_call* call, grpc_context_index elem) {
1791
- return call->context[elem].value;
1926
+ return grpc_core::Call::FromC(call)->ContextGet(elem);
1792
1927
  }
1793
1928
 
1794
- uint8_t grpc_call_is_client(grpc_call* call) { return call->is_client; }
1929
+ uint8_t grpc_call_is_client(grpc_call* call) {
1930
+ return grpc_core::Call::FromC(call)->is_client();
1931
+ }
1795
1932
 
1796
1933
  grpc_compression_algorithm grpc_call_compression_for_level(
1797
1934
  grpc_call* call, grpc_compression_level level) {
1798
- return call->encodings_accepted_by_peer.CompressionAlgorithmForLevel(level);
1935
+ return grpc_core::Call::FromC(call)->compression_for_level(level);
1799
1936
  }
1800
1937
 
1801
1938
  bool grpc_call_is_trailers_only(const grpc_call* call) {
1802
- bool result = call->is_trailers_only;
1803
- GPR_DEBUG_ASSERT(!result || call->recv_initial_metadata.empty());
1804
- return result;
1939
+ return grpc_core::Call::FromC(call)->is_trailers_only();
1805
1940
  }
1806
1941
 
1807
1942
  int grpc_call_failed_before_recv_message(const grpc_call* c) {
1808
- return c->call_failed_before_recv_message;
1943
+ return grpc_core::Call::FromC(c)->failed_before_recv_message();
1809
1944
  }
1810
1945
 
1811
1946
  const char* grpc_call_error_to_string(grpc_call_error error) {