grpc 1.43.1 → 1.44.0.pre2

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 (382) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +84 -64
  3. data/include/grpc/grpc_security.h +10 -0
  4. data/include/grpc/impl/codegen/compression_types.h +0 -2
  5. data/include/grpc/impl/codegen/grpc_types.h +6 -0
  6. data/src/core/ext/filters/client_channel/backend_metric.h +1 -1
  7. data/src/core/ext/filters/client_channel/client_channel.cc +62 -68
  8. data/src/core/ext/filters/client_channel/client_channel.h +8 -8
  9. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
  10. data/src/core/ext/filters/client_channel/config_selector.h +4 -4
  11. data/src/core/ext/filters/client_channel/dynamic_filters.h +1 -1
  12. data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -14
  13. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  14. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  15. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -3
  16. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +6 -5
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +3 -7
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +31 -32
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -7
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +1 -1
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +43 -29
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -2
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +120 -68
  26. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +60 -48
  27. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +62 -61
  28. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +16 -11
  29. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -5
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +19 -15
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -12
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +3 -2
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +50 -105
  35. data/src/core/ext/filters/client_channel/lb_policy.cc +15 -14
  36. data/src/core/ext/filters/client_channel/lb_policy.h +19 -3
  37. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +3 -3
  38. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +207 -81
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +22 -12
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +19 -15
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +23 -38
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +118 -207
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +25 -32
  44. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  45. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +82 -73
  46. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +10 -10
  47. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +2 -1
  48. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -5
  49. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -5
  50. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +157 -67
  51. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
  52. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
  53. data/src/core/ext/filters/client_channel/retry_filter.cc +37 -64
  54. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
  55. data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
  56. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
  57. data/src/core/ext/filters/client_channel/subchannel.cc +12 -16
  58. data/src/core/ext/filters/client_channel/subchannel.h +2 -3
  59. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +37 -48
  60. data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -8
  61. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  62. data/src/core/ext/filters/http/client/http_client_filter.cc +51 -122
  63. data/src/core/ext/filters/http/client_authority_filter.cc +8 -24
  64. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +42 -140
  65. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +5 -25
  66. data/src/core/ext/filters/http/server/http_server_filter.cc +50 -135
  67. data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
  68. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  69. data/src/core/ext/filters/rbac/rbac_filter.cc +157 -0
  70. data/src/core/ext/filters/rbac/rbac_filter.h +74 -0
  71. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +605 -0
  72. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +70 -0
  73. data/src/core/ext/filters/server_config_selector/server_config_selector.h +3 -2
  74. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +11 -6
  75. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +1 -1
  76. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
  77. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +89 -29
  78. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +0 -1
  79. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +45 -186
  80. data/src/core/ext/transport/chttp2/transport/frame_data.cc +0 -1
  81. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +341 -279
  82. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +69 -159
  83. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +1 -1
  84. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
  85. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +19 -32
  86. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +0 -1
  87. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +94 -1
  88. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +2 -24
  89. data/src/core/ext/transport/chttp2/transport/internal.h +0 -33
  90. data/src/core/ext/transport/chttp2/transport/parsing.cc +0 -6
  91. data/src/core/ext/transport/chttp2/transport/writing.cc +47 -116
  92. data/src/core/ext/transport/inproc/inproc_plugin.cc +0 -4
  93. data/src/core/ext/transport/inproc/inproc_transport.cc +11 -63
  94. data/src/core/ext/transport/inproc/inproc_transport.h +0 -3
  95. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +61 -0
  96. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +146 -0
  97. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +188 -0
  98. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +70 -0
  99. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +56 -0
  100. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.h +40 -0
  101. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c +154 -0
  102. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.h +95 -0
  103. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.c +58 -0
  104. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.h +55 -0
  105. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.c +44 -0
  106. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.h +40 -0
  107. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c +153 -0
  108. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.h +100 -0
  109. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.c +75 -0
  110. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.h +55 -0
  111. data/src/core/ext/xds/upb_utils.h +65 -0
  112. data/src/core/ext/xds/xds_api.cc +81 -3458
  113. data/src/core/ext/xds/xds_api.h +56 -611
  114. data/src/core/ext/xds/xds_bootstrap.cc +189 -125
  115. data/src/core/ext/xds/xds_bootstrap.h +20 -15
  116. data/src/core/ext/xds/xds_certificate_provider.h +1 -0
  117. data/src/core/ext/xds/xds_channel_creds.cc +108 -0
  118. data/src/core/ext/xds/xds_channel_creds.h +50 -0
  119. data/src/core/ext/xds/xds_client.cc +584 -994
  120. data/src/core/ext/xds/xds_client.h +78 -135
  121. data/src/core/ext/xds/xds_cluster.cc +451 -0
  122. data/src/core/ext/xds/xds_cluster.h +111 -0
  123. data/src/core/ext/xds/xds_common_types.cc +388 -0
  124. data/src/core/ext/xds/xds_common_types.h +110 -0
  125. data/src/core/ext/xds/xds_endpoint.cc +364 -0
  126. data/src/core/ext/xds/xds_endpoint.h +135 -0
  127. data/src/core/ext/xds/xds_http_filters.cc +5 -0
  128. data/src/core/ext/xds/xds_http_rbac_filter.cc +563 -0
  129. data/src/core/ext/xds/xds_http_rbac_filter.h +54 -0
  130. data/src/core/ext/xds/xds_listener.cc +1036 -0
  131. data/src/core/ext/xds/xds_listener.h +220 -0
  132. data/src/core/ext/{transport/chttp2/transport/hpack_utils.h → xds/xds_resource_type.cc} +12 -9
  133. data/src/core/ext/xds/xds_resource_type.h +98 -0
  134. data/src/core/ext/xds/xds_resource_type_impl.h +87 -0
  135. data/src/core/ext/xds/xds_route_config.cc +993 -0
  136. data/src/core/ext/xds/xds_route_config.h +215 -0
  137. data/src/core/ext/xds/xds_routing.cc +11 -8
  138. data/src/core/ext/xds/xds_routing.h +8 -5
  139. data/src/core/ext/xds/xds_server_config_fetcher.cc +159 -99
  140. data/src/core/lib/address_utils/parse_address.cc +20 -0
  141. data/src/core/lib/address_utils/parse_address.h +5 -0
  142. data/src/core/lib/address_utils/sockaddr_utils.cc +33 -36
  143. data/src/core/lib/address_utils/sockaddr_utils.h +1 -16
  144. data/src/core/lib/backoff/backoff.cc +4 -30
  145. data/src/core/lib/backoff/backoff.h +3 -3
  146. data/src/core/lib/channel/channel_args.cc +0 -1
  147. data/src/core/lib/channel/channel_stack.cc +8 -0
  148. data/src/core/lib/channel/channel_stack.h +1 -1
  149. data/src/core/lib/channel/channel_stack_builder.cc +5 -9
  150. data/src/core/lib/channel/channel_stack_builder.h +4 -7
  151. data/src/core/lib/channel/channelz.cc +1 -0
  152. data/src/core/lib/compression/compression.cc +19 -111
  153. data/src/core/lib/compression/compression_internal.cc +142 -202
  154. data/src/core/lib/compression/compression_internal.h +64 -69
  155. data/src/core/lib/compression/message_compress.cc +11 -11
  156. data/src/core/lib/compression/message_compress.h +2 -2
  157. data/src/core/lib/gpr/useful.h +4 -0
  158. data/src/core/lib/gprpp/bitset.h +7 -0
  159. data/src/core/lib/gprpp/chunked_vector.h +45 -3
  160. data/src/core/lib/gprpp/status_helper.cc +20 -28
  161. data/src/core/lib/gprpp/status_helper.h +6 -19
  162. data/src/core/lib/gprpp/table.h +11 -0
  163. data/src/core/lib/http/httpcli.cc +37 -46
  164. data/src/core/lib/http/httpcli.h +3 -15
  165. data/src/core/lib/iomgr/call_combiner.cc +15 -4
  166. data/src/core/lib/iomgr/closure.h +29 -9
  167. data/src/core/lib/iomgr/combiner.cc +25 -3
  168. data/src/core/lib/iomgr/error.cc +2 -0
  169. data/src/core/lib/iomgr/error.h +3 -0
  170. data/src/core/lib/iomgr/event_engine/iomgr.cc +3 -2
  171. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +6 -0
  172. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +2 -0
  173. data/src/core/lib/iomgr/event_engine/resolver.cc +66 -48
  174. data/src/core/lib/iomgr/event_engine/resolver.h +56 -0
  175. data/src/core/lib/iomgr/exec_ctx.cc +22 -9
  176. data/src/core/lib/iomgr/executor.cc +10 -1
  177. data/src/core/lib/iomgr/fork_posix.cc +3 -2
  178. data/src/core/lib/iomgr/iomgr_custom.cc +4 -1
  179. data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
  180. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
  181. data/src/core/lib/iomgr/iomgr_windows.cc +2 -2
  182. data/src/core/lib/iomgr/port.h +2 -2
  183. data/src/core/lib/iomgr/resolve_address.cc +5 -24
  184. data/src/core/lib/iomgr/resolve_address.h +47 -44
  185. data/src/core/lib/iomgr/resolve_address_custom.cc +131 -109
  186. data/src/core/lib/iomgr/resolve_address_custom.h +101 -19
  187. data/src/core/lib/iomgr/resolve_address_impl.h +59 -0
  188. data/src/core/lib/iomgr/resolve_address_posix.cc +82 -66
  189. data/src/core/lib/iomgr/resolve_address_posix.h +47 -0
  190. data/src/core/lib/iomgr/resolve_address_windows.cc +93 -74
  191. data/src/core/lib/iomgr/resolve_address_windows.h +47 -0
  192. data/src/core/lib/iomgr/resolved_address.h +39 -0
  193. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -0
  194. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +1 -0
  195. data/src/core/lib/iomgr/unix_sockets_posix.cc +22 -34
  196. data/src/core/lib/iomgr/unix_sockets_posix.h +4 -7
  197. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +6 -15
  198. data/src/core/lib/matchers/matchers.cc +1 -1
  199. data/src/core/lib/promise/activity.h +49 -20
  200. data/src/core/lib/promise/detail/status.h +5 -0
  201. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.cc +17 -25
  202. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.h +43 -44
  203. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_factory.h +10 -5
  204. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.cc +3 -2
  205. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.h +4 -5
  206. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.cc +1 -1
  207. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.h +4 -4
  208. data/src/core/lib/resource_quota/api.h +0 -1
  209. data/src/core/lib/{gprpp → resource_quota}/arena.cc +16 -13
  210. data/src/core/lib/{gprpp → resource_quota}/arena.h +24 -13
  211. data/src/core/lib/security/authorization/evaluate_args.cc +30 -15
  212. data/src/core/lib/security/authorization/evaluate_args.h +1 -0
  213. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +60 -0
  214. data/src/core/lib/security/authorization/grpc_authorization_engine.h +62 -0
  215. data/src/core/lib/security/authorization/matchers.cc +227 -0
  216. data/src/core/lib/security/authorization/matchers.h +211 -0
  217. data/src/core/lib/security/authorization/rbac_policy.cc +442 -0
  218. data/src/core/lib/security/authorization/rbac_policy.h +170 -0
  219. data/src/core/lib/security/context/security_context.cc +4 -2
  220. data/src/core/lib/security/context/security_context.h +1 -1
  221. data/src/core/lib/security/credentials/composite/composite_credentials.cc +5 -5
  222. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -3
  223. data/src/core/lib/security/credentials/credentials.h +10 -20
  224. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +6 -9
  225. data/src/core/lib/security/credentials/external/external_account_credentials.cc +7 -9
  226. data/src/core/lib/security/credentials/external/external_account_credentials.h +2 -7
  227. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -3
  228. data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -4
  229. data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -7
  230. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -5
  231. data/src/core/lib/security/credentials/iam/iam_credentials.cc +16 -19
  232. data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -5
  233. data/src/core/lib/security/credentials/jwt/json_token.cc +4 -6
  234. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +16 -28
  235. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +8 -8
  236. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +6 -13
  237. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +44 -57
  238. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +13 -15
  239. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -7
  240. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +5 -4
  241. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -10
  242. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +6 -0
  243. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +7 -0
  244. data/src/core/lib/security/credentials/xds/xds_credentials.h +1 -1
  245. data/src/core/lib/security/security_connector/security_connector.cc +0 -4
  246. data/src/core/lib/security/security_connector/security_connector.h +5 -1
  247. data/src/core/lib/security/security_connector/ssl_utils.cc +14 -24
  248. data/src/core/lib/security/security_connector/ssl_utils.h +5 -14
  249. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +2 -3
  250. data/src/core/lib/security/transport/auth_filters.h +7 -0
  251. data/src/core/lib/security/transport/client_auth_filter.cc +53 -33
  252. data/src/core/lib/security/transport/server_auth_filter.cc +40 -35
  253. data/src/core/{ext → lib}/service_config/service_config.cc +2 -2
  254. data/src/core/{ext → lib}/service_config/service_config.h +4 -4
  255. data/src/core/{ext → lib}/service_config/service_config_call_data.h +5 -5
  256. data/src/core/{ext → lib}/service_config/service_config_parser.cc +1 -1
  257. data/src/core/{ext → lib}/service_config/service_config_parser.h +3 -3
  258. data/src/core/lib/slice/slice.cc +3 -1
  259. data/src/core/lib/slice/slice.h +43 -13
  260. data/src/core/lib/slice/slice_intern.cc +3 -101
  261. data/src/core/lib/slice/slice_internal.h +1 -2
  262. data/src/core/lib/slice/slice_refcount.h +4 -13
  263. data/src/core/lib/slice/slice_refcount_base.h +0 -16
  264. data/src/core/lib/surface/call.cc +140 -382
  265. data/src/core/lib/surface/call.h +4 -4
  266. data/src/core/lib/surface/channel.cc +42 -44
  267. data/src/core/lib/surface/channel.h +4 -4
  268. data/src/core/lib/surface/init.cc +0 -2
  269. data/src/core/lib/surface/lame_client.cc +0 -1
  270. data/src/core/lib/surface/server.cc +12 -29
  271. data/src/core/lib/surface/server.h +2 -2
  272. data/src/core/lib/surface/version.cc +2 -2
  273. data/src/core/lib/transport/error_utils.h +14 -0
  274. data/src/core/lib/transport/metadata_batch.h +799 -717
  275. data/src/core/lib/transport/parsed_metadata.cc +2 -0
  276. data/src/core/lib/transport/parsed_metadata.h +95 -92
  277. data/src/core/lib/transport/timeout_encoding.cc +200 -66
  278. data/src/core/lib/transport/timeout_encoding.h +40 -10
  279. data/src/core/lib/transport/transport.h +1 -1
  280. data/src/core/lib/transport/transport_op_string.cc +6 -39
  281. data/src/core/lib/uri/uri_parser.cc +223 -53
  282. data/src/core/lib/uri/uri_parser.h +36 -23
  283. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -3
  284. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  285. data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -4
  286. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -5
  287. data/src/core/tsi/ssl_transport_security.cc +53 -13
  288. data/src/core/tsi/ssl_transport_security.h +18 -6
  289. data/src/ruby/ext/grpc/extconf.rb +10 -3
  290. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  291. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  292. data/src/ruby/lib/grpc/version.rb +1 -1
  293. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -1
  294. data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +48 -0
  295. data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +200 -0
  296. data/third_party/abseil-cpp/absl/random/beta_distribution.h +427 -0
  297. data/third_party/abseil-cpp/absl/random/discrete_distribution.cc +98 -0
  298. data/third_party/abseil-cpp/absl/random/discrete_distribution.h +247 -0
  299. data/third_party/abseil-cpp/absl/random/distributions.h +452 -0
  300. data/third_party/abseil-cpp/absl/random/exponential_distribution.h +165 -0
  301. data/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +104 -0
  302. data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +275 -0
  303. data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +92 -0
  304. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +268 -0
  305. data/third_party/abseil-cpp/absl/random/internal/fastmath.h +57 -0
  306. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +144 -0
  307. data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +245 -0
  308. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +150 -0
  309. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +308 -0
  310. data/third_party/abseil-cpp/absl/random/internal/platform.h +171 -0
  311. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +253 -0
  312. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +131 -0
  313. data/third_party/abseil-cpp/absl/random/internal/randen.cc +91 -0
  314. data/third_party/abseil-cpp/absl/random/internal/randen.h +102 -0
  315. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +221 -0
  316. data/third_party/abseil-cpp/absl/random/internal/randen_detect.h +33 -0
  317. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +239 -0
  318. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +526 -0
  319. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +50 -0
  320. data/third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc +462 -0
  321. data/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +471 -0
  322. data/third_party/abseil-cpp/absl/random/internal/randen_slow.h +40 -0
  323. data/third_party/abseil-cpp/absl/random/internal/randen_traits.h +88 -0
  324. data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +167 -0
  325. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +267 -0
  326. data/third_party/abseil-cpp/absl/random/internal/seed_material.h +104 -0
  327. data/third_party/abseil-cpp/absl/random/internal/traits.h +101 -0
  328. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +244 -0
  329. data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +111 -0
  330. data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +257 -0
  331. data/third_party/abseil-cpp/absl/random/poisson_distribution.h +258 -0
  332. data/third_party/abseil-cpp/absl/random/random.h +189 -0
  333. data/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +46 -0
  334. data/third_party/abseil-cpp/absl/random/seed_gen_exception.h +55 -0
  335. data/third_party/abseil-cpp/absl/random/seed_sequences.cc +29 -0
  336. data/third_party/abseil-cpp/absl/random/seed_sequences.h +110 -0
  337. data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +275 -0
  338. data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +202 -0
  339. data/third_party/abseil-cpp/absl/random/zipf_distribution.h +271 -0
  340. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -0
  341. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +13 -0
  342. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +21 -0
  343. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +12 -0
  344. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +1 -2
  345. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +2 -2
  346. data/third_party/boringssl-with-bazel/src/crypto/mem.c +1 -1
  347. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +29 -0
  348. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +0 -1
  349. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +1 -1
  350. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
  351. data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +8 -0
  352. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +13 -1
  353. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +10 -0
  354. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +1 -1
  355. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +9 -4
  356. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +6 -1
  357. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +23 -2
  358. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +4 -0
  359. data/third_party/xxhash/xxhash.h +607 -352
  360. metadata +149 -77
  361. data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +0 -107
  362. data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +0 -46
  363. data/src/core/ext/transport/chttp2/transport/popularity_count.h +0 -60
  364. data/src/core/lib/compression/algorithm_metadata.h +0 -62
  365. data/src/core/lib/compression/compression_args.cc +0 -140
  366. data/src/core/lib/compression/compression_args.h +0 -58
  367. data/src/core/lib/compression/stream_compression.cc +0 -81
  368. data/src/core/lib/compression/stream_compression.h +0 -117
  369. data/src/core/lib/compression/stream_compression_gzip.cc +0 -231
  370. data/src/core/lib/compression/stream_compression_gzip.h +0 -28
  371. data/src/core/lib/compression/stream_compression_identity.cc +0 -91
  372. data/src/core/lib/compression/stream_compression_identity.h +0 -29
  373. data/src/core/lib/security/credentials/credentials_metadata.cc +0 -61
  374. data/src/core/lib/slice/static_slice.cc +0 -377
  375. data/src/core/lib/slice/static_slice.h +0 -300
  376. data/src/core/lib/transport/metadata.cc +0 -714
  377. data/src/core/lib/transport/metadata.h +0 -449
  378. data/src/core/lib/transport/metadata_batch.cc +0 -99
  379. data/src/core/lib/transport/static_metadata.cc +0 -1032
  380. data/src/core/lib/transport/static_metadata.h +0 -322
  381. data/src/core/lib/transport/status_metadata.cc +0 -63
  382. data/src/core/lib/transport/status_metadata.h +0 -48
@@ -17,8 +17,10 @@
17
17
 
18
18
  #include <grpc/support/port_platform.h>
19
19
 
20
- #include "src/core/lib/gprpp/arena.h"
20
+ #include <cstddef>
21
+
21
22
  #include "src/core/lib/gprpp/manual_constructor.h"
23
+ #include "src/core/lib/resource_quota/arena.h"
22
24
 
23
25
  namespace grpc_core {
24
26
 
@@ -48,8 +50,9 @@ class ChunkedVector {
48
50
  }
49
51
  ChunkedVector(const ChunkedVector& other)
50
52
  : ChunkedVector(other.arena_, other.begin(), other.end()) {}
51
- ChunkedVector& operator=(ChunkedVector other) {
52
- Swap(&other);
53
+ ChunkedVector& operator=(const ChunkedVector& other) {
54
+ ChunkedVector tmp(other);
55
+ Swap(&tmp);
53
56
  return *this;
54
57
  }
55
58
  ChunkedVector(ChunkedVector&& other) noexcept
@@ -113,6 +116,12 @@ class ChunkedVector {
113
116
  public:
114
117
  ForwardIterator(Chunk* chunk, size_t n) : chunk_(chunk), n_(n) {}
115
118
 
119
+ using difference_type = std::ptrdiff_t;
120
+ using iterator_category = std::forward_iterator_tag;
121
+ using value_type = T;
122
+ using pointer = T*;
123
+ using reference = T&;
124
+
116
125
  T& operator*() const { return *chunk_->data[n_]; }
117
126
  T* operator->() const { return &*chunk_->data[n_]; }
118
127
  ForwardIterator& operator++() {
@@ -123,6 +132,11 @@ class ChunkedVector {
123
132
  }
124
133
  return *this;
125
134
  }
135
+ ForwardIterator& operator++(int) {
136
+ ForwardIterator tmp = *this;
137
+ ++*this;
138
+ return tmp;
139
+ }
126
140
  bool operator==(const ForwardIterator& other) const {
127
141
  return chunk_ == other.chunk_ && n_ == other.n_;
128
142
  }
@@ -131,6 +145,8 @@ class ChunkedVector {
131
145
  }
132
146
 
133
147
  private:
148
+ friend class ChunkedVector;
149
+
134
150
  Chunk* chunk_;
135
151
  size_t n_;
136
152
  };
@@ -140,6 +156,8 @@ class ChunkedVector {
140
156
  public:
141
157
  ConstForwardIterator(const Chunk* chunk, size_t n) : chunk_(chunk), n_(n) {}
142
158
 
159
+ using iterator_category = std::forward_iterator_tag;
160
+
143
161
  const T& operator*() const { return *chunk_->data[n_]; }
144
162
  const T* operator->() const { return &*chunk_->data[n_]; }
145
163
  ConstForwardIterator& operator++() {
@@ -150,6 +168,11 @@ class ChunkedVector {
150
168
  }
151
169
  return *this;
152
170
  }
171
+ ConstForwardIterator& operator++(int) {
172
+ ConstForwardIterator tmp = *this;
173
+ ++*this;
174
+ return tmp;
175
+ }
153
176
  bool operator==(const ConstForwardIterator& other) const {
154
177
  return chunk_ == other.chunk_ && n_ == other.n_;
155
178
  }
@@ -186,6 +209,25 @@ class ChunkedVector {
186
209
  return n;
187
210
  }
188
211
 
212
+ // Return true if the vector is empty.
213
+ bool empty() const { return first_ == nullptr || first_->count == 0; }
214
+
215
+ void SetEnd(ForwardIterator it) {
216
+ if (it == end()) return;
217
+ Chunk* chunk = it.chunk_;
218
+ for (size_t i = it.n_; i < chunk->count; i++) {
219
+ chunk->data[i].Destroy();
220
+ }
221
+ chunk->count = it.n_;
222
+ append_ = chunk;
223
+ while ((chunk = chunk->next) != nullptr) {
224
+ for (size_t i = 0; i < chunk->count; i++) {
225
+ chunk->data[i].Destroy();
226
+ }
227
+ chunk->count = 0;
228
+ }
229
+ }
230
+
189
231
  private:
190
232
  ManualConstructor<T>* AppendSlot() {
191
233
  if (append_ == nullptr) {
@@ -83,6 +83,8 @@ const char* GetStatusIntPropertyUrl(StatusIntProperty key) {
83
83
  return TYPE_URL(TYPE_INT_TAG "channel_connectivity_state");
84
84
  case StatusIntProperty::kLbPolicyDrop:
85
85
  return TYPE_URL(TYPE_INT_TAG "lb_policy_drop");
86
+ case StatusIntProperty::kStreamNetworkState:
87
+ return TYPE_URL(TYPE_INT_TAG "stream_network_state");
86
88
  }
87
89
  GPR_UNREACHABLE_CODE(return "unknown");
88
90
  }
@@ -159,7 +161,7 @@ std::vector<absl::Status> ParseChildren(absl::Cord children) {
159
161
 
160
162
  absl::Status StatusCreate(absl::StatusCode code, absl::string_view msg,
161
163
  const DebugLocation& location,
162
- std::initializer_list<absl::Status> children) {
164
+ std::vector<absl::Status> children) {
163
165
  absl::Status s(code, msg);
164
166
  if (location.file() != nullptr) {
165
167
  StatusSetStr(&s, StatusStrProperty::kFile, location.file());
@@ -230,7 +232,10 @@ absl::optional<absl::Time> StatusGetTime(const absl::Status& status,
230
232
  if (p.has_value()) {
231
233
  absl::optional<absl::string_view> sv = p->TryFlat();
232
234
  if (sv.has_value()) {
233
- return *reinterpret_cast<const absl::Time*>(sv->data());
235
+ // copy the content before casting to avoid misaligned address access
236
+ alignas(absl::Time) char buf[sizeof(const absl::Time)];
237
+ memcpy(buf, sv->data(), sizeof(const absl::Time));
238
+ return *reinterpret_cast<const absl::Time*>(buf);
234
239
  } else {
235
240
  std::string s = std::string(*p);
236
241
  return *reinterpret_cast<const absl::Time*>(s.c_str());
@@ -379,32 +384,8 @@ absl::Status StatusFromProto(google_rpc_Status* msg) {
379
384
  return status;
380
385
  }
381
386
 
382
- uintptr_t StatusAllocPtr(absl::Status s) {
383
- // This relies the fact that absl::Status has only one member, StatusRep*
384
- // so the sizeof(absl::Status) has the same size of intptr_t and StatusRep*
385
- // can be stolen using placement allocation.
386
- static_assert(sizeof(intptr_t) == sizeof(absl::Status),
387
- "absl::Status should be as big as intptr_t");
388
- // This does two things;
389
- // 1. Copies StatusRep* of absl::Status to ptr
390
- // 2. Increases the counter of StatusRep if it's not inlined
391
- uintptr_t ptr;
392
- new (&ptr) absl::Status(s);
393
- return ptr;
394
- }
395
-
396
- void StatusFreePtr(uintptr_t ptr) {
397
- // Decreases the counter of StatusRep if it's not inlined.
398
- reinterpret_cast<absl::Status*>(&ptr)->~Status();
399
- }
400
-
401
- absl::Status StatusGetFromPtr(uintptr_t ptr) {
402
- // Constructs Status from ptr having the address of StatusRep.
403
- return *reinterpret_cast<absl::Status*>(&ptr);
404
- }
405
-
406
387
  uintptr_t StatusAllocHeapPtr(absl::Status s) {
407
- if (s.ok()) return kOkStatusPtr;
388
+ if (s.ok()) return 0;
408
389
  absl::Status* ptr = new absl::Status(s);
409
390
  return reinterpret_cast<uintptr_t>(ptr);
410
391
  }
@@ -415,13 +396,24 @@ void StatusFreeHeapPtr(uintptr_t ptr) {
415
396
  }
416
397
 
417
398
  absl::Status StatusGetFromHeapPtr(uintptr_t ptr) {
418
- if (ptr == kOkStatusPtr) {
399
+ if (ptr == 0) {
419
400
  return absl::OkStatus();
420
401
  } else {
421
402
  return *reinterpret_cast<absl::Status*>(ptr);
422
403
  }
423
404
  }
424
405
 
406
+ absl::Status StatusMoveFromHeapPtr(uintptr_t ptr) {
407
+ if (ptr == 0) {
408
+ return absl::OkStatus();
409
+ } else {
410
+ absl::Status* s = reinterpret_cast<absl::Status*>(ptr);
411
+ absl::Status ret = std::move(*s);
412
+ delete s;
413
+ return ret;
414
+ }
415
+ }
416
+
425
417
  } // namespace internal
426
418
 
427
419
  } // namespace grpc_core
@@ -37,7 +37,6 @@ struct upb_arena;
37
37
  namespace grpc_core {
38
38
 
39
39
  /// This enum should have the same value of grpc_error_ints
40
- // TODO(veblush): Use camel-case names once migration to absl::Status is done.
41
40
  enum class StatusIntProperty {
42
41
  /// 'errno' from the operating system
43
42
  kErrorNo,
@@ -72,10 +71,11 @@ enum class StatusIntProperty {
72
71
  ChannelConnectivityState,
73
72
  /// LB policy drop
74
73
  kLbPolicyDrop,
74
+ /// stream network state
75
+ kStreamNetworkState,
75
76
  };
76
77
 
77
78
  /// This enum should have the same value of grpc_error_strs
78
- // TODO(veblush): Use camel-case names once migration to absl::Status is done.
79
79
  enum class StatusStrProperty {
80
80
  /// top-level textual description of this error
81
81
  kDescription,
@@ -110,7 +110,7 @@ enum class StatusTimeProperty {
110
110
  /// Creates a status with given additional information
111
111
  absl::Status StatusCreate(
112
112
  absl::StatusCode code, absl::string_view msg, const DebugLocation& location,
113
- std::initializer_list<absl::Status> children) GRPC_MUST_USE_RESULT;
113
+ std::vector<absl::Status> children) GRPC_MUST_USE_RESULT;
114
114
 
115
115
  /// Sets the int property to the status
116
116
  void StatusSetInt(absl::Status* status, StatusIntProperty key, intptr_t value);
@@ -160,22 +160,6 @@ google_rpc_Status* StatusToProto(const absl::Status& status,
160
160
  /// This is for internal implementation & test only
161
161
  absl::Status StatusFromProto(google_rpc_Status* msg) GRPC_MUST_USE_RESULT;
162
162
 
163
- /// The same value of internal::StatusAllocPtr(absl::OkStatus())
164
- static constexpr uintptr_t kOkStatusPtr = 0;
165
-
166
- /// Returns ptr where the given status is copied into.
167
- /// This ptr can be used to get Status later and should be freed by
168
- /// StatusFreePtr. This shouldn't be used except migration purpose.
169
- uintptr_t StatusAllocPtr(absl::Status s);
170
-
171
- /// Frees the allocated status at ptr.
172
- /// This shouldn't be used except migration purpose.
173
- void StatusFreePtr(uintptr_t ptr);
174
-
175
- /// Get the status from ptr.
176
- /// This shouldn't be used except migration purpose.
177
- absl::Status StatusGetFromPtr(uintptr_t ptr);
178
-
179
163
  /// Returns ptr that is allocated in the heap memory and the given status is
180
164
  /// copied into. This ptr can be used to get Status later and should be
181
165
  /// freed by StatusFreeHeapPtr. This can be 0 in case of OkStatus.
@@ -187,6 +171,9 @@ void StatusFreeHeapPtr(uintptr_t ptr);
187
171
  /// Get the status from a heap ptr.
188
172
  absl::Status StatusGetFromHeapPtr(uintptr_t ptr);
189
173
 
174
+ /// Move the status from a heap ptr. (GetFrom & FreeHeap)
175
+ absl::Status StatusMoveFromHeapPtr(uintptr_t ptr);
176
+
190
177
  } // namespace internal
191
178
 
192
179
  } // namespace grpc_core
@@ -311,6 +311,12 @@ class Table {
311
311
  // Count the number of set fields in the table
312
312
  size_t count() const { return present_bits_.count(); }
313
313
 
314
+ // Check if the table is completely empty
315
+ bool empty() const { return present_bits_.none(); }
316
+
317
+ // Clear all elements in the table.
318
+ void ClearAll() { ClearAllImpl(absl::make_index_sequence<sizeof...(Ts)>()); }
319
+
314
320
  private:
315
321
  // Bit field for which elements of the table are set (true) or un-set (false,
316
322
  // the default) -- one bit for each type in Ts.
@@ -412,6 +418,11 @@ class Table {
412
418
  table_detail::do_these_things<int>({(CallIf<I>(&f), 1)...});
413
419
  }
414
420
 
421
+ template <size_t... I>
422
+ void ClearAllImpl(absl::index_sequence<I...>) {
423
+ table_detail::do_these_things<int>({(clear<I>(), 1)...});
424
+ }
425
+
415
426
  // Bit field indicating which elements are set.
416
427
  GPR_NO_UNIQUE_ADDRESS PresentBits present_bits_;
417
428
  // The memory to store the elements themselves.
@@ -24,6 +24,7 @@
24
24
 
25
25
  #include <string>
26
26
 
27
+ #include "absl/functional/bind_front.h"
27
28
  #include "absl/strings/str_format.h"
28
29
  #include "absl/strings/string_view.h"
29
30
 
@@ -44,6 +45,7 @@
44
45
  #include "src/core/lib/iomgr/tcp_client.h"
45
46
  #include "src/core/lib/resource_quota/api.h"
46
47
  #include "src/core/lib/slice/slice_internal.h"
48
+ #include "src/core/lib/transport/error_utils.h"
47
49
 
48
50
  namespace grpc_core {
49
51
  namespace {
@@ -55,8 +57,8 @@ class InternalRequest {
55
57
  ResourceQuotaRefPtr resource_quota, absl::string_view host,
56
58
  absl::string_view ssl_host_override, grpc_millis deadline,
57
59
  const grpc_httpcli_handshaker* handshaker,
58
- grpc_closure* on_done, grpc_httpcli_context* context,
59
- grpc_polling_entity* pollent, const char* name)
60
+ grpc_closure* on_done, grpc_polling_entity* pollent,
61
+ const char* name)
60
62
  : request_text_(request_text),
61
63
  resource_quota_(std::move(resource_quota)),
62
64
  host_(host),
@@ -64,8 +66,8 @@ class InternalRequest {
64
66
  deadline_(deadline),
65
67
  handshaker_(handshaker),
66
68
  on_done_(on_done),
67
- context_(context),
68
- pollent_(pollent) {
69
+ pollent_(pollent),
70
+ pollset_set_(grpc_pollset_set_create()) {
69
71
  grpc_http_parser_init(&parser_, GRPC_HTTP_RESPONSE, response);
70
72
  grpc_slice_buffer_init(&incoming_);
71
73
  grpc_slice_buffer_init(&outgoing_);
@@ -74,18 +76,15 @@ class InternalRequest {
74
76
  GRPC_CLOSURE_INIT(&on_read_, OnRead, this, grpc_schedule_on_exec_ctx);
75
77
  GRPC_CLOSURE_INIT(&done_write_, DoneWrite, this, grpc_schedule_on_exec_ctx);
76
78
  GPR_ASSERT(pollent);
77
- grpc_polling_entity_add_to_pollset_set(pollent_, context->pollset_set);
78
- grpc_resolve_address(
79
- host_.c_str(), handshaker_->default_port, context_->pollset_set,
80
- GRPC_CLOSURE_CREATE(OnResolved, this, grpc_schedule_on_exec_ctx),
81
- &addresses_);
79
+ grpc_polling_entity_add_to_pollset_set(pollent, pollset_set_);
80
+ dns_request_ = GetDNSResolver()->ResolveName(
81
+ host_.c_str(), handshaker_->default_port, pollset_set_,
82
+ absl::bind_front(&InternalRequest::OnResolved, this));
83
+ dns_request_->Start();
82
84
  }
83
85
 
84
86
  ~InternalRequest() {
85
87
  grpc_http_parser_destroy(&parser_);
86
- if (addresses_ != nullptr) {
87
- grpc_resolved_addresses_destroy(addresses_);
88
- }
89
88
  if (ep_ != nullptr) {
90
89
  grpc_endpoint_destroy(ep_);
91
90
  }
@@ -94,11 +93,12 @@ class InternalRequest {
94
93
  grpc_slice_buffer_destroy_internal(&incoming_);
95
94
  grpc_slice_buffer_destroy_internal(&outgoing_);
96
95
  GRPC_ERROR_UNREF(overall_error_);
96
+ grpc_pollset_set_destroy(pollset_set_);
97
97
  }
98
98
 
99
99
  private:
100
100
  void Finish(grpc_error_handle error) {
101
- grpc_polling_entity_del_from_pollset_set(pollent_, context_->pollset_set);
101
+ grpc_polling_entity_del_from_pollset_set(pollent_, pollset_set_);
102
102
  ExecCtx::Run(DEBUG_LOCATION, on_done_, error);
103
103
  delete this;
104
104
  }
@@ -108,7 +108,7 @@ class InternalRequest {
108
108
  overall_error_ =
109
109
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed HTTP/1 client request");
110
110
  }
111
- grpc_resolved_address* addr = &addresses_->addrs[next_address_ - 1];
111
+ const grpc_resolved_address* addr = &addresses_[next_address_ - 1];
112
112
  std::string addr_text = grpc_sockaddr_to_uri(addr);
113
113
  overall_error_ = grpc_error_add_child(
114
114
  overall_error_,
@@ -193,16 +193,15 @@ class InternalRequest {
193
193
  }
194
194
 
195
195
  void NextAddress(grpc_error_handle error) {
196
- grpc_resolved_address* addr;
197
196
  if (error != GRPC_ERROR_NONE) {
198
197
  AppendError(error);
199
198
  }
200
- if (next_address_ == addresses_->naddrs) {
199
+ if (next_address_ == addresses_.size()) {
201
200
  Finish(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
202
201
  "Failed HTTP requests to all targets", &overall_error_, 1));
203
202
  return;
204
203
  }
205
- addr = &addresses_->addrs[next_address_++];
204
+ const grpc_resolved_address* addr = &addresses_[next_address_++];
206
205
  GRPC_CLOSURE_INIT(&connected_, OnConnected, this,
207
206
  grpc_schedule_on_exec_ctx);
208
207
  grpc_arg rq_arg = grpc_channel_arg_pointer_create(
@@ -212,24 +211,26 @@ class InternalRequest {
212
211
  auto* args = CoreConfiguration::Get()
213
212
  .channel_args_preconditioning()
214
213
  .PreconditionChannelArgs(&channel_args);
215
- grpc_tcp_client_connect(&connected_, &ep_, context_->pollset_set, args,
216
- addr, deadline_);
214
+ grpc_tcp_client_connect(&connected_, &ep_, pollset_set_, args, addr,
215
+ deadline_);
217
216
  grpc_channel_args_destroy(args);
218
217
  }
219
218
 
220
- static void OnResolved(void* arg, grpc_error_handle error) {
221
- InternalRequest* req = static_cast<InternalRequest*>(arg);
222
- if (error != GRPC_ERROR_NONE) {
223
- req->Finish(GRPC_ERROR_REF(error));
219
+ void OnResolved(
220
+ absl::StatusOr<std::vector<grpc_resolved_address>> addresses_or) {
221
+ dns_request_.reset();
222
+ if (!addresses_or.ok()) {
223
+ Finish(absl_status_to_grpc_error(addresses_or.status()));
224
224
  return;
225
225
  }
226
- req->next_address_ = 0;
227
- req->NextAddress(GRPC_ERROR_NONE);
226
+ addresses_ = std::move(*addresses_or);
227
+ next_address_ = 0;
228
+ NextAddress(GRPC_ERROR_NONE);
228
229
  }
229
230
 
230
231
  grpc_slice request_text_;
231
232
  grpc_http_parser parser_;
232
- grpc_resolved_addresses* addresses_ = nullptr;
233
+ std::vector<grpc_resolved_address> addresses_;
233
234
  size_t next_address_ = 0;
234
235
  grpc_endpoint* ep_ = nullptr;
235
236
  ResourceQuotaRefPtr resource_quota_;
@@ -239,8 +240,8 @@ class InternalRequest {
239
240
  int have_read_byte_ = 0;
240
241
  const grpc_httpcli_handshaker* handshaker_;
241
242
  grpc_closure* on_done_;
242
- grpc_httpcli_context* context_;
243
243
  grpc_polling_entity* pollent_;
244
+ grpc_pollset_set* pollset_set_;
244
245
  grpc_iomgr_object iomgr_obj_;
245
246
  grpc_slice_buffer incoming_;
246
247
  grpc_slice_buffer outgoing_;
@@ -248,6 +249,7 @@ class InternalRequest {
248
249
  grpc_closure done_write_;
249
250
  grpc_closure connected_;
250
251
  grpc_error_handle overall_error_ = GRPC_ERROR_NONE;
252
+ OrphanablePtr<DNSResolver::Request> dns_request_;
251
253
  };
252
254
 
253
255
  } // namespace
@@ -266,17 +268,8 @@ static void plaintext_handshake(void* arg, grpc_endpoint* endpoint,
266
268
  const grpc_httpcli_handshaker grpc_httpcli_plaintext = {"http",
267
269
  plaintext_handshake};
268
270
 
269
- void grpc_httpcli_context_init(grpc_httpcli_context* context) {
270
- context->pollset_set = grpc_pollset_set_create();
271
- }
272
-
273
- void grpc_httpcli_context_destroy(grpc_httpcli_context* context) {
274
- grpc_pollset_set_destroy(context->pollset_set);
275
- }
276
-
277
271
  static void internal_request_begin(
278
- grpc_httpcli_context* context, grpc_polling_entity* pollent,
279
- grpc_core::ResourceQuotaRefPtr resource_quota,
272
+ grpc_polling_entity* pollent, grpc_core::ResourceQuotaRefPtr resource_quota,
280
273
  const grpc_httpcli_request* request, grpc_millis deadline,
281
274
  grpc_closure* on_done, grpc_httpcli_response* response, const char* name,
282
275
  const grpc_slice& request_text) {
@@ -284,11 +277,10 @@ static void internal_request_begin(
284
277
  request_text, response, std::move(resource_quota), request->host,
285
278
  request->ssl_host_override, deadline,
286
279
  request->handshaker ? request->handshaker : &grpc_httpcli_plaintext,
287
- on_done, context, pollent, name);
280
+ on_done, pollent, name);
288
281
  }
289
282
 
290
- void grpc_httpcli_get(grpc_httpcli_context* context,
291
- grpc_polling_entity* pollent,
283
+ void grpc_httpcli_get(grpc_polling_entity* pollent,
292
284
  grpc_core::ResourceQuotaRefPtr resource_quota,
293
285
  const grpc_httpcli_request* request, grpc_millis deadline,
294
286
  grpc_closure* on_done, grpc_httpcli_response* response) {
@@ -297,13 +289,12 @@ void grpc_httpcli_get(grpc_httpcli_context* context,
297
289
  }
298
290
  std::string name =
299
291
  absl::StrFormat("HTTP:GET:%s:%s", request->host, request->http.path);
300
- internal_request_begin(context, pollent, std::move(resource_quota), request,
301
- deadline, on_done, response, name.c_str(),
292
+ internal_request_begin(pollent, std::move(resource_quota), request, deadline,
293
+ on_done, response, name.c_str(),
302
294
  grpc_httpcli_format_get_request(request));
303
295
  }
304
296
 
305
- void grpc_httpcli_post(grpc_httpcli_context* context,
306
- grpc_polling_entity* pollent,
297
+ void grpc_httpcli_post(grpc_polling_entity* pollent,
307
298
  grpc_core::ResourceQuotaRefPtr resource_quota,
308
299
  const grpc_httpcli_request* request,
309
300
  const char* body_bytes, size_t body_size,
@@ -316,8 +307,8 @@ void grpc_httpcli_post(grpc_httpcli_context* context,
316
307
  std::string name =
317
308
  absl::StrFormat("HTTP:POST:%s:%s", request->host, request->http.path);
318
309
  internal_request_begin(
319
- context, pollent, std::move(resource_quota), request, deadline, on_done,
320
- response, name.c_str(),
310
+ pollent, std::move(resource_quota), request, deadline, on_done, response,
311
+ name.c_str(),
321
312
  grpc_httpcli_format_post_request(request, body_bytes, body_size));
322
313
  }
323
314
 
@@ -35,13 +35,8 @@
35
35
  /* User agent this library reports */
36
36
  #define GRPC_HTTPCLI_USER_AGENT "grpc-httpcli/0.0"
37
37
 
38
- /* Tracks in-progress http requests
39
- TODO(ctiller): allow caching and capturing multiple requests for the
38
+ /* TODO(ctiller): allow caching and capturing multiple requests for the
40
39
  same content and combining them */
41
- typedef struct grpc_httpcli_context {
42
- grpc_pollset_set* pollset_set;
43
- } grpc_httpcli_context;
44
-
45
40
  struct grpc_httpcli_handshaker {
46
41
  const char* default_port;
47
42
  void (*handshake)(void* arg, grpc_endpoint* endpoint, const char* host,
@@ -68,11 +63,7 @@ typedef struct grpc_httpcli_request {
68
63
  /* Expose the parser response type as a httpcli response too */
69
64
  typedef struct grpc_http_response grpc_httpcli_response;
70
65
 
71
- void grpc_httpcli_context_init(grpc_httpcli_context* context);
72
- void grpc_httpcli_context_destroy(grpc_httpcli_context* context);
73
-
74
66
  /* Asynchronously perform a HTTP GET.
75
- 'context' specifies the http context under which to do the get
76
67
  'pollent' indicates a grpc_polling_entity that is interested in the result
77
68
  of the get - work on this entity may be used to progress the get
78
69
  operation
@@ -82,14 +73,12 @@ void grpc_httpcli_context_destroy(grpc_httpcli_context* context);
82
73
  can be destroyed once the call returns 'deadline' contains a deadline for the
83
74
  request (or gpr_inf_future)
84
75
  'on_response' is a callback to report results to */
85
- void grpc_httpcli_get(grpc_httpcli_context* context,
86
- grpc_polling_entity* pollent,
76
+ void grpc_httpcli_get(grpc_polling_entity* pollent,
87
77
  grpc_core::ResourceQuotaRefPtr resource_quota,
88
78
  const grpc_httpcli_request* request, grpc_millis deadline,
89
79
  grpc_closure* on_done, grpc_httpcli_response* response);
90
80
 
91
81
  /* Asynchronously perform a HTTP POST.
92
- 'context' specifies the http context under which to do the post
93
82
  'pollent' indicates a grpc_polling_entity that is interested in the result
94
83
  of the post - work on this entity may be used to progress the post
95
84
  operation
@@ -104,8 +93,7 @@ void grpc_httpcli_get(grpc_httpcli_context* context,
104
93
  lifetime of the request
105
94
  'on_response' is a callback to report results to
106
95
  Does not support ?var1=val1&var2=val2 in the path. */
107
- void grpc_httpcli_post(grpc_httpcli_context* context,
108
- grpc_polling_entity* pollent,
96
+ void grpc_httpcli_post(grpc_polling_entity* pollent,
109
97
  grpc_core::ResourceQuotaRefPtr resource_quota,
110
98
  const grpc_httpcli_request* request,
111
99
  const char* body_bytes, size_t body_size,
@@ -150,7 +150,11 @@ void CallCombiner::Start(grpc_closure* closure, grpc_error_handle error,
150
150
  gpr_log(GPR_INFO, " QUEUING");
151
151
  }
152
152
  // Queue was not empty, so add closure to queue.
153
- closure->error_data.error = error;
153
+ #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
154
+ closure->error_data.error = internal::StatusAllocHeapPtr(error);
155
+ #else
156
+ closure->error_data.error = reinterpret_cast<intptr_t>(error);
157
+ #endif
154
158
  queue_.Push(
155
159
  reinterpret_cast<MultiProducerSingleConsumerQueue::Node*>(closure));
156
160
  }
@@ -185,12 +189,19 @@ void CallCombiner::Stop(DEBUG_ARGS const char* reason) {
185
189
  }
186
190
  continue;
187
191
  }
192
+ #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
193
+ grpc_error_handle error =
194
+ internal::StatusMoveFromHeapPtr(closure->error_data.error);
195
+ #else
196
+ grpc_error_handle error =
197
+ reinterpret_cast<grpc_error_handle>(closure->error_data.error);
198
+ #endif
199
+ closure->error_data.error = 0;
188
200
  if (GRPC_TRACE_FLAG_ENABLED(grpc_call_combiner_trace)) {
189
201
  gpr_log(GPR_INFO, " EXECUTING FROM QUEUE: closure=%p error=%s",
190
- closure,
191
- grpc_error_std_string(closure->error_data.error).c_str());
202
+ closure, grpc_error_std_string(error).c_str());
192
203
  }
193
- ScheduleClosure(closure, closure->error_data.error);
204
+ ScheduleClosure(closure, error);
194
205
  break;
195
206
  }
196
207
  } else if (GRPC_TRACE_FLAG_ENABLED(grpc_call_combiner_trace)) {
@@ -72,7 +72,7 @@ struct grpc_closure {
72
72
 
73
73
  /** Once queued, the result of the closure. Before then: scratch space */
74
74
  union {
75
- grpc_error_handle error;
75
+ uintptr_t error;
76
76
  uintptr_t scratch;
77
77
  } error_data;
78
78
 
@@ -98,7 +98,7 @@ inline grpc_closure* grpc_closure_init(grpc_closure* closure,
98
98
  #endif
99
99
  closure->cb = cb;
100
100
  closure->cb_arg = cb_arg;
101
- closure->error_data.error = GRPC_ERROR_NONE;
101
+ closure->error_data.error = 0;
102
102
  #ifndef NDEBUG
103
103
  closure->scheduled = false;
104
104
  closure->file_initiated = nullptr;
@@ -172,16 +172,12 @@ inline void grpc_closure_list_init(grpc_closure_list* closure_list) {
172
172
  }
173
173
 
174
174
  /** add \a closure to the end of \a list
175
- and set \a closure's result to \a error
176
175
  Returns true if \a list becomes non-empty */
177
176
  inline bool grpc_closure_list_append(grpc_closure_list* closure_list,
178
- grpc_closure* closure,
179
- grpc_error_handle error) {
177
+ grpc_closure* closure) {
180
178
  if (closure == nullptr) {
181
- GRPC_ERROR_UNREF(error);
182
179
  return false;
183
180
  }
184
- closure->error_data.error = error;
185
181
  closure->next_data.next = nullptr;
186
182
  bool was_empty = (closure_list->head == nullptr);
187
183
  if (was_empty) {
@@ -193,12 +189,36 @@ inline bool grpc_closure_list_append(grpc_closure_list* closure_list,
193
189
  return was_empty;
194
190
  }
195
191
 
192
+ /** add \a closure to the end of \a list
193
+ and set \a closure's result to \a error
194
+ Returns true if \a list becomes non-empty */
195
+ inline bool grpc_closure_list_append(grpc_closure_list* closure_list,
196
+ grpc_closure* closure,
197
+ grpc_error_handle error) {
198
+ if (closure == nullptr) {
199
+ GRPC_ERROR_UNREF(error);
200
+ return false;
201
+ }
202
+ #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
203
+ closure->error_data.error = grpc_core::internal::StatusAllocHeapPtr(error);
204
+ #else
205
+ closure->error_data.error = reinterpret_cast<intptr_t>(error);
206
+ #endif
207
+ return grpc_closure_list_append(closure_list, closure);
208
+ }
209
+
196
210
  /** force all success bits in \a list to false */
197
211
  inline void grpc_closure_list_fail_all(grpc_closure_list* list,
198
212
  grpc_error_handle forced_failure) {
199
213
  for (grpc_closure* c = list->head; c != nullptr; c = c->next_data.next) {
200
- if (c->error_data.error == GRPC_ERROR_NONE) {
201
- c->error_data.error = GRPC_ERROR_REF(forced_failure);
214
+ if (c->error_data.error == 0) {
215
+ #ifdef GRPC_ERROR_IS_ABSEIL_STATUS
216
+ c->error_data.error =
217
+ grpc_core::internal::StatusAllocHeapPtr(forced_failure);
218
+ #else
219
+ c->error_data.error =
220
+ reinterpret_cast<intptr_t>(GRPC_ERROR_REF(forced_failure));
221
+ #endif
202
222
  }
203
223
  }
204
224
  GRPC_ERROR_UNREF(forced_failure);