grpc 1.47.0 → 1.53.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 (1777) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +386 -162
  3. data/include/grpc/byte_buffer.h +76 -1
  4. data/include/grpc/byte_buffer_reader.h +19 -1
  5. data/include/grpc/compression.h +2 -2
  6. data/include/grpc/event_engine/endpoint_config.h +11 -5
  7. data/include/grpc/event_engine/event_engine.h +87 -32
  8. data/include/grpc/event_engine/internal/memory_allocator_impl.h +1 -1
  9. data/include/grpc/event_engine/internal/slice_cast.h +67 -0
  10. data/include/grpc/event_engine/memory_allocator.h +1 -1
  11. data/include/grpc/event_engine/slice.h +24 -4
  12. data/include/grpc/event_engine/slice_buffer.h +52 -5
  13. data/include/grpc/fork.h +25 -1
  14. data/include/grpc/grpc.h +4 -14
  15. data/include/grpc/grpc_posix.h +1 -1
  16. data/include/grpc/impl/codegen/atm.h +3 -71
  17. data/include/grpc/impl/codegen/atm_gcc_atomic.h +3 -67
  18. data/include/grpc/impl/codegen/atm_gcc_sync.h +3 -61
  19. data/include/grpc/impl/codegen/atm_windows.h +3 -108
  20. data/include/grpc/impl/codegen/byte_buffer.h +4 -78
  21. data/include/grpc/impl/codegen/byte_buffer_reader.h +4 -19
  22. data/include/grpc/impl/codegen/compression_types.h +5 -83
  23. data/include/grpc/impl/codegen/connectivity_state.h +5 -21
  24. data/include/grpc/impl/codegen/fork.h +4 -25
  25. data/include/grpc/impl/codegen/gpr_types.h +4 -35
  26. data/include/grpc/impl/codegen/grpc_types.h +5 -791
  27. data/include/grpc/impl/codegen/log.h +3 -86
  28. data/include/grpc/impl/codegen/port_platform.h +3 -763
  29. data/include/grpc/impl/codegen/propagation_bits.h +3 -28
  30. data/include/grpc/impl/codegen/slice.h +3 -106
  31. data/include/grpc/impl/codegen/status.h +4 -131
  32. data/include/grpc/impl/codegen/sync.h +3 -42
  33. data/include/grpc/impl/codegen/sync_abseil.h +3 -12
  34. data/include/grpc/impl/codegen/sync_custom.h +3 -14
  35. data/include/grpc/impl/codegen/sync_generic.h +3 -25
  36. data/include/grpc/impl/codegen/sync_posix.h +3 -28
  37. data/include/grpc/impl/codegen/sync_windows.h +3 -16
  38. data/include/grpc/impl/compression_types.h +109 -0
  39. data/include/grpc/impl/connectivity_state.h +47 -0
  40. data/include/grpc/impl/grpc_types.h +827 -0
  41. data/include/grpc/impl/propagation_bits.h +54 -0
  42. data/include/grpc/impl/slice_type.h +112 -0
  43. data/include/grpc/load_reporting.h +1 -1
  44. data/include/grpc/module.modulemap +5 -1
  45. data/include/grpc/slice.h +1 -1
  46. data/include/grpc/status.h +131 -1
  47. data/include/grpc/support/atm.h +70 -1
  48. data/include/grpc/support/atm_gcc_atomic.h +59 -1
  49. data/include/grpc/support/atm_gcc_sync.h +58 -1
  50. data/include/grpc/support/atm_windows.h +105 -1
  51. data/include/grpc/support/log.h +87 -1
  52. data/include/grpc/support/log_windows.h +1 -1
  53. data/include/grpc/support/port_platform.h +767 -1
  54. data/include/grpc/support/string_util.h +1 -1
  55. data/include/grpc/support/sync.h +35 -2
  56. data/include/grpc/support/sync_abseil.h +11 -1
  57. data/include/grpc/support/sync_custom.h +13 -1
  58. data/include/grpc/support/sync_generic.h +24 -1
  59. data/include/grpc/support/sync_posix.h +27 -1
  60. data/include/grpc/support/sync_windows.h +15 -1
  61. data/include/grpc/support/time.h +31 -6
  62. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +148 -0
  63. data/src/core/ext/filters/backend_metrics/backend_metric_filter.h +52 -0
  64. data/src/core/ext/filters/backend_metrics/backend_metric_provider.h +29 -0
  65. data/src/core/ext/filters/census/grpc_context.cc +19 -17
  66. data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +49 -31
  67. data/src/core/ext/filters/channel_idle/channel_idle_filter.h +22 -5
  68. data/src/core/ext/filters/channel_idle/idle_filter_state.h +6 -4
  69. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -0
  70. data/src/core/ext/filters/client_channel/backend_metric.h +3 -3
  71. data/src/core/ext/filters/client_channel/backup_poller.cc +30 -30
  72. data/src/core/ext/filters/client_channel/backup_poller.h +24 -24
  73. data/src/core/ext/filters/client_channel/channel_connectivity.cc +52 -29
  74. data/src/core/ext/filters/client_channel/client_channel.cc +348 -441
  75. data/src/core/ext/filters/client_channel/client_channel.h +46 -24
  76. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +17 -19
  77. data/src/core/ext/filters/client_channel/client_channel_channelz.h +22 -22
  78. data/src/core/ext/filters/client_channel/client_channel_factory.cc +17 -46
  79. data/src/core/ext/filters/client_channel/client_channel_factory.h +5 -13
  80. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +18 -34
  81. data/src/core/ext/filters/client_channel/client_channel_service_config.cc +153 -0
  82. data/src/core/ext/filters/client_channel/{resolver_result_parsing.h → client_channel_service_config.h} +26 -26
  83. data/src/core/ext/filters/client_channel/config_selector.h +27 -23
  84. data/src/core/ext/filters/client_channel/connector.h +13 -10
  85. data/src/core/ext/filters/client_channel/dynamic_filters.cc +29 -54
  86. data/src/core/ext/filters/client_channel/dynamic_filters.h +10 -11
  87. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +21 -21
  88. data/src/core/ext/filters/client_channel/health/health_check_client.cc +4 -5
  89. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  90. data/src/core/ext/filters/client_channel/http_proxy.cc +90 -110
  91. data/src/core/ext/filters/client_channel/http_proxy.h +36 -32
  92. data/src/core/ext/filters/client_channel/lb_call_state_internal.h +39 -0
  93. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -5
  94. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +3 -3
  95. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +21 -21
  96. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +27 -18
  97. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +14 -14
  98. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +66 -132
  99. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +41 -24
  100. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +361 -366
  101. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +26 -27
  102. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +12 -4
  103. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +9 -7
  104. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +18 -20
  105. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +21 -22
  106. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +19 -19
  107. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +22 -24
  108. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +28 -98
  109. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.h +5 -5
  110. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric_internal.h +117 -0
  111. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +418 -327
  112. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +46 -6
  113. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +140 -154
  114. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +304 -387
  115. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +388 -363
  116. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +19 -11
  117. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +578 -628
  118. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +154 -138
  119. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +134 -115
  120. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +128 -0
  121. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.h +71 -0
  122. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +972 -0
  123. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +202 -224
  124. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +124 -139
  125. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.cc +42 -0
  126. data/src/core/ext/filters/client_channel/lb_policy/xds/{xds.h → xds_attributes.h} +15 -17
  127. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +3 -3
  128. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +154 -258
  129. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +183 -214
  130. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +361 -411
  131. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +819 -0
  132. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.h +67 -0
  133. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +369 -0
  134. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +21 -21
  135. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +15 -18
  136. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +452 -175
  137. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +42 -43
  138. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +22 -23
  139. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +88 -83
  140. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +276 -202
  141. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +69 -57
  142. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +18 -18
  143. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +18 -18
  144. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +20 -21
  145. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +32 -23
  146. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +9 -21
  147. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +15 -4
  148. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +83 -57
  149. data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +123 -67
  150. data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +25 -17
  151. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +9 -19
  152. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +293 -286
  153. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +6 -4
  154. data/src/core/ext/filters/client_channel/retry_filter.cc +135 -172
  155. data/src/core/ext/filters/client_channel/retry_filter.h +4 -3
  156. data/src/core/ext/filters/client_channel/retry_service_config.cc +193 -224
  157. data/src/core/ext/filters/client_channel/retry_service_config.h +22 -28
  158. data/src/core/ext/filters/client_channel/retry_throttle.cc +27 -29
  159. data/src/core/ext/filters/client_channel/retry_throttle.h +29 -28
  160. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +13 -13
  161. data/src/core/ext/filters/client_channel/subchannel.cc +275 -323
  162. data/src/core/ext/filters/client_channel/subchannel.h +45 -75
  163. data/src/core/ext/filters/client_channel/subchannel_interface_internal.h +4 -4
  164. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +6 -76
  165. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +37 -46
  166. data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +23 -111
  167. data/src/core/ext/filters/client_channel/subchannel_stream_client.h +8 -12
  168. data/src/core/ext/filters/deadline/deadline_filter.cc +90 -76
  169. data/src/core/ext/filters/deadline/deadline_filter.h +14 -12
  170. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +43 -18
  171. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +20 -11
  172. data/src/core/ext/filters/fault_injection/fault_injection_service_config_parser.cc +118 -0
  173. data/src/core/ext/filters/fault_injection/{service_config_parser.h → fault_injection_service_config_parser.h} +34 -13
  174. data/src/core/ext/filters/http/client/http_client_filter.cc +61 -48
  175. data/src/core/ext/filters/http/client/http_client_filter.h +29 -22
  176. data/src/core/ext/filters/http/client_authority_filter.cc +28 -28
  177. data/src/core/ext/filters/http/client_authority_filter.h +27 -24
  178. data/src/core/ext/filters/http/http_filters_plugin.cc +43 -51
  179. data/src/core/ext/filters/http/message_compress/compression_filter.cc +307 -0
  180. data/src/core/ext/filters/http/message_compress/compression_filter.h +139 -0
  181. data/src/core/ext/filters/http/server/http_server_filter.cc +63 -56
  182. data/src/core/ext/filters/http/server/http_server_filter.h +28 -23
  183. data/src/core/ext/filters/message_size/message_size_filter.cc +109 -123
  184. data/src/core/ext/filters/message_size/message_size_filter.h +34 -17
  185. data/src/core/ext/filters/rbac/rbac_filter.cc +28 -16
  186. data/src/core/ext/filters/rbac/rbac_filter.h +11 -3
  187. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +736 -523
  188. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +18 -7
  189. data/src/core/ext/filters/server_config_selector/server_config_selector.h +20 -8
  190. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +28 -12
  191. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.h +4 -3
  192. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +219 -0
  193. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +66 -0
  194. data/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc +82 -0
  195. data/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h +93 -0
  196. data/src/core/ext/transport/chttp2/alpn/alpn.cc +18 -18
  197. data/src/core/ext/transport/chttp2/alpn/alpn.h +24 -24
  198. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +109 -131
  199. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +30 -24
  200. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +167 -203
  201. data/src/core/ext/transport/chttp2/server/chttp2_server.h +25 -27
  202. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +22 -22
  203. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +33 -33
  204. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +30 -30
  205. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +29 -29
  206. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +714 -1060
  207. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +24 -24
  208. data/src/core/ext/transport/chttp2/transport/context_list.cc +19 -19
  209. data/src/core/ext/transport/chttp2/transport/context_list.h +28 -28
  210. data/src/core/ext/transport/chttp2/transport/decode_huff.cc +251 -0
  211. data/src/core/ext/transport/chttp2/transport/decode_huff.h +971 -0
  212. data/src/core/ext/transport/chttp2/transport/flow_control.cc +347 -301
  213. data/src/core/ext/transport/chttp2/transport/flow_control.h +245 -326
  214. data/src/core/ext/transport/chttp2/transport/frame.h +21 -21
  215. data/src/core/ext/transport/chttp2/transport/frame_data.cc +84 -239
  216. data/src/core/ext/transport/chttp2/transport/frame_data.h +36 -62
  217. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +38 -36
  218. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +20 -20
  219. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +27 -26
  220. data/src/core/ext/transport/chttp2/transport/frame_ping.h +22 -22
  221. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +30 -25
  222. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +21 -21
  223. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +35 -77
  224. data/src/core/ext/transport/chttp2/transport/frame_settings.h +22 -22
  225. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +31 -33
  226. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +21 -21
  227. data/src/core/ext/transport/chttp2/transport/hpack_constants.h +10 -4
  228. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +159 -208
  229. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +46 -61
  230. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +2 -2
  231. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +11 -5
  232. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +96 -542
  233. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +23 -23
  234. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +28 -38
  235. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +32 -27
  236. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +21 -19
  237. data/src/core/ext/transport/chttp2/transport/http2_settings.h +39 -37
  238. data/src/core/ext/transport/chttp2/transport/http_trace.cc +19 -0
  239. data/src/core/ext/transport/chttp2/transport/http_trace.h +24 -0
  240. data/src/core/ext/transport/chttp2/transport/huffsyms.cc +20 -20
  241. data/src/core/ext/transport/chttp2/transport/huffsyms.h +21 -21
  242. data/src/core/ext/transport/chttp2/transport/internal.h +225 -296
  243. data/src/core/ext/transport/chttp2/transport/parsing.cc +333 -129
  244. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +19 -23
  245. data/src/core/ext/transport/chttp2/transport/stream_map.cc +23 -23
  246. data/src/core/ext/transport/chttp2/transport/stream_map.h +33 -33
  247. data/src/core/ext/transport/chttp2/transport/varint.cc +19 -20
  248. data/src/core/ext/transport/chttp2/transport/varint.h +37 -34
  249. data/src/core/ext/transport/chttp2/transport/writing.cc +85 -94
  250. data/src/core/ext/transport/inproc/inproc_plugin.cc +17 -18
  251. data/src/core/ext/transport/inproc/inproc_transport.cc +223 -273
  252. data/src/core/ext/transport/inproc/inproc_transport.h +23 -21
  253. data/src/core/ext/upb-generated/envoy/admin/v3/certs.upb.c +5 -5
  254. data/src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h +30 -10
  255. data/src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.c +6 -5
  256. data/src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.h +33 -8
  257. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +8 -327
  258. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +83 -1723
  259. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump_shared.upb.c +388 -0
  260. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump_shared.upb.h +1953 -0
  261. data/src/core/ext/upb-generated/envoy/admin/v3/init_dump.upb.c +2 -2
  262. data/src/core/ext/upb-generated/envoy/admin/v3/init_dump.upb.h +12 -4
  263. data/src/core/ext/upb-generated/envoy/admin/v3/listeners.upb.c +6 -4
  264. data/src/core/ext/upb-generated/envoy/admin/v3/listeners.upb.h +33 -4
  265. data/src/core/ext/upb-generated/envoy/admin/v3/memory.upb.c +1 -1
  266. data/src/core/ext/upb-generated/envoy/admin/v3/memory.upb.h +6 -2
  267. data/src/core/ext/upb-generated/envoy/admin/v3/metrics.upb.c +1 -1
  268. data/src/core/ext/upb-generated/envoy/admin/v3/metrics.upb.h +6 -2
  269. data/src/core/ext/upb-generated/envoy/admin/v3/mutex_stats.upb.h +6 -2
  270. data/src/core/ext/upb-generated/envoy/admin/v3/server_info.upb.h +12 -4
  271. data/src/core/ext/upb-generated/envoy/admin/v3/tap.upb.c +1 -1
  272. data/src/core/ext/upb-generated/envoy/admin/v3/tap.upb.h +6 -2
  273. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +1 -1
  274. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +7 -3
  275. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +14 -14
  276. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +90 -30
  277. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +25 -19
  278. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +168 -34
  279. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +3 -3
  280. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +18 -6
  281. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -43
  282. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +195 -116
  283. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +1 -1
  284. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +6 -2
  285. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +1 -1
  286. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +6 -2
  287. data/src/core/ext/upb-generated/envoy/config/common/matcher/v3/matcher.upb.c +11 -11
  288. data/src/core/ext/upb-generated/envoy/config/common/matcher/v3/matcher.upb.h +84 -28
  289. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +35 -12
  290. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +179 -14
  291. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +1 -1
  292. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +6 -2
  293. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +25 -23
  294. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +156 -48
  295. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +7 -7
  296. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +42 -14
  297. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +1 -1
  298. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +6 -2
  299. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +1 -1
  300. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +6 -2
  301. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_method_list.upb.c +2 -2
  302. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_method_list.upb.h +12 -4
  303. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +12 -12
  304. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +78 -26
  305. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +23 -20
  306. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +137 -69
  307. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +1 -1
  308. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +6 -2
  309. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +23 -21
  310. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +132 -44
  311. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +1 -1
  312. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +6 -2
  313. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +2 -2
  314. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +12 -4
  315. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +17 -2
  316. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +67 -2
  317. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -1
  318. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +6 -2
  319. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +1 -1
  320. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +6 -2
  321. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +3 -3
  322. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +18 -6
  323. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +15 -9
  324. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +73 -18
  325. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +3 -3
  326. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +30 -10
  327. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +1 -1
  328. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +6 -2
  329. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +39 -13
  330. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +194 -15
  331. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +5 -5
  332. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +42 -14
  333. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +5 -3
  334. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +28 -2
  335. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +7 -4
  336. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +36 -4
  337. data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.c +1 -1
  338. data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.h +6 -2
  339. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +6 -6
  340. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +48 -16
  341. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +8 -8
  342. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +54 -18
  343. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +26 -11
  344. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +124 -14
  345. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +19 -15
  346. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +78 -69
  347. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +168 -82
  348. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +887 -166
  349. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +3 -3
  350. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +18 -6
  351. data/src/core/ext/upb-generated/envoy/config/tap/v3/common.upb.c +34 -15
  352. data/src/core/ext/upb-generated/envoy/config/tap/v3/common.upb.h +161 -22
  353. data/src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.c +3 -2
  354. data/src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.h +15 -2
  355. data/src/core/ext/upb-generated/envoy/config/trace/v3/dynamic_ot.upb.c +1 -1
  356. data/src/core/ext/upb-generated/envoy/config/trace/v3/dynamic_ot.upb.h +6 -2
  357. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +2 -2
  358. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +12 -4
  359. data/src/core/ext/upb-generated/envoy/config/trace/v3/lightstep.upb.c +1 -1
  360. data/src/core/ext/upb-generated/envoy/config/trace/v3/lightstep.upb.h +6 -2
  361. data/src/core/ext/upb-generated/envoy/config/trace/v3/opencensus.upb.c +1 -1
  362. data/src/core/ext/upb-generated/envoy/config/trace/v3/opencensus.upb.h +6 -2
  363. data/src/core/ext/upb-generated/envoy/config/trace/v3/opentelemetry.upb.c +47 -0
  364. data/src/core/ext/upb-generated/envoy/config/trace/v3/opentelemetry.upb.h +107 -0
  365. data/src/core/ext/upb-generated/envoy/config/trace/v3/service.upb.c +1 -1
  366. data/src/core/ext/upb-generated/envoy/config/trace/v3/service.upb.h +6 -2
  367. data/src/core/ext/upb-generated/envoy/config/trace/v3/skywalking.upb.c +2 -2
  368. data/src/core/ext/upb-generated/envoy/config/trace/v3/skywalking.upb.h +12 -4
  369. data/src/core/ext/upb-generated/envoy/config/trace/v3/trace.upb.c +1 -0
  370. data/src/core/ext/upb-generated/envoy/config/trace/v3/trace.upb.h +1 -0
  371. data/src/core/ext/upb-generated/envoy/config/trace/v3/xray.upb.c +2 -2
  372. data/src/core/ext/upb-generated/envoy/config/trace/v3/xray.upb.h +12 -4
  373. data/src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.c +7 -6
  374. data/src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.h +27 -14
  375. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +1 -1
  376. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +6 -2
  377. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +2 -2
  378. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +30 -10
  379. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +2 -2
  380. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +18 -6
  381. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +11 -4
  382. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +58 -4
  383. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -3
  384. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +29 -2
  385. data/src/core/ext/upb-generated/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb.c +62 -0
  386. data/src/core/ext/upb-generated/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upb.h +179 -0
  387. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +38 -27
  388. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +207 -52
  389. data/src/core/ext/upb-generated/envoy/extensions/http/stateful_session/cookie/v3/cookie.upb.c +46 -0
  390. data/src/core/ext/upb-generated/envoy/extensions/http/stateful_session/cookie/v3/cookie.upb.h +98 -0
  391. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.c +54 -0
  392. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h +188 -0
  393. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/common/v3/common.upb.c +111 -0
  394. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/common/v3/common.upb.h +444 -0
  395. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.c +56 -0
  396. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.h +192 -0
  397. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/wrr_locality/v3/wrr_locality.upb.c +46 -0
  398. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/wrr_locality/v3/wrr_locality.upb.h +98 -0
  399. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +10 -8
  400. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +66 -14
  401. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +3 -3
  402. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +18 -6
  403. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +13 -11
  404. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +73 -23
  405. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.c +2 -2
  406. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.h +12 -4
  407. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +1 -1
  408. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +6 -2
  409. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +133 -16
  410. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +656 -12
  411. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +2 -2
  412. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +12 -4
  413. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +5 -5
  414. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +30 -10
  415. data/src/core/ext/upb-generated/envoy/type/http/v3/cookie.upb.c +1 -1
  416. data/src/core/ext/upb-generated/envoy/type/http/v3/cookie.upb.h +6 -2
  417. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +4 -4
  418. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +24 -8
  419. data/src/core/ext/upb-generated/envoy/type/matcher/v3/filter_state.upb.c +47 -0
  420. data/src/core/ext/upb-generated/envoy/type/matcher/v3/filter_state.upb.h +113 -0
  421. data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.c +4 -4
  422. data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.h +24 -8
  423. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +2 -2
  424. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +12 -4
  425. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +1 -1
  426. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +6 -2
  427. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +1 -1
  428. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +6 -2
  429. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +1 -1
  430. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +6 -2
  431. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +3 -3
  432. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +18 -6
  433. data/src/core/ext/upb-generated/envoy/type/matcher/v3/status_code_input.upb.c +43 -0
  434. data/src/core/ext/upb-generated/envoy/type/matcher/v3/status_code_input.upb.h +114 -0
  435. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +1 -1
  436. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +12 -4
  437. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +2 -2
  438. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +12 -4
  439. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +3 -3
  440. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +18 -6
  441. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +7 -7
  442. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +42 -14
  443. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +5 -5
  444. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +30 -10
  445. data/src/core/ext/upb-generated/envoy/type/v3/hash_policy.upb.c +3 -3
  446. data/src/core/ext/upb-generated/envoy/type/v3/hash_policy.upb.h +18 -6
  447. data/src/core/ext/upb-generated/envoy/type/v3/http_status.upb.c +1 -1
  448. data/src/core/ext/upb-generated/envoy/type/v3/http_status.upb.h +6 -2
  449. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +12 -4
  450. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +2 -2
  451. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +18 -6
  452. data/src/core/ext/upb-generated/envoy/type/v3/ratelimit_strategy.upb.c +63 -0
  453. data/src/core/ext/upb-generated/envoy/type/v3/ratelimit_strategy.upb.h +202 -0
  454. data/src/core/ext/upb-generated/envoy/type/v3/ratelimit_unit.upb.h +3 -1
  455. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +1 -1
  456. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +6 -2
  457. data/src/core/ext/upb-generated/envoy/type/v3/token_bucket.upb.h +6 -2
  458. data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -1
  459. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +11 -11
  460. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +66 -22
  461. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +9 -9
  462. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +72 -24
  463. data/src/core/ext/upb-generated/google/api/http.upb.c +3 -3
  464. data/src/core/ext/upb-generated/google/api/http.upb.h +18 -6
  465. data/src/core/ext/upb-generated/google/api/httpbody.upb.c +1 -1
  466. data/src/core/ext/upb-generated/google/api/httpbody.upb.h +6 -2
  467. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +1 -1
  468. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +6 -2
  469. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +44 -43
  470. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +177 -55
  471. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +1 -1
  472. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +6 -2
  473. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +1 -1
  474. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +6 -2
  475. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +2 -2
  476. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +18 -6
  477. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +1 -1
  478. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +6 -2
  479. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +6 -6
  480. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +54 -18
  481. data/src/core/ext/upb-generated/google/rpc/status.upb.c +1 -1
  482. data/src/core/ext/upb-generated/google/rpc/status.upb.h +6 -2
  483. data/src/core/ext/upb-generated/opencensus/proto/trace/v1/trace_config.upb.c +2 -2
  484. data/src/core/ext/upb-generated/opencensus/proto/trace/v1/trace_config.upb.h +24 -8
  485. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +6 -2
  486. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +7 -7
  487. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +60 -20
  488. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +1 -1
  489. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +12 -4
  490. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +2 -2
  491. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +12 -4
  492. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +6 -6
  493. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +54 -18
  494. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c +2 -2
  495. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.h +12 -4
  496. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls_config.upb.c +7 -7
  497. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls_config.upb.h +42 -14
  498. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +3 -3
  499. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +23 -11
  500. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +1 -1
  501. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +7 -3
  502. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +7 -3
  503. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +1 -1
  504. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +7 -3
  505. data/src/core/ext/upb-generated/validate/validate.upb.c +22 -22
  506. data/src/core/ext/upb-generated/validate/validate.upb.h +139 -47
  507. data/src/core/ext/upb-generated/xds/annotations/v3/migrate.upb.c +3 -3
  508. data/src/core/ext/upb-generated/xds/annotations/v3/migrate.upb.h +23 -11
  509. data/src/core/ext/upb-generated/xds/annotations/v3/security.upb.c +1 -1
  510. data/src/core/ext/upb-generated/xds/annotations/v3/security.upb.h +7 -3
  511. data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.c +3 -3
  512. data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.h +27 -11
  513. data/src/core/ext/upb-generated/xds/annotations/v3/versioning.upb.c +1 -1
  514. data/src/core/ext/upb-generated/xds/annotations/v3/versioning.upb.h +7 -3
  515. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +1 -1
  516. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +6 -2
  517. data/src/core/ext/upb-generated/xds/core/v3/cidr.upb.c +47 -0
  518. data/src/core/ext/upb-generated/xds/core/v3/cidr.upb.h +107 -0
  519. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +2 -2
  520. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +12 -4
  521. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +1 -1
  522. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +6 -2
  523. data/src/core/ext/upb-generated/xds/core/v3/extension.upb.c +1 -1
  524. data/src/core/ext/upb-generated/xds/core/v3/extension.upb.h +6 -2
  525. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +1 -1
  526. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +6 -2
  527. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +1 -1
  528. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +12 -4
  529. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +1 -1
  530. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +6 -2
  531. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +3 -2
  532. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +15 -2
  533. data/src/core/ext/upb-generated/xds/service/orca/v3/orca.upb.c +1 -2
  534. data/src/core/ext/upb-generated/xds/service/orca/v3/orca.upb.h +6 -2
  535. data/src/core/ext/upb-generated/xds/type/matcher/v3/cel.upb.c +46 -0
  536. data/src/core/ext/upb-generated/xds/type/matcher/v3/cel.upb.h +98 -0
  537. data/src/core/ext/upb-generated/xds/type/matcher/v3/domain.upb.c +62 -0
  538. data/src/core/ext/upb-generated/xds/type/matcher/v3/domain.upb.h +174 -0
  539. data/src/core/ext/upb-generated/xds/type/matcher/v3/http_inputs.upb.c +36 -0
  540. data/src/core/ext/upb-generated/xds/type/matcher/v3/http_inputs.upb.h +74 -0
  541. data/src/core/ext/upb-generated/xds/type/matcher/v3/ip.upb.c +65 -0
  542. data/src/core/ext/upb-generated/xds/type/matcher/v3/ip.upb.h +191 -0
  543. data/src/core/ext/upb-generated/xds/type/matcher/v3/matcher.upb.c +6 -6
  544. data/src/core/ext/upb-generated/xds/type/matcher/v3/matcher.upb.h +54 -18
  545. data/src/core/ext/upb-generated/xds/type/matcher/v3/range.upb.c +127 -0
  546. data/src/core/ext/upb-generated/xds/type/matcher/v3/range.upb.h +474 -0
  547. data/src/core/ext/upb-generated/xds/type/matcher/v3/regex.upb.c +2 -2
  548. data/src/core/ext/upb-generated/xds/type/matcher/v3/regex.upb.h +12 -4
  549. data/src/core/ext/upb-generated/xds/type/matcher/v3/string.upb.c +1 -1
  550. data/src/core/ext/upb-generated/xds/type/matcher/v3/string.upb.h +12 -4
  551. data/src/core/ext/upb-generated/xds/type/v3/cel.upb.c +67 -0
  552. data/src/core/ext/upb-generated/xds/type/v3/cel.upb.h +214 -0
  553. data/src/core/ext/upb-generated/xds/type/v3/range.upb.c +64 -0
  554. data/src/core/ext/upb-generated/xds/type/v3/range.upb.h +208 -0
  555. data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.c +1 -2
  556. data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.h +6 -2
  557. data/src/core/ext/upbdefs-generated/envoy/admin/v3/clusters.upbdefs.c +54 -53
  558. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +67 -274
  559. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.h +0 -85
  560. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump_shared.upbdefs.c +277 -0
  561. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump_shared.upbdefs.h +125 -0
  562. data/src/core/ext/upbdefs-generated/envoy/admin/v3/listeners.upbdefs.c +14 -11
  563. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +107 -107
  564. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +199 -187
  565. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +232 -222
  566. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +0 -5
  567. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c +95 -75
  568. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.h +5 -0
  569. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +187 -183
  570. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +81 -75
  571. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +190 -186
  572. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c +7 -3
  573. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.h +5 -0
  574. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +16 -16
  575. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +71 -66
  576. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +164 -137
  577. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
  578. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +16 -12
  579. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +39 -31
  580. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +140 -129
  581. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +5 -0
  582. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +82 -74
  583. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +2 -2
  584. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +740 -667
  585. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +20 -0
  586. data/src/core/ext/upbdefs-generated/envoy/config/tap/v3/common.upbdefs.c +150 -139
  587. data/src/core/ext/upbdefs-generated/envoy/config/tap/v3/common.upbdefs.h +5 -0
  588. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/datadog.upbdefs.c +16 -14
  589. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/opentelemetry.upbdefs.c +48 -0
  590. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/opentelemetry.upbdefs.h +35 -0
  591. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/trace.upbdefs.c +16 -12
  592. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/zipkin.upbdefs.c +20 -18
  593. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +46 -25
  594. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +53 -42
  595. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upbdefs.c +60 -0
  596. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/stateful_session/v3/stateful_session.upbdefs.h +40 -0
  597. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +485 -467
  598. data/src/core/ext/upbdefs-generated/envoy/extensions/http/stateful_session/cookie/v3/cookie.upbdefs.c +50 -0
  599. data/src/core/ext/upbdefs-generated/envoy/extensions/http/stateful_session/cookie/v3/cookie.upbdefs.h +35 -0
  600. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +21 -18
  601. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +149 -145
  602. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +156 -84
  603. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.h +35 -0
  604. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +113 -113
  605. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/filter_state.upbdefs.c +48 -0
  606. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/filter_state.upbdefs.h +35 -0
  607. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +29 -28
  608. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/status_code_input.upbdefs.c +40 -0
  609. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/status_code_input.upbdefs.h +40 -0
  610. data/src/core/ext/upbdefs-generated/envoy/type/v3/ratelimit_strategy.upbdefs.c +69 -0
  611. data/src/core/ext/upbdefs-generated/envoy/type/v3/ratelimit_strategy.upbdefs.h +40 -0
  612. data/src/core/ext/upbdefs-generated/envoy/type/v3/ratelimit_unit.upbdefs.c +10 -9
  613. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +92 -90
  614. data/src/core/ext/upbdefs-generated/xds/core/v3/cidr.upbdefs.c +45 -0
  615. data/src/core/ext/upbdefs-generated/xds/core/v3/cidr.upbdefs.h +35 -0
  616. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/cel.upbdefs.c +43 -0
  617. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/cel.upbdefs.h +35 -0
  618. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/domain.upbdefs.c +51 -0
  619. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/domain.upbdefs.h +40 -0
  620. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/http_inputs.upbdefs.c +36 -0
  621. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/http_inputs.upbdefs.h +35 -0
  622. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/ip.upbdefs.c +55 -0
  623. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/ip.upbdefs.h +40 -0
  624. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/matcher.upbdefs.c +9 -9
  625. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/range.upbdefs.c +71 -0
  626. data/src/core/ext/upbdefs-generated/xds/type/matcher/v3/range.upbdefs.h +60 -0
  627. data/src/core/ext/upbdefs-generated/xds/type/v3/cel.upbdefs.c +60 -0
  628. data/src/core/ext/upbdefs-generated/xds/type/v3/cel.upbdefs.h +40 -0
  629. data/src/core/ext/upbdefs-generated/xds/type/v3/range.upbdefs.c +36 -0
  630. data/src/core/ext/upbdefs-generated/xds/type/v3/range.upbdefs.h +45 -0
  631. data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.c +4 -7
  632. data/src/core/ext/xds/certificate_provider_store.cc +65 -3
  633. data/src/core/ext/xds/certificate_provider_store.h +21 -4
  634. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +17 -10
  635. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +12 -4
  636. data/src/core/ext/xds/upb_utils.h +3 -25
  637. data/src/core/ext/xds/xds_api.cc +90 -196
  638. data/src/core/ext/xds/xds_api.h +41 -39
  639. data/src/core/ext/xds/xds_bootstrap.cc +5 -537
  640. data/src/core/ext/xds/xds_bootstrap.h +41 -96
  641. data/src/core/ext/xds/xds_bootstrap_grpc.cc +362 -0
  642. data/src/core/ext/xds/xds_bootstrap_grpc.h +184 -0
  643. data/src/core/ext/xds/xds_certificate_provider.cc +31 -25
  644. data/src/core/ext/xds/xds_certificate_provider.h +28 -4
  645. data/src/core/ext/xds/xds_channel_args.h +3 -3
  646. data/src/core/ext/xds/xds_channel_stack_modifier.cc +15 -5
  647. data/src/core/ext/xds/xds_channel_stack_modifier.h +16 -4
  648. data/src/core/ext/xds/xds_client.cc +833 -1324
  649. data/src/core/ext/xds/xds_client.h +57 -61
  650. data/src/core/ext/xds/xds_client_grpc.cc +235 -0
  651. data/src/core/ext/xds/xds_client_grpc.h +79 -0
  652. data/src/core/ext/xds/xds_client_stats.cc +24 -25
  653. data/src/core/ext/xds/xds_client_stats.h +26 -24
  654. data/src/core/ext/xds/xds_cluster.cc +413 -245
  655. data/src/core/ext/xds/xds_cluster.h +66 -40
  656. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +67 -77
  657. data/src/core/ext/xds/xds_cluster_specifier_plugin.h +47 -29
  658. data/src/core/ext/xds/xds_common_types.cc +238 -123
  659. data/src/core/ext/xds/xds_common_types.h +29 -16
  660. data/src/core/ext/xds/xds_endpoint.cc +265 -162
  661. data/src/core/ext/xds/xds_endpoint.h +19 -15
  662. data/src/core/ext/xds/xds_health_status.cc +80 -0
  663. data/src/core/ext/xds/xds_health_status.h +109 -0
  664. data/src/core/ext/xds/xds_http_fault_filter.cc +66 -57
  665. data/src/core/ext/xds/xds_http_fault_filter.h +19 -25
  666. data/src/core/ext/xds/xds_http_filters.cc +70 -71
  667. data/src/core/ext/xds/xds_http_filters.h +73 -25
  668. data/src/core/ext/xds/xds_http_rbac_filter.cc +168 -225
  669. data/src/core/ext/xds/xds_http_rbac_filter.h +22 -18
  670. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +218 -0
  671. data/src/core/ext/xds/xds_http_stateful_session_filter.h +58 -0
  672. data/src/core/ext/xds/xds_lb_policy_registry.cc +334 -0
  673. data/src/core/ext/xds/xds_lb_policy_registry.h +71 -0
  674. data/src/core/ext/xds/xds_listener.cc +557 -475
  675. data/src/core/ext/xds/xds_listener.h +57 -51
  676. data/src/core/ext/xds/xds_resource_type.h +28 -22
  677. data/src/core/ext/xds/xds_resource_type_impl.h +18 -17
  678. data/src/core/ext/xds/xds_route_config.cc +592 -570
  679. data/src/core/ext/xds/xds_route_config.h +74 -40
  680. data/src/core/ext/xds/xds_routing.cc +21 -7
  681. data/src/core/ext/xds/xds_routing.h +17 -12
  682. data/src/core/ext/xds/xds_server_config_fetcher.cc +227 -179
  683. data/src/core/ext/xds/xds_transport.h +86 -0
  684. data/src/core/ext/xds/xds_transport_grpc.cc +356 -0
  685. data/src/core/ext/xds/xds_transport_grpc.h +135 -0
  686. data/src/core/lib/address_utils/parse_address.cc +52 -52
  687. data/src/core/lib/address_utils/parse_address.h +46 -42
  688. data/src/core/lib/address_utils/sockaddr_utils.cc +38 -35
  689. data/src/core/lib/address_utils/sockaddr_utils.h +38 -36
  690. data/src/core/lib/avl/avl.h +54 -32
  691. data/src/core/lib/backoff/backoff.cc +19 -21
  692. data/src/core/lib/backoff/backoff.h +21 -21
  693. data/src/core/lib/channel/call_finalization.h +4 -6
  694. data/src/core/lib/channel/call_tracer.h +17 -8
  695. data/src/core/lib/channel/channel_args.cc +108 -39
  696. data/src/core/lib/channel/channel_args.h +285 -111
  697. data/src/core/lib/channel/channel_args_preconditioning.cc +1 -0
  698. data/src/core/lib/channel/channel_args_preconditioning.h +4 -4
  699. data/src/core/lib/channel/channel_fwd.h +26 -0
  700. data/src/core/lib/channel/channel_stack.cc +60 -58
  701. data/src/core/lib/channel/channel_stack.h +149 -146
  702. data/src/core/lib/channel/channel_stack_builder.cc +21 -24
  703. data/src/core/lib/channel/channel_stack_builder.h +19 -14
  704. data/src/core/lib/channel/channel_stack_builder_impl.cc +55 -26
  705. data/src/core/lib/channel/channel_stack_builder_impl.h +6 -3
  706. data/src/core/lib/channel/channel_trace.cc +24 -26
  707. data/src/core/lib/channel/channel_trace.h +22 -22
  708. data/src/core/lib/channel/channelz.cc +44 -54
  709. data/src/core/lib/channel/channelz.h +40 -32
  710. data/src/core/lib/channel/channelz_registry.cc +21 -22
  711. data/src/core/lib/channel/channelz_registry.h +21 -21
  712. data/src/core/lib/channel/connected_channel.cc +1264 -65
  713. data/src/core/lib/channel/connected_channel.h +21 -24
  714. data/src/core/lib/channel/context.h +25 -21
  715. data/src/core/lib/channel/promise_based_filter.cc +1544 -280
  716. data/src/core/lib/channel/promise_based_filter.h +466 -99
  717. data/src/core/lib/channel/status_util.cc +62 -17
  718. data/src/core/lib/channel/status_util.h +39 -22
  719. data/src/core/lib/compression/compression.cc +24 -19
  720. data/src/core/lib/compression/compression_internal.cc +43 -53
  721. data/src/core/lib/compression/compression_internal.h +27 -26
  722. data/src/core/lib/compression/message_compress.cc +28 -26
  723. data/src/core/lib/compression/message_compress.h +28 -29
  724. data/src/core/lib/config/core_configuration.cc +5 -1
  725. data/src/core/lib/config/core_configuration.h +84 -38
  726. data/src/core/lib/debug/event_log.cc +88 -0
  727. data/src/core/lib/debug/event_log.h +81 -0
  728. data/src/core/lib/debug/histogram_view.cc +69 -0
  729. data/src/core/lib/debug/histogram_view.h +37 -0
  730. data/src/core/lib/debug/stats.cc +48 -152
  731. data/src/core/lib/debug/stats.h +50 -57
  732. data/src/core/lib/debug/stats_data.cc +302 -645
  733. data/src/core/lib/debug/stats_data.h +293 -545
  734. data/src/core/lib/debug/trace.cc +18 -20
  735. data/src/core/lib/debug/trace.h +27 -48
  736. data/src/core/lib/event_engine/channel_args_endpoint_config.cc +15 -18
  737. data/src/core/lib/event_engine/channel_args_endpoint_config.h +16 -10
  738. data/src/core/lib/event_engine/common_closures.h +71 -0
  739. data/src/core/lib/event_engine/default_event_engine.cc +99 -0
  740. data/src/core/lib/event_engine/default_event_engine.h +73 -0
  741. data/src/core/lib/event_engine/default_event_engine_factory.cc +20 -5
  742. data/src/core/lib/event_engine/{event_engine_factory.h → default_event_engine_factory.h} +4 -12
  743. data/src/core/lib/event_engine/event_engine.cc +3 -40
  744. data/src/core/lib/event_engine/executor/executor.h +38 -0
  745. data/src/core/lib/event_engine/forkable.cc +106 -0
  746. data/src/core/lib/event_engine/forkable.h +61 -0
  747. data/src/core/lib/event_engine/handle_containers.h +10 -3
  748. data/src/core/lib/event_engine/memory_allocator.cc +1 -1
  749. data/src/core/lib/event_engine/poller.h +62 -0
  750. data/src/core/lib/event_engine/posix.h +158 -0
  751. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +642 -0
  752. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +139 -0
  753. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +899 -0
  754. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +97 -0
  755. data/src/core/lib/event_engine/posix_engine/event_poller.h +111 -0
  756. data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +74 -0
  757. data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +33 -0
  758. data/src/core/lib/event_engine/posix_engine/internal_errqueue.cc +77 -0
  759. data/src/core/lib/event_engine/posix_engine/internal_errqueue.h +179 -0
  760. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +265 -0
  761. data/src/core/lib/event_engine/posix_engine/lockfree_event.h +73 -0
  762. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +1305 -0
  763. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +717 -0
  764. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +640 -0
  765. data/src/core/lib/event_engine/posix_engine/posix_engine.h +259 -0
  766. data/src/core/lib/event_engine/posix_engine/posix_engine_closure.h +80 -0
  767. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +289 -0
  768. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +279 -0
  769. data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +379 -0
  770. data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h +91 -0
  771. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +853 -0
  772. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +316 -0
  773. data/src/core/lib/event_engine/posix_engine/timer.cc +311 -0
  774. data/src/core/lib/event_engine/posix_engine/timer.h +194 -0
  775. data/src/core/lib/event_engine/posix_engine/timer_heap.cc +107 -0
  776. data/src/core/lib/event_engine/posix_engine/timer_heap.h +56 -0
  777. data/src/core/lib/event_engine/posix_engine/timer_manager.cc +173 -0
  778. data/src/core/lib/event_engine/posix_engine/timer_manager.h +114 -0
  779. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +332 -0
  780. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +185 -0
  781. data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc +127 -0
  782. data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h +45 -0
  783. data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc +150 -0
  784. data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h +45 -0
  785. data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h +76 -0
  786. data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc +67 -0
  787. data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h +37 -0
  788. data/src/core/lib/event_engine/resolved_address.cc +19 -0
  789. data/src/core/lib/event_engine/resolved_address_internal.h +34 -0
  790. data/src/core/lib/event_engine/shim.cc +56 -0
  791. data/src/core/lib/event_engine/shim.h +33 -0
  792. data/src/core/lib/event_engine/slice.cc +8 -7
  793. data/src/core/lib/event_engine/slice_buffer.cc +2 -2
  794. data/src/core/lib/event_engine/tcp_socket_utils.cc +389 -0
  795. data/src/core/lib/event_engine/tcp_socket_utils.h +90 -0
  796. data/src/core/lib/event_engine/thread_local.cc +29 -0
  797. data/src/core/lib/event_engine/thread_local.h +32 -0
  798. data/src/core/lib/event_engine/thread_pool.cc +253 -0
  799. data/src/core/lib/event_engine/thread_pool.h +141 -0
  800. data/src/core/lib/event_engine/time_util.cc +30 -0
  801. data/src/core/lib/event_engine/time_util.h +32 -0
  802. data/src/core/lib/event_engine/trace.cc +6 -0
  803. data/src/core/lib/event_engine/trace.h +16 -3
  804. data/src/core/lib/event_engine/utils.cc +44 -0
  805. data/src/core/lib/event_engine/utils.h +44 -0
  806. data/src/core/lib/event_engine/windows/iocp.cc +140 -0
  807. data/src/core/lib/event_engine/windows/iocp.h +69 -0
  808. data/src/core/lib/event_engine/windows/win_socket.cc +219 -0
  809. data/src/core/lib/event_engine/windows/win_socket.h +129 -0
  810. data/src/core/lib/event_engine/windows/windows_endpoint.cc +331 -0
  811. data/src/core/lib/event_engine/windows/windows_endpoint.h +103 -0
  812. data/src/core/lib/event_engine/windows/windows_engine.cc +388 -0
  813. data/src/core/lib/event_engine/windows/windows_engine.h +163 -0
  814. data/src/core/lib/experiments/config.cc +161 -0
  815. data/src/core/lib/experiments/config.h +53 -0
  816. data/src/core/lib/experiments/experiments.cc +81 -0
  817. data/src/core/lib/experiments/experiments.h +117 -0
  818. data/src/core/lib/gpr/alloc.cc +19 -25
  819. data/src/core/lib/gpr/alloc.h +20 -20
  820. data/src/core/lib/gpr/atm.cc +17 -17
  821. data/src/core/lib/gpr/cpu_iphone.cc +24 -24
  822. data/src/core/lib/gpr/cpu_linux.cc +28 -23
  823. data/src/core/lib/gpr/cpu_posix.cc +23 -22
  824. data/src/core/lib/gpr/cpu_windows.cc +20 -18
  825. data/src/core/lib/gpr/log.cc +27 -19
  826. data/src/core/lib/gpr/log_android.cc +22 -20
  827. data/src/core/lib/gpr/log_linux.cc +24 -24
  828. data/src/core/lib/gpr/log_posix.cc +20 -19
  829. data/src/core/lib/gpr/log_windows.cc +25 -25
  830. data/src/core/lib/gpr/spinlock.h +20 -20
  831. data/src/core/lib/gpr/string.cc +25 -24
  832. data/src/core/lib/gpr/string.h +61 -61
  833. data/src/core/lib/gpr/string_posix.cc +24 -24
  834. data/src/core/lib/gpr/string_util_windows.cc +25 -52
  835. data/src/core/lib/gpr/string_windows.cc +24 -24
  836. data/src/core/lib/gpr/sync.cc +25 -25
  837. data/src/core/lib/gpr/sync_abseil.cc +36 -40
  838. data/src/core/lib/gpr/sync_posix.cc +22 -34
  839. data/src/core/lib/gpr/sync_windows.cc +29 -27
  840. data/src/core/lib/gpr/time.cc +34 -30
  841. data/src/core/lib/gpr/time_posix.cc +41 -45
  842. data/src/core/lib/gpr/time_precise.cc +22 -22
  843. data/src/core/lib/gpr/time_precise.h +21 -22
  844. data/src/core/lib/gpr/time_windows.cc +35 -29
  845. data/src/core/lib/gpr/tmpfile.h +24 -24
  846. data/src/core/lib/gpr/tmpfile_msys.cc +21 -20
  847. data/src/core/lib/gpr/tmpfile_posix.cc +22 -20
  848. data/src/core/lib/gpr/tmpfile_windows.cc +28 -29
  849. data/src/core/lib/gpr/useful.h +83 -30
  850. data/src/core/lib/gpr/wrap_memcpy.cc +23 -23
  851. data/src/core/lib/gprpp/atomic_utils.h +20 -20
  852. data/src/core/lib/gprpp/bitset.h +30 -16
  853. data/src/core/lib/gprpp/chunked_vector.h +3 -3
  854. data/src/core/lib/gprpp/construct_destruct.h +3 -3
  855. data/src/core/lib/gprpp/cpp_impl_of.h +3 -3
  856. data/src/core/{ext/xds/xds_resource_type.cc → lib/gprpp/crash.cc} +12 -12
  857. data/src/core/lib/gprpp/crash.h +34 -0
  858. data/src/core/lib/gprpp/debug_location.h +60 -31
  859. data/src/core/lib/gprpp/dual_ref_counted.h +3 -3
  860. data/src/core/lib/gprpp/env.h +53 -0
  861. data/src/core/lib/gprpp/env_linux.cc +80 -0
  862. data/src/core/lib/gprpp/env_posix.cc +47 -0
  863. data/src/core/lib/gprpp/env_windows.cc +56 -0
  864. data/src/core/lib/gprpp/examine_stack.cc +17 -17
  865. data/src/core/lib/gprpp/examine_stack.h +21 -21
  866. data/src/core/lib/gprpp/fork.cc +56 -48
  867. data/src/core/lib/gprpp/fork.h +29 -35
  868. data/src/core/lib/gprpp/global_config.h +20 -20
  869. data/src/core/lib/gprpp/global_config_custom.h +20 -20
  870. data/src/core/lib/gprpp/global_config_env.cc +25 -23
  871. data/src/core/lib/gprpp/global_config_env.h +26 -26
  872. data/src/core/lib/gprpp/global_config_generic.h +21 -21
  873. data/src/core/lib/gprpp/host_port.cc +28 -26
  874. data/src/core/lib/gprpp/host_port.h +32 -31
  875. data/src/core/lib/gprpp/load_file.cc +75 -0
  876. data/src/core/lib/gprpp/load_file.h +33 -0
  877. data/src/core/lib/gprpp/manual_constructor.h +21 -88
  878. data/src/core/lib/gprpp/match.h +3 -3
  879. data/src/core/lib/gprpp/memory.h +21 -21
  880. data/src/core/lib/gprpp/mpscq.cc +17 -17
  881. data/src/core/lib/gprpp/mpscq.h +21 -21
  882. data/src/core/lib/gprpp/no_destruct.h +95 -0
  883. data/src/core/lib/gprpp/notification.h +67 -0
  884. data/src/core/lib/gprpp/orphanable.h +21 -21
  885. data/src/core/lib/gprpp/overload.h +3 -3
  886. data/src/core/lib/gprpp/packed_table.h +40 -0
  887. data/src/core/lib/gprpp/per_cpu.h +46 -0
  888. data/src/core/lib/gprpp/ref_counted.h +21 -21
  889. data/src/core/lib/gprpp/ref_counted_ptr.h +41 -54
  890. data/src/core/lib/gprpp/single_set_ptr.h +3 -3
  891. data/src/core/lib/gprpp/sorted_pack.h +98 -0
  892. data/src/core/lib/gprpp/stat.h +3 -3
  893. data/src/core/lib/gprpp/stat_posix.cc +5 -4
  894. data/src/core/lib/gprpp/stat_windows.cc +4 -2
  895. data/src/core/lib/gprpp/status_helper.cc +49 -33
  896. data/src/core/lib/gprpp/status_helper.h +9 -5
  897. data/src/core/lib/gprpp/strerror.cc +43 -0
  898. data/src/core/lib/gprpp/strerror.h +29 -0
  899. data/src/core/lib/gprpp/sync.h +23 -23
  900. data/src/core/lib/gprpp/table.h +12 -4
  901. data/src/core/lib/gprpp/tchar.cc +49 -0
  902. data/src/core/lib/gprpp/tchar.h +33 -0
  903. data/src/core/lib/gprpp/thd.h +23 -23
  904. data/src/core/lib/gprpp/thd_posix.cc +30 -31
  905. data/src/core/lib/gprpp/thd_windows.cc +26 -26
  906. data/src/core/lib/gprpp/time.cc +44 -9
  907. data/src/core/lib/gprpp/time.h +73 -4
  908. data/src/core/lib/gprpp/time_averaged_stats.cc +60 -0
  909. data/src/core/lib/gprpp/time_averaged_stats.h +79 -0
  910. data/src/core/lib/gprpp/time_util.h +4 -4
  911. data/src/core/lib/gprpp/unique_type_name.h +21 -21
  912. data/src/core/lib/gprpp/validation_errors.cc +61 -0
  913. data/src/core/lib/gprpp/validation_errors.h +127 -0
  914. data/src/core/lib/{iomgr → gprpp}/work_serializer.cc +34 -18
  915. data/src/core/lib/{iomgr → gprpp}/work_serializer.h +21 -28
  916. data/src/core/lib/handshaker/proxy_mapper.h +53 -0
  917. data/src/core/lib/handshaker/proxy_mapper_registry.cc +71 -0
  918. data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
  919. data/src/core/lib/http/format_request.cc +24 -22
  920. data/src/core/lib/http/format_request.h +21 -21
  921. data/src/core/lib/http/httpcli.cc +79 -88
  922. data/src/core/lib/http/httpcli.h +47 -31
  923. data/src/core/lib/http/httpcli_security_connector.cc +47 -38
  924. data/src/core/lib/http/httpcli_ssl_credentials.h +6 -4
  925. data/src/core/lib/http/parser.cc +78 -90
  926. data/src/core/lib/http/parser.h +38 -35
  927. data/src/core/lib/iomgr/block_annotate.h +23 -23
  928. data/src/core/lib/iomgr/buffer_list.cc +156 -136
  929. data/src/core/lib/iomgr/buffer_list.h +123 -101
  930. data/src/core/lib/iomgr/call_combiner.cc +32 -64
  931. data/src/core/lib/iomgr/call_combiner.h +24 -25
  932. data/src/core/lib/iomgr/cfstream_handle.cc +33 -36
  933. data/src/core/lib/iomgr/cfstream_handle.h +25 -25
  934. data/src/core/lib/iomgr/closure.cc +27 -0
  935. data/src/core/lib/iomgr/closure.h +95 -58
  936. data/src/core/lib/iomgr/combiner.cc +20 -39
  937. data/src/core/lib/iomgr/combiner.h +20 -20
  938. data/src/core/lib/iomgr/dualstack_socket_posix.cc +21 -21
  939. data/src/core/lib/iomgr/dynamic_annotations.h +22 -22
  940. data/src/core/lib/iomgr/endpoint.cc +17 -17
  941. data/src/core/lib/iomgr/endpoint.h +49 -49
  942. data/src/core/lib/iomgr/endpoint_cfstream.cc +44 -43
  943. data/src/core/lib/iomgr/endpoint_cfstream.h +32 -32
  944. data/src/core/lib/iomgr/endpoint_pair.h +20 -20
  945. data/src/core/lib/iomgr/endpoint_pair_posix.cc +34 -28
  946. data/src/core/lib/iomgr/endpoint_pair_windows.cc +30 -21
  947. data/src/core/lib/iomgr/error.cc +51 -834
  948. data/src/core/lib/iomgr/error.h +45 -317
  949. data/src/core/lib/iomgr/error_cfstream.cc +18 -23
  950. data/src/core/lib/iomgr/error_cfstream.h +21 -21
  951. data/src/core/lib/iomgr/ev_apple.cc +21 -21
  952. data/src/core/lib/iomgr/ev_apple.h +21 -21
  953. data/src/core/lib/iomgr/ev_epoll1_linux.cc +263 -248
  954. data/src/core/lib/iomgr/ev_epoll1_linux.h +21 -21
  955. data/src/core/lib/iomgr/ev_poll_posix.cc +296 -271
  956. data/src/core/lib/iomgr/ev_poll_posix.h +22 -22
  957. data/src/core/lib/iomgr/ev_posix.cc +87 -117
  958. data/src/core/lib/iomgr/ev_posix.h +93 -87
  959. data/src/core/lib/iomgr/ev_windows.cc +18 -18
  960. data/src/core/lib/iomgr/event_engine_shims/closure.cc +62 -0
  961. data/src/core/lib/iomgr/event_engine_shims/closure.h +39 -0
  962. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +430 -0
  963. data/src/core/lib/iomgr/event_engine_shims/endpoint.h +43 -0
  964. data/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +91 -0
  965. data/src/core/lib/iomgr/event_engine_shims/tcp_client.h +44 -0
  966. data/src/core/lib/iomgr/exec_ctx.cc +34 -56
  967. data/src/core/lib/iomgr/exec_ctx.h +151 -175
  968. data/src/core/lib/iomgr/executor.cc +21 -31
  969. data/src/core/lib/iomgr/executor.h +27 -30
  970. data/src/core/lib/iomgr/fork_posix.cc +30 -27
  971. data/src/core/lib/iomgr/fork_windows.cc +21 -21
  972. data/src/core/lib/iomgr/gethostname.h +20 -20
  973. data/src/core/lib/iomgr/gethostname_fallback.cc +17 -17
  974. data/src/core/lib/iomgr/gethostname_host_name_max.cc +17 -17
  975. data/src/core/lib/iomgr/gethostname_sysconf.cc +17 -17
  976. data/src/core/lib/iomgr/grpc_if_nametoindex.h +22 -22
  977. data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +20 -19
  978. data/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc +20 -19
  979. data/src/core/lib/iomgr/internal_errqueue.cc +4 -2
  980. data/src/core/lib/iomgr/internal_errqueue.h +83 -83
  981. data/src/core/lib/iomgr/iocp_windows.cc +23 -23
  982. data/src/core/lib/iomgr/iocp_windows.h +21 -21
  983. data/src/core/lib/iomgr/iomgr.cc +25 -19
  984. data/src/core/lib/iomgr/iomgr.h +35 -35
  985. data/src/core/lib/iomgr/iomgr_fwd.h +4 -3
  986. data/src/core/lib/iomgr/iomgr_internal.cc +17 -17
  987. data/src/core/lib/iomgr/iomgr_internal.h +28 -28
  988. data/src/core/lib/iomgr/iomgr_posix.cc +21 -20
  989. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +21 -19
  990. data/src/core/lib/iomgr/iomgr_windows.cc +24 -22
  991. data/src/core/lib/iomgr/load_file.cc +24 -27
  992. data/src/core/lib/iomgr/load_file.h +22 -22
  993. data/src/core/lib/iomgr/lockfree_event.cc +114 -131
  994. data/src/core/lib/iomgr/lockfree_event.h +23 -23
  995. data/src/core/lib/iomgr/nameser.h +86 -86
  996. data/src/core/lib/iomgr/polling_entity.cc +25 -21
  997. data/src/core/lib/iomgr/polling_entity.h +29 -29
  998. data/src/core/lib/iomgr/pollset.cc +17 -17
  999. data/src/core/lib/iomgr/pollset.h +55 -55
  1000. data/src/core/lib/iomgr/pollset_set.cc +17 -17
  1001. data/src/core/lib/iomgr/pollset_set.h +25 -26
  1002. data/src/core/lib/iomgr/pollset_set_windows.cc +18 -18
  1003. data/src/core/lib/iomgr/pollset_set_windows.h +20 -20
  1004. data/src/core/lib/iomgr/pollset_windows.cc +32 -31
  1005. data/src/core/lib/iomgr/pollset_windows.h +24 -24
  1006. data/src/core/lib/iomgr/port.h +34 -31
  1007. data/src/core/lib/iomgr/python_util.h +24 -24
  1008. data/src/core/lib/iomgr/resolve_address.cc +26 -20
  1009. data/src/core/lib/iomgr/resolve_address.h +54 -31
  1010. data/src/core/lib/iomgr/resolve_address_impl.h +5 -4
  1011. data/src/core/lib/iomgr/resolve_address_posix.cc +74 -49
  1012. data/src/core/lib/iomgr/resolve_address_posix.h +23 -10
  1013. data/src/core/lib/iomgr/resolve_address_windows.cc +59 -26
  1014. data/src/core/lib/iomgr/resolve_address_windows.h +23 -10
  1015. data/src/core/lib/iomgr/resolved_address.h +3 -3
  1016. data/src/core/lib/iomgr/sockaddr.h +23 -23
  1017. data/src/core/lib/iomgr/sockaddr_posix.h +21 -21
  1018. data/src/core/lib/iomgr/sockaddr_utils_posix.cc +20 -18
  1019. data/src/core/lib/iomgr/sockaddr_windows.h +21 -21
  1020. data/src/core/lib/iomgr/socket_factory_posix.cc +18 -18
  1021. data/src/core/lib/iomgr/socket_factory_posix.h +32 -32
  1022. data/src/core/lib/iomgr/socket_mutator.cc +19 -18
  1023. data/src/core/lib/iomgr/socket_mutator.h +39 -39
  1024. data/src/core/lib/iomgr/socket_utils.h +27 -27
  1025. data/src/core/lib/iomgr/socket_utils_common_posix.cc +80 -100
  1026. data/src/core/lib/iomgr/socket_utils_linux.cc +18 -17
  1027. data/src/core/lib/iomgr/socket_utils_posix.cc +103 -19
  1028. data/src/core/lib/iomgr/socket_utils_posix.h +176 -84
  1029. data/src/core/lib/iomgr/socket_utils_windows.cc +20 -19
  1030. data/src/core/lib/iomgr/socket_windows.cc +37 -36
  1031. data/src/core/lib/iomgr/socket_windows.h +59 -61
  1032. data/src/core/lib/iomgr/systemd_utils.cc +116 -0
  1033. data/src/core/lib/iomgr/systemd_utils.h +33 -0
  1034. data/src/core/lib/iomgr/tcp_client.cc +28 -24
  1035. data/src/core/lib/iomgr/tcp_client.h +49 -38
  1036. data/src/core/lib/iomgr/tcp_client_cfstream.cc +39 -36
  1037. data/src/core/lib/iomgr/tcp_client_posix.cc +236 -105
  1038. data/src/core/lib/iomgr/tcp_client_posix.h +55 -52
  1039. data/src/core/lib/iomgr/tcp_client_windows.cc +64 -51
  1040. data/src/core/lib/iomgr/tcp_posix.cc +502 -341
  1041. data/src/core/lib/iomgr/tcp_posix.h +32 -30
  1042. data/src/core/lib/iomgr/tcp_server.cc +33 -24
  1043. data/src/core/lib/iomgr/tcp_server.h +78 -69
  1044. data/src/core/lib/iomgr/tcp_server_posix.cc +358 -124
  1045. data/src/core/lib/iomgr/tcp_server_utils_posix.h +68 -55
  1046. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +93 -58
  1047. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +40 -40
  1048. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +19 -19
  1049. data/src/core/lib/iomgr/tcp_server_windows.cc +106 -116
  1050. data/src/core/lib/iomgr/tcp_windows.cc +109 -94
  1051. data/src/core/lib/iomgr/tcp_windows.h +34 -35
  1052. data/src/core/lib/iomgr/timer.cc +17 -17
  1053. data/src/core/lib/iomgr/timer.h +68 -68
  1054. data/src/core/lib/iomgr/timer_generic.cc +125 -134
  1055. data/src/core/lib/iomgr/timer_generic.h +21 -21
  1056. data/src/core/lib/iomgr/timer_heap.cc +25 -25
  1057. data/src/core/lib/iomgr/timer_heap.h +22 -22
  1058. data/src/core/lib/iomgr/timer_manager.cc +31 -31
  1059. data/src/core/lib/iomgr/timer_manager.h +27 -27
  1060. data/src/core/lib/iomgr/unix_sockets_posix.cc +20 -21
  1061. data/src/core/lib/iomgr/unix_sockets_posix.h +21 -21
  1062. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +19 -17
  1063. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +23 -23
  1064. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +23 -23
  1065. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +29 -26
  1066. data/src/core/lib/iomgr/wakeup_fd_pipe.h +20 -20
  1067. data/src/core/lib/iomgr/wakeup_fd_posix.cc +33 -30
  1068. data/src/core/lib/iomgr/wakeup_fd_posix.h +52 -54
  1069. data/src/core/lib/json/json.h +22 -25
  1070. data/src/core/{ext/filters/http/message_compress/message_decompress_filter.h → lib/json/json_args.h} +13 -10
  1071. data/src/core/lib/json/json_channel_args.h +42 -0
  1072. data/src/core/lib/json/json_object_loader.cc +217 -0
  1073. data/src/core/lib/json/json_object_loader.h +634 -0
  1074. data/src/core/lib/json/json_reader.cc +115 -90
  1075. data/src/core/lib/json/json_util.cc +14 -41
  1076. data/src/core/lib/json/json_util.h +7 -7
  1077. data/src/core/lib/json/json_writer.cc +56 -56
  1078. data/src/core/{ext/filters/client_channel → lib/load_balancing}/lb_policy.cc +26 -58
  1079. data/src/core/{ext/filters/client_channel → lib/load_balancing}/lb_policy.h +32 -41
  1080. data/src/core/lib/load_balancing/lb_policy_factory.h +49 -0
  1081. data/src/core/lib/load_balancing/lb_policy_registry.cc +142 -0
  1082. data/src/core/lib/load_balancing/lb_policy_registry.h +82 -0
  1083. data/src/core/{ext/filters/client_channel → lib/load_balancing}/subchannel_interface.h +18 -31
  1084. data/src/core/lib/matchers/matchers.cc +12 -7
  1085. data/src/core/lib/matchers/matchers.h +5 -3
  1086. data/src/core/lib/promise/activity.cc +22 -7
  1087. data/src/core/lib/promise/activity.h +110 -52
  1088. data/src/core/lib/promise/arena_promise.h +105 -72
  1089. data/src/core/lib/promise/context.h +17 -10
  1090. data/src/core/lib/promise/detail/basic_join.h +197 -0
  1091. data/src/core/lib/promise/detail/basic_seq.h +27 -32
  1092. data/src/core/lib/promise/detail/promise_factory.h +61 -13
  1093. data/src/core/lib/promise/detail/promise_like.h +3 -3
  1094. data/src/core/lib/promise/detail/status.h +31 -3
  1095. data/src/core/lib/promise/detail/switch.h +21 -21
  1096. data/src/core/lib/promise/exec_ctx_wakeup_scheduler.h +23 -15
  1097. data/src/core/lib/promise/if.h +195 -0
  1098. data/src/core/lib/promise/interceptor_list.h +308 -0
  1099. data/src/core/lib/promise/intra_activity_waiter.h +9 -3
  1100. data/src/core/lib/promise/latch.h +110 -22
  1101. data/src/core/lib/promise/loop.h +12 -9
  1102. data/src/core/lib/promise/map.h +4 -6
  1103. data/src/core/lib/promise/pipe.h +608 -0
  1104. data/src/core/lib/promise/poll.h +129 -11
  1105. data/src/core/lib/promise/promise.h +5 -5
  1106. data/src/core/lib/promise/race.h +6 -9
  1107. data/src/core/lib/promise/seq.h +32 -12
  1108. data/src/core/lib/promise/sleep.cc +56 -42
  1109. data/src/core/lib/promise/sleep.h +40 -32
  1110. data/src/core/lib/promise/trace.cc +20 -0
  1111. data/src/core/lib/promise/trace.h +24 -0
  1112. data/src/core/lib/promise/try_join.h +82 -0
  1113. data/src/core/lib/promise/try_seq.h +39 -21
  1114. data/src/core/lib/resolver/resolver.cc +17 -59
  1115. data/src/core/lib/resolver/resolver.h +21 -18
  1116. data/src/core/lib/resolver/resolver_factory.h +10 -8
  1117. data/src/core/lib/resolver/resolver_registry.cc +17 -9
  1118. data/src/core/lib/resolver/resolver_registry.h +15 -5
  1119. data/src/core/lib/resolver/server_address.cc +38 -32
  1120. data/src/core/lib/resolver/server_address.h +32 -31
  1121. data/src/core/lib/resource_quota/api.cc +10 -2
  1122. data/src/core/lib/resource_quota/api.h +10 -4
  1123. data/src/core/lib/resource_quota/arena.cc +85 -21
  1124. data/src/core/lib/resource_quota/arena.h +196 -23
  1125. data/src/core/lib/resource_quota/memory_quota.cc +287 -108
  1126. data/src/core/lib/resource_quota/memory_quota.h +175 -59
  1127. data/src/core/lib/resource_quota/periodic_update.cc +78 -0
  1128. data/src/core/lib/resource_quota/periodic_update.h +71 -0
  1129. data/src/core/lib/resource_quota/resource_quota.h +4 -4
  1130. data/src/core/lib/resource_quota/thread_quota.h +3 -3
  1131. data/src/core/lib/resource_quota/trace.h +3 -3
  1132. data/src/core/lib/security/authorization/authorization_engine.h +3 -3
  1133. data/src/core/lib/security/authorization/authorization_policy_provider.h +10 -3
  1134. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +3 -0
  1135. data/src/core/lib/security/authorization/evaluate_args.cc +17 -8
  1136. data/src/core/lib/security/authorization/evaluate_args.h +9 -6
  1137. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +5 -1
  1138. data/src/core/lib/security/authorization/grpc_authorization_engine.h +10 -3
  1139. data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +16 -3
  1140. data/src/core/lib/security/authorization/grpc_server_authz_filter.h +16 -5
  1141. data/src/core/lib/security/authorization/matchers.cc +44 -30
  1142. data/src/core/lib/security/authorization/matchers.h +10 -3
  1143. data/src/core/lib/security/authorization/rbac_policy.cc +6 -2
  1144. data/src/core/lib/security/authorization/rbac_policy.h +10 -3
  1145. data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +9 -4
  1146. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
  1147. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
  1148. data/src/core/lib/security/context/security_context.cc +27 -25
  1149. data/src/core/lib/security/context/security_context.h +56 -34
  1150. data/src/core/lib/security/credentials/alts/alts_credentials.cc +23 -22
  1151. data/src/core/lib/security/credentials/alts/alts_credentials.h +61 -57
  1152. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +19 -19
  1153. data/src/core/lib/security/credentials/alts/check_gcp_environment.h +43 -43
  1154. data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +17 -17
  1155. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +18 -17
  1156. data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +18 -17
  1157. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_client_options.cc +20 -22
  1158. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.cc +18 -18
  1159. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +38 -39
  1160. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +19 -22
  1161. data/src/core/lib/security/credentials/call_creds_util.cc +8 -0
  1162. data/src/core/lib/security/credentials/call_creds_util.h +4 -3
  1163. data/src/core/lib/security/credentials/channel_creds_registry.h +9 -4
  1164. data/src/core/lib/security/credentials/channel_creds_registry_init.cc +13 -3
  1165. data/src/core/lib/security/credentials/composite/composite_credentials.cc +27 -31
  1166. data/src/core/lib/security/credentials/composite/composite_credentials.h +40 -29
  1167. data/src/core/lib/security/credentials/credentials.cc +23 -26
  1168. data/src/core/lib/security/credentials/credentials.h +62 -55
  1169. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +123 -76
  1170. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +13 -3
  1171. data/src/core/lib/security/credentials/external/aws_request_signer.cc +14 -3
  1172. data/src/core/lib/security/credentials/external/aws_request_signer.h +3 -3
  1173. data/src/core/lib/security/credentials/external/external_account_credentials.cc +83 -68
  1174. data/src/core/lib/security/credentials/external/external_account_credentials.h +14 -3
  1175. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +29 -26
  1176. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +9 -3
  1177. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +42 -31
  1178. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +13 -3
  1179. data/src/core/lib/security/credentials/fake/fake_credentials.cc +30 -36
  1180. data/src/core/lib/security/credentials/fake/fake_credentials.h +49 -42
  1181. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +23 -25
  1182. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +129 -107
  1183. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +31 -25
  1184. data/src/core/lib/security/credentials/iam/iam_credentials.cc +27 -20
  1185. data/src/core/lib/security/credentials/iam/iam_credentials.h +31 -21
  1186. data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +7 -3
  1187. data/src/core/lib/security/credentials/insecure/insecure_credentials.h +10 -6
  1188. data/src/core/lib/security/credentials/jwt/json_token.cc +40 -29
  1189. data/src/core/lib/security/credentials/jwt/json_token.h +36 -36
  1190. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +29 -27
  1191. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +35 -21
  1192. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +113 -89
  1193. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +49 -47
  1194. data/src/core/lib/security/credentials/local/local_credentials.cc +24 -24
  1195. data/src/core/lib/security/credentials/local/local_credentials.h +32 -26
  1196. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +85 -81
  1197. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +42 -21
  1198. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +31 -30
  1199. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +47 -23
  1200. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +36 -40
  1201. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +35 -23
  1202. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +22 -30
  1203. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +16 -17
  1204. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +55 -48
  1205. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +22 -9
  1206. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc +10 -3
  1207. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h +9 -10
  1208. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +22 -23
  1209. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +3 -3
  1210. data/src/core/lib/security/credentials/tls/tls_credentials.cc +36 -44
  1211. data/src/core/lib/security/credentials/tls/tls_credentials.h +28 -25
  1212. data/src/core/lib/security/credentials/tls/tls_utils.cc +5 -1
  1213. data/src/core/lib/security/credentials/tls/tls_utils.h +4 -4
  1214. data/src/core/lib/security/credentials/xds/xds_credentials.cc +21 -32
  1215. data/src/core/lib/security/credentials/xds/xds_credentials.h +19 -5
  1216. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +60 -54
  1217. data/src/core/lib/security/security_connector/alts/alts_security_connector.h +49 -47
  1218. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +74 -78
  1219. data/src/core/lib/security/security_connector/fake/fake_security_connector.h +25 -26
  1220. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +15 -6
  1221. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +26 -15
  1222. data/src/core/lib/security/security_connector/load_system_roots.h +20 -20
  1223. data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +22 -20
  1224. data/src/core/lib/security/security_connector/{load_system_roots_linux.cc → load_system_roots_supported.cc} +43 -38
  1225. data/src/core/lib/security/security_connector/load_system_roots_supported.h +45 -0
  1226. data/src/core/lib/security/security_connector/local/local_security_connector.cc +64 -47
  1227. data/src/core/lib/security/security_connector/local/local_security_connector.h +49 -46
  1228. data/src/core/lib/security/security_connector/security_connector.cc +37 -35
  1229. data/src/core/lib/security/security_connector/security_connector.h +57 -44
  1230. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +54 -45
  1231. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +44 -43
  1232. data/src/core/lib/security/security_connector/ssl_utils.cc +47 -39
  1233. data/src/core/lib/security/security_connector/ssl_utils.h +45 -42
  1234. data/src/core/lib/security/security_connector/ssl_utils_config.cc +22 -22
  1235. data/src/core/lib/security/security_connector/ssl_utils_config.h +21 -22
  1236. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +58 -56
  1237. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +48 -28
  1238. data/src/core/lib/security/transport/auth_filters.h +53 -24
  1239. data/src/core/lib/security/transport/client_auth_filter.cc +51 -32
  1240. data/src/core/lib/security/transport/secure_endpoint.cc +112 -68
  1241. data/src/core/lib/security/transport/secure_endpoint.h +28 -27
  1242. data/src/core/lib/security/transport/security_handshaker.cc +139 -109
  1243. data/src/core/lib/security/transport/security_handshaker.h +27 -22
  1244. data/src/core/lib/security/transport/server_auth_filter.cc +157 -267
  1245. data/src/core/lib/security/transport/tsi_error.cc +23 -20
  1246. data/src/core/lib/security/transport/tsi_error.h +20 -20
  1247. data/src/core/lib/security/util/json_util.cc +24 -24
  1248. data/src/core/lib/security/util/json_util.h +21 -23
  1249. data/src/core/lib/service_config/service_config.h +15 -4
  1250. data/src/core/lib/service_config/service_config_call_data.h +11 -4
  1251. data/src/core/lib/service_config/service_config_impl.cc +107 -153
  1252. data/src/core/lib/service_config/service_config_impl.h +19 -26
  1253. data/src/core/lib/service_config/service_config_parser.cc +10 -30
  1254. data/src/core/lib/service_config/service_config_parser.h +13 -21
  1255. data/src/core/lib/slice/b64.cc +26 -26
  1256. data/src/core/lib/slice/b64.h +32 -32
  1257. data/src/core/lib/slice/percent_encoding.cc +21 -30
  1258. data/src/core/lib/slice/percent_encoding.h +28 -28
  1259. data/src/core/lib/slice/slice.cc +57 -45
  1260. data/src/core/lib/slice/slice.h +57 -18
  1261. data/src/core/lib/slice/slice_buffer.cc +93 -60
  1262. data/src/core/lib/slice/slice_buffer.h +72 -10
  1263. data/src/core/lib/slice/slice_internal.h +34 -42
  1264. data/src/core/lib/slice/slice_refcount.cc +3 -18
  1265. data/src/core/lib/slice/slice_refcount.h +53 -18
  1266. data/src/core/lib/slice/slice_string_helpers.cc +17 -37
  1267. data/src/core/lib/slice/slice_string_helpers.h +21 -25
  1268. data/src/core/lib/surface/api_trace.cc +17 -17
  1269. data/src/core/lib/surface/api_trace.h +25 -25
  1270. data/src/core/lib/surface/builtins.h +3 -3
  1271. data/src/core/lib/surface/byte_buffer.cc +22 -23
  1272. data/src/core/lib/surface/byte_buffer_reader.cc +23 -23
  1273. data/src/core/lib/surface/call.cc +2205 -471
  1274. data/src/core/lib/surface/call.h +121 -42
  1275. data/src/core/lib/surface/call_details.cc +20 -21
  1276. data/src/core/lib/surface/call_log_batch.cc +19 -18
  1277. data/src/core/lib/surface/call_test_only.h +33 -33
  1278. data/src/core/lib/surface/call_trace.cc +123 -0
  1279. data/src/core/lib/surface/call_trace.h +30 -0
  1280. data/src/core/lib/surface/channel.cc +65 -69
  1281. data/src/core/lib/surface/channel.h +45 -35
  1282. data/src/core/lib/surface/channel_init.cc +17 -17
  1283. data/src/core/lib/surface/channel_init.h +20 -20
  1284. data/src/core/lib/surface/channel_ping.cc +20 -20
  1285. data/src/core/lib/surface/channel_stack_type.cc +21 -17
  1286. data/src/core/lib/surface/channel_stack_type.h +22 -20
  1287. data/src/core/lib/surface/completion_queue.cc +188 -218
  1288. data/src/core/lib/surface/completion_queue.h +39 -41
  1289. data/src/core/lib/surface/completion_queue_factory.cc +33 -28
  1290. data/src/core/lib/surface/completion_queue_factory.h +22 -22
  1291. data/src/core/lib/surface/event_string.cc +18 -17
  1292. data/src/core/lib/surface/event_string.h +22 -22
  1293. data/src/core/lib/surface/init.cc +44 -73
  1294. data/src/core/lib/surface/init.h +20 -20
  1295. data/src/core/lib/surface/init_internally.cc +25 -0
  1296. data/src/core/lib/surface/init_internally.h +37 -0
  1297. data/src/core/lib/surface/lame_client.cc +33 -30
  1298. data/src/core/lib/surface/lame_client.h +23 -23
  1299. data/src/core/lib/surface/metadata_array.cc +17 -18
  1300. data/src/core/lib/surface/server.cc +349 -130
  1301. data/src/core/lib/surface/server.h +24 -22
  1302. data/src/core/lib/surface/validate_metadata.cc +32 -43
  1303. data/src/core/lib/surface/validate_metadata.h +21 -21
  1304. data/src/core/lib/surface/version.cc +21 -21
  1305. data/src/core/lib/transport/bdp_estimator.cc +18 -20
  1306. data/src/core/lib/transport/bdp_estimator.h +21 -22
  1307. data/src/core/lib/transport/connectivity_state.cc +19 -20
  1308. data/src/core/lib/transport/connectivity_state.h +23 -23
  1309. data/src/core/lib/transport/error_utils.cc +54 -78
  1310. data/src/core/lib/transport/error_utils.h +24 -24
  1311. data/src/core/lib/transport/handshaker.cc +66 -54
  1312. data/src/core/lib/transport/handshaker.h +51 -47
  1313. data/src/core/lib/transport/handshaker_factory.h +49 -24
  1314. data/src/core/lib/transport/handshaker_registry.cc +27 -20
  1315. data/src/core/lib/transport/handshaker_registry.h +25 -28
  1316. data/src/core/lib/transport/http2_errors.h +22 -22
  1317. data/src/core/lib/transport/http_connect_handshaker.cc +56 -57
  1318. data/src/core/lib/transport/http_connect_handshaker.h +21 -21
  1319. data/src/core/lib/transport/metadata_batch.cc +22 -4
  1320. data/src/core/lib/transport/metadata_batch.h +129 -35
  1321. data/src/core/lib/transport/parsed_metadata.cc +2 -6
  1322. data/src/core/lib/transport/parsed_metadata.h +7 -5
  1323. data/src/core/lib/transport/pid_controller.cc +20 -20
  1324. data/src/core/lib/transport/pid_controller.h +27 -27
  1325. data/src/core/lib/transport/status_conversion.cc +23 -25
  1326. data/src/core/lib/transport/status_conversion.h +22 -22
  1327. data/src/core/lib/transport/tcp_connect_handshaker.cc +34 -42
  1328. data/src/core/lib/transport/tcp_connect_handshaker.h +3 -3
  1329. data/src/core/lib/transport/timeout_encoding.cc +22 -22
  1330. data/src/core/lib/transport/timeout_encoding.h +20 -20
  1331. data/src/core/lib/transport/transport.cc +85 -46
  1332. data/src/core/lib/transport/transport.h +219 -215
  1333. data/src/core/lib/transport/transport_fwd.h +20 -0
  1334. data/src/core/lib/transport/transport_impl.h +46 -46
  1335. data/src/core/lib/transport/transport_op_string.cc +32 -30
  1336. data/src/core/lib/uri/uri_parser.cc +1 -1
  1337. data/src/core/lib/uri/uri_parser.h +3 -3
  1338. data/src/core/plugin_registry/grpc_plugin_registry.cc +53 -73
  1339. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +20 -39
  1340. data/src/core/tsi/alts/crypt/aes_gcm.cc +20 -20
  1341. data/src/core/tsi/alts/crypt/gsec.cc +26 -26
  1342. data/src/core/tsi/alts/crypt/gsec.h +336 -336
  1343. data/src/core/tsi/alts/frame_protector/alts_counter.cc +23 -23
  1344. data/src/core/tsi/alts/frame_protector/alts_counter.h +68 -68
  1345. data/src/core/tsi/alts/frame_protector/alts_crypter.cc +19 -19
  1346. data/src/core/tsi/alts/frame_protector/alts_crypter.h +209 -209
  1347. data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +72 -71
  1348. data/src/core/tsi/alts/frame_protector/alts_frame_protector.h +40 -40
  1349. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc +18 -18
  1350. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h +82 -83
  1351. data/src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc +22 -22
  1352. data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +22 -22
  1353. data/src/core/tsi/alts/frame_protector/frame_handler.cc +26 -25
  1354. data/src/core/tsi/alts/frame_protector/frame_handler.h +169 -169
  1355. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +117 -97
  1356. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +104 -104
  1357. data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +18 -17
  1358. data/src/core/tsi/alts/handshaker/alts_shared_resource.h +43 -44
  1359. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +51 -43
  1360. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +60 -60
  1361. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +24 -24
  1362. data/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +21 -20
  1363. data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +38 -38
  1364. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +19 -19
  1365. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +105 -104
  1366. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +45 -44
  1367. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +40 -41
  1368. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc +38 -36
  1369. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h +35 -36
  1370. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h +67 -68
  1371. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +32 -31
  1372. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +55 -56
  1373. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +54 -53
  1374. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h +141 -142
  1375. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +67 -58
  1376. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +43 -44
  1377. data/src/core/tsi/fake_transport_security.cc +146 -110
  1378. data/src/core/tsi/fake_transport_security.h +36 -30
  1379. data/src/core/tsi/local_transport_security.cc +43 -38
  1380. data/src/core/tsi/local_transport_security.h +33 -33
  1381. data/src/core/tsi/ssl/key_logging/ssl_key_logging.cc +9 -4
  1382. data/src/core/tsi/ssl/key_logging/ssl_key_logging.h +3 -3
  1383. data/src/core/tsi/ssl/session_cache/ssl_session.h +21 -21
  1384. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +19 -19
  1385. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +18 -17
  1386. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +31 -22
  1387. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +25 -20
  1388. data/src/core/tsi/ssl_transport_security.cc +299 -370
  1389. data/src/core/tsi/ssl_transport_security.h +206 -203
  1390. data/src/core/tsi/ssl_transport_security_utils.cc +250 -0
  1391. data/src/core/tsi/ssl_transport_security_utils.h +147 -0
  1392. data/src/core/tsi/ssl_types.h +27 -27
  1393. data/src/core/tsi/transport_security.cc +44 -32
  1394. data/src/core/tsi/transport_security.h +49 -48
  1395. data/src/core/tsi/transport_security_grpc.cc +23 -22
  1396. data/src/core/tsi/transport_security_grpc.h +44 -41
  1397. data/src/core/tsi/transport_security_interface.h +344 -332
  1398. data/src/ruby/ext/grpc/ext-export-truffleruby-with-ruby-abi-version.clang +2 -0
  1399. data/src/ruby/ext/grpc/ext-export-truffleruby-with-ruby-abi-version.gcc +7 -0
  1400. data/src/ruby/ext/grpc/ext-export-with-ruby-abi-version.clang +2 -0
  1401. data/src/ruby/ext/grpc/ext-export-with-ruby-abi-version.gcc +7 -0
  1402. data/src/ruby/ext/grpc/ext-export.gcc +1 -1
  1403. data/src/ruby/ext/grpc/extconf.rb +97 -19
  1404. data/src/ruby/ext/grpc/rb_call.c +1 -0
  1405. data/src/ruby/ext/grpc/rb_channel.c +1 -0
  1406. data/src/ruby/ext/grpc/rb_channel_args.c +1 -0
  1407. data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
  1408. data/src/ruby/ext/grpc/rb_grpc.c +1 -0
  1409. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +38 -38
  1410. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +60 -60
  1411. data/src/ruby/ext/grpc/rb_loader.c +6 -2
  1412. data/src/ruby/lib/grpc/errors.rb +1 -1
  1413. data/src/ruby/lib/grpc/generic/bidi_call.rb +2 -0
  1414. data/src/ruby/lib/grpc/version.rb +1 -1
  1415. data/src/ruby/pb/generate_proto_ruby.sh +0 -6
  1416. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +4 -0
  1417. data/src/ruby/spec/channel_spec.rb +5 -43
  1418. data/src/ruby/spec/client_server_spec.rb +20 -8
  1419. data/src/ruby/spec/generic/active_call_spec.rb +12 -3
  1420. data/src/ruby/spec/generic/client_stub_spec.rb +23 -23
  1421. data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
  1422. data/src/ruby/spec/user_agent_spec.rb +1 -1
  1423. data/third_party/abseil-cpp/absl/algorithm/container.h +57 -58
  1424. data/third_party/abseil-cpp/absl/base/attributes.h +88 -41
  1425. data/third_party/abseil-cpp/absl/base/casts.h +61 -68
  1426. data/third_party/abseil-cpp/absl/base/config.h +221 -39
  1427. data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +12 -42
  1428. data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +52 -2
  1429. data/third_party/abseil-cpp/absl/base/internal/cycleclock_config.h +55 -0
  1430. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +5 -4
  1431. data/third_party/abseil-cpp/absl/base/internal/endian.h +17 -62
  1432. data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +2 -0
  1433. data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +3 -3
  1434. data/third_party/abseil-cpp/absl/base/internal/invoke.h +54 -0
  1435. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +2 -2
  1436. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +1 -1
  1437. data/third_party/abseil-cpp/absl/base/internal/prefetch.h +138 -0
  1438. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +39 -28
  1439. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +36 -36
  1440. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +6 -3
  1441. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +10 -6
  1442. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +2 -5
  1443. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +4 -1
  1444. data/third_party/abseil-cpp/absl/base/internal/strerror.cc +88 -0
  1445. data/third_party/abseil-cpp/absl/base/internal/strerror.h +39 -0
  1446. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +14 -11
  1447. data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +9 -0
  1448. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +2 -1
  1449. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +4 -0
  1450. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +6 -7
  1451. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +12 -40
  1452. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock_config.h +62 -0
  1453. data/third_party/abseil-cpp/absl/base/log_severity.cc +28 -0
  1454. data/third_party/abseil-cpp/absl/base/log_severity.h +51 -0
  1455. data/third_party/abseil-cpp/absl/base/macros.h +4 -21
  1456. data/third_party/abseil-cpp/absl/base/optimization.h +76 -16
  1457. data/third_party/abseil-cpp/absl/base/options.h +1 -7
  1458. data/third_party/abseil-cpp/absl/base/policy_checks.h +15 -13
  1459. data/third_party/abseil-cpp/absl/base/thread_annotations.h +2 -2
  1460. data/third_party/abseil-cpp/absl/container/fixed_array.h +9 -5
  1461. data/third_party/abseil-cpp/absl/container/flat_hash_map.h +11 -4
  1462. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +15 -16
  1463. data/third_party/abseil-cpp/absl/container/inlined_vector.h +84 -25
  1464. data/third_party/abseil-cpp/absl/container/internal/common.h +9 -8
  1465. data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +132 -0
  1466. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +23 -29
  1467. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +4 -55
  1468. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +116 -23
  1469. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +40 -54
  1470. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +165 -66
  1471. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +159 -4
  1472. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1121 -470
  1473. data/third_party/abseil-cpp/absl/crc/crc32c.cc +99 -0
  1474. data/third_party/abseil-cpp/absl/crc/crc32c.h +183 -0
  1475. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +256 -0
  1476. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.h +57 -0
  1477. data/third_party/abseil-cpp/absl/crc/internal/crc.cc +468 -0
  1478. data/third_party/abseil-cpp/absl/crc/internal/crc.h +91 -0
  1479. data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +269 -0
  1480. data/third_party/abseil-cpp/absl/crc/internal/crc32c.h +39 -0
  1481. data/third_party/abseil-cpp/absl/crc/internal/crc32c_inline.h +72 -0
  1482. data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.cc +130 -0
  1483. data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.h +159 -0
  1484. data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +179 -0
  1485. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy.h +119 -0
  1486. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_fallback.cc +75 -0
  1487. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_64.cc +434 -0
  1488. data/third_party/abseil-cpp/absl/crc/internal/crc_non_temporal_memcpy.cc +93 -0
  1489. data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +725 -0
  1490. data/third_party/abseil-cpp/absl/crc/internal/non_temporal_arm_intrinsics.h +79 -0
  1491. data/third_party/abseil-cpp/absl/crc/internal/non_temporal_memcpy.h +180 -0
  1492. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +45 -88
  1493. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +67 -38
  1494. data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +1 -1
  1495. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +16 -13
  1496. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +3 -2
  1497. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +19 -12
  1498. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +8 -3
  1499. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +2 -1
  1500. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +1 -1
  1501. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +8 -3
  1502. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +59 -102
  1503. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +5 -4
  1504. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +41 -11
  1505. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +18 -4
  1506. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +6 -1
  1507. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +3 -2
  1508. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +164 -101
  1509. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +7 -6
  1510. data/third_party/abseil-cpp/absl/functional/any_invocable.h +316 -0
  1511. data/third_party/abseil-cpp/absl/functional/bind_front.h +10 -1
  1512. data/third_party/abseil-cpp/absl/functional/function_ref.h +2 -1
  1513. data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +878 -0
  1514. data/third_party/abseil-cpp/absl/hash/hash.h +82 -8
  1515. data/third_party/abseil-cpp/absl/hash/internal/city.cc +10 -10
  1516. data/third_party/abseil-cpp/absl/hash/internal/hash.h +235 -26
  1517. data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +3 -14
  1518. data/third_party/abseil-cpp/absl/memory/memory.h +26 -447
  1519. data/third_party/abseil-cpp/absl/meta/type_traits.h +104 -12
  1520. data/third_party/abseil-cpp/absl/numeric/bits.h +1 -1
  1521. data/third_party/abseil-cpp/absl/numeric/int128.cc +14 -10
  1522. data/third_party/abseil-cpp/absl/numeric/int128.h +2 -2
  1523. data/third_party/abseil-cpp/absl/profiling/internal/sample_recorder.h +33 -10
  1524. data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +4 -4
  1525. data/third_party/abseil-cpp/absl/random/distributions.h +3 -3
  1526. data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +3 -0
  1527. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +4 -2
  1528. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +2 -2
  1529. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +59 -48
  1530. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +3 -24
  1531. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +9 -9
  1532. data/third_party/abseil-cpp/absl/random/internal/randen.h +5 -11
  1533. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +6 -2
  1534. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +48 -23
  1535. data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +24 -26
  1536. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +2 -2
  1537. data/third_party/abseil-cpp/absl/random/internal/traits.h +53 -5
  1538. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +5 -5
  1539. data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +33 -48
  1540. data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +9 -10
  1541. data/third_party/abseil-cpp/absl/random/poisson_distribution.h +7 -4
  1542. data/third_party/abseil-cpp/absl/random/random.h +6 -6
  1543. data/third_party/abseil-cpp/absl/random/seed_sequences.h +1 -0
  1544. data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +2 -2
  1545. data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +1 -1
  1546. data/third_party/abseil-cpp/absl/random/zipf_distribution.h +4 -3
  1547. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +18 -0
  1548. data/third_party/abseil-cpp/absl/status/status.cc +193 -14
  1549. data/third_party/abseil-cpp/absl/status/status.h +24 -14
  1550. data/third_party/abseil-cpp/absl/status/statusor.h +9 -3
  1551. data/third_party/abseil-cpp/absl/strings/ascii.cc +5 -5
  1552. data/third_party/abseil-cpp/absl/strings/ascii.h +4 -4
  1553. data/third_party/abseil-cpp/absl/strings/charconv.cc +534 -96
  1554. data/third_party/abseil-cpp/absl/strings/cord.cc +257 -924
  1555. data/third_party/abseil-cpp/absl/strings/cord.h +268 -156
  1556. data/third_party/abseil-cpp/absl/strings/cord_analysis.cc +188 -0
  1557. data/third_party/abseil-cpp/absl/strings/cord_analysis.h +44 -0
  1558. data/third_party/abseil-cpp/absl/strings/cord_buffer.cc +30 -0
  1559. data/third_party/abseil-cpp/absl/strings/cord_buffer.h +575 -0
  1560. data/third_party/abseil-cpp/absl/strings/escaping.cc +73 -62
  1561. data/third_party/abseil-cpp/absl/strings/escaping.h +24 -19
  1562. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +14 -12
  1563. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +4 -4
  1564. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +2 -2
  1565. data/third_party/abseil-cpp/absl/strings/internal/cord_data_edge.h +63 -0
  1566. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +20 -32
  1567. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +441 -150
  1568. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +157 -53
  1569. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.h +70 -73
  1570. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_navigator.cc +8 -6
  1571. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_navigator.h +4 -2
  1572. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_reader.cc +3 -2
  1573. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_reader.h +5 -4
  1574. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.cc +7 -74
  1575. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_crc.cc +56 -0
  1576. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_crc.h +103 -0
  1577. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +58 -17
  1578. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.cc +13 -11
  1579. data/third_party/abseil-cpp/absl/strings/internal/cordz_functions.h +7 -15
  1580. data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.h +3 -3
  1581. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +19 -43
  1582. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.h +7 -7
  1583. data/third_party/abseil-cpp/absl/strings/internal/cordz_statistics.h +5 -4
  1584. data/third_party/abseil-cpp/absl/strings/internal/cordz_update_tracker.h +4 -2
  1585. data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.cc +93 -0
  1586. data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.h +34 -0
  1587. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +18 -15
  1588. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +7 -9
  1589. data/third_party/abseil-cpp/absl/strings/internal/has_absl_stringify.h +55 -0
  1590. data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +9 -6
  1591. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +14 -7
  1592. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +35 -10
  1593. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +113 -46
  1594. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +127 -30
  1595. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +3 -2
  1596. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +42 -10
  1597. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +56 -289
  1598. data/third_party/abseil-cpp/absl/strings/internal/str_format/constexpr_parser.h +351 -0
  1599. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +6 -6
  1600. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +9 -4
  1601. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +215 -181
  1602. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +2 -1
  1603. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +10 -209
  1604. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +14 -103
  1605. data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +9 -6
  1606. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +2 -1
  1607. data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +10 -2
  1608. data/third_party/abseil-cpp/absl/strings/internal/stringify_sink.cc +28 -0
  1609. data/third_party/abseil-cpp/absl/strings/internal/stringify_sink.h +57 -0
  1610. data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +9 -9
  1611. data/third_party/abseil-cpp/absl/strings/numbers.cc +42 -39
  1612. data/third_party/abseil-cpp/absl/strings/numbers.h +26 -23
  1613. data/third_party/abseil-cpp/absl/strings/str_cat.cc +9 -6
  1614. data/third_party/abseil-cpp/absl/strings/str_cat.h +70 -16
  1615. data/third_party/abseil-cpp/absl/strings/str_format.h +71 -9
  1616. data/third_party/abseil-cpp/absl/strings/str_join.h +9 -15
  1617. data/third_party/abseil-cpp/absl/strings/str_split.h +1 -2
  1618. data/third_party/abseil-cpp/absl/strings/string_view.cc +8 -19
  1619. data/third_party/abseil-cpp/absl/strings/string_view.h +6 -12
  1620. data/third_party/abseil-cpp/absl/strings/strip.h +8 -6
  1621. data/third_party/abseil-cpp/absl/strings/substitute.cc +8 -6
  1622. data/third_party/abseil-cpp/absl/strings/substitute.h +55 -21
  1623. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +9 -6
  1624. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +0 -4
  1625. data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +20 -17
  1626. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +37 -31
  1627. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +22 -8
  1628. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +0 -4
  1629. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +1 -6
  1630. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +0 -25
  1631. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +10 -4
  1632. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +172 -88
  1633. data/third_party/abseil-cpp/absl/synchronization/mutex.h +102 -55
  1634. data/third_party/abseil-cpp/absl/synchronization/notification.cc +0 -1
  1635. data/third_party/abseil-cpp/absl/synchronization/notification.h +3 -3
  1636. data/third_party/abseil-cpp/absl/time/civil_time.cc +26 -0
  1637. data/third_party/abseil-cpp/absl/time/civil_time.h +25 -0
  1638. data/third_party/abseil-cpp/absl/time/clock.cc +17 -11
  1639. data/third_party/abseil-cpp/absl/time/duration.cc +12 -11
  1640. data/third_party/abseil-cpp/absl/time/format.cc +2 -1
  1641. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +11 -7
  1642. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +1 -1
  1643. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +26 -5
  1644. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +7 -6
  1645. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +36 -35
  1646. data/third_party/abseil-cpp/absl/time/time.cc +2 -2
  1647. data/third_party/abseil-cpp/absl/time/time.h +268 -169
  1648. data/third_party/abseil-cpp/absl/types/internal/optional.h +8 -0
  1649. data/third_party/abseil-cpp/absl/types/internal/span.h +30 -19
  1650. data/third_party/abseil-cpp/absl/types/internal/variant.h +28 -40
  1651. data/third_party/abseil-cpp/absl/types/optional.h +17 -14
  1652. data/third_party/abseil-cpp/absl/types/span.h +31 -8
  1653. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +1 -1
  1654. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +1 -2
  1655. data/third_party/re2/re2/bitstate.cc +3 -3
  1656. data/third_party/re2/re2/dfa.cc +13 -13
  1657. data/third_party/re2/re2/nfa.cc +4 -4
  1658. data/third_party/re2/re2/onepass.cc +2 -2
  1659. data/third_party/re2/re2/prefilter_tree.cc +27 -59
  1660. data/third_party/re2/re2/prefilter_tree.h +3 -2
  1661. data/third_party/re2/re2/prog.cc +11 -2
  1662. data/third_party/re2/re2/prog.h +17 -5
  1663. data/third_party/re2/re2/re2.cc +6 -11
  1664. data/third_party/re2/re2/re2.h +1 -1
  1665. data/third_party/re2/re2/regexp.cc +1 -2
  1666. data/third_party/re2/re2/stringpiece.h +10 -7
  1667. data/third_party/re2/re2/unicode_casefold.cc +25 -11
  1668. data/third_party/re2/re2/unicode_groups.cc +319 -151
  1669. data/third_party/re2/re2/walker-inl.h +3 -2
  1670. data/third_party/re2/util/mutex.h +4 -4
  1671. data/third_party/upb/third_party/utf8_range/utf8_range.h +1 -1
  1672. data/third_party/upb/upb/arena.c +277 -0
  1673. data/third_party/upb/upb/arena.h +225 -0
  1674. data/third_party/upb/upb/array.c +114 -0
  1675. data/third_party/upb/upb/array.h +83 -0
  1676. data/third_party/upb/upb/collections.h +36 -0
  1677. data/third_party/upb/upb/decode.c +161 -65
  1678. data/third_party/upb/upb/decode.h +1 -0
  1679. data/third_party/upb/upb/decode_fast.c +1 -1
  1680. data/third_party/upb/upb/def.c +10 -2
  1681. data/third_party/upb/upb/def.h +8 -1
  1682. data/third_party/upb/upb/def.hpp +7 -4
  1683. data/third_party/upb/upb/encode.c +29 -20
  1684. data/third_party/upb/upb/encode.h +16 -6
  1685. data/third_party/upb/upb/extension_registry.c +93 -0
  1686. data/third_party/upb/upb/extension_registry.h +84 -0
  1687. data/third_party/upb/upb/{decode_internal.h → internal/decode.h} +5 -5
  1688. data/third_party/upb/upb/internal/table.h +385 -0
  1689. data/third_party/upb/upb/{upb_internal.h → internal/upb.h} +3 -3
  1690. data/third_party/upb/upb/internal/vsnprintf_compat.h +52 -0
  1691. data/third_party/upb/upb/json_decode.c +1512 -0
  1692. data/third_party/upb/upb/json_decode.h +47 -0
  1693. data/third_party/upb/upb/json_encode.c +7 -3
  1694. data/third_party/upb/upb/json_encode.h +6 -3
  1695. data/third_party/upb/upb/map.c +108 -0
  1696. data/third_party/upb/upb/map.h +117 -0
  1697. data/third_party/upb/upb/message_value.h +66 -0
  1698. data/third_party/upb/upb/mini_table.c +1147 -0
  1699. data/third_party/upb/upb/mini_table.h +189 -0
  1700. data/third_party/upb/upb/mini_table.hpp +112 -0
  1701. data/third_party/upb/upb/msg.c +2 -62
  1702. data/third_party/upb/upb/msg.h +2 -45
  1703. data/third_party/upb/upb/msg_internal.h +28 -22
  1704. data/third_party/upb/upb/port_def.inc +2 -1
  1705. data/third_party/upb/upb/port_undef.inc +1 -0
  1706. data/third_party/upb/upb/reflection.c +2 -159
  1707. data/third_party/upb/upb/reflection.h +2 -112
  1708. data/third_party/upb/upb/status.c +86 -0
  1709. data/third_party/upb/upb/status.h +66 -0
  1710. data/third_party/upb/upb/table.c +2 -2
  1711. data/third_party/upb/upb/table_internal.h +3 -352
  1712. data/third_party/upb/upb/text_encode.c +3 -2
  1713. data/third_party/upb/upb/upb.c +4 -290
  1714. data/third_party/upb/upb/upb.h +7 -196
  1715. data/third_party/zlib/compress.c +3 -3
  1716. data/third_party/zlib/crc32.c +21 -12
  1717. data/third_party/zlib/deflate.c +112 -106
  1718. data/third_party/zlib/deflate.h +2 -2
  1719. data/third_party/zlib/gzlib.c +1 -1
  1720. data/third_party/zlib/gzread.c +3 -5
  1721. data/third_party/zlib/gzwrite.c +1 -1
  1722. data/third_party/zlib/infback.c +10 -7
  1723. data/third_party/zlib/inflate.c +5 -2
  1724. data/third_party/zlib/inftrees.c +2 -2
  1725. data/third_party/zlib/inftrees.h +1 -1
  1726. data/third_party/zlib/trees.c +61 -62
  1727. data/third_party/zlib/uncompr.c +2 -2
  1728. data/third_party/zlib/zconf.h +16 -3
  1729. data/third_party/zlib/zlib.h +10 -10
  1730. data/third_party/zlib/zutil.c +9 -7
  1731. data/third_party/zlib/zutil.h +1 -0
  1732. metadata +339 -78
  1733. data/include/grpc/impl/codegen/gpr_slice.h +0 -71
  1734. data/src/core/ext/filters/client_channel/lb_policy_factory.h +0 -50
  1735. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +0 -192
  1736. data/src/core/ext/filters/client_channel/lb_policy_registry.h +0 -70
  1737. data/src/core/ext/filters/client_channel/proxy_mapper.h +0 -54
  1738. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +0 -91
  1739. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -55
  1740. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +0 -180
  1741. data/src/core/ext/filters/fault_injection/service_config_parser.cc +0 -179
  1742. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +0 -457
  1743. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +0 -53
  1744. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -388
  1745. data/src/core/ext/filters/server_config_selector/server_config_selector.cc +0 -61
  1746. data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
  1747. data/src/core/ext/xds/certificate_provider_registry.h +0 -57
  1748. data/src/core/lib/event_engine/iomgr_engine.cc +0 -206
  1749. data/src/core/lib/event_engine/iomgr_engine.h +0 -118
  1750. data/src/core/lib/gpr/env.h +0 -40
  1751. data/src/core/lib/gpr/env_linux.cc +0 -75
  1752. data/src/core/lib/gpr/env_posix.cc +0 -46
  1753. data/src/core/lib/gpr/env_windows.cc +0 -74
  1754. data/src/core/lib/gpr/murmur_hash.cc +0 -82
  1755. data/src/core/lib/gpr/murmur_hash.h +0 -29
  1756. data/src/core/lib/gpr/string_windows.h +0 -32
  1757. data/src/core/lib/gpr/tls.h +0 -156
  1758. data/src/core/lib/iomgr/error_internal.h +0 -66
  1759. data/src/core/lib/iomgr/executor/mpmcqueue.cc +0 -182
  1760. data/src/core/lib/iomgr/executor/mpmcqueue.h +0 -171
  1761. data/src/core/lib/iomgr/executor/threadpool.cc +0 -136
  1762. data/src/core/lib/iomgr/executor/threadpool.h +0 -150
  1763. data/src/core/lib/iomgr/time_averaged_stats.cc +0 -64
  1764. data/src/core/lib/iomgr/time_averaged_stats.h +0 -72
  1765. data/src/core/lib/profiling/basic_timers.cc +0 -295
  1766. data/src/core/lib/profiling/stap_timers.cc +0 -50
  1767. data/src/core/lib/profiling/timers.h +0 -94
  1768. data/src/core/lib/promise/call_push_pull.h +0 -148
  1769. data/src/core/lib/security/security_connector/load_system_roots_linux.h +0 -46
  1770. data/src/core/lib/slice/slice_api.cc +0 -39
  1771. data/src/core/lib/slice/slice_buffer_api.cc +0 -35
  1772. data/src/core/lib/slice/slice_refcount_base.h +0 -60
  1773. data/src/core/lib/slice/slice_split.cc +0 -103
  1774. data/src/core/lib/slice/slice_split.h +0 -36
  1775. data/src/core/lib/transport/byte_stream.cc +0 -165
  1776. data/src/core/lib/transport/byte_stream.h +0 -170
  1777. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +0 -50
@@ -1,47 +1,54 @@
1
- /*
2
- *
3
- * Copyright 2015 gRPC authors.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- *
17
- */
1
+ //
2
+ //
3
+ // Copyright 2015 gRPC authors.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ //
17
+ //
18
18
 
19
19
  #include <grpc/support/port_platform.h>
20
20
 
21
21
  #include "src/core/lib/surface/call.h"
22
22
 
23
+ #include <inttypes.h>
23
24
  #include <limits.h>
24
25
  #include <stdlib.h>
25
26
 
26
27
  #include <algorithm>
27
28
  #include <atomic>
29
+ #include <initializer_list>
28
30
  #include <memory>
29
31
  #include <new>
30
32
  #include <string>
33
+ #include <type_traits>
31
34
  #include <utility>
35
+ #include <vector>
32
36
 
33
37
  #include "absl/base/thread_annotations.h"
38
+ #include "absl/cleanup/cleanup.h"
34
39
  #include "absl/meta/type_traits.h"
35
40
  #include "absl/status/status.h"
36
41
  #include "absl/strings/str_cat.h"
37
42
  #include "absl/strings/str_format.h"
43
+ #include "absl/strings/str_join.h"
38
44
  #include "absl/strings/string_view.h"
45
+ #include "absl/types/variant.h"
39
46
 
40
47
  #include <grpc/byte_buffer.h>
41
48
  #include <grpc/compression.h>
49
+ #include <grpc/event_engine/event_engine.h>
42
50
  #include <grpc/grpc.h>
43
- #include <grpc/impl/codegen/gpr_types.h>
44
- #include <grpc/impl/codegen/propagation_bits.h>
51
+ #include <grpc/impl/propagation_bits.h>
45
52
  #include <grpc/slice.h>
46
53
  #include <grpc/slice_buffer.h>
47
54
  #include <grpc/status.h>
@@ -49,44 +56,60 @@
49
56
  #include <grpc/support/atm.h>
50
57
  #include <grpc/support/log.h>
51
58
  #include <grpc/support/string_util.h>
59
+ #include <grpc/support/time.h>
52
60
 
61
+ #include "src/core/lib/channel/call_finalization.h"
53
62
  #include "src/core/lib/channel/channel_stack.h"
54
- #include "src/core/lib/channel/channel_stack_builder.h"
55
63
  #include "src/core/lib/channel/channelz.h"
56
64
  #include "src/core/lib/channel/context.h"
65
+ #include "src/core/lib/channel/status_util.h"
57
66
  #include "src/core/lib/compression/compression_internal.h"
58
67
  #include "src/core/lib/debug/stats.h"
68
+ #include "src/core/lib/debug/stats_data.h"
69
+ #include "src/core/lib/experiments/experiments.h"
59
70
  #include "src/core/lib/gpr/alloc.h"
60
71
  #include "src/core/lib/gpr/time_precise.h"
72
+ #include "src/core/lib/gpr/useful.h"
73
+ #include "src/core/lib/gprpp/bitset.h"
61
74
  #include "src/core/lib/gprpp/cpp_impl_of.h"
75
+ #include "src/core/lib/gprpp/crash.h"
62
76
  #include "src/core/lib/gprpp/debug_location.h"
63
- #include "src/core/lib/gprpp/manual_constructor.h"
64
- #include "src/core/lib/gprpp/orphanable.h"
65
77
  #include "src/core/lib/gprpp/ref_counted.h"
78
+ #include "src/core/lib/gprpp/ref_counted_ptr.h"
79
+ #include "src/core/lib/gprpp/status_helper.h"
66
80
  #include "src/core/lib/gprpp/sync.h"
67
81
  #include "src/core/lib/iomgr/call_combiner.h"
68
82
  #include "src/core/lib/iomgr/exec_ctx.h"
69
83
  #include "src/core/lib/iomgr/polling_entity.h"
70
- #include "src/core/lib/profiling/timers.h"
84
+ #include "src/core/lib/promise/activity.h"
85
+ #include "src/core/lib/promise/arena_promise.h"
86
+ #include "src/core/lib/promise/context.h"
87
+ #include "src/core/lib/promise/detail/basic_seq.h"
88
+ #include "src/core/lib/promise/pipe.h"
89
+ #include "src/core/lib/promise/poll.h"
71
90
  #include "src/core/lib/resource_quota/arena.h"
91
+ #include "src/core/lib/slice/slice_buffer.h"
72
92
  #include "src/core/lib/slice/slice_internal.h"
73
- #include "src/core/lib/slice/slice_refcount.h"
74
93
  #include "src/core/lib/surface/api_trace.h"
75
94
  #include "src/core/lib/surface/call_test_only.h"
76
95
  #include "src/core/lib/surface/channel.h"
77
96
  #include "src/core/lib/surface/completion_queue.h"
78
97
  #include "src/core/lib/surface/server.h"
79
98
  #include "src/core/lib/surface/validate_metadata.h"
80
- #include "src/core/lib/transport/byte_stream.h"
81
99
  #include "src/core/lib/transport/error_utils.h"
82
100
  #include "src/core/lib/transport/metadata_batch.h"
83
101
  #include "src/core/lib/transport/transport.h"
84
102
 
85
103
  grpc_core::TraceFlag grpc_call_error_trace(false, "call_error");
86
104
  grpc_core::TraceFlag grpc_compression_trace(false, "compression");
105
+ grpc_core::TraceFlag grpc_call_trace(false, "call");
106
+ grpc_core::DebugOnlyTraceFlag grpc_call_refcount_trace(false, "call_refcount");
87
107
 
88
108
  namespace grpc_core {
89
109
 
110
+ ///////////////////////////////////////////////////////////////////////////////
111
+ // Call
112
+
90
113
  class Call : public CppImplOf<Call, grpc_call> {
91
114
  public:
92
115
  Arena* arena() { return arena_; }
@@ -99,12 +122,13 @@ class Call : public CppImplOf<Call, grpc_call> {
99
122
  void CancelWithStatus(grpc_status_code status, const char* description);
100
123
  virtual void CancelWithError(grpc_error_handle error) = 0;
101
124
  virtual void SetCompletionQueue(grpc_completion_queue* cq) = 0;
102
- virtual char* GetPeer() = 0;
125
+ char* GetPeer();
103
126
  virtual grpc_call_error StartBatch(const grpc_op* ops, size_t nops,
104
127
  void* notify_tag,
105
128
  bool is_notify_tag_closure) = 0;
106
129
  virtual bool failed_before_recv_message() const = 0;
107
130
  virtual bool is_trailers_only() const = 0;
131
+ virtual absl::string_view GetServerAuthority() const = 0;
108
132
  virtual void ExternalRef() = 0;
109
133
  virtual void ExternalUnref() = 0;
110
134
  virtual void InternalRef(const char* reason) = 0;
@@ -120,12 +144,19 @@ class Call : public CppImplOf<Call, grpc_call> {
120
144
  // for that functionality be invented)
121
145
  virtual grpc_call_stack* call_stack() = 0;
122
146
 
147
+ gpr_atm* peer_string_atm_ptr() { return &peer_string_; }
148
+
123
149
  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;
150
+ // The maximum number of concurrent batches possible.
151
+ // Based upon the maximum number of individually queueable ops in the batch
152
+ // api:
153
+ // - initial metadata send
154
+ // - message send
155
+ // - status/close send (depending on client/server)
156
+ // - initial metadata recv
157
+ // - message recv
158
+ // - status/close recv (depending on client/server)
159
+ static constexpr size_t kMaxConcurrentBatches = 6;
129
160
 
130
161
  struct ParentCall {
131
162
  Mutex child_list_mu;
@@ -135,15 +166,32 @@ class Call : public CppImplOf<Call, grpc_call> {
135
166
  struct ChildCall {
136
167
  explicit ChildCall(Call* parent) : parent(parent) {}
137
168
  Call* parent;
138
- /** siblings: children of the same parent form a list, and this list is
139
- protected under
140
- parent->mu */
169
+ /// siblings: children of the same parent form a list, and this list is
170
+ /// protected under
171
+ /// parent->mu
141
172
  Call* sibling_next = nullptr;
142
173
  Call* sibling_prev = nullptr;
143
174
  };
144
175
 
176
+ Call(Arena* arena, bool is_client, Timestamp send_deadline,
177
+ RefCountedPtr<Channel> channel)
178
+ : channel_(std::move(channel)),
179
+ arena_(arena),
180
+ send_deadline_(send_deadline),
181
+ is_client_(is_client) {
182
+ GPR_DEBUG_ASSERT(arena_ != nullptr);
183
+ GPR_DEBUG_ASSERT(channel_ != nullptr);
184
+ }
185
+ virtual ~Call() = default;
186
+
187
+ void DeleteThis();
188
+
145
189
  ParentCall* GetOrCreateParentCall();
146
190
  ParentCall* parent_call();
191
+ Channel* channel() {
192
+ GPR_DEBUG_ASSERT(channel_ != nullptr);
193
+ return channel_.get();
194
+ }
147
195
 
148
196
  absl::Status InitParent(Call* parent, uint32_t propagation_mask);
149
197
  void PublishToParent(Call* parent);
@@ -155,7 +203,10 @@ class Call : public CppImplOf<Call, grpc_call> {
155
203
  send_deadline_ = send_deadline;
156
204
  }
157
205
 
206
+ void ClearPeerString() { gpr_atm_rel_store(&peer_string_, 0); }
207
+
158
208
  private:
209
+ RefCountedPtr<Channel> channel_;
159
210
  Arena* const arena_;
160
211
  std::atomic<ParentCall*> parent_call_{nullptr};
161
212
  ChildCall* child_ = nullptr;
@@ -163,11 +214,151 @@ class Call : public CppImplOf<Call, grpc_call> {
163
214
  const bool is_client_;
164
215
  // flag indicating that cancellation is inherited
165
216
  bool cancellation_is_inherited_ = false;
217
+ // A char* indicating the peer name.
218
+ gpr_atm peer_string_ = 0;
166
219
  };
167
220
 
221
+ Call::ParentCall* Call::GetOrCreateParentCall() {
222
+ ParentCall* p = parent_call_.load(std::memory_order_acquire);
223
+ if (p == nullptr) {
224
+ p = arena_->New<ParentCall>();
225
+ ParentCall* expected = nullptr;
226
+ if (!parent_call_.compare_exchange_strong(expected, p,
227
+ std::memory_order_release,
228
+ std::memory_order_relaxed)) {
229
+ p->~ParentCall();
230
+ p = expected;
231
+ }
232
+ }
233
+ return p;
234
+ }
235
+
236
+ Call::ParentCall* Call::parent_call() {
237
+ return parent_call_.load(std::memory_order_acquire);
238
+ }
239
+
240
+ absl::Status Call::InitParent(Call* parent, uint32_t propagation_mask) {
241
+ child_ = arena()->New<ChildCall>(parent);
242
+
243
+ parent->InternalRef("child");
244
+ GPR_ASSERT(is_client_);
245
+ GPR_ASSERT(!parent->is_client_);
246
+
247
+ if (propagation_mask & GRPC_PROPAGATE_DEADLINE) {
248
+ send_deadline_ = std::min(send_deadline_, parent->send_deadline_);
249
+ }
250
+ // for now GRPC_PROPAGATE_TRACING_CONTEXT *MUST* be passed with
251
+ // GRPC_PROPAGATE_STATS_CONTEXT
252
+ // TODO(ctiller): This should change to use the appropriate census start_op
253
+ // call.
254
+ if (propagation_mask & GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT) {
255
+ if (0 == (propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT)) {
256
+ return absl::UnknownError(
257
+ "Census tracing propagation requested without Census context "
258
+ "propagation");
259
+ }
260
+ ContextSet(GRPC_CONTEXT_TRACING, parent->ContextGet(GRPC_CONTEXT_TRACING),
261
+ nullptr);
262
+ } else if (propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT) {
263
+ return absl::UnknownError(
264
+ "Census context propagation requested without Census tracing "
265
+ "propagation");
266
+ }
267
+ if (propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
268
+ cancellation_is_inherited_ = true;
269
+ }
270
+ return absl::OkStatus();
271
+ }
272
+
273
+ void Call::PublishToParent(Call* parent) {
274
+ ChildCall* cc = child_;
275
+ ParentCall* pc = parent->GetOrCreateParentCall();
276
+ MutexLock lock(&pc->child_list_mu);
277
+ if (pc->first_child == nullptr) {
278
+ pc->first_child = this;
279
+ cc->sibling_next = cc->sibling_prev = this;
280
+ } else {
281
+ cc->sibling_next = pc->first_child;
282
+ cc->sibling_prev = pc->first_child->child_->sibling_prev;
283
+ cc->sibling_next->child_->sibling_prev =
284
+ cc->sibling_prev->child_->sibling_next = this;
285
+ }
286
+ if (parent->Completed()) {
287
+ CancelWithError(absl::CancelledError());
288
+ }
289
+ }
290
+
291
+ void Call::MaybeUnpublishFromParent() {
292
+ ChildCall* cc = child_;
293
+ if (cc == nullptr) return;
294
+
295
+ ParentCall* pc = cc->parent->parent_call();
296
+ {
297
+ MutexLock lock(&pc->child_list_mu);
298
+ if (this == pc->first_child) {
299
+ pc->first_child = cc->sibling_next;
300
+ if (this == pc->first_child) {
301
+ pc->first_child = nullptr;
302
+ }
303
+ }
304
+ cc->sibling_prev->child_->sibling_next = cc->sibling_next;
305
+ cc->sibling_next->child_->sibling_prev = cc->sibling_prev;
306
+ }
307
+ cc->parent->InternalUnref("child");
308
+ }
309
+
310
+ void Call::CancelWithStatus(grpc_status_code status, const char* description) {
311
+ // copying 'description' is needed to ensure the grpc_call_cancel_with_status
312
+ // guarantee that can be short-lived.
313
+ CancelWithError(grpc_error_set_int(
314
+ grpc_error_set_str(GRPC_ERROR_CREATE(description),
315
+ StatusStrProperty::kGrpcMessage, description),
316
+ StatusIntProperty::kRpcStatus, status));
317
+ }
318
+
319
+ void Call::PropagateCancellationToChildren() {
320
+ ParentCall* pc = parent_call();
321
+ if (pc != nullptr) {
322
+ Call* child;
323
+ MutexLock lock(&pc->child_list_mu);
324
+ child = pc->first_child;
325
+ if (child != nullptr) {
326
+ do {
327
+ Call* next_child_call = child->child_->sibling_next;
328
+ if (child->cancellation_is_inherited_) {
329
+ child->InternalRef("propagate_cancel");
330
+ child->CancelWithError(absl::CancelledError());
331
+ child->InternalUnref("propagate_cancel");
332
+ }
333
+ child = next_child_call;
334
+ } while (child != pc->first_child);
335
+ }
336
+ }
337
+ }
338
+
339
+ char* Call::GetPeer() {
340
+ char* peer_string = reinterpret_cast<char*>(gpr_atm_acq_load(&peer_string_));
341
+ if (peer_string != nullptr) return gpr_strdup(peer_string);
342
+ peer_string = grpc_channel_get_target(channel_->c_ptr());
343
+ if (peer_string != nullptr) return peer_string;
344
+ return gpr_strdup("unknown");
345
+ }
346
+
347
+ void Call::DeleteThis() {
348
+ RefCountedPtr<Channel> channel = std::move(channel_);
349
+ Arena* arena = arena_;
350
+ this->~Call();
351
+ channel->UpdateCallSizeEstimate(arena->TotalUsedBytes());
352
+ arena->Destroy();
353
+ }
354
+
355
+ ///////////////////////////////////////////////////////////////////////////////
356
+ // FilterStackCall
357
+ // To be removed once promise conversion is complete
358
+
168
359
  class FilterStackCall final : public Call {
169
360
  public:
170
- ~FilterStackCall() {
361
+ ~FilterStackCall() override {
171
362
  for (int i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
172
363
  if (context_[i].destroy) {
173
364
  context_[i].destroy(context_[i].value);
@@ -202,7 +393,6 @@ class FilterStackCall final : public Call {
202
393
 
203
394
  void CancelWithError(grpc_error_handle error) override;
204
395
  void SetCompletionQueue(grpc_completion_queue* cq) override;
205
- char* GetPeer() override;
206
396
  grpc_call_error StartBatch(const grpc_op* ops, size_t nops, void* notify_tag,
207
397
  bool is_notify_tag_closure) override;
208
398
  void ExternalRef() override { ext_ref_.Ref(); }
@@ -235,6 +425,13 @@ class FilterStackCall final : public Call {
235
425
  return call_failed_before_recv_message_;
236
426
  }
237
427
 
428
+ absl::string_view GetServerAuthority() const override {
429
+ const Slice* authority_metadata =
430
+ recv_initial_metadata_.get_pointer(HttpAuthorityMetadata());
431
+ if (authority_metadata == nullptr) return "";
432
+ return authority_metadata->as_string_view();
433
+ }
434
+
238
435
  grpc_compression_algorithm test_only_compression_algorithm() override {
239
436
  return incoming_compression_algorithm_;
240
437
  }
@@ -253,57 +450,78 @@ class FilterStackCall final : public Call {
253
450
  }
254
451
 
255
452
  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
453
  static constexpr gpr_atm kRecvNone = 0;
268
454
  static constexpr gpr_atm kRecvInitialMetadataFirst = 1;
269
455
 
456
+ enum class PendingOp {
457
+ kRecvMessage,
458
+ kRecvInitialMetadata,
459
+ kRecvTrailingMetadata,
460
+ kSends
461
+ };
462
+ static intptr_t PendingOpMask(PendingOp op) {
463
+ return static_cast<intptr_t>(1) << static_cast<intptr_t>(op);
464
+ }
465
+ static std::string PendingOpString(intptr_t pending_ops) {
466
+ std::vector<absl::string_view> pending_op_strings;
467
+ if (pending_ops & PendingOpMask(PendingOp::kRecvMessage)) {
468
+ pending_op_strings.push_back("kRecvMessage");
469
+ }
470
+ if (pending_ops & PendingOpMask(PendingOp::kRecvInitialMetadata)) {
471
+ pending_op_strings.push_back("kRecvInitialMetadata");
472
+ }
473
+ if (pending_ops & PendingOpMask(PendingOp::kRecvTrailingMetadata)) {
474
+ pending_op_strings.push_back("kRecvTrailingMetadata");
475
+ }
476
+ if (pending_ops & PendingOpMask(PendingOp::kSends)) {
477
+ pending_op_strings.push_back("kSends");
478
+ }
479
+ return absl::StrCat("{", absl::StrJoin(pending_op_strings, ","), "}");
480
+ }
270
481
  struct BatchControl {
271
482
  FilterStackCall* call_ = nullptr;
272
483
  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,
484
+ // Share memory for cq_completion and notify_tag as they are never needed
485
+ // simultaneously. Each byte used in this data structure count as six bytes
486
+ // per call, so any savings we can make are worthwhile,
276
487
 
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. */
488
+ // We use notify_tag to determine whether or not to send notification to the
489
+ // completion queue. Once we've made that determination, we can reuse the
490
+ // memory for cq_completion.
280
491
  union {
281
492
  grpc_cq_completion cq_completion;
282
493
  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. */
494
+ // Any given op indicates completion by either (a) calling a closure or
495
+ // (b) sending a notification on the call's completion queue. If
496
+ // \a is_closure is true, \a tag indicates a closure to be invoked;
497
+ // otherwise, \a tag indicates the tag to be used in the notification to
498
+ // be sent to the completion queue.
288
499
  void* tag;
289
500
  bool is_closure;
290
501
  } notify_tag;
291
502
  } completion_data_;
292
503
  grpc_closure start_batch_;
293
504
  grpc_closure finish_batch_;
294
- std::atomic<intptr_t> steps_to_complete_{0};
505
+ std::atomic<intptr_t> ops_pending_{0};
295
506
  AtomicError batch_error_;
296
- void set_num_steps_to_complete(uintptr_t steps) {
297
- steps_to_complete_.store(steps, std::memory_order_release);
507
+ void set_pending_ops(uintptr_t ops) {
508
+ ops_pending_.store(ops, std::memory_order_release);
298
509
  }
299
- bool completed_batch_step() {
300
- return steps_to_complete_.fetch_sub(1, std::memory_order_acq_rel) == 1;
510
+ bool completed_batch_step(PendingOp op) {
511
+ auto mask = PendingOpMask(op);
512
+ auto r = ops_pending_.fetch_sub(mask, std::memory_order_acq_rel);
513
+ if (grpc_call_trace.enabled()) {
514
+ gpr_log(GPR_DEBUG, "BATCH:%p COMPLETE:%s REMAINING:%s (tag:%p)", this,
515
+ PendingOpString(mask).c_str(),
516
+ PendingOpString(r & ~mask).c_str(),
517
+ completion_data_.notify_tag.tag);
518
+ }
519
+ GPR_ASSERT((r & mask) != 0);
520
+ return r == mask;
301
521
  }
302
522
 
303
523
  void PostCompletion();
304
- void FinishStep();
305
- void ContinueReceivingSlices();
306
- void ReceivingSliceReady(grpc_error_handle error);
524
+ void FinishStep(PendingOp op);
307
525
  void ProcessDataAfterMetadata();
308
526
  void ReceivingStreamReady(grpc_error_handle error);
309
527
  void ValidateFilteredMetadata();
@@ -313,9 +531,9 @@ class FilterStackCall final : public Call {
313
531
  };
314
532
 
315
533
  FilterStackCall(Arena* arena, const grpc_call_create_args& args)
316
- : Call(arena, args.server_transport_data == nullptr, args.send_deadline),
534
+ : Call(arena, args.server_transport_data == nullptr, args.send_deadline,
535
+ args.channel->Ref()),
317
536
  cq_(args.cq),
318
- channel_(args.channel->Ref()),
319
537
  stream_op_payload_(context_) {}
320
538
 
321
539
  static void ReleaseCall(void* call, grpc_error_handle);
@@ -346,60 +564,55 @@ class FilterStackCall final : public Call {
346
564
  CallCombiner call_combiner_;
347
565
  grpc_completion_queue* cq_;
348
566
  grpc_polling_entity pollent_;
349
- RefCountedPtr<Channel> channel_;
350
567
  gpr_cycle_counter start_time_ = gpr_get_cycle_counter();
351
568
 
352
- /** has grpc_call_unref been called */
569
+ /// has grpc_call_unref been called
353
570
  bool destroy_called_ = false;
354
571
  // Trailers-only response status
355
572
  bool is_trailers_only_ = false;
356
- /** which ops are in-flight */
573
+ /// which ops are in-flight
357
574
  bool sent_initial_metadata_ = false;
358
575
  bool sending_message_ = false;
359
576
  bool sent_final_op_ = false;
360
577
  bool received_initial_metadata_ = false;
361
578
  bool receiving_message_ = false;
362
579
  bool requested_final_op_ = false;
363
- gpr_atm any_ops_sent_atm_ = 0;
364
580
  gpr_atm received_final_op_atm_ = 0;
365
581
 
366
582
  BatchControl* active_batches_[kMaxConcurrentBatches] = {};
367
583
  grpc_transport_stream_op_batch_payload stream_op_payload_;
368
584
 
369
- /* first idx: is_receiving, second idx: is_trailing */
585
+ // first idx: is_receiving, second idx: is_trailing
370
586
  grpc_metadata_batch send_initial_metadata_{arena()};
371
587
  grpc_metadata_batch send_trailing_metadata_{arena()};
372
588
  grpc_metadata_batch recv_initial_metadata_{arena()};
373
589
  grpc_metadata_batch recv_trailing_metadata_{arena()};
374
590
 
375
- /* Buffered read metadata waiting to be returned to the application.
376
- Element 0 is initial metadata, element 1 is trailing metadata. */
591
+ // Buffered read metadata waiting to be returned to the application.
592
+ // Element 0 is initial metadata, element 1 is trailing metadata.
377
593
  grpc_metadata_array* buffered_metadata_[2] = {};
378
594
 
379
- // A char* indicating the peer name.
380
- gpr_atm peer_string_ = 0;
381
-
382
- /* Call data useful used for reporting. Only valid after the call has
383
- * completed */
595
+ // Call data useful used for reporting. Only valid after the call has
596
+ // completed
384
597
  grpc_call_final_info final_info_;
385
598
 
386
- /* Compression algorithm for *incoming* data */
599
+ // Compression algorithm for *incoming* data
387
600
  grpc_compression_algorithm incoming_compression_algorithm_ =
388
601
  GRPC_COMPRESS_NONE;
389
- /* Supported encodings (compression algorithms), a bitset.
390
- * Always support no compression. */
602
+ // Supported encodings (compression algorithms), a bitset.
603
+ // Always support no compression.
391
604
  CompressionAlgorithmSet encodings_accepted_by_peer_{GRPC_COMPRESS_NONE};
392
605
 
393
- /* Contexts for various subsystems (security, tracing, ...). */
606
+ // Contexts for various subsystems (security, tracing, ...).
394
607
  grpc_call_context_element context_[GRPC_CONTEXT_COUNT] = {};
395
608
 
396
- ManualConstructor<SliceBufferByteStream> sending_stream_;
609
+ SliceBuffer send_slice_buffer_;
610
+ absl::optional<SliceBuffer> receiving_slice_buffer_;
611
+ uint32_t receiving_stream_flags_;
397
612
 
398
- OrphanablePtr<ByteStream> receiving_stream_;
399
613
  bool call_failed_before_recv_message_ = false;
400
614
  grpc_byte_buffer** receiving_buffer_ = nullptr;
401
615
  grpc_slice receiving_slice_ = grpc_empty_slice();
402
- grpc_closure receiving_slice_ready_;
403
616
  grpc_closure receiving_stream_ready_;
404
617
  grpc_closure receiving_initial_metadata_ready_;
405
618
  grpc_closure receiving_trailing_metadata_ready_;
@@ -424,116 +637,44 @@ class FilterStackCall final : public Call {
424
637
  } final_op_;
425
638
  AtomicError status_error_;
426
639
 
427
- /* recv_state can contain one of the following values:
428
- RECV_NONE : : no initial metadata and messages received
429
- RECV_INITIAL_METADATA_FIRST : received initial metadata first
430
- a batch_control* : received messages first
431
-
432
- +------1------RECV_NONE------3-----+
433
- | |
434
- | |
435
- v v
436
- RECV_INITIAL_METADATA_FIRST receiving_stream_ready_bctlp
437
- | ^ | ^
438
- | | | |
439
- +-----2-----+ +-----4-----+
440
-
441
- For 1, 4: See receiving_initial_metadata_ready() function
442
- For 2, 3: See receiving_stream_ready() function */
640
+ // recv_state can contain one of the following values:
641
+ // RECV_NONE : : no initial metadata and messages received
642
+ // RECV_INITIAL_METADATA_FIRST : received initial metadata first
643
+ // a batch_control* : received messages first
644
+
645
+ // +------1------RECV_NONE------3-----+
646
+ // | |
647
+ // | |
648
+ // v v
649
+ // RECV_INITIAL_METADATA_FIRST receiving_stream_ready_bctlp
650
+ // | ^ | ^
651
+ // | | | |
652
+ // +-----2-----+ +-----4-----+
653
+
654
+ // For 1, 4: See receiving_initial_metadata_ready() function
655
+ // For 2, 3: See receiving_stream_ready() function
443
656
  gpr_atm recv_state_ = 0;
444
657
  };
445
658
 
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
- }
457
- }
458
- return p;
459
- }
460
-
461
- Call::ParentCall* Call::parent_call() {
462
- return parent_call_.load(std::memory_order_acquire);
463
- }
464
-
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");
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");
491
- }
492
- if (propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
493
- cancellation_is_inherited_ = true;
494
- }
495
- return absl::OkStatus();
496
- }
497
-
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
- }
514
- }
515
-
516
659
  grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
517
660
  grpc_call** out_call) {
518
- GPR_TIMER_SCOPE("grpc_call_create", 0);
519
-
520
661
  Channel* channel = args->channel.get();
521
662
 
522
663
  auto add_init_error = [](grpc_error_handle* composite,
523
664
  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");
665
+ if (new_err.ok()) return;
666
+ if (composite->ok()) {
667
+ *composite = GRPC_ERROR_CREATE("Call creation failed");
527
668
  }
528
669
  *composite = grpc_error_add_child(*composite, new_err);
529
670
  };
530
671
 
531
672
  Arena* arena;
532
673
  FilterStackCall* call;
533
- grpc_error_handle error = GRPC_ERROR_NONE;
674
+ grpc_error_handle error;
534
675
  grpc_channel_stack* channel_stack = channel->channel_stack();
535
676
  size_t initial_size = channel->CallSizeEstimate();
536
- GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
677
+ global_stats().IncrementCallInitialSize(initial_size);
537
678
  size_t call_alloc_size =
538
679
  GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(FilterStackCall)) +
539
680
  channel_stack->call_stack_size;
@@ -550,8 +691,8 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
550
691
  call->final_op_.client.status_details = nullptr;
551
692
  call->final_op_.client.status = nullptr;
552
693
  call->final_op_.client.error_string = nullptr;
553
- GRPC_STATS_INC_CLIENT_CALLS_CREATED();
554
- path = grpc_slice_ref_internal(args->path->c_slice());
694
+ global_stats().IncrementClientCallsCreated();
695
+ path = CSliceRef(args->path->c_slice());
555
696
  call->send_initial_metadata_.Set(HttpPathMetadata(),
556
697
  std::move(*args->path));
557
698
  if (args->authority.has_value()) {
@@ -559,7 +700,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
559
700
  std::move(*args->authority));
560
701
  }
561
702
  } else {
562
- GRPC_STATS_INC_SERVER_CALLS_CREATED();
703
+ global_stats().IncrementServerCallsCreated();
563
704
  call->final_op_.server.cancelled = nullptr;
564
705
  call->final_op_.server.core_server = args->server;
565
706
  }
@@ -569,7 +710,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
569
710
  add_init_error(&error, absl_status_to_grpc_error(call->InitParent(
570
711
  parent, args->propagation_mask)));
571
712
  }
572
- /* initial refcount dropped by grpc_call_unref */
713
+ // initial refcount dropped by grpc_call_unref
573
714
  grpc_call_element_args call_args = {
574
715
  call->call_stack(), args->server_transport_data,
575
716
  call->context_, path,
@@ -582,8 +723,8 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
582
723
  call->PublishToParent(parent);
583
724
  }
584
725
 
585
- if (error != GRPC_ERROR_NONE) {
586
- call->CancelWithError(GRPC_ERROR_REF(error));
726
+ if (!error.ok()) {
727
+ call->CancelWithError(error);
587
728
  }
588
729
  if (args->cq != nullptr) {
589
730
  GPR_ASSERT(args->pollset_set_alternative == nullptr &&
@@ -615,7 +756,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
615
756
  }
616
757
  }
617
758
 
618
- grpc_slice_unref_internal(path);
759
+ CSliceUnref(path);
619
760
 
620
761
  return error;
621
762
  }
@@ -624,8 +765,7 @@ void FilterStackCall::SetCompletionQueue(grpc_completion_queue* cq) {
624
765
  GPR_ASSERT(cq);
625
766
 
626
767
  if (grpc_polling_entity_pollset_set(&pollent_) != nullptr) {
627
- gpr_log(GPR_ERROR, "A pollset_set is already registered for this call.");
628
- abort();
768
+ Crash("A pollset_set is already registered for this call.");
629
769
  }
630
770
  cq_ = cq;
631
771
  GRPC_CQ_INTERNAL_REF(cq, "bind");
@@ -634,19 +774,14 @@ void FilterStackCall::SetCompletionQueue(grpc_completion_queue* cq) {
634
774
  }
635
775
 
636
776
  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());
777
+ static_cast<FilterStackCall*>(call)->DeleteThis();
642
778
  }
643
779
 
644
780
  void FilterStackCall::DestroyCall(void* call, grpc_error_handle /*error*/) {
645
- GPR_TIMER_SCOPE("destroy_call", 0);
646
781
  auto* c = static_cast<FilterStackCall*>(call);
647
782
  c->recv_initial_metadata_.Clear();
648
783
  c->recv_trailing_metadata_.Clear();
649
- c->receiving_stream_.reset();
784
+ c->receiving_slice_buffer_.reset();
650
785
  ParentCall* pc = c->parent_call();
651
786
  if (pc != nullptr) {
652
787
  pc->~ParentCall();
@@ -659,7 +794,7 @@ void FilterStackCall::DestroyCall(void* call, grpc_error_handle /*error*/) {
659
794
  grpc_error_get_status(status_error, c->send_deadline(),
660
795
  &c->final_info_.final_status, nullptr, nullptr,
661
796
  &(c->final_info_.error_string));
662
- c->status_error_.set(GRPC_ERROR_NONE);
797
+ c->status_error_.set(absl::OkStatus());
663
798
  c->final_info_.stats.latency =
664
799
  gpr_cycle_counter_sub(gpr_get_cycle_counter(), c->start_time_);
665
800
  grpc_call_stack_destroy(c->call_stack(), &c->final_info_,
@@ -667,30 +802,9 @@ void FilterStackCall::DestroyCall(void* call, grpc_error_handle /*error*/) {
667
802
  grpc_schedule_on_exec_ctx));
668
803
  }
669
804
 
670
- void Call::MaybeUnpublishFromParent() {
671
- ChildCall* cc = child_;
672
- if (cc == nullptr) return;
673
-
674
- ParentCall* pc = cc->parent->parent_call();
675
- {
676
- MutexLock lock(&pc->child_list_mu);
677
- if (this == pc->first_child) {
678
- pc->first_child = cc->sibling_next;
679
- if (this == pc->first_child) {
680
- pc->first_child = nullptr;
681
- }
682
- }
683
- cc->sibling_prev->child_->sibling_next = cc->sibling_next;
684
- cc->sibling_next->child_->sibling_prev = cc->sibling_prev;
685
- }
686
- cc->parent->InternalUnref("child");
687
- }
688
-
689
805
  void FilterStackCall::ExternalUnref() {
690
806
  if (GPR_LIKELY(!ext_ref_.Unref())) return;
691
807
 
692
- GPR_TIMER_SCOPE("grpc_call_unref", 0);
693
-
694
808
  ApplicationCallbackExecCtx callback_exec_ctx;
695
809
  ExecCtx exec_ctx;
696
810
 
@@ -700,10 +814,9 @@ void FilterStackCall::ExternalUnref() {
700
814
 
701
815
  GPR_ASSERT(!destroy_called_);
702
816
  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;
817
+ bool cancel = gpr_atm_acq_load(&received_final_op_atm_) == 0;
705
818
  if (cancel) {
706
- CancelWithError(GRPC_ERROR_CANCELLED);
819
+ CancelWithError(absl::CancelledError());
707
820
  } else {
708
821
  // Unset the call combiner cancellation closure. This has the
709
822
  // effect of scheduling the previously set cancellation closure, if
@@ -714,14 +827,6 @@ void FilterStackCall::ExternalUnref() {
714
827
  InternalUnref("destroy");
715
828
  }
716
829
 
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");
723
- }
724
-
725
830
  // start_batch_closure points to a caller-allocated closure to be used
726
831
  // for entering the call combiner.
727
832
  void FilterStackCall::ExecuteBatch(grpc_transport_stream_op_batch* batch,
@@ -729,7 +834,6 @@ void FilterStackCall::ExecuteBatch(grpc_transport_stream_op_batch* batch,
729
834
  // This is called via the call combiner to start sending a batch down
730
835
  // the filter stack.
731
836
  auto execute_batch_in_call_combiner = [](void* arg, grpc_error_handle) {
732
- GPR_TIMER_SCOPE("execute_batch_in_call_combiner", 0);
733
837
  grpc_transport_stream_op_batch* batch =
734
838
  static_cast<grpc_transport_stream_op_batch*>(arg);
735
839
  auto* call =
@@ -742,7 +846,7 @@ void FilterStackCall::ExecuteBatch(grpc_transport_stream_op_batch* batch,
742
846
  GRPC_CLOSURE_INIT(start_batch_closure, execute_batch_in_call_combiner, batch,
743
847
  grpc_schedule_on_exec_ctx);
744
848
  GRPC_CALL_COMBINER_START(call_combiner(), start_batch_closure,
745
- GRPC_ERROR_NONE, "executing batch");
849
+ absl::OkStatus(), "executing batch");
746
850
  }
747
851
 
748
852
  namespace {
@@ -765,15 +869,15 @@ static void done_termination(void* arg, grpc_error_handle /*error*/) {
765
869
 
766
870
  void FilterStackCall::CancelWithError(grpc_error_handle error) {
767
871
  if (!gpr_atm_rel_cas(&cancelled_with_error_, 0, 1)) {
768
- GRPC_ERROR_UNREF(error);
769
872
  return;
770
873
  }
874
+ ClearPeerString();
771
875
  InternalRef("termination");
772
876
  // Inform the call combiner of the cancellation, so that it can cancel
773
877
  // any in-flight asynchronous actions that may be holding the call
774
878
  // combiner. This ensures that the cancel_stream batch can be sent
775
879
  // down the filter stack in a timely manner.
776
- call_combiner_.Cancel(GRPC_ERROR_REF(error));
880
+ call_combiner_.Cancel(error);
777
881
  CancelState* state = new CancelState;
778
882
  state->call = this;
779
883
  GRPC_CLOSURE_INIT(&state->finish_batch, done_termination, state,
@@ -785,19 +889,10 @@ void FilterStackCall::CancelWithError(grpc_error_handle error) {
785
889
  ExecuteBatch(op, &state->start_batch);
786
890
  }
787
891
 
788
- void Call::CancelWithStatus(grpc_status_code status, const char* description) {
789
- // copying 'description' is needed to ensure the grpc_call_cancel_with_status
790
- // guarantee that can be short-lived.
791
- CancelWithError(grpc_error_set_int(
792
- grpc_error_set_str(GRPC_ERROR_CREATE_FROM_COPIED_STRING(description),
793
- GRPC_ERROR_STR_GRPC_MESSAGE, description),
794
- GRPC_ERROR_INT_GRPC_STATUS, status));
795
- }
796
-
797
892
  void FilterStackCall::SetFinalStatus(grpc_error_handle error) {
798
893
  if (GRPC_TRACE_FLAG_ENABLED(grpc_call_error_trace)) {
799
894
  gpr_log(GPR_DEBUG, "set_final_status %s", is_client() ? "CLI" : "SVR");
800
- gpr_log(GPR_DEBUG, "%s", grpc_error_std_string(error).c_str());
895
+ gpr_log(GPR_DEBUG, "%s", StatusToString(error).c_str());
801
896
  }
802
897
  if (is_client()) {
803
898
  std::string status_details;
@@ -807,8 +902,7 @@ void FilterStackCall::SetFinalStatus(grpc_error_handle error) {
807
902
  *final_op_.client.status_details =
808
903
  grpc_slice_from_cpp_string(std::move(status_details));
809
904
  status_error_.set(error);
810
- GRPC_ERROR_UNREF(error);
811
- channelz::ChannelNode* channelz_channel = channel_->channelz_node();
905
+ channelz::ChannelNode* channelz_channel = channel()->channelz_node();
812
906
  if (channelz_channel != nullptr) {
813
907
  if (*final_op_.client.status != GRPC_STATUS_OK) {
814
908
  channelz_channel->RecordCallFailed();
@@ -818,7 +912,7 @@ void FilterStackCall::SetFinalStatus(grpc_error_handle error) {
818
912
  }
819
913
  } else {
820
914
  *final_op_.server.cancelled =
821
- error != GRPC_ERROR_NONE || !sent_server_trailing_metadata_;
915
+ !error.ok() || !sent_server_trailing_metadata_;
822
916
  channelz::ServerNode* channelz_node =
823
917
  final_op_.server.core_server->channelz_node();
824
918
  if (channelz_node != nullptr) {
@@ -828,7 +922,6 @@ void FilterStackCall::SetFinalStatus(grpc_error_handle error) {
828
922
  channelz_node->RecordCallSucceeded();
829
923
  }
830
924
  }
831
- GRPC_ERROR_UNREF(error);
832
925
  }
833
926
  }
834
927
 
@@ -854,8 +947,7 @@ bool FilterStackCall::PrepareApplicationMetadata(size_t count,
854
947
  // Filter "content-length metadata"
855
948
  continue;
856
949
  }
857
- batch->Append(StringViewFromSlice(md->key),
858
- Slice(grpc_slice_ref_internal(md->value)),
950
+ batch->Append(StringViewFromSlice(md->key), Slice(CSliceRef(md->value)),
859
951
  [md](absl::string_view error, const Slice& value) {
860
952
  gpr_log(GPR_DEBUG, "Append error: %s",
861
953
  absl::StrCat("key=", StringViewFromSlice(md->key),
@@ -928,7 +1020,6 @@ void FilterStackCall::PublishAppMetadata(grpc_metadata_batch* b,
928
1020
  if (b->count() == 0) return;
929
1021
  if (!is_client() && is_trailing) return;
930
1022
  if (is_trailing && buffered_metadata_[1] == nullptr) return;
931
- GPR_TIMER_SCOPE("publish_app_metadata", 0);
932
1023
  grpc_metadata_array* dest;
933
1024
  dest = buffered_metadata_[is_trailing];
934
1025
  if (dest->count + b->count() > dest->capacity) {
@@ -952,39 +1043,37 @@ void FilterStackCall::RecvInitialFilter(grpc_metadata_batch* b) {
952
1043
 
953
1044
  void FilterStackCall::RecvTrailingFilter(grpc_metadata_batch* b,
954
1045
  grpc_error_handle batch_error) {
955
- if (batch_error != GRPC_ERROR_NONE) {
1046
+ if (!batch_error.ok()) {
956
1047
  SetFinalStatus(batch_error);
957
1048
  } else {
958
1049
  absl::optional<grpc_status_code> grpc_status =
959
1050
  b->Take(GrpcStatusMetadata());
960
1051
  if (grpc_status.has_value()) {
961
1052
  grpc_status_code status_code = *grpc_status;
962
- grpc_error_handle error = GRPC_ERROR_NONE;
1053
+ grpc_error_handle error;
963
1054
  if (status_code != GRPC_STATUS_OK) {
964
1055
  char* peer = GetPeer();
965
1056
  error = grpc_error_set_int(
966
- GRPC_ERROR_CREATE_FROM_CPP_STRING(
967
- absl::StrCat("Error received from peer ", peer)),
968
- GRPC_ERROR_INT_GRPC_STATUS, static_cast<intptr_t>(status_code));
1057
+ GRPC_ERROR_CREATE(absl::StrCat("Error received from peer ", peer)),
1058
+ StatusIntProperty::kRpcStatus, static_cast<intptr_t>(status_code));
969
1059
  gpr_free(peer);
970
1060
  }
971
1061
  auto grpc_message = b->Take(GrpcMessageMetadata());
972
1062
  if (grpc_message.has_value()) {
973
- error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
1063
+ error = grpc_error_set_str(error, StatusStrProperty::kGrpcMessage,
974
1064
  grpc_message->as_string_view());
975
- } else if (error != GRPC_ERROR_NONE) {
976
- error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "");
1065
+ } else if (!error.ok()) {
1066
+ error = grpc_error_set_str(error, StatusStrProperty::kGrpcMessage, "");
977
1067
  }
978
- SetFinalStatus(GRPC_ERROR_REF(error));
979
- GRPC_ERROR_UNREF(error);
1068
+ SetFinalStatus(error);
980
1069
  } else if (!is_client()) {
981
- SetFinalStatus(GRPC_ERROR_NONE);
1070
+ SetFinalStatus(absl::OkStatus());
982
1071
  } else {
983
1072
  gpr_log(GPR_DEBUG,
984
1073
  "Received trailing metadata with no error and no status");
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));
1074
+ SetFinalStatus(grpc_error_set_int(GRPC_ERROR_CREATE("No status received"),
1075
+ StatusIntProperty::kRpcStatus,
1076
+ GRPC_STATUS_UNKNOWN));
988
1077
  }
989
1078
  }
990
1079
  PublishAppMetadata(b, true);
@@ -992,7 +1081,7 @@ void FilterStackCall::RecvTrailingFilter(grpc_metadata_batch* b,
992
1081
 
993
1082
  namespace {
994
1083
  bool AreWriteFlagsValid(uint32_t flags) {
995
- /* check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set */
1084
+ // check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set
996
1085
  const uint32_t allowed_write_positions =
997
1086
  (GRPC_WRITE_USED_MASK | GRPC_WRITE_INTERNAL_USED_MASK);
998
1087
  const uint32_t invalid_positions = ~allowed_write_positions;
@@ -1000,7 +1089,7 @@ bool AreWriteFlagsValid(uint32_t flags) {
1000
1089
  }
1001
1090
 
1002
1091
  bool AreInitialMetadataFlagsValid(uint32_t flags) {
1003
- /* check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set */
1092
+ // check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set
1004
1093
  uint32_t invalid_positions = ~GRPC_INITIAL_METADATA_USED_MASK;
1005
1094
  return !(flags & invalid_positions);
1006
1095
  }
@@ -1048,68 +1137,48 @@ FilterStackCall::BatchControl* FilterStackCall::ReuseOrAllocateBatchControl(
1048
1137
  return bctl;
1049
1138
  }
1050
1139
 
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
- }
1069
- }
1070
-
1071
1140
  void FilterStackCall::BatchControl::PostCompletion() {
1072
1141
  FilterStackCall* call = call_;
1073
- grpc_error_handle error = GRPC_ERROR_REF(batch_error_.get());
1142
+ grpc_error_handle error = batch_error_.get();
1143
+ if (grpc_call_trace.enabled()) {
1144
+ gpr_log(GPR_DEBUG, "tag:%p batch_error=%s", completion_data_.notify_tag.tag,
1145
+ error.ToString().c_str());
1146
+ }
1074
1147
 
1075
1148
  if (op_.send_initial_metadata) {
1076
1149
  call->send_initial_metadata_.Clear();
1077
1150
  }
1078
1151
  if (op_.send_message) {
1079
- if (op_.payload->send_message.stream_write_closed &&
1080
- error == GRPC_ERROR_NONE) {
1152
+ if (op_.payload->send_message.stream_write_closed && error.ok()) {
1081
1153
  error = grpc_error_add_child(
1082
- error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1154
+ error, GRPC_ERROR_CREATE(
1083
1155
  "Attempt to send message after stream was closed."));
1084
1156
  }
1085
1157
  call->sending_message_ = false;
1158
+ call->send_slice_buffer_.Clear();
1086
1159
  }
1087
1160
  if (op_.send_trailing_metadata) {
1088
1161
  call->send_trailing_metadata_.Clear();
1089
1162
  }
1090
1163
  if (op_.recv_trailing_metadata) {
1091
- /* propagate cancellation to any interested children */
1164
+ // propagate cancellation to any interested children
1092
1165
  gpr_atm_rel_store(&call->received_final_op_atm_, 1);
1093
1166
  call->PropagateCancellationToChildren();
1094
- GRPC_ERROR_UNREF(error);
1095
- error = GRPC_ERROR_NONE;
1167
+ error = absl::OkStatus();
1096
1168
  }
1097
- if (error != GRPC_ERROR_NONE && op_.recv_message &&
1098
- *call->receiving_buffer_ != nullptr) {
1169
+ if (!error.ok() && op_.recv_message && *call->receiving_buffer_ != nullptr) {
1099
1170
  grpc_byte_buffer_destroy(*call->receiving_buffer_);
1100
1171
  *call->receiving_buffer_ = nullptr;
1101
1172
  }
1102
- batch_error_.set(GRPC_ERROR_NONE);
1173
+ batch_error_.set(absl::OkStatus());
1103
1174
 
1104
1175
  if (completion_data_.notify_tag.is_closure) {
1105
- /* unrefs error */
1106
1176
  call_ = nullptr;
1107
1177
  Closure::Run(DEBUG_LOCATION,
1108
1178
  static_cast<grpc_closure*>(completion_data_.notify_tag.tag),
1109
1179
  error);
1110
1180
  call->InternalUnref("completion");
1111
1181
  } else {
1112
- /* unrefs error */
1113
1182
  grpc_cq_end_op(
1114
1183
  call->cq_, completion_data_.notify_tag.tag, error,
1115
1184
  [](void* user_data, grpc_cq_completion* /*storage*/) {
@@ -1122,118 +1191,58 @@ void FilterStackCall::BatchControl::PostCompletion() {
1122
1191
  }
1123
1192
  }
1124
1193
 
1125
- void FilterStackCall::BatchControl::FinishStep() {
1126
- if (GPR_UNLIKELY(completed_batch_step())) {
1194
+ void FilterStackCall::BatchControl::FinishStep(PendingOp op) {
1195
+ if (GPR_UNLIKELY(completed_batch_step(op))) {
1127
1196
  PostCompletion();
1128
1197
  }
1129
1198
  }
1130
1199
 
1131
- void FilterStackCall::BatchControl::ContinueReceivingSlices() {
1132
- grpc_error_handle error;
1133
- FilterStackCall* call = call_;
1134
- for (;;) {
1135
- size_t remaining = call->receiving_stream_->length() -
1136
- (*call->receiving_buffer_)->data.raw.slice_buffer.length;
1137
- if (remaining == 0) {
1138
- call->receiving_message_ = false;
1139
- call->receiving_stream_.reset();
1140
- FinishStep();
1141
- return;
1142
- }
1143
- if (call->receiving_stream_->Next(remaining,
1144
- &call->receiving_slice_ready_)) {
1145
- error = call->receiving_stream_->Pull(&call->receiving_slice_);
1146
- if (error == GRPC_ERROR_NONE) {
1147
- grpc_slice_buffer_add(
1148
- &(*call->receiving_buffer_)->data.raw.slice_buffer,
1149
- call->receiving_slice_);
1150
- } else {
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();
1156
- GRPC_ERROR_UNREF(error);
1157
- return;
1158
- }
1159
- } else {
1160
- return;
1161
- }
1162
- }
1163
- }
1164
-
1165
- void FilterStackCall::BatchControl::ReceivingSliceReady(
1166
- grpc_error_handle error) {
1167
- FilterStackCall* call = call_;
1168
- bool release_error = false;
1169
-
1170
- if (error == GRPC_ERROR_NONE) {
1171
- grpc_slice slice;
1172
- error = call->receiving_stream_->Pull(&slice);
1173
- if (error == GRPC_ERROR_NONE) {
1174
- grpc_slice_buffer_add(&(*call->receiving_buffer_)->data.raw.slice_buffer,
1175
- slice);
1176
- ContinueReceivingSlices();
1177
- } else {
1178
- /* Error returned by ByteStream::Pull() needs to be released manually */
1179
- release_error = true;
1180
- }
1181
- }
1182
-
1183
- if (error != GRPC_ERROR_NONE) {
1184
- if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures)) {
1185
- GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error));
1186
- }
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();
1192
- if (release_error) {
1193
- GRPC_ERROR_UNREF(error);
1194
- }
1195
- }
1196
- }
1197
-
1198
1200
  void FilterStackCall::BatchControl::ProcessDataAfterMetadata() {
1199
1201
  FilterStackCall* call = call_;
1200
- if (call->receiving_stream_ == nullptr) {
1202
+ if (!call->receiving_slice_buffer_.has_value()) {
1201
1203
  *call->receiving_buffer_ = nullptr;
1202
1204
  call->receiving_message_ = false;
1203
- FinishStep();
1205
+ FinishStep(PendingOp::kRecvMessage);
1204
1206
  } else {
1205
- call->test_only_last_message_flags_ = call->receiving_stream_->flags();
1206
- if ((call->receiving_stream_->flags() & GRPC_WRITE_INTERNAL_COMPRESS) &&
1207
+ call->test_only_last_message_flags_ = call->receiving_stream_flags_;
1208
+ if ((call->receiving_stream_flags_ & GRPC_WRITE_INTERNAL_COMPRESS) &&
1207
1209
  (call->incoming_compression_algorithm_ != GRPC_COMPRESS_NONE)) {
1208
1210
  *call->receiving_buffer_ = grpc_raw_compressed_byte_buffer_create(
1209
1211
  nullptr, 0, call->incoming_compression_algorithm_);
1210
1212
  } else {
1211
1213
  *call->receiving_buffer_ = grpc_raw_byte_buffer_create(nullptr, 0);
1212
1214
  }
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();
1215
+ grpc_slice_buffer_move_into(
1216
+ call->receiving_slice_buffer_->c_slice_buffer(),
1217
+ &(*call->receiving_buffer_)->data.raw.slice_buffer);
1218
+ call->receiving_message_ = false;
1219
+ call->receiving_slice_buffer_.reset();
1220
+ FinishStep(PendingOp::kRecvMessage);
1220
1221
  }
1221
1222
  }
1222
1223
 
1223
1224
  void FilterStackCall::BatchControl::ReceivingStreamReady(
1224
1225
  grpc_error_handle error) {
1226
+ if (grpc_call_trace.enabled()) {
1227
+ gpr_log(GPR_DEBUG,
1228
+ "tag:%p ReceivingStreamReady error=%s "
1229
+ "receiving_slice_buffer.has_value=%d recv_state=%" PRIdPTR,
1230
+ completion_data_.notify_tag.tag, error.ToString().c_str(),
1231
+ call_->receiving_slice_buffer_.has_value(),
1232
+ gpr_atm_no_barrier_load(&call_->recv_state_));
1233
+ }
1225
1234
  FilterStackCall* call = call_;
1226
- if (error != GRPC_ERROR_NONE) {
1227
- call->receiving_stream_.reset();
1235
+ if (!error.ok()) {
1236
+ call->receiving_slice_buffer_.reset();
1228
1237
  if (batch_error_.ok()) {
1229
1238
  batch_error_.set(error);
1230
1239
  }
1231
- call->CancelWithError(GRPC_ERROR_REF(error));
1240
+ call->CancelWithError(error);
1232
1241
  }
1233
- /* If recv_state is kRecvNone, we will save the batch_control
1234
- * object with rel_cas, and will not use it after the cas. Its corresponding
1235
- * acq_load is in receiving_initial_metadata_ready() */
1236
- if (error != GRPC_ERROR_NONE || call->receiving_stream_ == nullptr ||
1242
+ // If recv_state is kRecvNone, we will save the batch_control
1243
+ // object with rel_cas, and will not use it after the cas. Its corresponding
1244
+ // acq_load is in receiving_initial_metadata_ready()
1245
+ if (!error.ok() || !call->receiving_slice_buffer_.has_value() ||
1237
1246
  !gpr_atm_rel_cas(&call->recv_state_, kRecvNone,
1238
1247
  reinterpret_cast<gpr_atm>(this))) {
1239
1248
  ProcessDataAfterMetadata();
@@ -1265,16 +1274,16 @@ void FilterStackCall::BatchControl::ValidateFilteredMetadata() {
1265
1274
  FilterStackCall* call = call_;
1266
1275
 
1267
1276
  const grpc_compression_options compression_options =
1268
- call->channel_->compression_options();
1277
+ call->channel()->compression_options();
1269
1278
  const grpc_compression_algorithm compression_algorithm =
1270
1279
  call->incoming_compression_algorithm_;
1271
1280
  if (GPR_UNLIKELY(!CompressionAlgorithmSet::FromUint32(
1272
1281
  compression_options.enabled_algorithms_bitset)
1273
1282
  .IsSet(compression_algorithm))) {
1274
- /* check if algorithm is supported by current channel config */
1283
+ // check if algorithm is supported by current channel config
1275
1284
  call->HandleCompressionAlgorithmDisabled(compression_algorithm);
1276
1285
  }
1277
- /* GRPC_COMPRESS_NONE is always set. */
1286
+ // GRPC_COMPRESS_NONE is always set.
1278
1287
  GPR_DEBUG_ASSERT(call->encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE));
1279
1288
  if (GPR_UNLIKELY(
1280
1289
  !call->encodings_accepted_by_peer_.IsSet(compression_algorithm))) {
@@ -1290,12 +1299,11 @@ void FilterStackCall::BatchControl::ReceivingInitialMetadataReady(
1290
1299
 
1291
1300
  GRPC_CALL_COMBINER_STOP(call->call_combiner(), "recv_initial_metadata_ready");
1292
1301
 
1293
- if (error == GRPC_ERROR_NONE) {
1302
+ if (error.ok()) {
1294
1303
  grpc_metadata_batch* md = &call->recv_initial_metadata_;
1295
1304
  call->RecvInitialFilter(md);
1296
1305
 
1297
- /* TODO(ctiller): this could be moved into recv_initial_filter now */
1298
- GPR_TIMER_SCOPE("validate_filtered_metadata", 0);
1306
+ // TODO(ctiller): this could be moved into recv_initial_filter now
1299
1307
  ValidateFilteredMetadata();
1300
1308
 
1301
1309
  absl::optional<Timestamp> deadline = md->get(GrpcTimeoutMetadata());
@@ -1306,41 +1314,41 @@ void FilterStackCall::BatchControl::ReceivingInitialMetadataReady(
1306
1314
  if (batch_error_.ok()) {
1307
1315
  batch_error_.set(error);
1308
1316
  }
1309
- call->CancelWithError(GRPC_ERROR_REF(error));
1317
+ call->CancelWithError(error);
1310
1318
  }
1311
1319
 
1312
1320
  grpc_closure* saved_rsr_closure = nullptr;
1313
1321
  while (true) {
1314
1322
  gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state_);
1315
- /* Should only receive initial metadata once */
1323
+ // Should only receive initial metadata once
1316
1324
  GPR_ASSERT(rsr_bctlp != 1);
1317
1325
  if (rsr_bctlp == 0) {
1318
- /* We haven't seen initial metadata and messages before, thus initial
1319
- * metadata is received first.
1320
- * no_barrier_cas is used, as this function won't access the batch_control
1321
- * object saved by receiving_stream_ready() if the initial metadata is
1322
- * received first. */
1326
+ // We haven't seen initial metadata and messages before, thus initial
1327
+ // metadata is received first.
1328
+ // no_barrier_cas is used, as this function won't access the batch_control
1329
+ // object saved by receiving_stream_ready() if the initial metadata is
1330
+ // received first.
1323
1331
  if (gpr_atm_no_barrier_cas(&call->recv_state_, kRecvNone,
1324
1332
  kRecvInitialMetadataFirst)) {
1325
1333
  break;
1326
1334
  }
1327
1335
  } else {
1328
- /* Already received messages */
1336
+ // Already received messages
1329
1337
  saved_rsr_closure = GRPC_CLOSURE_CREATE(
1330
1338
  [](void* bctl, grpc_error_handle error) {
1331
1339
  static_cast<BatchControl*>(bctl)->ReceivingStreamReady(error);
1332
1340
  },
1333
1341
  reinterpret_cast<BatchControl*>(rsr_bctlp),
1334
1342
  grpc_schedule_on_exec_ctx);
1335
- /* No need to modify recv_state */
1343
+ // No need to modify recv_state
1336
1344
  break;
1337
1345
  }
1338
1346
  }
1339
1347
  if (saved_rsr_closure != nullptr) {
1340
- Closure::Run(DEBUG_LOCATION, saved_rsr_closure, GRPC_ERROR_REF(error));
1348
+ Closure::Run(DEBUG_LOCATION, saved_rsr_closure, error);
1341
1349
  }
1342
1350
 
1343
- FinishStep();
1351
+ FinishStep(PendingOp::kRecvInitialMetadata);
1344
1352
  }
1345
1353
 
1346
1354
  void FilterStackCall::BatchControl::ReceivingTrailingMetadataReady(
@@ -1348,8 +1356,8 @@ void FilterStackCall::BatchControl::ReceivingTrailingMetadataReady(
1348
1356
  GRPC_CALL_COMBINER_STOP(call_->call_combiner(),
1349
1357
  "recv_trailing_metadata_ready");
1350
1358
  grpc_metadata_batch* md = &call_->recv_trailing_metadata_;
1351
- call_->RecvTrailingFilter(md, GRPC_ERROR_REF(error));
1352
- FinishStep();
1359
+ call_->RecvTrailingFilter(md, error);
1360
+ FinishStep(PendingOp::kRecvTrailingMetadata);
1353
1361
  }
1354
1362
 
1355
1363
  void FilterStackCall::BatchControl::FinishBatch(grpc_error_handle error) {
@@ -1357,26 +1365,41 @@ void FilterStackCall::BatchControl::FinishBatch(grpc_error_handle error) {
1357
1365
  if (batch_error_.ok()) {
1358
1366
  batch_error_.set(error);
1359
1367
  }
1360
- if (error != GRPC_ERROR_NONE) {
1361
- call_->CancelWithError(GRPC_ERROR_REF(error));
1368
+ if (!error.ok()) {
1369
+ call_->CancelWithError(error);
1362
1370
  }
1363
- FinishStep();
1371
+ FinishStep(PendingOp::kSends);
1364
1372
  }
1365
1373
 
1374
+ namespace {
1375
+ void EndOpImmediately(grpc_completion_queue* cq, void* notify_tag,
1376
+ bool is_notify_tag_closure) {
1377
+ if (!is_notify_tag_closure) {
1378
+ GPR_ASSERT(grpc_cq_begin_op(cq, notify_tag));
1379
+ grpc_cq_end_op(
1380
+ cq, notify_tag, absl::OkStatus(),
1381
+ [](void*, grpc_cq_completion* completion) { gpr_free(completion); },
1382
+ nullptr,
1383
+ static_cast<grpc_cq_completion*>(
1384
+ gpr_malloc(sizeof(grpc_cq_completion))));
1385
+ } else {
1386
+ Closure::Run(DEBUG_LOCATION, static_cast<grpc_closure*>(notify_tag),
1387
+ absl::OkStatus());
1388
+ }
1389
+ }
1390
+ } // namespace
1391
+
1366
1392
  grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1367
1393
  void* notify_tag,
1368
1394
  bool is_notify_tag_closure) {
1369
- GPR_TIMER_SCOPE("call_start_batch", 0);
1370
-
1371
1395
  size_t i;
1372
1396
  const grpc_op* op;
1373
1397
  BatchControl* bctl;
1374
- bool has_send_ops = false;
1375
- int num_recv_ops = 0;
1376
1398
  grpc_call_error error = GRPC_CALL_OK;
1377
1399
  grpc_transport_stream_op_batch* stream_op;
1378
1400
  grpc_transport_stream_op_batch_payload* stream_op_payload;
1379
1401
  uint32_t seen_ops = 0;
1402
+ intptr_t pending_ops = 0;
1380
1403
 
1381
1404
  for (i = 0; i < nops; i++) {
1382
1405
  if (seen_ops & (1u << ops[i].op)) {
@@ -1385,21 +1408,19 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1385
1408
  seen_ops |= (1u << ops[i].op);
1386
1409
  }
1387
1410
 
1411
+ if (!is_client() &&
1412
+ (seen_ops & (1u << GRPC_OP_SEND_STATUS_FROM_SERVER)) != 0 &&
1413
+ (seen_ops & (1u << GRPC_OP_RECV_MESSAGE)) != 0) {
1414
+ gpr_log(GPR_ERROR,
1415
+ "******************* SEND_STATUS WITH RECV_MESSAGE "
1416
+ "*******************");
1417
+ return GRPC_CALL_ERROR;
1418
+ }
1419
+
1388
1420
  GRPC_CALL_LOG_BATCH(GPR_INFO, ops, nops);
1389
1421
 
1390
1422
  if (nops == 0) {
1391
- if (!is_notify_tag_closure) {
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))));
1399
- } else {
1400
- Closure::Run(DEBUG_LOCATION, static_cast<grpc_closure*>(notify_tag),
1401
- GRPC_ERROR_NONE);
1402
- }
1423
+ EndOpImmediately(cq_, notify_tag, is_notify_tag_closure);
1403
1424
  error = GRPC_CALL_OK;
1404
1425
  goto done;
1405
1426
  }
@@ -1415,7 +1436,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1415
1436
  stream_op = &bctl->op_;
1416
1437
  stream_op_payload = &stream_op_payload_;
1417
1438
 
1418
- /* rewrite batch ops into a transport op */
1439
+ // rewrite batch ops into a transport op
1419
1440
  for (i = 0; i < nops; i++) {
1420
1441
  op = &ops[i];
1421
1442
  if (op->reserved != nullptr) {
@@ -1424,7 +1445,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1424
1445
  }
1425
1446
  switch (op->op) {
1426
1447
  case GRPC_OP_SEND_INITIAL_METADATA: {
1427
- /* Flag validation: currently allow no flags */
1448
+ // Flag validation: currently allow no flags
1428
1449
  if (!AreInitialMetadataFlagsValid(op->flags)) {
1429
1450
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1430
1451
  goto done_with_error;
@@ -1437,7 +1458,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1437
1458
  // algorithm by setting the initial metadata with key of
1438
1459
  // GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, we shouldn't override that
1439
1460
  // with the compression algorithm mapped from compression level.
1440
- /* process compression level */
1461
+ // process compression level
1441
1462
  grpc_compression_level effective_compression_level =
1442
1463
  GRPC_COMPRESS_LEVEL_NONE;
1443
1464
  bool level_set = false;
@@ -1447,7 +1468,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1447
1468
  level_set = true;
1448
1469
  } else {
1449
1470
  const grpc_compression_options copts =
1450
- channel_->compression_options();
1471
+ channel()->compression_options();
1451
1472
  if (copts.default_level.is_set) {
1452
1473
  level_set = true;
1453
1474
  effective_compression_level = copts.default_level.level;
@@ -1477,18 +1498,25 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1477
1498
  }
1478
1499
  // Ignore any te metadata key value pairs specified.
1479
1500
  send_initial_metadata_.Remove(TeMetadata());
1480
- /* TODO(ctiller): just make these the same variable? */
1501
+ // TODO(ctiller): just make these the same variable?
1481
1502
  if (is_client() && send_deadline() != Timestamp::InfFuture()) {
1482
1503
  send_initial_metadata_.Set(GrpcTimeoutMetadata(), send_deadline());
1483
1504
  }
1505
+ if (is_client()) {
1506
+ send_initial_metadata_.Set(
1507
+ WaitForReady(),
1508
+ WaitForReady::ValueType{
1509
+ (op->flags & GRPC_INITIAL_METADATA_WAIT_FOR_READY) != 0,
1510
+ (op->flags &
1511
+ GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET) != 0});
1512
+ }
1484
1513
  stream_op_payload->send_initial_metadata.send_initial_metadata =
1485
1514
  &send_initial_metadata_;
1486
- stream_op_payload->send_initial_metadata.send_initial_metadata_flags =
1487
- op->flags;
1488
1515
  if (is_client()) {
1489
- stream_op_payload->send_initial_metadata.peer_string = &peer_string_;
1516
+ stream_op_payload->send_initial_metadata.peer_string =
1517
+ peer_string_atm_ptr();
1490
1518
  }
1491
- has_send_ops = true;
1519
+ pending_ops |= PendingOpMask(PendingOp::kSends);
1492
1520
  break;
1493
1521
  }
1494
1522
  case GRPC_OP_SEND_MESSAGE: {
@@ -1505,24 +1533,26 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1505
1533
  goto done_with_error;
1506
1534
  }
1507
1535
  uint32_t flags = op->flags;
1508
- /* If the outgoing buffer is already compressed, mark it as so in the
1509
- flags. These will be picked up by the compression filter and further
1510
- (wasteful) attempts at compression skipped. */
1536
+ // If the outgoing buffer is already compressed, mark it as so in the
1537
+ // flags. These will be picked up by the compression filter and further
1538
+ // (wasteful) attempts at compression skipped.
1511
1539
  if (op->data.send_message.send_message->data.raw.compression >
1512
1540
  GRPC_COMPRESS_NONE) {
1513
1541
  flags |= GRPC_WRITE_INTERNAL_COMPRESS;
1514
1542
  }
1515
1543
  stream_op->send_message = true;
1516
1544
  sending_message_ = true;
1517
- sending_stream_.Init(
1518
- &op->data.send_message.send_message->data.raw.slice_buffer, flags);
1519
- stream_op_payload->send_message.send_message.reset(
1520
- sending_stream_.get());
1521
- has_send_ops = true;
1545
+ send_slice_buffer_.Clear();
1546
+ grpc_slice_buffer_move_into(
1547
+ &op->data.send_message.send_message->data.raw.slice_buffer,
1548
+ send_slice_buffer_.c_slice_buffer());
1549
+ stream_op_payload->send_message.flags = flags;
1550
+ stream_op_payload->send_message.send_message = &send_slice_buffer_;
1551
+ pending_ops |= PendingOpMask(PendingOp::kSends);
1522
1552
  break;
1523
1553
  }
1524
1554
  case GRPC_OP_SEND_CLOSE_FROM_CLIENT: {
1525
- /* Flag validation: currently allow no flags */
1555
+ // Flag validation: currently allow no flags
1526
1556
  if (op->flags != 0) {
1527
1557
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1528
1558
  goto done_with_error;
@@ -1539,11 +1569,11 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1539
1569
  sent_final_op_ = true;
1540
1570
  stream_op_payload->send_trailing_metadata.send_trailing_metadata =
1541
1571
  &send_trailing_metadata_;
1542
- has_send_ops = true;
1572
+ pending_ops |= PendingOpMask(PendingOp::kSends);
1543
1573
  break;
1544
1574
  }
1545
1575
  case GRPC_OP_SEND_STATUS_FROM_SERVER: {
1546
- /* Flag validation: currently allow no flags */
1576
+ // Flag validation: currently allow no flags
1547
1577
  if (op->flags != 0) {
1548
1578
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1549
1579
  goto done_with_error;
@@ -1573,11 +1603,10 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1573
1603
 
1574
1604
  grpc_error_handle status_error =
1575
1605
  op->data.send_status_from_server.status == GRPC_STATUS_OK
1576
- ? GRPC_ERROR_NONE
1606
+ ? absl::OkStatus()
1577
1607
  : grpc_error_set_int(
1578
- GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1579
- "Server returned error"),
1580
- GRPC_ERROR_INT_GRPC_STATUS,
1608
+ GRPC_ERROR_CREATE("Server returned error"),
1609
+ StatusIntProperty::kRpcStatus,
1581
1610
  static_cast<intptr_t>(
1582
1611
  op->data.send_status_from_server.status));
1583
1612
  if (op->data.send_status_from_server.status_details != nullptr) {
@@ -1585,16 +1614,15 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1585
1614
  GrpcMessageMetadata(),
1586
1615
  Slice(grpc_slice_copy(
1587
1616
  *op->data.send_status_from_server.status_details)));
1588
- if (status_error != GRPC_ERROR_NONE) {
1617
+ if (!status_error.ok()) {
1589
1618
  status_error = grpc_error_set_str(
1590
- status_error, GRPC_ERROR_STR_GRPC_MESSAGE,
1619
+ status_error, StatusStrProperty::kGrpcMessage,
1591
1620
  StringViewFromSlice(
1592
1621
  *op->data.send_status_from_server.status_details));
1593
1622
  }
1594
1623
  }
1595
1624
 
1596
1625
  status_error_.set(status_error);
1597
- GRPC_ERROR_UNREF(status_error);
1598
1626
 
1599
1627
  send_trailing_metadata_.Set(GrpcStatusMetadata(),
1600
1628
  op->data.send_status_from_server.status);
@@ -1605,11 +1633,11 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1605
1633
  &send_trailing_metadata_;
1606
1634
  stream_op_payload->send_trailing_metadata.sent =
1607
1635
  &sent_server_trailing_metadata_;
1608
- has_send_ops = true;
1636
+ pending_ops |= PendingOpMask(PendingOp::kSends);
1609
1637
  break;
1610
1638
  }
1611
1639
  case GRPC_OP_RECV_INITIAL_METADATA: {
1612
- /* Flag validation: currently allow no flags */
1640
+ // Flag validation: currently allow no flags
1613
1641
  if (op->flags != 0) {
1614
1642
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1615
1643
  goto done_with_error;
@@ -1637,13 +1665,14 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1637
1665
  stream_op_payload->recv_initial_metadata.trailing_metadata_available =
1638
1666
  &is_trailers_only_;
1639
1667
  } else {
1640
- stream_op_payload->recv_initial_metadata.peer_string = &peer_string_;
1668
+ stream_op_payload->recv_initial_metadata.peer_string =
1669
+ peer_string_atm_ptr();
1641
1670
  }
1642
- ++num_recv_ops;
1671
+ pending_ops |= PendingOpMask(PendingOp::kRecvInitialMetadata);
1643
1672
  break;
1644
1673
  }
1645
1674
  case GRPC_OP_RECV_MESSAGE: {
1646
- /* Flag validation: currently allow no flags */
1675
+ // Flag validation: currently allow no flags
1647
1676
  if (op->flags != 0) {
1648
1677
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1649
1678
  goto done_with_error;
@@ -1654,8 +1683,11 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1654
1683
  }
1655
1684
  receiving_message_ = true;
1656
1685
  stream_op->recv_message = true;
1686
+ receiving_slice_buffer_.reset();
1657
1687
  receiving_buffer_ = op->data.recv_message.recv_message;
1658
- stream_op_payload->recv_message.recv_message = &receiving_stream_;
1688
+ stream_op_payload->recv_message.recv_message = &receiving_slice_buffer_;
1689
+ receiving_stream_flags_ = 0;
1690
+ stream_op_payload->recv_message.flags = &receiving_stream_flags_;
1659
1691
  stream_op_payload->recv_message.call_failed_before_recv_message =
1660
1692
  &call_failed_before_recv_message_;
1661
1693
  GRPC_CLOSURE_INIT(
@@ -1672,11 +1704,11 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1672
1704
  bctl, grpc_schedule_on_exec_ctx);
1673
1705
  stream_op_payload->recv_message.recv_message_ready =
1674
1706
  &receiving_stream_ready_;
1675
- ++num_recv_ops;
1707
+ pending_ops |= PendingOpMask(PendingOp::kRecvMessage);
1676
1708
  break;
1677
1709
  }
1678
1710
  case GRPC_OP_RECV_STATUS_ON_CLIENT: {
1679
- /* Flag validation: currently allow no flags */
1711
+ // Flag validation: currently allow no flags
1680
1712
  if (op->flags != 0) {
1681
1713
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1682
1714
  goto done_with_error;
@@ -1711,11 +1743,11 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1711
1743
  bctl, grpc_schedule_on_exec_ctx);
1712
1744
  stream_op_payload->recv_trailing_metadata.recv_trailing_metadata_ready =
1713
1745
  &receiving_trailing_metadata_ready_;
1714
- ++num_recv_ops;
1746
+ pending_ops |= PendingOpMask(PendingOp::kRecvTrailingMetadata);
1715
1747
  break;
1716
1748
  }
1717
1749
  case GRPC_OP_RECV_CLOSE_ON_SERVER: {
1718
- /* Flag validation: currently allow no flags */
1750
+ // Flag validation: currently allow no flags
1719
1751
  if (op->flags != 0) {
1720
1752
  error = GRPC_CALL_ERROR_INVALID_FLAGS;
1721
1753
  goto done_with_error;
@@ -1744,7 +1776,7 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1744
1776
  bctl, grpc_schedule_on_exec_ctx);
1745
1777
  stream_op_payload->recv_trailing_metadata.recv_trailing_metadata_ready =
1746
1778
  &receiving_trailing_metadata_ready_;
1747
- ++num_recv_ops;
1779
+ pending_ops |= PendingOpMask(PendingOp::kRecvTrailingMetadata);
1748
1780
  break;
1749
1781
  }
1750
1782
  }
@@ -1754,9 +1786,9 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1754
1786
  if (!is_notify_tag_closure) {
1755
1787
  GPR_ASSERT(grpc_cq_begin_op(cq_, notify_tag));
1756
1788
  }
1757
- bctl->set_num_steps_to_complete((has_send_ops ? 1 : 0) + num_recv_ops);
1789
+ bctl->set_pending_ops(pending_ops);
1758
1790
 
1759
- if (has_send_ops) {
1791
+ if (pending_ops & PendingOpMask(PendingOp::kSends)) {
1760
1792
  GRPC_CLOSURE_INIT(
1761
1793
  &bctl->finish_batch_,
1762
1794
  [](void* bctl, grpc_error_handle error) {
@@ -1766,24 +1798,26 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
1766
1798
  stream_op->on_complete = &bctl->finish_batch_;
1767
1799
  }
1768
1800
 
1769
- gpr_atm_rel_store(&any_ops_sent_atm_, 1);
1801
+ if (grpc_call_trace.enabled()) {
1802
+ gpr_log(GPR_DEBUG, "BATCH:%p START:%s BATCH:%s (tag:%p)", bctl,
1803
+ PendingOpString(pending_ops).c_str(),
1804
+ grpc_transport_stream_op_batch_string(stream_op).c_str(),
1805
+ bctl->completion_data_.notify_tag.tag);
1806
+ }
1807
+
1770
1808
  ExecuteBatch(stream_op, &bctl->start_batch_);
1771
1809
 
1772
1810
  done:
1773
1811
  return error;
1774
1812
 
1775
1813
  done_with_error:
1776
- /* reverse any mutations that occurred */
1814
+ // reverse any mutations that occurred
1777
1815
  if (stream_op->send_initial_metadata) {
1778
1816
  sent_initial_metadata_ = false;
1779
1817
  send_initial_metadata_.Clear();
1780
1818
  }
1781
1819
  if (stream_op->send_message) {
1782
1820
  sending_message_ = false;
1783
- // No need to invoke call->sending_stream->Orphan() explicitly.
1784
- // stream_op_payload->send_message.send_message.reset() calls Deletor
1785
- // of call->sending_stream which in-turn invokes the Orphan() method.
1786
- stream_op_payload->send_message.send_message.reset();
1787
1821
  }
1788
1822
  if (stream_op->send_trailing_metadata) {
1789
1823
  sent_final_op_ = false;
@@ -1810,8 +1844,1689 @@ void FilterStackCall::ContextSet(grpc_context_index elem, void* value,
1810
1844
  context_[elem].destroy = destroy;
1811
1845
  }
1812
1846
 
1847
+ ///////////////////////////////////////////////////////////////////////////////
1848
+ // Metadata validation helpers
1849
+
1850
+ namespace {
1851
+ bool ValidateMetadata(size_t count, grpc_metadata* metadata) {
1852
+ for (size_t i = 0; i < count; i++) {
1853
+ grpc_metadata* md = &metadata[i];
1854
+ if (!GRPC_LOG_IF_ERROR("validate_metadata",
1855
+ grpc_validate_header_key_is_legal(md->key))) {
1856
+ return false;
1857
+ } else if (!grpc_is_binary_header_internal(md->key) &&
1858
+ !GRPC_LOG_IF_ERROR(
1859
+ "validate_metadata",
1860
+ grpc_validate_header_nonbin_value_is_legal(md->value))) {
1861
+ return false;
1862
+ } else if (GRPC_SLICE_LENGTH(md->value) >= UINT32_MAX) {
1863
+ // HTTP2 hpack encoding has a maximum limit.
1864
+ return false;
1865
+ }
1866
+ }
1867
+ return true;
1868
+ }
1869
+ } // namespace
1870
+
1871
+ ///////////////////////////////////////////////////////////////////////////////
1872
+ // PromiseBasedCall
1873
+ // Will be folded into Call once the promise conversion is done
1874
+
1875
+ class PromiseBasedCall : public Call,
1876
+ public Activity,
1877
+ public Wakeable,
1878
+ public grpc_event_engine::experimental::EventEngine::
1879
+ Closure /* for deadlines */ {
1880
+ public:
1881
+ PromiseBasedCall(Arena* arena, uint32_t initial_external_refs,
1882
+ const grpc_call_create_args& args);
1883
+
1884
+ void ContextSet(grpc_context_index elem, void* value,
1885
+ void (*destroy)(void* value)) override;
1886
+ void* ContextGet(grpc_context_index elem) const override;
1887
+ void SetCompletionQueue(grpc_completion_queue* cq) override;
1888
+ void SetCompletionQueueLocked(grpc_completion_queue* cq)
1889
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
1890
+ void CancelWithError(absl::Status error) final ABSL_LOCKS_EXCLUDED(mu_) {
1891
+ MutexLock lock(&mu_);
1892
+ CancelWithErrorLocked(std::move(error));
1893
+ }
1894
+ virtual void CancelWithErrorLocked(absl::Status error)
1895
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) = 0;
1896
+ bool Completed() final ABSL_LOCKS_EXCLUDED(mu_) {
1897
+ MutexLock lock(&mu_);
1898
+ return completed_;
1899
+ }
1900
+
1901
+ void Orphan() final {
1902
+ MutexLock lock(&mu_);
1903
+ if (!completed_) {
1904
+ CancelWithErrorLocked(absl::CancelledError("Call orphaned"));
1905
+ }
1906
+ }
1907
+
1908
+ // Implementation of call refcounting: move this to DualRefCounted once we
1909
+ // don't need to maintain FilterStackCall compatibility
1910
+ void ExternalRef() final {
1911
+ const uint64_t prev_ref_pair =
1912
+ refs_.fetch_add(MakeRefPair(1, 0), std::memory_order_relaxed);
1913
+ if (grpc_call_refcount_trace.enabled()) {
1914
+ gpr_log(GPR_DEBUG, "%s EXTERNAL_REF: %d:%d->%d:%d", DebugTag().c_str(),
1915
+ GetStrongRefs(prev_ref_pair), GetWeakRefs(prev_ref_pair),
1916
+ GetStrongRefs(prev_ref_pair) + 1, GetWeakRefs(prev_ref_pair));
1917
+ }
1918
+ }
1919
+ void ExternalUnref() final {
1920
+ const uint64_t prev_ref_pair =
1921
+ refs_.fetch_add(MakeRefPair(-1, 1), std::memory_order_acq_rel);
1922
+ if (grpc_call_refcount_trace.enabled()) {
1923
+ gpr_log(GPR_DEBUG, "%s EXTERNAL_UNREF: %d:%d->%d:%d", DebugTag().c_str(),
1924
+ GetStrongRefs(prev_ref_pair), GetWeakRefs(prev_ref_pair),
1925
+ GetStrongRefs(prev_ref_pair) - 1, GetWeakRefs(prev_ref_pair) + 1);
1926
+ }
1927
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
1928
+ if (GPR_UNLIKELY(strong_refs == 1)) {
1929
+ Orphan();
1930
+ }
1931
+ // Now drop the weak ref.
1932
+ InternalUnref("external_ref");
1933
+ }
1934
+ void InternalRef(const char* reason) final {
1935
+ uint64_t n = refs_.fetch_add(MakeRefPair(0, 1), std::memory_order_relaxed);
1936
+ if (grpc_call_refcount_trace.enabled()) {
1937
+ gpr_log(GPR_DEBUG, "%s REF: %s %d:%d->%d:%d", DebugTag().c_str(), reason,
1938
+ GetStrongRefs(n), GetWeakRefs(n), GetStrongRefs(n),
1939
+ GetWeakRefs(n) + 1);
1940
+ }
1941
+ }
1942
+ void InternalUnref(const char* reason) final {
1943
+ const uint64_t prev_ref_pair =
1944
+ refs_.fetch_sub(MakeRefPair(0, 1), std::memory_order_acq_rel);
1945
+ if (grpc_call_refcount_trace.enabled()) {
1946
+ gpr_log(GPR_DEBUG, "%s UNREF: %s %d:%d->%d:%d", DebugTag().c_str(),
1947
+ reason, GetStrongRefs(prev_ref_pair), GetWeakRefs(prev_ref_pair),
1948
+ GetStrongRefs(prev_ref_pair), GetWeakRefs(prev_ref_pair) - 1);
1949
+ }
1950
+ if (GPR_UNLIKELY(prev_ref_pair == MakeRefPair(0, 1))) {
1951
+ DeleteThis();
1952
+ }
1953
+ }
1954
+
1955
+ // Activity methods
1956
+ void ForceImmediateRepoll() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) override;
1957
+ Waker MakeOwningWaker() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) override {
1958
+ InternalRef("wakeup");
1959
+ // If ASAN is defined, we leverage it to detect dropped Waker objects.
1960
+ // Usually Waker must be destroyed or woken up, but (especially with arenas)
1961
+ // it's not uncommon to create a Waker and then do neither. In that case it's
1962
+ // incredibly fraught to diagnose where the dropped reference to this object was
1963
+ // created. Instead, leverage ASAN and create a new object per expected wakeup.
1964
+ // Now when we drop such an object ASAN will fail and we'll get a callstack to
1965
+ // the creation of the waker in question.
1966
+ #if defined(__has_feature)
1967
+ #if __has_feature(address_sanitizer)
1968
+ #define GRPC_CALL_USES_ASAN_WAKER
1969
+ class AsanWaker final : public Wakeable {
1970
+ public:
1971
+ explicit AsanWaker(PromiseBasedCall* call) : call_(call) {}
1972
+
1973
+ void Wakeup(void*) override {
1974
+ call_->Wakeup(nullptr);
1975
+ delete this;
1976
+ }
1977
+
1978
+ void Drop(void*) override {
1979
+ call_->Drop(nullptr);
1980
+ delete this;
1981
+ }
1982
+
1983
+ std::string ActivityDebugTag(void*) const override {
1984
+ return call_->DebugTag();
1985
+ }
1986
+
1987
+ private:
1988
+ PromiseBasedCall* call_;
1989
+ };
1990
+ return Waker(new AsanWaker(this), nullptr);
1991
+ #endif
1992
+ #endif
1993
+ #ifndef GRPC_CALL_USES_ASAN_WAKER
1994
+ return Waker(this, nullptr);
1995
+ #endif
1996
+ }
1997
+ Waker MakeNonOwningWaker() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) override;
1998
+
1999
+ // Wakeable methods
2000
+ void Wakeup(void*) override {
2001
+ channel()->event_engine()->Run([this] {
2002
+ ApplicationCallbackExecCtx app_exec_ctx;
2003
+ ExecCtx exec_ctx;
2004
+ {
2005
+ ScopedContext activity_context(this);
2006
+ MutexLock lock(&mu_);
2007
+ Update();
2008
+ }
2009
+ InternalUnref("wakeup");
2010
+ });
2011
+ }
2012
+ void Drop(void*) override { InternalUnref("wakeup"); }
2013
+
2014
+ void RunInContext(absl::AnyInvocable<void()> fn) {
2015
+ if (Activity::current() == this) {
2016
+ fn();
2017
+ } else {
2018
+ InternalRef("in_context");
2019
+ channel()->event_engine()->Run([this, fn = std::move(fn)]() mutable {
2020
+ ApplicationCallbackExecCtx app_exec_ctx;
2021
+ ExecCtx exec_ctx;
2022
+ {
2023
+ ScopedContext activity_context(this);
2024
+ MutexLock lock(&mu_);
2025
+ fn();
2026
+ Update();
2027
+ }
2028
+ InternalUnref("in_context");
2029
+ });
2030
+ }
2031
+ }
2032
+
2033
+ grpc_compression_algorithm test_only_compression_algorithm() override {
2034
+ abort();
2035
+ }
2036
+ uint32_t test_only_message_flags() override { abort(); }
2037
+ uint32_t test_only_encodings_accepted_by_peer() override { abort(); }
2038
+ grpc_compression_algorithm compression_for_level(
2039
+ grpc_compression_level) override {
2040
+ abort();
2041
+ }
2042
+
2043
+ // This should return nullptr for the promise stack (and alternative means
2044
+ // for that functionality be invented)
2045
+ grpc_call_stack* call_stack() override { return nullptr; }
2046
+
2047
+ void UpdateDeadline(Timestamp deadline);
2048
+ void ResetDeadline();
2049
+
2050
+ // Implementation of EventEngine::Closure, called when deadline expires
2051
+ void Run() override;
2052
+
2053
+ virtual ServerCallContext* server_call_context() { return nullptr; }
2054
+
2055
+ protected:
2056
+ class ScopedContext
2057
+ : public ScopedActivity,
2058
+ public promise_detail::Context<Arena>,
2059
+ public promise_detail::Context<grpc_call_context_element>,
2060
+ public promise_detail::Context<CallContext>,
2061
+ public promise_detail::Context<CallFinalization> {
2062
+ public:
2063
+ explicit ScopedContext(PromiseBasedCall* call)
2064
+ : ScopedActivity(call),
2065
+ promise_detail::Context<Arena>(call->arena()),
2066
+ promise_detail::Context<grpc_call_context_element>(call->context_),
2067
+ promise_detail::Context<CallContext>(&call->call_context_),
2068
+ promise_detail::Context<CallFinalization>(&call->finalization_) {}
2069
+ };
2070
+
2071
+ class Completion {
2072
+ public:
2073
+ Completion() : index_(kNullIndex) {}
2074
+ ~Completion() { GPR_ASSERT(index_ == kNullIndex); }
2075
+ explicit Completion(uint8_t index) : index_(index) {}
2076
+ Completion(const Completion& other) = delete;
2077
+ Completion& operator=(const Completion& other) = delete;
2078
+ Completion(Completion&& other) noexcept : index_(other.index_) {
2079
+ other.index_ = kNullIndex;
2080
+ }
2081
+ Completion& operator=(Completion&& other) noexcept {
2082
+ GPR_ASSERT(index_ == kNullIndex);
2083
+ index_ = other.index_;
2084
+ other.index_ = kNullIndex;
2085
+ return *this;
2086
+ }
2087
+
2088
+ uint8_t index() const { return index_; }
2089
+ uint8_t TakeIndex() { return std::exchange(index_, kNullIndex); }
2090
+ bool has_value() const { return index_ != kNullIndex; }
2091
+
2092
+ private:
2093
+ enum : uint8_t { kNullIndex = 0xff };
2094
+ uint8_t index_;
2095
+ };
2096
+
2097
+ ~PromiseBasedCall() override {
2098
+ if (non_owning_wakeable_) non_owning_wakeable_->DropActivity();
2099
+ if (cq_) GRPC_CQ_INTERNAL_UNREF(cq_, "bind");
2100
+ }
2101
+
2102
+ // Enumerates why a Completion is still pending
2103
+ enum class PendingOp {
2104
+ // We're in the midst of starting a batch of operations
2105
+ kStartingBatch = 0,
2106
+ // The following correspond with the batch operations from above
2107
+ kReceiveInitialMetadata,
2108
+ kReceiveStatusOnClient,
2109
+ kReceiveCloseOnServer = kReceiveStatusOnClient,
2110
+ kSendMessage,
2111
+ kReceiveMessage,
2112
+ kSendStatusFromServer,
2113
+ kSendCloseFromClient = kSendStatusFromServer,
2114
+ };
2115
+
2116
+ const char* PendingOpString(PendingOp reason) const {
2117
+ switch (reason) {
2118
+ case PendingOp::kStartingBatch:
2119
+ return "StartingBatch";
2120
+ case PendingOp::kReceiveInitialMetadata:
2121
+ return "ReceiveInitialMetadata";
2122
+ case PendingOp::kReceiveStatusOnClient:
2123
+ return is_client() ? "ReceiveStatusOnClient" : "ReceiveCloseOnServer";
2124
+ case PendingOp::kSendMessage:
2125
+ return "SendMessage";
2126
+ case PendingOp::kReceiveMessage:
2127
+ return "ReceiveMessage";
2128
+ case PendingOp::kSendStatusFromServer:
2129
+ return is_client() ? "SendCloseFromClient" : "SendStatusFromServer";
2130
+ }
2131
+ return "Unknown";
2132
+ }
2133
+
2134
+ static constexpr uint8_t PendingOpBit(PendingOp reason) {
2135
+ return 1 << static_cast<int>(reason);
2136
+ }
2137
+
2138
+ Mutex* mu() const ABSL_LOCK_RETURNED(mu_) { return &mu_; }
2139
+ // Begin work on a completion, recording the tag/closure to notify.
2140
+ // Use the op selected in \a ops to determine the index to allocate into.
2141
+ // Starts the "StartingBatch" PendingOp immediately.
2142
+ // Assumes at least one operation in \a ops.
2143
+ Completion StartCompletion(void* tag, bool is_closure, const grpc_op* ops)
2144
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2145
+ // Add one pending op to the completion, and return it.
2146
+ Completion AddOpToCompletion(const Completion& completion, PendingOp reason)
2147
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2148
+ // Stringify a completion
2149
+ std::string CompletionString(const Completion& completion) const {
2150
+ return completion.has_value()
2151
+ ? absl::StrFormat(
2152
+ "%d:tag=%p", static_cast<int>(completion.index()),
2153
+ completion_info_[completion.index()].pending.tag)
2154
+ : "no-completion";
2155
+ }
2156
+ // Finish one op on the completion. Must have been previously been added.
2157
+ // The completion as a whole finishes when all pending ops finish.
2158
+ void FinishOpOnCompletion(Completion* completion, PendingOp reason)
2159
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2160
+ // Mark the completion as failed. Does not finish it.
2161
+ void FailCompletion(const Completion& completion,
2162
+ SourceLocation source_location = {});
2163
+ // Run the promise polling loop until it stalls.
2164
+ void Update() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2165
+ // Update the promise state once.
2166
+ virtual void UpdateOnce() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) = 0;
2167
+ // Accept the stats from the context (call once we have proof the transport is
2168
+ // done with them).
2169
+ // Right now this means that promise based calls do not record correct stats
2170
+ // with census if they are cancelled.
2171
+ // TODO(ctiller): this should be remedied before promise based calls are
2172
+ // dexperimentalized.
2173
+ void AcceptTransportStatsFromContext() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
2174
+ final_stats_ = *call_context_.call_stats();
2175
+ }
2176
+
2177
+ grpc_completion_queue* cq() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { return cq_; }
2178
+
2179
+ void CToMetadata(grpc_metadata* metadata, size_t count,
2180
+ grpc_metadata_batch* batch);
2181
+
2182
+ std::string ActivityDebugTag(void*) const override { return DebugTag(); }
2183
+
2184
+ // At the end of the call run any finalization actions.
2185
+ void RunFinalization(grpc_status_code status, const char* status_details) {
2186
+ grpc_call_final_info final_info;
2187
+ final_info.stats = final_stats_;
2188
+ final_info.final_status = status;
2189
+ final_info.error_string = status_details;
2190
+ finalization_.Run(&final_info);
2191
+ }
2192
+
2193
+ std::string PresentAndCompletionText(const char* caption, bool has,
2194
+ const Completion& completion) const {
2195
+ if (has) {
2196
+ if (completion.has_value()) {
2197
+ return absl::StrCat(caption, ":", CompletionString(completion), " ");
2198
+ } else {
2199
+ return absl::StrCat(caption,
2200
+ ":!!BUG:operation is present, no completion!! ");
2201
+ }
2202
+ } else {
2203
+ if (!completion.has_value()) {
2204
+ return "";
2205
+ } else {
2206
+ return absl::StrCat(caption, ":no-op:", CompletionString(completion),
2207
+ " ");
2208
+ }
2209
+ }
2210
+ }
2211
+
2212
+ std::string PollStateDebugString() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
2213
+ return absl::StrCat(PresentAndCompletionText("outstanding_send",
2214
+ outstanding_send_.has_value(),
2215
+ send_message_completion_)
2216
+ .c_str(),
2217
+ PresentAndCompletionText("outstanding_recv",
2218
+ outstanding_recv_.has_value(),
2219
+ recv_message_completion_)
2220
+ .c_str());
2221
+ }
2222
+
2223
+ void StartRecvMessage(const grpc_op& op, const Completion& completion,
2224
+ PipeReceiver<MessageHandle>* receiver)
2225
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2226
+ void PollRecvMessage(grpc_compression_algorithm compression_algorithm)
2227
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2228
+ void CancelRecvMessage() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2229
+ void StartSendMessage(const grpc_op& op, const Completion& completion,
2230
+ PipeSender<MessageHandle>* sender)
2231
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2232
+ bool PollSendMessage() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2233
+ void CancelSendMessage() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
2234
+
2235
+ bool completed() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
2236
+ return completed_;
2237
+ }
2238
+ void set_completed() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { completed_ = true; }
2239
+ bool is_sending() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
2240
+ return outstanding_send_.has_value();
2241
+ }
2242
+
2243
+ private:
2244
+ union CompletionInfo {
2245
+ struct Pending {
2246
+ // Bitmask of PendingOps
2247
+ uint8_t pending_op_bits;
2248
+ bool is_closure;
2249
+ bool success;
2250
+ void* tag;
2251
+ } pending;
2252
+ grpc_cq_completion completion;
2253
+ };
2254
+
2255
+ class NonOwningWakable final : public Wakeable {
2256
+ public:
2257
+ explicit NonOwningWakable(PromiseBasedCall* call) : call_(call) {}
2258
+
2259
+ // Ref the Handle (not the activity).
2260
+ void Ref() { refs_.fetch_add(1, std::memory_order_relaxed); }
2261
+
2262
+ // Activity is going away... drop its reference and sever the connection
2263
+ // back.
2264
+ void DropActivity() ABSL_LOCKS_EXCLUDED(mu_) {
2265
+ auto unref = absl::MakeCleanup([this]() { Unref(); });
2266
+ MutexLock lock(&mu_);
2267
+ GPR_ASSERT(call_ != nullptr);
2268
+ call_ = nullptr;
2269
+ }
2270
+
2271
+ // Activity needs to wake up (if it still exists!) - wake it up, and drop
2272
+ // the ref that was kept for this handle.
2273
+ void Wakeup(void*) override ABSL_LOCKS_EXCLUDED(mu_) {
2274
+ // Drop the ref to the handle at end of scope (we have one ref = one
2275
+ // wakeup semantics).
2276
+ auto unref = absl::MakeCleanup([this]() { Unref(); });
2277
+ ReleasableMutexLock lock(&mu_);
2278
+ // Note that activity refcount can drop to zero, but we could win the lock
2279
+ // against DropActivity, so we need to only increase activities refcount
2280
+ // if it is non-zero.
2281
+ PromiseBasedCall* call = call_;
2282
+ if (call != nullptr && call->RefIfNonZero()) {
2283
+ lock.Release();
2284
+ // Activity still exists and we have a reference: wake it up, which will
2285
+ // drop the ref.
2286
+ call->Wakeup(nullptr);
2287
+ }
2288
+ }
2289
+
2290
+ std::string ActivityDebugTag(void*) const override {
2291
+ MutexLock lock(&mu_);
2292
+ return call_ == nullptr ? "<unknown>" : call_->DebugTag();
2293
+ }
2294
+
2295
+ void Drop(void*) override { Unref(); }
2296
+
2297
+ private:
2298
+ // Unref the Handle (not the activity).
2299
+ void Unref() {
2300
+ if (1 == refs_.fetch_sub(1, std::memory_order_acq_rel)) {
2301
+ delete this;
2302
+ }
2303
+ }
2304
+
2305
+ mutable Mutex mu_;
2306
+ // We have two initial refs: one for the wakeup that this is created for,
2307
+ // and will be dropped by Wakeup, and the other for the activity which is
2308
+ // dropped by DropActivity.
2309
+ std::atomic<size_t> refs_{2};
2310
+ PromiseBasedCall* call_ ABSL_GUARDED_BY(mu_);
2311
+ };
2312
+
2313
+ static void OnDestroy(void* arg, grpc_error_handle) {
2314
+ auto* call = static_cast<PromiseBasedCall*>(arg);
2315
+ ScopedContext context(call);
2316
+ call->DeleteThis();
2317
+ }
2318
+
2319
+ // First 32 bits are strong refs, next 32 bits are weak refs.
2320
+ static uint64_t MakeRefPair(uint32_t strong, uint32_t weak) {
2321
+ return (static_cast<uint64_t>(strong) << 32) + static_cast<int64_t>(weak);
2322
+ }
2323
+ static uint32_t GetStrongRefs(uint64_t ref_pair) {
2324
+ return static_cast<uint32_t>(ref_pair >> 32);
2325
+ }
2326
+ static uint32_t GetWeakRefs(uint64_t ref_pair) {
2327
+ return static_cast<uint32_t>(ref_pair & 0xffffffffu);
2328
+ }
2329
+
2330
+ bool RefIfNonZero() {
2331
+ uint64_t prev_ref_pair = refs_.load(std::memory_order_acquire);
2332
+ do {
2333
+ const uint32_t strong_refs = GetStrongRefs(prev_ref_pair);
2334
+ if (strong_refs == 0) return false;
2335
+ } while (!refs_.compare_exchange_weak(
2336
+ prev_ref_pair, prev_ref_pair + MakeRefPair(1, 0),
2337
+ std::memory_order_acq_rel, std::memory_order_acquire));
2338
+ return true;
2339
+ }
2340
+
2341
+ mutable Mutex mu_;
2342
+ std::atomic<uint64_t> refs_;
2343
+ CallContext call_context_{this};
2344
+ bool keep_polling_ ABSL_GUARDED_BY(mu()) = false;
2345
+
2346
+ // Contexts for various subsystems (security, tracing, ...).
2347
+ grpc_call_context_element context_[GRPC_CONTEXT_COUNT] = {};
2348
+ grpc_completion_queue* cq_ ABSL_GUARDED_BY(mu_);
2349
+ NonOwningWakable* non_owning_wakeable_ ABSL_GUARDED_BY(mu_) = nullptr;
2350
+ CompletionInfo completion_info_[6];
2351
+ grpc_call_stats final_stats_{};
2352
+ CallFinalization finalization_;
2353
+ // Current deadline.
2354
+ Timestamp deadline_ = Timestamp::InfFuture();
2355
+ grpc_event_engine::experimental::EventEngine::TaskHandle deadline_task_;
2356
+ absl::optional<PipeSender<MessageHandle>::PushType> outstanding_send_
2357
+ ABSL_GUARDED_BY(mu_);
2358
+ absl::optional<PipeReceiverNextType<MessageHandle>> outstanding_recv_
2359
+ ABSL_GUARDED_BY(mu_);
2360
+ grpc_byte_buffer** recv_message_ ABSL_GUARDED_BY(mu_) = nullptr;
2361
+ Completion send_message_completion_ ABSL_GUARDED_BY(mu_);
2362
+ Completion recv_message_completion_ ABSL_GUARDED_BY(mu_);
2363
+ bool completed_ ABSL_GUARDED_BY(mu_) = false;
2364
+ };
2365
+
2366
+ template <typename T>
2367
+ grpc_error_handle MakePromiseBasedCall(grpc_call_create_args* args,
2368
+ grpc_call** out_call) {
2369
+ Channel* channel = args->channel.get();
2370
+
2371
+ auto alloc = Arena::CreateWithAlloc(channel->CallSizeEstimate(), sizeof(T),
2372
+ channel->allocator());
2373
+ PromiseBasedCall* call = new (alloc.second) T(alloc.first, args);
2374
+ *out_call = call->c_ptr();
2375
+ GPR_DEBUG_ASSERT(Call::FromC(*out_call) == call);
2376
+ return absl::OkStatus();
2377
+ }
2378
+
2379
+ PromiseBasedCall::PromiseBasedCall(Arena* arena, uint32_t initial_external_refs,
2380
+ const grpc_call_create_args& args)
2381
+ : Call(arena, args.server_transport_data == nullptr, args.send_deadline,
2382
+ args.channel->Ref()),
2383
+ refs_(MakeRefPair(initial_external_refs, 0)),
2384
+ cq_(args.cq) {
2385
+ if (args.cq != nullptr) {
2386
+ GPR_ASSERT(args.pollset_set_alternative == nullptr &&
2387
+ "Only one of 'cq' and 'pollset_set_alternative' should be "
2388
+ "non-nullptr.");
2389
+ GRPC_CQ_INTERNAL_REF(args.cq, "bind");
2390
+ call_context_.pollent_ =
2391
+ grpc_polling_entity_create_from_pollset(grpc_cq_pollset(args.cq));
2392
+ }
2393
+ if (args.pollset_set_alternative != nullptr) {
2394
+ call_context_.pollent_ = grpc_polling_entity_create_from_pollset_set(
2395
+ args.pollset_set_alternative);
2396
+ }
2397
+ }
2398
+
2399
+ Waker PromiseBasedCall::MakeNonOwningWaker() {
2400
+ if (non_owning_wakeable_ == nullptr) {
2401
+ non_owning_wakeable_ = new NonOwningWakable(this);
2402
+ } else {
2403
+ non_owning_wakeable_->Ref();
2404
+ }
2405
+ return Waker(non_owning_wakeable_, nullptr);
2406
+ }
2407
+
2408
+ void PromiseBasedCall::CToMetadata(grpc_metadata* metadata, size_t count,
2409
+ grpc_metadata_batch* b) {
2410
+ for (size_t i = 0; i < count; i++) {
2411
+ grpc_metadata* md = &metadata[i];
2412
+ auto key = StringViewFromSlice(md->key);
2413
+ // Filter "content-length metadata"
2414
+ if (key == "content-length") continue;
2415
+ b->Append(key, Slice(CSliceRef(md->value)),
2416
+ [md](absl::string_view error, const Slice& value) {
2417
+ gpr_log(GPR_DEBUG, "Append error: %s",
2418
+ absl::StrCat("key=", StringViewFromSlice(md->key),
2419
+ " error=", error,
2420
+ " value=", value.as_string_view())
2421
+ .c_str());
2422
+ });
2423
+ }
2424
+ }
2425
+
2426
+ void PromiseBasedCall::ContextSet(grpc_context_index elem, void* value,
2427
+ void (*destroy)(void*)) {
2428
+ if (context_[elem].destroy != nullptr) {
2429
+ context_[elem].destroy(context_[elem].value);
2430
+ }
2431
+ context_[elem].value = value;
2432
+ context_[elem].destroy = destroy;
2433
+ }
2434
+
2435
+ void* PromiseBasedCall::ContextGet(grpc_context_index elem) const {
2436
+ return context_[elem].value;
2437
+ }
2438
+
2439
+ PromiseBasedCall::Completion PromiseBasedCall::StartCompletion(
2440
+ void* tag, bool is_closure, const grpc_op* ops) {
2441
+ Completion c(BatchSlotForOp(ops[0].op));
2442
+ if (grpc_call_trace.enabled()) {
2443
+ gpr_log(GPR_INFO, "%s[call] StartCompletion %s tag=%p", DebugTag().c_str(),
2444
+ CompletionString(c).c_str(), tag);
2445
+ }
2446
+ if (!is_closure) {
2447
+ grpc_cq_begin_op(cq(), tag);
2448
+ }
2449
+ completion_info_[c.index()].pending = {
2450
+ PendingOpBit(PendingOp::kStartingBatch), is_closure, true, tag};
2451
+ return c;
2452
+ }
2453
+
2454
+ PromiseBasedCall::Completion PromiseBasedCall::AddOpToCompletion(
2455
+ const Completion& completion, PendingOp reason) {
2456
+ if (grpc_call_trace.enabled()) {
2457
+ gpr_log(GPR_INFO, "%s[call] AddOpToCompletion %s %s", DebugTag().c_str(),
2458
+ CompletionString(completion).c_str(), PendingOpString(reason));
2459
+ }
2460
+ GPR_ASSERT(completion.has_value());
2461
+ auto& pending_op_bits =
2462
+ completion_info_[completion.index()].pending.pending_op_bits;
2463
+ GPR_ASSERT((pending_op_bits & PendingOpBit(reason)) == 0);
2464
+ pending_op_bits |= PendingOpBit(reason);
2465
+ return Completion(completion.index());
2466
+ }
2467
+
2468
+ void PromiseBasedCall::FailCompletion(const Completion& completion,
2469
+ SourceLocation location) {
2470
+ if (grpc_call_trace.enabled()) {
2471
+ gpr_log(location.file(), location.line(), GPR_LOG_SEVERITY_ERROR,
2472
+ "%s[call] FailCompletion %s", DebugTag().c_str(),
2473
+ CompletionString(completion).c_str());
2474
+ }
2475
+ completion_info_[completion.index()].pending.success = false;
2476
+ }
2477
+
2478
+ void PromiseBasedCall::FinishOpOnCompletion(Completion* completion,
2479
+ PendingOp reason) {
2480
+ if (grpc_call_trace.enabled()) {
2481
+ auto pending_op_bits =
2482
+ completion_info_[completion->index()].pending.pending_op_bits;
2483
+ bool success = completion_info_[completion->index()].pending.success;
2484
+ std::vector<const char*> pending;
2485
+ for (size_t i = 0; i < 8 * sizeof(pending_op_bits); i++) {
2486
+ if (static_cast<PendingOp>(i) == reason) continue;
2487
+ if (pending_op_bits & (1 << i)) {
2488
+ pending.push_back(PendingOpString(static_cast<PendingOp>(i)));
2489
+ }
2490
+ }
2491
+ gpr_log(
2492
+ GPR_INFO, "%s[call] FinishOpOnCompletion tag:%p %s %s %s",
2493
+ DebugTag().c_str(), completion_info_[completion->index()].pending.tag,
2494
+ CompletionString(*completion).c_str(), PendingOpString(reason),
2495
+ (pending.empty()
2496
+ ? (success ? std::string("done") : std::string("failed"))
2497
+ : absl::StrFormat("pending_ops={%s}", absl::StrJoin(pending, ",")))
2498
+ .c_str());
2499
+ }
2500
+ const uint8_t i = completion->TakeIndex();
2501
+ GPR_ASSERT(i < GPR_ARRAY_SIZE(completion_info_));
2502
+ CompletionInfo::Pending& pending = completion_info_[i].pending;
2503
+ GPR_ASSERT(pending.pending_op_bits & PendingOpBit(reason));
2504
+ pending.pending_op_bits &= ~PendingOpBit(reason);
2505
+ auto error = pending.success ? absl::OkStatus() : absl::CancelledError();
2506
+ if (pending.pending_op_bits == 0) {
2507
+ if (pending.is_closure) {
2508
+ ExecCtx::Run(DEBUG_LOCATION, static_cast<grpc_closure*>(pending.tag),
2509
+ error);
2510
+ } else {
2511
+ grpc_cq_end_op(
2512
+ cq(), pending.tag, error, [](void*, grpc_cq_completion*) {}, nullptr,
2513
+ &completion_info_[i].completion);
2514
+ }
2515
+ }
2516
+ }
2517
+
2518
+ void PromiseBasedCall::Update() {
2519
+ keep_polling_ = false;
2520
+ do {
2521
+ UpdateOnce();
2522
+ } while (std::exchange(keep_polling_, false));
2523
+ }
2524
+
2525
+ void PromiseBasedCall::ForceImmediateRepoll() { keep_polling_ = true; }
2526
+
2527
+ void PromiseBasedCall::SetCompletionQueue(grpc_completion_queue* cq) {
2528
+ MutexLock lock(&mu_);
2529
+ SetCompletionQueueLocked(cq);
2530
+ }
2531
+
2532
+ void PromiseBasedCall::SetCompletionQueueLocked(grpc_completion_queue* cq) {
2533
+ cq_ = cq;
2534
+ GRPC_CQ_INTERNAL_REF(cq, "bind");
2535
+ call_context_.pollent_ =
2536
+ grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq));
2537
+ }
2538
+
2539
+ void PromiseBasedCall::UpdateDeadline(Timestamp deadline) {
2540
+ if (deadline >= deadline_) return;
2541
+ auto* const event_engine = channel()->event_engine();
2542
+ if (deadline_ != Timestamp::InfFuture()) {
2543
+ if (!event_engine->Cancel(deadline_task_)) return;
2544
+ } else {
2545
+ InternalRef("deadline");
2546
+ }
2547
+ event_engine->RunAfter(deadline - Timestamp::Now(), this);
2548
+ }
2549
+
2550
+ void PromiseBasedCall::ResetDeadline() {
2551
+ if (deadline_ == Timestamp::InfFuture()) return;
2552
+ auto* const event_engine = channel()->event_engine();
2553
+ if (!event_engine->Cancel(deadline_task_)) return;
2554
+ deadline_ = Timestamp::InfFuture();
2555
+ InternalUnref("deadline");
2556
+ }
2557
+
2558
+ void PromiseBasedCall::Run() {
2559
+ ApplicationCallbackExecCtx callback_exec_ctx;
2560
+ ExecCtx exec_ctx;
2561
+ CancelWithError(absl::DeadlineExceededError("Deadline exceeded"));
2562
+ InternalUnref("deadline");
2563
+ }
2564
+
2565
+ void PromiseBasedCall::StartSendMessage(const grpc_op& op,
2566
+ const Completion& completion,
2567
+ PipeSender<MessageHandle>* sender) {
2568
+ GPR_ASSERT(!outstanding_send_.has_value());
2569
+ if (!completed_) {
2570
+ send_message_completion_ =
2571
+ AddOpToCompletion(completion, PendingOp::kSendMessage);
2572
+ SliceBuffer send;
2573
+ grpc_slice_buffer_swap(
2574
+ &op.data.send_message.send_message->data.raw.slice_buffer,
2575
+ send.c_slice_buffer());
2576
+ outstanding_send_.emplace(sender->Push(
2577
+ GetContext<Arena>()->MakePooled<Message>(std::move(send), op.flags)));
2578
+ } else {
2579
+ FailCompletion(completion);
2580
+ }
2581
+ }
2582
+
2583
+ bool PromiseBasedCall::PollSendMessage() {
2584
+ if (!outstanding_send_.has_value()) return true;
2585
+ Poll<bool> r = (*outstanding_send_)();
2586
+ if (const bool* result = r.value_if_ready()) {
2587
+ if (grpc_call_trace.enabled()) {
2588
+ gpr_log(GPR_DEBUG, "%sPollSendMessage completes %s", DebugTag().c_str(),
2589
+ *result ? "successfully" : "with failure");
2590
+ }
2591
+ if (!*result) {
2592
+ FailCompletion(send_message_completion_);
2593
+ return false;
2594
+ }
2595
+ FinishOpOnCompletion(&send_message_completion_, PendingOp::kSendMessage);
2596
+ outstanding_send_.reset();
2597
+ }
2598
+ return true;
2599
+ }
2600
+
2601
+ void PromiseBasedCall::CancelSendMessage() {
2602
+ if (!outstanding_send_.has_value()) return;
2603
+ FinishOpOnCompletion(&send_message_completion_, PendingOp::kSendMessage);
2604
+ outstanding_send_.reset();
2605
+ }
2606
+
2607
+ void PromiseBasedCall::StartRecvMessage(const grpc_op& op,
2608
+ const Completion& completion,
2609
+ PipeReceiver<MessageHandle>* receiver) {
2610
+ GPR_ASSERT(!outstanding_recv_.has_value());
2611
+ recv_message_ = op.data.recv_message.recv_message;
2612
+ recv_message_completion_ =
2613
+ AddOpToCompletion(completion, PendingOp::kReceiveMessage);
2614
+ outstanding_recv_.emplace(receiver->Next());
2615
+ }
2616
+
2617
+ void PromiseBasedCall::PollRecvMessage(
2618
+ grpc_compression_algorithm incoming_compression_algorithm) {
2619
+ if (!outstanding_recv_.has_value()) return;
2620
+ Poll<NextResult<MessageHandle>> r = (*outstanding_recv_)();
2621
+ if (auto* result = r.value_if_ready()) {
2622
+ outstanding_recv_.reset();
2623
+ if (result->has_value()) {
2624
+ MessageHandle& message = **result;
2625
+ if ((message->flags() & GRPC_WRITE_INTERNAL_COMPRESS) &&
2626
+ (incoming_compression_algorithm != GRPC_COMPRESS_NONE)) {
2627
+ *recv_message_ = grpc_raw_compressed_byte_buffer_create(
2628
+ nullptr, 0, incoming_compression_algorithm);
2629
+ } else {
2630
+ *recv_message_ = grpc_raw_byte_buffer_create(nullptr, 0);
2631
+ }
2632
+ grpc_slice_buffer_move_into(message->payload()->c_slice_buffer(),
2633
+ &(*recv_message_)->data.raw.slice_buffer);
2634
+ if (grpc_call_trace.enabled()) {
2635
+ gpr_log(GPR_INFO,
2636
+ "%s[call] PollRecvMessage: outstanding_recv finishes: received "
2637
+ "%" PRIdPTR " byte message",
2638
+ DebugTag().c_str(),
2639
+ (*recv_message_)->data.raw.slice_buffer.length);
2640
+ }
2641
+ } else if (result->cancelled()) {
2642
+ if (grpc_call_trace.enabled()) {
2643
+ gpr_log(GPR_INFO,
2644
+ "%s[call] PollRecvMessage: outstanding_recv finishes: received "
2645
+ "end-of-stream with error",
2646
+ DebugTag().c_str());
2647
+ }
2648
+ FailCompletion(recv_message_completion_);
2649
+ *recv_message_ = nullptr;
2650
+ } else {
2651
+ if (grpc_call_trace.enabled()) {
2652
+ gpr_log(GPR_INFO,
2653
+ "%s[call] PollRecvMessage: outstanding_recv finishes: received "
2654
+ "end-of-stream",
2655
+ DebugTag().c_str());
2656
+ }
2657
+ *recv_message_ = nullptr;
2658
+ }
2659
+ FinishOpOnCompletion(&recv_message_completion_, PendingOp::kReceiveMessage);
2660
+ } else if (completed_) {
2661
+ if (grpc_call_trace.enabled()) {
2662
+ gpr_log(GPR_INFO,
2663
+ "%s[call] UpdateOnce: outstanding_recv finishes: promise has "
2664
+ "completed without queuing a message, forcing end-of-stream",
2665
+ DebugTag().c_str());
2666
+ }
2667
+ outstanding_recv_.reset();
2668
+ *recv_message_ = nullptr;
2669
+ FinishOpOnCompletion(&recv_message_completion_, PendingOp::kReceiveMessage);
2670
+ }
2671
+ }
2672
+
2673
+ void PromiseBasedCall::CancelRecvMessage() {
2674
+ if (!outstanding_recv_.has_value()) return;
2675
+ *recv_message_ = nullptr;
2676
+ outstanding_recv_.reset();
2677
+ FinishOpOnCompletion(&recv_message_completion_, PendingOp::kReceiveMessage);
2678
+ }
2679
+
2680
+ ///////////////////////////////////////////////////////////////////////////////
2681
+ // CallContext
2682
+
2683
+ void CallContext::RunInContext(absl::AnyInvocable<void()> fn) {
2684
+ call_->RunInContext(std::move(fn));
2685
+ }
2686
+
2687
+ void CallContext::IncrementRefCount(const char* reason) {
2688
+ call_->InternalRef(reason);
2689
+ }
2690
+
2691
+ void CallContext::Unref(const char* reason) { call_->InternalUnref(reason); }
2692
+
2693
+ gpr_atm* CallContext::peer_string_atm_ptr() {
2694
+ return call_->peer_string_atm_ptr();
2695
+ }
2696
+
2697
+ void CallContext::UpdateDeadline(Timestamp deadline) {
2698
+ call_->UpdateDeadline(deadline);
2699
+ }
2700
+
2701
+ ServerCallContext* CallContext::server_call_context() {
2702
+ return call_->server_call_context();
2703
+ }
2704
+
2705
+ ///////////////////////////////////////////////////////////////////////////////
2706
+ // PublishMetadataArray
2707
+
2708
+ namespace {
2709
+ void PublishMetadataArray(grpc_metadata_batch* md, grpc_metadata_array* array) {
2710
+ const auto md_count = md->count();
2711
+ if (md_count > array->capacity) {
2712
+ array->capacity =
2713
+ std::max(array->capacity + md->count(), array->capacity * 3 / 2);
2714
+ array->metadata = static_cast<grpc_metadata*>(
2715
+ gpr_realloc(array->metadata, sizeof(grpc_metadata) * array->capacity));
2716
+ }
2717
+ PublishToAppEncoder encoder(array);
2718
+ md->Encode(&encoder);
2719
+ }
2720
+ } // namespace
2721
+
2722
+ ///////////////////////////////////////////////////////////////////////////////
2723
+ // ClientPromiseBasedCall
2724
+
2725
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_CLIENT_CALL
2726
+ class ClientPromiseBasedCall final : public PromiseBasedCall {
2727
+ public:
2728
+ ClientPromiseBasedCall(Arena* arena, grpc_call_create_args* args)
2729
+ : PromiseBasedCall(arena, 1, *args) {
2730
+ global_stats().IncrementClientCallsCreated();
2731
+ ScopedContext context(this);
2732
+ send_initial_metadata_ =
2733
+ GetContext<Arena>()->MakePooled<ClientMetadata>(GetContext<Arena>());
2734
+ send_initial_metadata_->Set(HttpPathMetadata(), std::move(*args->path));
2735
+ if (args->authority.has_value()) {
2736
+ send_initial_metadata_->Set(HttpAuthorityMetadata(),
2737
+ std::move(*args->authority));
2738
+ }
2739
+ if (auto* channelz_channel = channel()->channelz_node()) {
2740
+ channelz_channel->RecordCallStarted();
2741
+ }
2742
+ if (args->send_deadline != Timestamp::InfFuture()) {
2743
+ UpdateDeadline(args->send_deadline);
2744
+ }
2745
+ }
2746
+
2747
+ ~ClientPromiseBasedCall() override {
2748
+ ScopedContext context(this);
2749
+ send_initial_metadata_.reset();
2750
+ recv_status_on_client_ = absl::monostate();
2751
+ promise_ = ArenaPromise<ServerMetadataHandle>();
2752
+ // Need to destroy the pipes under the ScopedContext above, so we move them
2753
+ // out here and then allow the destructors to run at end of scope, but
2754
+ // before context.
2755
+ auto c2s = std::move(client_to_server_messages_);
2756
+ auto s2c = std::move(server_to_client_messages_);
2757
+ auto sim = std::move(server_initial_metadata_);
2758
+ }
2759
+
2760
+ absl::string_view GetServerAuthority() const override { abort(); }
2761
+ void CancelWithErrorLocked(grpc_error_handle error) override
2762
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
2763
+ bool is_trailers_only() const override {
2764
+ MutexLock lock(mu());
2765
+ return is_trailers_only_;
2766
+ }
2767
+ bool failed_before_recv_message() const override { abort(); }
2768
+
2769
+ grpc_call_error StartBatch(const grpc_op* ops, size_t nops, void* notify_tag,
2770
+ bool is_notify_tag_closure) override;
2771
+
2772
+ std::string DebugTag() const override {
2773
+ return absl::StrFormat("CLIENT_CALL[%p]: ", this);
2774
+ }
2775
+
2776
+ private:
2777
+ // Poll the underlying promise (and sundry objects) once.
2778
+ void UpdateOnce() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) override;
2779
+ // Finish the call with the given status/trailing metadata.
2780
+ void Finish(ServerMetadataHandle trailing_metadata)
2781
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
2782
+ // Validate that a set of ops is valid for a client call.
2783
+ grpc_call_error ValidateBatch(const grpc_op* ops, size_t nops) const
2784
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
2785
+ // Commit a valid batch of operations to be executed.
2786
+ void CommitBatch(const grpc_op* ops, size_t nops,
2787
+ const Completion& completion)
2788
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
2789
+ // Start the underlying promise.
2790
+ void StartPromise(ClientMetadataHandle client_initial_metadata)
2791
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
2792
+ // Publish status out to the application.
2793
+ void PublishStatus(
2794
+ grpc_op::grpc_op_data::grpc_op_recv_status_on_client op_args,
2795
+ ServerMetadataHandle trailing_metadata)
2796
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
2797
+ // Publish server initial metadata out to the application.
2798
+ void PublishInitialMetadata(ServerMetadata* metadata)
2799
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
2800
+
2801
+ ArenaPromise<ServerMetadataHandle> promise_ ABSL_GUARDED_BY(mu());
2802
+ Pipe<ServerMetadataHandle> server_initial_metadata_ ABSL_GUARDED_BY(mu()){
2803
+ arena()};
2804
+ Pipe<MessageHandle> client_to_server_messages_ ABSL_GUARDED_BY(mu()){arena()};
2805
+ Pipe<MessageHandle> server_to_client_messages_ ABSL_GUARDED_BY(mu()){arena()};
2806
+
2807
+ ClientMetadataHandle send_initial_metadata_;
2808
+ grpc_metadata_array* recv_initial_metadata_ ABSL_GUARDED_BY(mu()) = nullptr;
2809
+ absl::variant<absl::monostate,
2810
+ grpc_op::grpc_op_data::grpc_op_recv_status_on_client,
2811
+ ServerMetadataHandle>
2812
+ recv_status_on_client_ ABSL_GUARDED_BY(mu());
2813
+ absl::optional<PipeReceiverNextType<ServerMetadataHandle>>
2814
+ server_initial_metadata_ready_;
2815
+ absl::optional<grpc_compression_algorithm> incoming_compression_algorithm_;
2816
+ Completion recv_initial_metadata_completion_ ABSL_GUARDED_BY(mu());
2817
+ Completion recv_status_on_client_completion_ ABSL_GUARDED_BY(mu());
2818
+ Completion close_send_completion_ ABSL_GUARDED_BY(mu());
2819
+ bool is_trailers_only_ ABSL_GUARDED_BY(mu());
2820
+ };
2821
+
2822
+ void ClientPromiseBasedCall::StartPromise(
2823
+ ClientMetadataHandle client_initial_metadata) {
2824
+ GPR_ASSERT(!promise_.has_value());
2825
+ promise_ = channel()->channel_stack()->MakeClientCallPromise(CallArgs{
2826
+ std::move(client_initial_metadata),
2827
+ &server_initial_metadata_.sender,
2828
+ &client_to_server_messages_.receiver,
2829
+ &server_to_client_messages_.sender,
2830
+ });
2831
+ }
2832
+
2833
+ void ClientPromiseBasedCall::CancelWithErrorLocked(grpc_error_handle error) {
2834
+ ScopedContext context(this);
2835
+ Finish(ServerMetadataFromStatus(grpc_error_to_absl_status(error)));
2836
+ }
2837
+
2838
+ grpc_call_error ClientPromiseBasedCall::ValidateBatch(const grpc_op* ops,
2839
+ size_t nops) const {
2840
+ BitSet<8> got_ops;
2841
+ for (size_t op_idx = 0; op_idx < nops; op_idx++) {
2842
+ const grpc_op& op = ops[op_idx];
2843
+ switch (op.op) {
2844
+ case GRPC_OP_SEND_INITIAL_METADATA:
2845
+ if (!AreInitialMetadataFlagsValid(op.flags)) {
2846
+ return GRPC_CALL_ERROR_INVALID_FLAGS;
2847
+ }
2848
+ if (!ValidateMetadata(op.data.send_initial_metadata.count,
2849
+ op.data.send_initial_metadata.metadata)) {
2850
+ return GRPC_CALL_ERROR_INVALID_METADATA;
2851
+ }
2852
+ break;
2853
+ case GRPC_OP_SEND_MESSAGE:
2854
+ if (!AreWriteFlagsValid(op.flags)) {
2855
+ return GRPC_CALL_ERROR_INVALID_FLAGS;
2856
+ }
2857
+ break;
2858
+ case GRPC_OP_RECV_INITIAL_METADATA:
2859
+ case GRPC_OP_RECV_MESSAGE:
2860
+ case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
2861
+ case GRPC_OP_RECV_STATUS_ON_CLIENT:
2862
+ if (op.flags != 0) return GRPC_CALL_ERROR_INVALID_FLAGS;
2863
+ break;
2864
+ case GRPC_OP_RECV_CLOSE_ON_SERVER:
2865
+ case GRPC_OP_SEND_STATUS_FROM_SERVER:
2866
+ return GRPC_CALL_ERROR_NOT_ON_CLIENT;
2867
+ }
2868
+ if (got_ops.is_set(op.op)) return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
2869
+ got_ops.set(op.op);
2870
+ }
2871
+ return GRPC_CALL_OK;
2872
+ }
2873
+
2874
+ void ClientPromiseBasedCall::CommitBatch(const grpc_op* ops, size_t nops,
2875
+ const Completion& completion) {
2876
+ for (size_t op_idx = 0; op_idx < nops; op_idx++) {
2877
+ const grpc_op& op = ops[op_idx];
2878
+ switch (op.op) {
2879
+ case GRPC_OP_SEND_INITIAL_METADATA: {
2880
+ // compression not implemented
2881
+ GPR_ASSERT(
2882
+ !op.data.send_initial_metadata.maybe_compression_level.is_set);
2883
+ if (!completed()) {
2884
+ CToMetadata(op.data.send_initial_metadata.metadata,
2885
+ op.data.send_initial_metadata.count,
2886
+ send_initial_metadata_.get());
2887
+ StartPromise(std::move(send_initial_metadata_));
2888
+ }
2889
+ } break;
2890
+ case GRPC_OP_RECV_INITIAL_METADATA: {
2891
+ recv_initial_metadata_ =
2892
+ op.data.recv_initial_metadata.recv_initial_metadata;
2893
+ server_initial_metadata_ready_.emplace(
2894
+ server_initial_metadata_.receiver.Next());
2895
+ recv_initial_metadata_completion_ =
2896
+ AddOpToCompletion(completion, PendingOp::kReceiveInitialMetadata);
2897
+ } break;
2898
+ case GRPC_OP_RECV_STATUS_ON_CLIENT: {
2899
+ recv_status_on_client_completion_ =
2900
+ AddOpToCompletion(completion, PendingOp::kReceiveStatusOnClient);
2901
+ if (auto* finished_metadata =
2902
+ absl::get_if<ServerMetadataHandle>(&recv_status_on_client_)) {
2903
+ PublishStatus(op.data.recv_status_on_client,
2904
+ std::move(*finished_metadata));
2905
+ } else {
2906
+ recv_status_on_client_ = op.data.recv_status_on_client;
2907
+ }
2908
+ } break;
2909
+ case GRPC_OP_SEND_MESSAGE:
2910
+ StartSendMessage(op, completion, &client_to_server_messages_.sender);
2911
+ break;
2912
+ case GRPC_OP_RECV_MESSAGE:
2913
+ StartRecvMessage(op, completion, &server_to_client_messages_.receiver);
2914
+ break;
2915
+ case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
2916
+ close_send_completion_ =
2917
+ AddOpToCompletion(completion, PendingOp::kSendCloseFromClient);
2918
+ GPR_ASSERT(close_send_completion_.has_value());
2919
+ break;
2920
+ case GRPC_OP_SEND_STATUS_FROM_SERVER:
2921
+ case GRPC_OP_RECV_CLOSE_ON_SERVER:
2922
+ abort(); // unreachable
2923
+ }
2924
+ }
2925
+ }
2926
+
2927
+ grpc_call_error ClientPromiseBasedCall::StartBatch(const grpc_op* ops,
2928
+ size_t nops,
2929
+ void* notify_tag,
2930
+ bool is_notify_tag_closure) {
2931
+ MutexLock lock(mu());
2932
+ ScopedContext activity_context(this);
2933
+ if (nops == 0) {
2934
+ EndOpImmediately(cq(), notify_tag, is_notify_tag_closure);
2935
+ return GRPC_CALL_OK;
2936
+ }
2937
+ const grpc_call_error validation_result = ValidateBatch(ops, nops);
2938
+ if (validation_result != GRPC_CALL_OK) {
2939
+ return validation_result;
2940
+ }
2941
+ Completion completion =
2942
+ StartCompletion(notify_tag, is_notify_tag_closure, ops);
2943
+ CommitBatch(ops, nops, completion);
2944
+ Update();
2945
+ FinishOpOnCompletion(&completion, PendingOp::kStartingBatch);
2946
+ return GRPC_CALL_OK;
2947
+ }
2948
+
2949
+ void ClientPromiseBasedCall::PublishInitialMetadata(ServerMetadata* metadata) {
2950
+ incoming_compression_algorithm_ =
2951
+ metadata->Take(GrpcEncodingMetadata()).value_or(GRPC_COMPRESS_NONE);
2952
+ server_initial_metadata_ready_.reset();
2953
+ GPR_ASSERT(recv_initial_metadata_ != nullptr);
2954
+ PublishMetadataArray(metadata,
2955
+ std::exchange(recv_initial_metadata_, nullptr));
2956
+ FinishOpOnCompletion(&recv_initial_metadata_completion_,
2957
+ PendingOp::kReceiveInitialMetadata);
2958
+ }
2959
+
2960
+ void ClientPromiseBasedCall::UpdateOnce() {
2961
+ if (grpc_call_trace.enabled()) {
2962
+ gpr_log(GPR_INFO, "%s[call] UpdateOnce: %s%shas_promise=%s",
2963
+ DebugTag().c_str(),
2964
+ PresentAndCompletionText("server_initial_metadata_ready",
2965
+ server_initial_metadata_ready_.has_value(),
2966
+ recv_initial_metadata_completion_)
2967
+ .c_str(),
2968
+ PollStateDebugString().c_str(),
2969
+ promise_.has_value() ? "true" : "false");
2970
+ }
2971
+ if (server_initial_metadata_ready_.has_value()) {
2972
+ Poll<NextResult<ServerMetadataHandle>> r =
2973
+ (*server_initial_metadata_ready_)();
2974
+ if (auto* server_initial_metadata = r.value_if_ready()) {
2975
+ PublishInitialMetadata(server_initial_metadata->value().get());
2976
+ } else if (completed()) {
2977
+ ServerMetadata no_metadata{GetContext<Arena>()};
2978
+ PublishInitialMetadata(&no_metadata);
2979
+ }
2980
+ }
2981
+ if (!PollSendMessage()) {
2982
+ Finish(ServerMetadataFromStatus(absl::Status(
2983
+ absl::StatusCode::kInternal, "Failed to send message to server")));
2984
+ }
2985
+ if (!is_sending() && close_send_completion_.has_value()) {
2986
+ client_to_server_messages_.sender.Close();
2987
+ FinishOpOnCompletion(&close_send_completion_,
2988
+ PendingOp::kSendCloseFromClient);
2989
+ }
2990
+ if (promise_.has_value()) {
2991
+ Poll<ServerMetadataHandle> r = promise_();
2992
+ if (grpc_call_trace.enabled()) {
2993
+ gpr_log(GPR_INFO, "%s[call] UpdateOnce: promise returns %s",
2994
+ DebugTag().c_str(),
2995
+ PollToString(r, [](const ServerMetadataHandle& h) {
2996
+ return h->DebugString();
2997
+ }).c_str());
2998
+ }
2999
+ if (auto* result = r.value_if_ready()) {
3000
+ AcceptTransportStatsFromContext();
3001
+ Finish(std::move(*result));
3002
+ }
3003
+ }
3004
+ if (incoming_compression_algorithm_.has_value()) {
3005
+ PollRecvMessage(*incoming_compression_algorithm_);
3006
+ }
3007
+ }
3008
+
3009
+ void ClientPromiseBasedCall::Finish(ServerMetadataHandle trailing_metadata) {
3010
+ if (grpc_call_trace.enabled()) {
3011
+ gpr_log(GPR_INFO, "%s[call] Finish: %s", DebugTag().c_str(),
3012
+ trailing_metadata->DebugString().c_str());
3013
+ }
3014
+ promise_ = ArenaPromise<ServerMetadataHandle>();
3015
+ ResetDeadline();
3016
+ set_completed();
3017
+ if (recv_initial_metadata_ != nullptr) {
3018
+ ForceImmediateRepoll();
3019
+ }
3020
+ const bool pending_initial_metadata =
3021
+ server_initial_metadata_ready_.has_value();
3022
+ if (!pending_initial_metadata) {
3023
+ server_initial_metadata_ready_.emplace(
3024
+ server_initial_metadata_.receiver.Next());
3025
+ }
3026
+ Poll<NextResult<ServerMetadataHandle>> r =
3027
+ (*server_initial_metadata_ready_)();
3028
+ server_initial_metadata_ready_.reset();
3029
+ if (auto* result = r.value_if_ready()) {
3030
+ if (pending_initial_metadata) PublishInitialMetadata(result->value().get());
3031
+ is_trailers_only_ = false;
3032
+ } else {
3033
+ if (pending_initial_metadata) {
3034
+ ServerMetadata no_metadata{GetContext<Arena>()};
3035
+ PublishInitialMetadata(&no_metadata);
3036
+ }
3037
+ is_trailers_only_ = true;
3038
+ }
3039
+ if (auto* channelz_channel = channel()->channelz_node()) {
3040
+ if (trailing_metadata->get(GrpcStatusMetadata())
3041
+ .value_or(GRPC_STATUS_UNKNOWN) == GRPC_STATUS_OK) {
3042
+ channelz_channel->RecordCallSucceeded();
3043
+ } else {
3044
+ channelz_channel->RecordCallFailed();
3045
+ }
3046
+ }
3047
+ if (auto* status_request =
3048
+ absl::get_if<grpc_op::grpc_op_data::grpc_op_recv_status_on_client>(
3049
+ &recv_status_on_client_)) {
3050
+ PublishStatus(*status_request, std::move(trailing_metadata));
3051
+ } else {
3052
+ recv_status_on_client_ = std::move(trailing_metadata);
3053
+ }
3054
+ }
3055
+
3056
+ namespace {
3057
+ std::string MakeErrorString(const ServerMetadata* trailing_metadata) {
3058
+ std::string out = absl::StrCat(
3059
+ trailing_metadata->get(GrpcStatusFromWire()).value_or(false)
3060
+ ? "Error received from peer"
3061
+ : "Error generated by client",
3062
+ "grpc_status: ",
3063
+ grpc_status_code_to_string(trailing_metadata->get(GrpcStatusMetadata())
3064
+ .value_or(GRPC_STATUS_UNKNOWN)));
3065
+ if (const Slice* message =
3066
+ trailing_metadata->get_pointer(GrpcMessageMetadata())) {
3067
+ absl::StrAppend(&out, "\ngrpc_message: ", message->as_string_view());
3068
+ }
3069
+ if (auto annotations = trailing_metadata->get_pointer(GrpcStatusContext())) {
3070
+ absl::StrAppend(&out, "\nStatus Context:");
3071
+ for (const std::string& annotation : *annotations) {
3072
+ absl::StrAppend(&out, "\n ", annotation);
3073
+ }
3074
+ }
3075
+ return out;
3076
+ }
3077
+ } // namespace
3078
+
3079
+ void ClientPromiseBasedCall::PublishStatus(
3080
+ grpc_op::grpc_op_data::grpc_op_recv_status_on_client op_args,
3081
+ ServerMetadataHandle trailing_metadata) {
3082
+ const grpc_status_code status = trailing_metadata->get(GrpcStatusMetadata())
3083
+ .value_or(GRPC_STATUS_UNKNOWN);
3084
+ *op_args.status = status;
3085
+ absl::string_view message_string;
3086
+ if (Slice* message = trailing_metadata->get_pointer(GrpcMessageMetadata())) {
3087
+ message_string = message->as_string_view();
3088
+ *op_args.status_details = message->Ref().TakeCSlice();
3089
+ } else {
3090
+ *op_args.status_details = grpc_empty_slice();
3091
+ }
3092
+ if (message_string.empty()) {
3093
+ RunFinalization(status, nullptr);
3094
+ } else {
3095
+ std::string error_string(message_string);
3096
+ RunFinalization(status, error_string.c_str());
3097
+ }
3098
+ if (op_args.error_string != nullptr && status != GRPC_STATUS_OK) {
3099
+ *op_args.error_string =
3100
+ gpr_strdup(MakeErrorString(trailing_metadata.get()).c_str());
3101
+ }
3102
+ PublishMetadataArray(trailing_metadata.get(), op_args.trailing_metadata);
3103
+ // Clear state saying we have a RECV_STATUS_ON_CLIENT outstanding
3104
+ // (so we don't call through twice)
3105
+ recv_status_on_client_ = absl::monostate();
3106
+ FinishOpOnCompletion(&recv_status_on_client_completion_,
3107
+ PendingOp::kReceiveStatusOnClient);
3108
+ }
3109
+ #endif
3110
+
3111
+ ///////////////////////////////////////////////////////////////////////////////
3112
+ // ServerPromiseBasedCall
3113
+
3114
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_SERVER_CALL
3115
+
3116
+ class ServerPromiseBasedCall final : public PromiseBasedCall {
3117
+ public:
3118
+ ServerPromiseBasedCall(Arena* arena, grpc_call_create_args* args);
3119
+
3120
+ void CancelWithErrorLocked(grpc_error_handle) override
3121
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
3122
+ grpc_call_error StartBatch(const grpc_op* ops, size_t nops, void* notify_tag,
3123
+ bool is_notify_tag_closure) override;
3124
+ bool failed_before_recv_message() const override { abort(); }
3125
+ bool is_trailers_only() const override { abort(); }
3126
+ absl::string_view GetServerAuthority() const override { return ""; }
3127
+
3128
+ // Polling order for the server promise stack:
3129
+ //
3130
+ // │ ┌───────────────────────────────────────┐
3131
+ // │ │ ServerPromiseBasedCall::UpdateOnce ├──► Lifetime management,
3132
+ // │ ├───────────────────────────────────────┤ signal call end to app
3133
+ // │ │ ConnectedChannel ├─┐
3134
+ // │ ├───────────────────────────────────────┤ └► Interactions with the
3135
+ // │ │ ... closest to transport filter │ transport - send/recv msgs
3136
+ // │ ├───────────────────────────────────────┤ and metadata, call phase
3137
+ // │ │ ... │ ordering
3138
+ // │ ├───────────────────────────────────────┤
3139
+ // │ │ ... closest to app filter │ ┌► Request matching, initial
3140
+ // │ ├───────────────────────────────────────┤ │ setup, publishing call to
3141
+ // │ │ Server::ChannelData::MakeCallPromise ├─┘ application
3142
+ // │ ├───────────────────────────────────────┤
3143
+ // │ │ ServerPromiseBasedCall::PollTopOfCall ├──► Application interactions,
3144
+ // ▼ └───────────────────────────────────────┘ forwarding messages,
3145
+ // Polling & sending trailing metadata
3146
+ // instantiation
3147
+ // order
3148
+
3149
+ void UpdateOnce() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) override;
3150
+ Poll<ServerMetadataHandle> PollTopOfCall()
3151
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
3152
+
3153
+ std::string DebugTag() const override {
3154
+ return absl::StrFormat("SERVER_CALL[%p]: ", this);
3155
+ }
3156
+
3157
+ ServerCallContext* server_call_context() override { return &call_context_; }
3158
+
3159
+ private:
3160
+ class RecvCloseOpCancelState {
3161
+ public:
3162
+ // Request that receiver be filled in per grpc_op_recv_close_on_server.
3163
+ // Returns true if the request can be fulfilled immediately.
3164
+ // Returns false if the request will be fulfilled later.
3165
+ bool ReceiveCloseOnServerOpStarted(int* receiver) {
3166
+ switch (state_) {
3167
+ case kUnset:
3168
+ state_ = reinterpret_cast<uintptr_t>(receiver);
3169
+ return false;
3170
+ case kFinishedWithFailure:
3171
+ *receiver = 1;
3172
+ return true;
3173
+ case kFinishedWithSuccess:
3174
+ *receiver = 0;
3175
+ return true;
3176
+ default:
3177
+ abort(); // unreachable
3178
+ }
3179
+ }
3180
+
3181
+ // Mark the call as having completed.
3182
+ // Returns true if this finishes a previous RequestReceiveCloseOnServer.
3183
+ bool CompleteCall(bool success) {
3184
+ switch (state_) {
3185
+ case kUnset:
3186
+ state_ = success ? kFinishedWithSuccess : kFinishedWithFailure;
3187
+ return false;
3188
+ case kFinishedWithFailure:
3189
+ case kFinishedWithSuccess:
3190
+ abort(); // unreachable
3191
+ default:
3192
+ *reinterpret_cast<int*>(state_) = success ? 0 : 1;
3193
+ state_ = success ? kFinishedWithSuccess : kFinishedWithFailure;
3194
+ return true;
3195
+ }
3196
+ }
3197
+
3198
+ std::string ToString() const {
3199
+ switch (state_) {
3200
+ case kUnset:
3201
+ return "Unset";
3202
+ case kFinishedWithFailure:
3203
+ return "FinishedWithFailure";
3204
+ case kFinishedWithSuccess:
3205
+ return "FinishedWithSuccess";
3206
+ default:
3207
+ return absl::StrFormat("WaitingForReceiver(%p)",
3208
+ reinterpret_cast<void*>(state_));
3209
+ }
3210
+ }
3211
+
3212
+ private:
3213
+ static constexpr uintptr_t kUnset = 0;
3214
+ static constexpr uintptr_t kFinishedWithFailure = 1;
3215
+ static constexpr uintptr_t kFinishedWithSuccess = 2;
3216
+ // Holds one of kUnset, kFinishedWithFailure, or kFinishedWithSuccess
3217
+ // OR an int* that wants to receive the final status.
3218
+ uintptr_t state_ = kUnset;
3219
+ };
3220
+
3221
+ grpc_call_error ValidateBatch(const grpc_op* ops, size_t nops) const;
3222
+ void CommitBatch(const grpc_op* ops, size_t nops,
3223
+ const Completion& completion)
3224
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu());
3225
+
3226
+ friend class ServerCallContext;
3227
+ ServerCallContext call_context_;
3228
+ Server* const server_;
3229
+ ArenaPromise<ServerMetadataHandle> promise_ ABSL_GUARDED_BY(mu());
3230
+ PipeSender<MessageHandle>* server_to_client_messages_ ABSL_GUARDED_BY(mu()) =
3231
+ nullptr;
3232
+ PipeReceiver<MessageHandle>* client_to_server_messages_
3233
+ ABSL_GUARDED_BY(mu()) = nullptr;
3234
+ using SendInitialMetadataState =
3235
+ absl::variant<absl::monostate, PipeSender<ServerMetadataHandle>*,
3236
+ typename PipeSender<ServerMetadataHandle>::PushType>;
3237
+ SendInitialMetadataState send_initial_metadata_state_ ABSL_GUARDED_BY(mu()) =
3238
+ absl::monostate{};
3239
+ ServerMetadataHandle send_trailing_metadata_ ABSL_GUARDED_BY(mu());
3240
+ grpc_compression_algorithm incoming_compression_algorithm_
3241
+ ABSL_GUARDED_BY(mu());
3242
+ RecvCloseOpCancelState recv_close_op_cancel_state_ ABSL_GUARDED_BY(mu());
3243
+ Completion recv_close_completion_ ABSL_GUARDED_BY(mu());
3244
+ bool cancel_send_and_receive_ ABSL_GUARDED_BY(mu()) = false;
3245
+ Completion send_status_from_server_completion_ ABSL_GUARDED_BY(mu());
3246
+ ClientMetadataHandle client_initial_metadata_ ABSL_GUARDED_BY(mu());
3247
+ };
3248
+
3249
+ ServerPromiseBasedCall::ServerPromiseBasedCall(Arena* arena,
3250
+ grpc_call_create_args* args)
3251
+ : PromiseBasedCall(arena, 0, *args),
3252
+ call_context_(this, args->server_transport_data),
3253
+ server_(args->server) {
3254
+ global_stats().IncrementServerCallsCreated();
3255
+ channelz::ServerNode* channelz_node = server_->channelz_node();
3256
+ if (channelz_node != nullptr) {
3257
+ channelz_node->RecordCallStarted();
3258
+ }
3259
+ MutexLock lock(mu());
3260
+ ScopedContext activity_context(this);
3261
+ promise_ = channel()->channel_stack()->MakeServerCallPromise(
3262
+ CallArgs{nullptr, nullptr, nullptr, nullptr});
3263
+ }
3264
+
3265
+ Poll<ServerMetadataHandle> ServerPromiseBasedCall::PollTopOfCall() {
3266
+ if (grpc_call_trace.enabled()) {
3267
+ gpr_log(GPR_INFO, "%s[call] PollTopOfCall: %s%s%s", DebugTag().c_str(),
3268
+ cancel_send_and_receive_ ? "force-" : "",
3269
+ send_trailing_metadata_ != nullptr
3270
+ ? absl::StrCat("send-metadata:",
3271
+ send_trailing_metadata_->DebugString(), " ")
3272
+ .c_str()
3273
+ : " ",
3274
+ PollStateDebugString().c_str());
3275
+ }
3276
+
3277
+ if (cancel_send_and_receive_) {
3278
+ CancelSendMessage();
3279
+ CancelRecvMessage();
3280
+ }
3281
+
3282
+ PollSendMessage();
3283
+ PollRecvMessage(incoming_compression_algorithm_);
3284
+
3285
+ if (!is_sending() && send_trailing_metadata_ != nullptr) {
3286
+ server_to_client_messages_->Close();
3287
+ return std::move(send_trailing_metadata_);
3288
+ }
3289
+
3290
+ return Pending{};
3291
+ }
3292
+
3293
+ void ServerPromiseBasedCall::UpdateOnce() {
3294
+ if (grpc_call_trace.enabled()) {
3295
+ gpr_log(
3296
+ GPR_INFO, "%s[call] UpdateOnce: recv_close:%s%s %s%shas_promise=%s",
3297
+ DebugTag().c_str(), recv_close_op_cancel_state_.ToString().c_str(),
3298
+ recv_close_completion_.has_value()
3299
+ ? absl::StrCat(":", CompletionString(recv_close_completion_))
3300
+ .c_str()
3301
+ : "",
3302
+ send_status_from_server_completion_.has_value()
3303
+ ? absl::StrCat(
3304
+ "send_status:",
3305
+ CompletionString(send_status_from_server_completion_), " ")
3306
+ .c_str()
3307
+ : "",
3308
+ PollStateDebugString().c_str(),
3309
+ promise_.has_value() ? "true" : "false");
3310
+ }
3311
+ if (auto* p =
3312
+ absl::get_if<typename PipeSender<ServerMetadataHandle>::PushType>(
3313
+ &send_initial_metadata_state_)) {
3314
+ if ((*p)().ready()) {
3315
+ send_initial_metadata_state_ = absl::monostate{};
3316
+ }
3317
+ }
3318
+ if (promise_.has_value()) {
3319
+ auto r = promise_();
3320
+ if (grpc_call_trace.enabled()) {
3321
+ gpr_log(GPR_INFO, "%s[call] UpdateOnce: promise returns %s",
3322
+ DebugTag().c_str(),
3323
+ PollToString(r, [](const ServerMetadataHandle& h) {
3324
+ return h->DebugString();
3325
+ }).c_str());
3326
+ }
3327
+ if (auto* result = r.value_if_ready()) {
3328
+ if (grpc_call_trace.enabled()) {
3329
+ gpr_log(GPR_INFO, "%s[call] UpdateOnce: GotResult %s result:%s",
3330
+ DebugTag().c_str(),
3331
+ recv_close_op_cancel_state_.ToString().c_str(),
3332
+ (*result)->DebugString().c_str());
3333
+ }
3334
+ if (recv_close_op_cancel_state_.CompleteCall(
3335
+ (*result)->get(GrpcStatusFromWire()).value_or(false))) {
3336
+ FinishOpOnCompletion(&recv_close_completion_,
3337
+ PendingOp::kReceiveCloseOnServer);
3338
+ }
3339
+ channelz::ServerNode* channelz_node = server_->channelz_node();
3340
+ if (channelz_node != nullptr) {
3341
+ if ((*result)
3342
+ ->get(GrpcStatusMetadata())
3343
+ .value_or(GRPC_STATUS_UNKNOWN) == GRPC_STATUS_OK) {
3344
+ channelz_node->RecordCallSucceeded();
3345
+ } else {
3346
+ channelz_node->RecordCallFailed();
3347
+ }
3348
+ }
3349
+ if (send_status_from_server_completion_.has_value()) {
3350
+ FinishOpOnCompletion(&send_status_from_server_completion_,
3351
+ PendingOp::kSendStatusFromServer);
3352
+ }
3353
+ CancelSendMessage();
3354
+ CancelRecvMessage();
3355
+ set_completed();
3356
+ promise_ = ArenaPromise<ServerMetadataHandle>();
3357
+ }
3358
+ }
3359
+ }
3360
+
3361
+ grpc_call_error ServerPromiseBasedCall::ValidateBatch(const grpc_op* ops,
3362
+ size_t nops) const {
3363
+ BitSet<8> got_ops;
3364
+ for (size_t op_idx = 0; op_idx < nops; op_idx++) {
3365
+ const grpc_op& op = ops[op_idx];
3366
+ switch (op.op) {
3367
+ case GRPC_OP_SEND_INITIAL_METADATA:
3368
+ if (!AreInitialMetadataFlagsValid(op.flags)) {
3369
+ return GRPC_CALL_ERROR_INVALID_FLAGS;
3370
+ }
3371
+ if (!ValidateMetadata(op.data.send_initial_metadata.count,
3372
+ op.data.send_initial_metadata.metadata)) {
3373
+ return GRPC_CALL_ERROR_INVALID_METADATA;
3374
+ }
3375
+ break;
3376
+ case GRPC_OP_SEND_MESSAGE:
3377
+ if (!AreWriteFlagsValid(op.flags)) {
3378
+ return GRPC_CALL_ERROR_INVALID_FLAGS;
3379
+ }
3380
+ break;
3381
+ case GRPC_OP_RECV_MESSAGE:
3382
+ case GRPC_OP_RECV_CLOSE_ON_SERVER:
3383
+ case GRPC_OP_SEND_STATUS_FROM_SERVER:
3384
+ if (op.flags != 0) return GRPC_CALL_ERROR_INVALID_FLAGS;
3385
+ break;
3386
+ case GRPC_OP_RECV_INITIAL_METADATA:
3387
+ case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
3388
+ case GRPC_OP_RECV_STATUS_ON_CLIENT:
3389
+ return GRPC_CALL_ERROR_NOT_ON_SERVER;
3390
+ }
3391
+ if (got_ops.is_set(op.op)) return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
3392
+ got_ops.set(op.op);
3393
+ }
3394
+ return GRPC_CALL_OK;
3395
+ }
3396
+
3397
+ void ServerPromiseBasedCall::CommitBatch(const grpc_op* ops, size_t nops,
3398
+ const Completion& completion) {
3399
+ for (size_t op_idx = 0; op_idx < nops; op_idx++) {
3400
+ const grpc_op& op = ops[op_idx];
3401
+ switch (op.op) {
3402
+ case GRPC_OP_SEND_INITIAL_METADATA: {
3403
+ // compression not implemented
3404
+ GPR_ASSERT(
3405
+ !op.data.send_initial_metadata.maybe_compression_level.is_set);
3406
+ if (!completed()) {
3407
+ auto metadata = arena()->MakePooled<ServerMetadata>(arena());
3408
+ CToMetadata(op.data.send_initial_metadata.metadata,
3409
+ op.data.send_initial_metadata.count, metadata.get());
3410
+ if (grpc_call_trace.enabled()) {
3411
+ gpr_log(GPR_INFO, "%s[call] Send initial metadata",
3412
+ DebugTag().c_str());
3413
+ }
3414
+ auto* pipe = absl::get<PipeSender<ServerMetadataHandle>*>(
3415
+ send_initial_metadata_state_);
3416
+ send_initial_metadata_state_ = pipe->Push(std::move(metadata));
3417
+ }
3418
+ } break;
3419
+ case GRPC_OP_SEND_MESSAGE:
3420
+ StartSendMessage(op, completion, server_to_client_messages_);
3421
+ break;
3422
+ case GRPC_OP_RECV_MESSAGE:
3423
+ StartRecvMessage(op, completion, client_to_server_messages_);
3424
+ break;
3425
+ case GRPC_OP_SEND_STATUS_FROM_SERVER:
3426
+ send_trailing_metadata_ = arena()->MakePooled<ServerMetadata>(arena());
3427
+ CToMetadata(op.data.send_status_from_server.trailing_metadata,
3428
+ op.data.send_status_from_server.trailing_metadata_count,
3429
+ send_trailing_metadata_.get());
3430
+ send_trailing_metadata_->Set(GrpcStatusMetadata(),
3431
+ op.data.send_status_from_server.status);
3432
+ if (auto* details = op.data.send_status_from_server.status_details) {
3433
+ send_trailing_metadata_->Set(GrpcMessageMetadata(),
3434
+ Slice(CSliceRef(*details)));
3435
+ }
3436
+ send_status_from_server_completion_ =
3437
+ AddOpToCompletion(completion, PendingOp::kSendStatusFromServer);
3438
+ break;
3439
+ case GRPC_OP_RECV_CLOSE_ON_SERVER:
3440
+ if (grpc_call_trace.enabled()) {
3441
+ gpr_log(GPR_INFO, "%s[call] StartBatch: RecvClose %s",
3442
+ DebugTag().c_str(),
3443
+ recv_close_op_cancel_state_.ToString().c_str());
3444
+ }
3445
+ if (!recv_close_op_cancel_state_.ReceiveCloseOnServerOpStarted(
3446
+ op.data.recv_close_on_server.cancelled)) {
3447
+ recv_close_completion_ =
3448
+ AddOpToCompletion(completion, PendingOp::kReceiveCloseOnServer);
3449
+ }
3450
+ break;
3451
+ case GRPC_OP_RECV_STATUS_ON_CLIENT:
3452
+ case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
3453
+ case GRPC_OP_RECV_INITIAL_METADATA:
3454
+ abort(); // unreachable
3455
+ }
3456
+ }
3457
+ }
3458
+
3459
+ grpc_call_error ServerPromiseBasedCall::StartBatch(const grpc_op* ops,
3460
+ size_t nops,
3461
+ void* notify_tag,
3462
+ bool is_notify_tag_closure) {
3463
+ MutexLock lock(mu());
3464
+ ScopedContext activity_context(this);
3465
+ if (nops == 0) {
3466
+ EndOpImmediately(cq(), notify_tag, is_notify_tag_closure);
3467
+ return GRPC_CALL_OK;
3468
+ }
3469
+ const grpc_call_error validation_result = ValidateBatch(ops, nops);
3470
+ if (validation_result != GRPC_CALL_OK) {
3471
+ return validation_result;
3472
+ }
3473
+ Completion completion =
3474
+ StartCompletion(notify_tag, is_notify_tag_closure, ops);
3475
+ CommitBatch(ops, nops, completion);
3476
+ Update();
3477
+ FinishOpOnCompletion(&completion, PendingOp::kStartingBatch);
3478
+ return GRPC_CALL_OK;
3479
+ }
3480
+
3481
+ void ServerPromiseBasedCall::CancelWithErrorLocked(absl::Status error) {
3482
+ if (!promise_.has_value()) return;
3483
+ cancel_send_and_receive_ = true;
3484
+ send_trailing_metadata_ = ServerMetadataFromStatus(error, arena());
3485
+ ForceWakeup();
3486
+ }
3487
+
3488
+ #endif
3489
+
3490
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_SERVER_CALL
3491
+ ArenaPromise<ServerMetadataHandle>
3492
+ ServerCallContext::MakeTopOfServerCallPromise(
3493
+ CallArgs call_args, grpc_completion_queue* cq,
3494
+ grpc_metadata_array* publish_initial_metadata,
3495
+ absl::FunctionRef<void(grpc_call* call)> publish) {
3496
+ call_->mu()->AssertHeld();
3497
+ call_->SetCompletionQueueLocked(cq);
3498
+ call_->server_to_client_messages_ = call_args.server_to_client_messages;
3499
+ call_->client_to_server_messages_ = call_args.client_to_server_messages;
3500
+ call_->send_initial_metadata_state_ = call_args.server_initial_metadata;
3501
+ call_->incoming_compression_algorithm_ =
3502
+ call_args.client_initial_metadata->get(GrpcEncodingMetadata())
3503
+ .value_or(GRPC_COMPRESS_NONE);
3504
+ call_->client_initial_metadata_ =
3505
+ std::move(call_args.client_initial_metadata);
3506
+ PublishMetadataArray(call_->client_initial_metadata_.get(),
3507
+ publish_initial_metadata);
3508
+ call_->ExternalRef();
3509
+ publish(call_->c_ptr());
3510
+ return [this]() {
3511
+ call_->mu()->AssertHeld();
3512
+ return call_->PollTopOfCall();
3513
+ };
3514
+ }
3515
+ #else
3516
+ ArenaPromise<ServerMetadataHandle>
3517
+ ServerCallContext::MakeTopOfServerCallPromise(
3518
+ CallArgs, grpc_completion_queue*, grpc_metadata_array*,
3519
+ absl::FunctionRef<void(grpc_call*)>) {
3520
+ (void)call_;
3521
+ Crash("Promise-based server call is not enabled");
3522
+ }
3523
+ #endif
3524
+
1813
3525
  } // namespace grpc_core
1814
3526
 
3527
+ ///////////////////////////////////////////////////////////////////////////////
3528
+ // C-based API
3529
+
1815
3530
  void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
1816
3531
  grpc_core::ExecCtx exec_ctx;
1817
3532
  return grpc_core::Call::FromC(call)->arena()->Alloc(size);
@@ -1823,6 +3538,20 @@ size_t grpc_call_get_initial_size_estimate() {
1823
3538
 
1824
3539
  grpc_error_handle grpc_call_create(grpc_call_create_args* args,
1825
3540
  grpc_call** out_call) {
3541
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_CLIENT_CALL
3542
+ if (grpc_core::IsPromiseBasedClientCallEnabled() &&
3543
+ args->server_transport_data == nullptr && args->channel->is_promising()) {
3544
+ return grpc_core::MakePromiseBasedCall<grpc_core::ClientPromiseBasedCall>(
3545
+ args, out_call);
3546
+ }
3547
+ #endif
3548
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_SERVER_CALL
3549
+ if (grpc_core::IsPromiseBasedServerCallEnabled() &&
3550
+ args->server_transport_data != nullptr && args->channel->is_promising()) {
3551
+ return grpc_core::MakePromiseBasedCall<grpc_core::ServerPromiseBasedCall>(
3552
+ args, out_call);
3553
+ }
3554
+ #endif
1826
3555
  return grpc_core::FilterStackCall::Create(args, out_call);
1827
3556
  }
1828
3557
 
@@ -1834,6 +3563,7 @@ void grpc_call_set_completion_queue(grpc_call* call,
1834
3563
  void grpc_call_ref(grpc_call* c) { grpc_core::Call::FromC(c)->ExternalRef(); }
1835
3564
 
1836
3565
  void grpc_call_unref(grpc_call* c) {
3566
+ grpc_core::ExecCtx exec_ctx;
1837
3567
  grpc_core::Call::FromC(c)->ExternalUnref();
1838
3568
  }
1839
3569
 
@@ -1850,7 +3580,7 @@ grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
1850
3580
  GPR_ASSERT(reserved == nullptr);
1851
3581
  grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
1852
3582
  grpc_core::ExecCtx exec_ctx;
1853
- grpc_core::Call::FromC(call)->CancelWithError(GRPC_ERROR_CANCELLED);
3583
+ grpc_core::Call::FromC(call)->CancelWithError(absl::CancelledError());
1854
3584
  return GRPC_CALL_OK;
1855
3585
  }
1856
3586
 
@@ -1870,7 +3600,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
1870
3600
  }
1871
3601
 
1872
3602
  void grpc_call_cancel_internal(grpc_call* call) {
1873
- grpc_core::Call::FromC(call)->CancelWithError(GRPC_ERROR_CANCELLED);
3603
+ grpc_core::Call::FromC(call)->CancelWithError(absl::CancelledError());
1874
3604
  }
1875
3605
 
1876
3606
  grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
@@ -1943,6 +3673,10 @@ int grpc_call_failed_before_recv_message(const grpc_call* c) {
1943
3673
  return grpc_core::Call::FromC(c)->failed_before_recv_message();
1944
3674
  }
1945
3675
 
3676
+ absl::string_view grpc_call_server_authority(const grpc_call* call) {
3677
+ return grpc_core::Call::FromC(call)->GetServerAuthority();
3678
+ }
3679
+
1946
3680
  const char* grpc_call_error_to_string(grpc_call_error error) {
1947
3681
  switch (error) {
1948
3682
  case GRPC_CALL_ERROR: