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
@@ -23,11 +23,11 @@
23
23
 
24
24
  #include <ares.h>
25
25
 
26
- #include "src/core/ext/filters/client_channel/server_address.h"
27
26
  #include "src/core/lib/iomgr/iomgr.h"
28
27
  #include "src/core/lib/iomgr/polling_entity.h"
29
28
  #include "src/core/lib/iomgr/resolve_address.h"
30
29
  #include "src/core/lib/iomgr/work_serializer.h"
30
+ #include "src/core/lib/resolver/server_address.h"
31
31
 
32
32
  #define GRPC_DNS_ARES_DEFAULT_QUERY_TIMEOUT_MS 120000
33
33
 
@@ -45,54 +45,51 @@ extern grpc_core::TraceFlag grpc_trace_cares_resolver;
45
45
  typedef struct grpc_ares_ev_driver grpc_ares_ev_driver;
46
46
 
47
47
  struct grpc_ares_request {
48
+ /** synchronizes access to this request, and also to associated
49
+ * ev_driver and fd_node objects */
50
+ grpc_core::Mutex mu;
48
51
  /** indicates the DNS server to use, if specified */
49
- struct ares_addr_port_node dns_server_addr;
52
+ struct ares_addr_port_node dns_server_addr ABSL_GUARDED_BY(mu);
50
53
  /** following members are set in grpc_resolve_address_ares_impl */
51
54
  /** closure to call when the request completes */
52
- grpc_closure* on_done = nullptr;
55
+ grpc_closure* on_done ABSL_GUARDED_BY(mu) = nullptr;
53
56
  /** the pointer to receive the resolved addresses */
54
- std::unique_ptr<grpc_core::ServerAddressList>* addresses_out;
57
+ std::unique_ptr<grpc_core::ServerAddressList>* addresses_out
58
+ ABSL_GUARDED_BY(mu);
55
59
  /** the pointer to receive the resolved balancer addresses */
56
- std::unique_ptr<grpc_core::ServerAddressList>* balancer_addresses_out;
60
+ std::unique_ptr<grpc_core::ServerAddressList>* balancer_addresses_out
61
+ ABSL_GUARDED_BY(mu);
57
62
  /** the pointer to receive the service config in JSON */
58
- char** service_config_json_out = nullptr;
63
+ char** service_config_json_out ABSL_GUARDED_BY(mu) = nullptr;
59
64
  /** the evernt driver used by this request */
60
- grpc_ares_ev_driver* ev_driver = nullptr;
65
+ grpc_ares_ev_driver* ev_driver ABSL_GUARDED_BY(mu) = nullptr;
61
66
  /** number of ongoing queries */
62
- size_t pending_queries = 0;
67
+ size_t pending_queries ABSL_GUARDED_BY(mu) = 0;
63
68
  /** the errors explaining query failures, appended to in query callbacks */
64
- grpc_error_handle error = GRPC_ERROR_NONE;
69
+ grpc_error_handle error ABSL_GUARDED_BY(mu) = GRPC_ERROR_NONE;
65
70
  };
66
71
 
67
- /* Asynchronously resolve \a name. Use \a default_port if a port isn't
68
- designated in \a name, otherwise use the port in \a name. grpc_ares_init()
69
- must be called at least once before this function. \a on_done may be
70
- called directly in this function without being scheduled with \a exec_ctx,
71
- so it must not try to acquire locks that are being held by the caller. */
72
- extern void (*grpc_resolve_address_ares)(const char* name,
73
- const char* default_port,
74
- grpc_pollset_set* interested_parties,
75
- grpc_closure* on_done,
76
- grpc_resolved_addresses** addresses);
77
-
78
72
  /* Asynchronously resolve \a name. It will try to resolve grpclb SRV records in
79
73
  addition to the normal address records. For normal address records, it uses
80
74
  \a default_port if a port isn't designated in \a name, otherwise it uses the
81
75
  port in \a name. grpc_ares_init() must be called at least once before this
82
- function. \a on_done may be called directly in this function without being
83
- scheduled with \a exec_ctx, so it must not try to acquire locks that are
84
- being held by the caller. The returned grpc_ares_request object is owned
85
- by the caller and it is safe to free after on_done is called back. */
86
- extern grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
76
+ function. The returned grpc_ares_request object is owned by the caller and it
77
+ is safe to free after on_done is called back.
78
+
79
+ Note on synchronization: \a as on_done might be called from another thread
80
+ ~immediately, access to the grpc_ares_request* return value must be
81
+ synchronized by the caller. TODO(apolcyn): we should remove this requirement
82
+ by changing this API to use two phase initialization - one API to create
83
+ the grpc_ares_request* and another to start the async work. */
84
+ extern grpc_ares_request* (*grpc_dns_lookup_ares)(
87
85
  const char* dns_server, const char* name, const char* default_port,
88
86
  grpc_pollset_set* interested_parties, grpc_closure* on_done,
89
87
  std::unique_ptr<grpc_core::ServerAddressList>* addresses,
90
88
  std::unique_ptr<grpc_core::ServerAddressList>* balancer_addresses,
91
- char** service_config_json, int query_timeout_ms,
92
- std::shared_ptr<grpc_core::WorkSerializer> work_serializer);
89
+ char** service_config_json, int query_timeout_ms);
93
90
 
94
91
  /* Cancel the pending grpc_ares_request \a request */
95
- extern void (*grpc_cancel_ares_request_locked)(grpc_ares_request* request);
92
+ extern void (*grpc_cancel_ares_request)(grpc_ares_request* request);
96
93
 
97
94
  /* Initialize gRPC ares wrapper. Must be called at least once before
98
95
  grpc_resolve_address_ares(). */
@@ -103,10 +100,6 @@ grpc_error_handle grpc_ares_init(void);
103
100
  it has been called the same number of times as grpc_ares_init(). */
104
101
  void grpc_ares_cleanup(void);
105
102
 
106
- /** Schedules the desired callback for request completion
107
- * and destroys the grpc_ares_request */
108
- void grpc_ares_complete_request_locked(grpc_ares_request* request);
109
-
110
103
  /* Indicates whether or not AAAA queries should be attempted. */
111
104
  /* E.g., return false if ipv6 is known to not be available. */
112
105
  bool grpc_ares_query_ipv6();
@@ -24,10 +24,10 @@
24
24
  #include <grpc/support/string_util.h>
25
25
 
26
26
  #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
27
- #include "src/core/ext/filters/client_channel/server_address.h"
28
27
  #include "src/core/lib/address_utils/parse_address.h"
29
28
  #include "src/core/lib/gpr/string.h"
30
29
  #include "src/core/lib/iomgr/socket_windows.h"
30
+ #include "src/core/lib/resolver/server_address.h"
31
31
 
32
32
  bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); }
33
33
 
@@ -1,20 +1,18 @@
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
+ // Copyright 2015 gRPC authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
18
16
 
19
17
  #include <grpc/support/port_platform.h>
20
18
 
@@ -23,6 +21,7 @@
23
21
  #include <climits>
24
22
  #include <cstring>
25
23
 
24
+ #include "absl/functional/bind_front.h"
26
25
  #include "absl/strings/str_cat.h"
27
26
 
28
27
  #include <grpc/support/alloc.h>
@@ -30,8 +29,6 @@
30
29
  #include <grpc/support/time.h>
31
30
 
32
31
  #include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h"
33
- #include "src/core/ext/filters/client_channel/resolver_registry.h"
34
- #include "src/core/ext/filters/client_channel/server_address.h"
35
32
  #include "src/core/lib/backoff/backoff.h"
36
33
  #include "src/core/lib/channel/channel_args.h"
37
34
  #include "src/core/lib/gpr/string.h"
@@ -39,6 +36,8 @@
39
36
  #include "src/core/lib/iomgr/resolve_address.h"
40
37
  #include "src/core/lib/iomgr/timer.h"
41
38
  #include "src/core/lib/iomgr/work_serializer.h"
39
+ #include "src/core/lib/resolver/resolver_registry.h"
40
+ #include "src/core/lib/resolver/server_address.h"
42
41
 
43
42
  #define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1
44
43
  #define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6
@@ -49,9 +48,9 @@ namespace grpc_core {
49
48
 
50
49
  namespace {
51
50
 
52
- class NativeDnsResolver : public Resolver {
51
+ class NativeClientChannelDNSResolver : public Resolver {
53
52
  public:
54
- explicit NativeDnsResolver(ResolverArgs args);
53
+ explicit NativeClientChannelDNSResolver(ResolverArgs args);
55
54
 
56
55
  void StartLocked() override;
57
56
 
@@ -62,15 +61,17 @@ class NativeDnsResolver : public Resolver {
62
61
  void ShutdownLocked() override;
63
62
 
64
63
  private:
65
- ~NativeDnsResolver() override;
64
+ ~NativeClientChannelDNSResolver() override;
66
65
 
67
66
  void MaybeStartResolvingLocked();
68
67
  void StartResolvingLocked();
69
68
 
70
69
  static void OnNextResolution(void* arg, grpc_error_handle error);
71
70
  void OnNextResolutionLocked(grpc_error_handle error);
72
- static void OnResolved(void* arg, grpc_error_handle error);
73
- void OnResolvedLocked(grpc_error_handle error);
71
+ void OnResolved(
72
+ absl::StatusOr<std::vector<grpc_resolved_address>> addresses_or);
73
+ void OnResolvedLocked(
74
+ absl::StatusOr<std::vector<grpc_resolved_address>> addresses_or);
74
75
 
75
76
  /// name to resolve
76
77
  std::string name_to_resolve_;
@@ -84,7 +85,6 @@ class NativeDnsResolver : public Resolver {
84
85
  bool shutdown_ = false;
85
86
  /// are we currently resolving?
86
87
  bool resolving_ = false;
87
- grpc_closure on_resolved_;
88
88
  /// next resolution timer
89
89
  bool have_next_resolution_timer_ = false;
90
90
  grpc_timer next_resolution_timer_;
@@ -95,11 +95,12 @@ class NativeDnsResolver : public Resolver {
95
95
  grpc_millis last_resolution_timestamp_ = -1;
96
96
  /// retry backoff state
97
97
  BackOff backoff_;
98
- /// currently resolving addresses
99
- grpc_resolved_addresses* addresses_ = nullptr;
98
+ /// tracks pending resolutions
99
+ OrphanablePtr<DNSResolver::Request> dns_request_;
100
100
  };
101
101
 
102
- NativeDnsResolver::NativeDnsResolver(ResolverArgs args)
102
+ NativeClientChannelDNSResolver::NativeClientChannelDNSResolver(
103
+ ResolverArgs args)
103
104
  : name_to_resolve_(absl::StripPrefix(args.uri.path(), "/")),
104
105
  channel_args_(grpc_channel_args_copy(args.args)),
105
106
  work_serializer_(std::move(args.work_serializer)),
@@ -120,41 +121,47 @@ NativeDnsResolver::NativeDnsResolver(ResolverArgs args)
120
121
  }
121
122
  }
122
123
 
123
- NativeDnsResolver::~NativeDnsResolver() {
124
+ NativeClientChannelDNSResolver::~NativeClientChannelDNSResolver() {
124
125
  grpc_channel_args_destroy(channel_args_);
125
126
  grpc_pollset_set_destroy(interested_parties_);
126
127
  }
127
128
 
128
- void NativeDnsResolver::StartLocked() { MaybeStartResolvingLocked(); }
129
+ void NativeClientChannelDNSResolver::StartLocked() {
130
+ MaybeStartResolvingLocked();
131
+ }
129
132
 
130
- void NativeDnsResolver::RequestReresolutionLocked() {
133
+ void NativeClientChannelDNSResolver::RequestReresolutionLocked() {
131
134
  if (!resolving_) {
132
135
  MaybeStartResolvingLocked();
133
136
  }
134
137
  }
135
138
 
136
- void NativeDnsResolver::ResetBackoffLocked() {
139
+ void NativeClientChannelDNSResolver::ResetBackoffLocked() {
137
140
  if (have_next_resolution_timer_) {
138
141
  grpc_timer_cancel(&next_resolution_timer_);
139
142
  }
140
143
  backoff_.Reset();
141
144
  }
142
145
 
143
- void NativeDnsResolver::ShutdownLocked() {
146
+ void NativeClientChannelDNSResolver::ShutdownLocked() {
144
147
  shutdown_ = true;
145
148
  if (have_next_resolution_timer_) {
146
149
  grpc_timer_cancel(&next_resolution_timer_);
147
150
  }
151
+ dns_request_.reset();
148
152
  }
149
153
 
150
- void NativeDnsResolver::OnNextResolution(void* arg, grpc_error_handle error) {
151
- NativeDnsResolver* r = static_cast<NativeDnsResolver*>(arg);
154
+ void NativeClientChannelDNSResolver::OnNextResolution(void* arg,
155
+ grpc_error_handle error) {
156
+ NativeClientChannelDNSResolver* r =
157
+ static_cast<NativeClientChannelDNSResolver*>(arg);
152
158
  (void)GRPC_ERROR_REF(error); // ref owned by lambda
153
159
  r->work_serializer_->Run([r, error]() { r->OnNextResolutionLocked(error); },
154
160
  DEBUG_LOCATION);
155
161
  }
156
162
 
157
- void NativeDnsResolver::OnNextResolutionLocked(grpc_error_handle error) {
163
+ void NativeClientChannelDNSResolver::OnNextResolutionLocked(
164
+ grpc_error_handle error) {
158
165
  have_next_resolution_timer_ = false;
159
166
  if (error == GRPC_ERROR_NONE && !resolving_) {
160
167
  StartResolvingLocked();
@@ -163,44 +170,46 @@ void NativeDnsResolver::OnNextResolutionLocked(grpc_error_handle error) {
163
170
  GRPC_ERROR_UNREF(error);
164
171
  }
165
172
 
166
- void NativeDnsResolver::OnResolved(void* arg, grpc_error_handle error) {
167
- NativeDnsResolver* r = static_cast<NativeDnsResolver*>(arg);
168
- (void)GRPC_ERROR_REF(error); // owned by lambda
169
- r->work_serializer_->Run([r, error]() { r->OnResolvedLocked(error); },
170
- DEBUG_LOCATION);
173
+ void NativeClientChannelDNSResolver::OnResolved(
174
+ absl::StatusOr<std::vector<grpc_resolved_address>> addresses_or) {
175
+ work_serializer_->Run(
176
+ [this, addresses_or]() mutable {
177
+ OnResolvedLocked(std::move(addresses_or));
178
+ },
179
+ DEBUG_LOCATION);
171
180
  }
172
181
 
173
- void NativeDnsResolver::OnResolvedLocked(grpc_error_handle error) {
182
+ void NativeClientChannelDNSResolver::OnResolvedLocked(
183
+ absl::StatusOr<std::vector<grpc_resolved_address>> addresses_or) {
174
184
  GPR_ASSERT(resolving_);
175
185
  resolving_ = false;
186
+ dns_request_.reset();
176
187
  if (shutdown_) {
177
188
  Unref(DEBUG_LOCATION, "dns-resolving");
178
- GRPC_ERROR_UNREF(error);
179
189
  return;
180
190
  }
181
- if (addresses_ != nullptr) {
182
- Result result;
183
- for (size_t i = 0; i < addresses_->naddrs; ++i) {
184
- result.addresses.emplace_back(&addresses_->addrs[i].addr,
185
- addresses_->addrs[i].len,
186
- nullptr /* args */);
191
+ if (addresses_or.ok()) {
192
+ ServerAddressList addresses;
193
+ for (auto& addr : *addresses_or) {
194
+ addresses.emplace_back(addr, nullptr /* args */);
187
195
  }
188
- grpc_resolved_addresses_destroy(addresses_);
196
+ Result result;
197
+ result.addresses = std::move(addresses);
189
198
  result.args = grpc_channel_args_copy(channel_args_);
190
- result_handler_->ReturnResult(std::move(result));
199
+ result_handler_->ReportResult(std::move(result));
191
200
  // Reset backoff state so that we start from the beginning when the
192
201
  // next request gets triggered.
193
202
  backoff_.Reset();
194
203
  } else {
204
+ std::string error_message = addresses_or.status().ToString();
195
205
  gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
196
- grpc_error_std_string(error).c_str());
206
+ error_message.c_str());
197
207
  // Return transient error.
198
- std::string error_message =
199
- absl::StrCat("DNS resolution failed for service: ", name_to_resolve_);
200
- result_handler_->ReturnError(grpc_error_set_int(
201
- GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(error_message.c_str(),
202
- &error, 1),
203
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
208
+ Result result;
209
+ result.addresses = absl::UnavailableError(absl::StrCat(
210
+ "DNS resolution failed for ", name_to_resolve_, ": ", error_message));
211
+ result.args = grpc_channel_args_copy(channel_args_);
212
+ result_handler_->ReportResult(std::move(result));
204
213
  // Set up for retry.
205
214
  // InvalidateNow to avoid getting stuck re-initializing this timer
206
215
  // in a loop while draining the currently-held WorkSerializer.
@@ -219,15 +228,15 @@ void NativeDnsResolver::OnResolvedLocked(grpc_error_handle error) {
219
228
  } else {
220
229
  gpr_log(GPR_DEBUG, "retrying immediately");
221
230
  }
222
- GRPC_CLOSURE_INIT(&on_next_resolution_, NativeDnsResolver::OnNextResolution,
223
- this, grpc_schedule_on_exec_ctx);
231
+ GRPC_CLOSURE_INIT(&on_next_resolution_,
232
+ NativeClientChannelDNSResolver::OnNextResolution, this,
233
+ grpc_schedule_on_exec_ctx);
224
234
  grpc_timer_init(&next_resolution_timer_, next_try, &on_next_resolution_);
225
235
  }
226
236
  Unref(DEBUG_LOCATION, "dns-resolving");
227
- GRPC_ERROR_UNREF(error);
228
237
  }
229
238
 
230
- void NativeDnsResolver::MaybeStartResolvingLocked() {
239
+ void NativeClientChannelDNSResolver::MaybeStartResolvingLocked() {
231
240
  // If there is an existing timer, the time it fires is the earliest time we
232
241
  // can start the next resolution.
233
242
  if (have_next_resolution_timer_) return;
@@ -253,7 +262,7 @@ void NativeDnsResolver::MaybeStartResolvingLocked() {
253
262
  // callback as part of the type system.
254
263
  Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown").release();
255
264
  GRPC_CLOSURE_INIT(&on_next_resolution_,
256
- NativeDnsResolver::OnNextResolution, this,
265
+ NativeClientChannelDNSResolver::OnNextResolution, this,
257
266
  grpc_schedule_on_exec_ctx);
258
267
  grpc_timer_init(&next_resolution_timer_,
259
268
  ExecCtx::Get()->Now() + ms_until_next_resolution,
@@ -264,7 +273,7 @@ void NativeDnsResolver::MaybeStartResolvingLocked() {
264
273
  StartResolvingLocked();
265
274
  }
266
275
 
267
- void NativeDnsResolver::StartResolvingLocked() {
276
+ void NativeClientChannelDNSResolver::StartResolvingLocked() {
268
277
  gpr_log(GPR_DEBUG, "Start resolving.");
269
278
  // TODO(roth): We currently deal with this ref manually. Once the
270
279
  // new closure API is done, find a way to track this ref with the timer
@@ -272,11 +281,10 @@ void NativeDnsResolver::StartResolvingLocked() {
272
281
  Ref(DEBUG_LOCATION, "dns-resolving").release();
273
282
  GPR_ASSERT(!resolving_);
274
283
  resolving_ = true;
275
- addresses_ = nullptr;
276
- GRPC_CLOSURE_INIT(&on_resolved_, NativeDnsResolver::OnResolved, this,
277
- grpc_schedule_on_exec_ctx);
278
- grpc_resolve_address(name_to_resolve_.c_str(), kDefaultSecurePort,
279
- interested_parties_, &on_resolved_, &addresses_);
284
+ dns_request_ = GetDNSResolver()->ResolveName(
285
+ name_to_resolve_, kDefaultSecurePort, interested_parties_,
286
+ absl::bind_front(&NativeClientChannelDNSResolver::OnResolved, this));
287
+ dns_request_->Start();
280
288
  last_resolution_timestamp_ = ExecCtx::Get()->Now();
281
289
  }
282
290
 
@@ -284,7 +292,7 @@ void NativeDnsResolver::StartResolvingLocked() {
284
292
  // Factory
285
293
  //
286
294
 
287
- class NativeDnsResolverFactory : public ResolverFactory {
295
+ class NativeClientChannelDNSResolverFactory : public ResolverFactory {
288
296
  public:
289
297
  bool IsValidUri(const URI& uri) const override {
290
298
  if (GPR_UNLIKELY(!uri.authority().empty())) {
@@ -300,7 +308,7 @@ class NativeDnsResolverFactory : public ResolverFactory {
300
308
 
301
309
  OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
302
310
  if (!IsValidUri(args.uri)) return nullptr;
303
- return MakeOrphanable<NativeDnsResolver>(std::move(args));
311
+ return MakeOrphanable<NativeClientChannelDNSResolver>(std::move(args));
304
312
  }
305
313
 
306
314
  const char* scheme() const override { return "dns"; }
@@ -316,7 +324,7 @@ void grpc_resolver_dns_native_init() {
316
324
  if (gpr_stricmp(resolver.get(), "native") == 0) {
317
325
  gpr_log(GPR_DEBUG, "Using native dns resolver");
318
326
  grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
319
- absl::make_unique<grpc_core::NativeDnsResolverFactory>());
327
+ absl::make_unique<grpc_core::NativeClientChannelDNSResolverFactory>());
320
328
  } else {
321
329
  grpc_core::ResolverRegistry::Builder::InitRegistry();
322
330
  grpc_core::ResolverFactory* existing_factory =
@@ -324,7 +332,8 @@ void grpc_resolver_dns_native_init() {
324
332
  if (existing_factory == nullptr) {
325
333
  gpr_log(GPR_DEBUG, "Using native dns resolver");
326
334
  grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
327
- absl::make_unique<grpc_core::NativeDnsResolverFactory>());
335
+ absl::make_unique<
336
+ grpc_core::NativeClientChannelDNSResolverFactory>());
328
337
  }
329
338
  }
330
339
  }
@@ -30,8 +30,6 @@
30
30
  #include <grpc/support/alloc.h>
31
31
  #include <grpc/support/string_util.h>
32
32
 
33
- #include "src/core/ext/filters/client_channel/resolver_registry.h"
34
- #include "src/core/ext/filters/client_channel/server_address.h"
35
33
  #include "src/core/lib/address_utils/parse_address.h"
36
34
  #include "src/core/lib/channel/channel_args.h"
37
35
  #include "src/core/lib/gpr/string.h"
@@ -40,6 +38,8 @@
40
38
  #include "src/core/lib/iomgr/resolve_address.h"
41
39
  #include "src/core/lib/iomgr/unix_sockets_posix.h"
42
40
  #include "src/core/lib/iomgr/work_serializer.h"
41
+ #include "src/core/lib/resolver/resolver_registry.h"
42
+ #include "src/core/lib/resolver/server_address.h"
43
43
  #include "src/core/lib/slice/slice_internal.h"
44
44
  #include "src/core/lib/slice/slice_string_helpers.h"
45
45
 
@@ -142,23 +142,23 @@ void FakeResolver::MaybeSendResultLocked() {
142
142
  if (!started_ || shutdown_) return;
143
143
  if (return_failure_) {
144
144
  // TODO(roth): Change resolver result generator to be able to inject
145
- // the error to be returned.
146
- result_handler_->ReturnError(grpc_error_set_int(
147
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver transient failure"),
148
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
145
+ // the error to be returned and to be able to independently set errors
146
+ // for addresses and service config.
147
+ Result result;
148
+ result.addresses = absl::UnavailableError("Resolver transient failure");
149
+ result.service_config = result.addresses.status();
150
+ result.args = grpc_channel_args_copy(channel_args_);
151
+ result_handler_->ReportResult(std::move(result));
149
152
  return_failure_ = false;
150
153
  } else if (has_next_result_) {
151
154
  Result result;
152
155
  result.addresses = std::move(next_result_.addresses);
153
156
  result.service_config = std::move(next_result_.service_config);
154
- // TODO(roth): Use std::move() once grpc_error is converted to C++.
155
- result.service_config_error = next_result_.service_config_error;
156
- next_result_.service_config_error = GRPC_ERROR_NONE;
157
157
  // When both next_results_ and channel_args_ contain an arg with the same
158
158
  // name, only the one in next_results_ will be kept since next_results_ is
159
159
  // before channel_args_.
160
160
  result.args = grpc_channel_args_union(next_result_.args, channel_args_);
161
- result_handler_->ReturnResult(std::move(result));
161
+ result_handler_->ReportResult(std::move(result));
162
162
  has_next_result_ = false;
163
163
  }
164
164
  }
@@ -19,10 +19,11 @@
19
19
 
20
20
  #include <grpc/support/port_platform.h>
21
21
 
22
- #include "src/core/ext/filters/client_channel/resolver.h"
23
22
  #include "src/core/lib/channel/channel_args.h"
24
23
  #include "src/core/lib/gprpp/ref_counted.h"
24
+ #include "src/core/lib/gprpp/sync.h"
25
25
  #include "src/core/lib/iomgr/error.h"
26
+ #include "src/core/lib/resolver/resolver.h"
26
27
 
27
28
  #define GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR \
28
29
  "grpc.fake_resolver.response_generator"
@@ -18,12 +18,12 @@
18
18
 
19
19
  #include <random>
20
20
 
21
- #include "src/core/ext/filters/client_channel/resolver_registry.h"
22
21
  #include "src/core/ext/xds/xds_client.h"
23
22
  #include "src/core/lib/gpr/env.h"
24
23
  #include "src/core/lib/gpr/string.h"
25
24
  #include "src/core/lib/http/httpcli.h"
26
25
  #include "src/core/lib/iomgr/polling_entity.h"
26
+ #include "src/core/lib/resolver/resolver_registry.h"
27
27
  #include "src/core/lib/security/credentials/alts/check_gcp_environment.h"
28
28
 
29
29
  namespace grpc_core {
@@ -61,7 +61,6 @@ class GoogleCloud2ProdResolver : public Resolver {
61
61
  grpc_error_handle error) = 0;
62
62
 
63
63
  RefCountedPtr<GoogleCloud2ProdResolver> resolver_;
64
- grpc_httpcli_context context_;
65
64
  grpc_httpcli_response response_;
66
65
  grpc_closure on_done_;
67
66
  std::atomic<bool> on_done_called_{false};
@@ -115,7 +114,6 @@ GoogleCloud2ProdResolver::MetadataQuery::MetadataQuery(
115
114
  RefCountedPtr<GoogleCloud2ProdResolver> resolver, const char* path,
116
115
  grpc_polling_entity* pollent)
117
116
  : resolver_(std::move(resolver)) {
118
- grpc_httpcli_context_init(&context_);
119
117
  // Start HTTP request.
120
118
  GRPC_CLOSURE_INIT(&on_done_, OnHttpRequestDone, this, nullptr);
121
119
  Ref().release(); // Ref held by callback.
@@ -128,13 +126,12 @@ GoogleCloud2ProdResolver::MetadataQuery::MetadataQuery(
128
126
  request.http.hdr_count = 1;
129
127
  request.http.hdrs = &header;
130
128
  // TODO(ctiller): share the quota from whomever instantiates this!
131
- grpc_httpcli_get(&context_, pollent, ResourceQuota::Default(), &request,
129
+ grpc_httpcli_get(pollent, ResourceQuota::Default(), &request,
132
130
  ExecCtx::Get()->Now() + 10000, // 10s timeout
133
131
  &on_done_, &response_);
134
132
  }
135
133
 
136
134
  GoogleCloud2ProdResolver::MetadataQuery::~MetadataQuery() {
137
- grpc_httpcli_context_destroy(&context_);
138
135
  grpc_http_response_destroy(&response_);
139
136
  }
140
137
 
@@ -28,13 +28,13 @@
28
28
  #include <grpc/support/alloc.h>
29
29
  #include <grpc/support/string_util.h>
30
30
 
31
- #include "src/core/ext/filters/client_channel/resolver_registry.h"
32
- #include "src/core/ext/filters/client_channel/server_address.h"
33
31
  #include "src/core/lib/address_utils/parse_address.h"
34
32
  #include "src/core/lib/channel/channel_args.h"
35
33
  #include "src/core/lib/gpr/string.h"
36
34
  #include "src/core/lib/iomgr/resolve_address.h"
37
35
  #include "src/core/lib/iomgr/unix_sockets_posix.h"
36
+ #include "src/core/lib/resolver/resolver_registry.h"
37
+ #include "src/core/lib/resolver/server_address.h"
38
38
  #include "src/core/lib/slice/slice_internal.h"
39
39
  #include "src/core/lib/slice/slice_string_helpers.h"
40
40
 
@@ -73,7 +73,7 @@ void SockaddrResolver::StartLocked() {
73
73
  // TODO(roth): Use std::move() once channel args is converted to C++.
74
74
  result.args = channel_args_;
75
75
  channel_args_ = nullptr;
76
- result_handler_->ReturnResult(std::move(result));
76
+ result_handler_->ReportResult(std::move(result));
77
77
  }
78
78
 
79
79
  //
@@ -91,9 +91,9 @@ bool ParseUri(const URI& uri,
91
91
  // Construct addresses.
92
92
  bool errors_found = false;
93
93
  for (absl::string_view ith_path : absl::StrSplit(uri.path(), ',')) {
94
- URI ith_uri(uri.scheme(), "", std::string(ith_path), {}, "");
94
+ auto ith_uri = URI::Create(uri.scheme(), "", std::string(ith_path), {}, "");
95
95
  grpc_resolved_address addr;
96
- if (!parse(ith_uri, &addr)) {
96
+ if (!ith_uri.ok() || !parse(*ith_uri, &addr)) {
97
97
  errors_found = true;
98
98
  break;
99
99
  }