grpc 1.57.0 → 1.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +534 -284
- data/include/grpc/event_engine/event_engine.h +0 -1
- data/include/grpc/event_engine/memory_allocator.h +2 -2
- data/include/grpc/impl/channel_arg_names.h +371 -0
- data/include/grpc/impl/grpc_types.h +1 -353
- data/include/grpc/module.modulemap +1 -0
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -1
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +2 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +7 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +10 -5
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +1 -0
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +5 -3
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +4 -2
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +115 -109
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.h +0 -5
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +7 -2
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +1 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +11 -3
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +6 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +8 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +102 -11
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +9 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +4 -1
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_plugin.cc +6 -0
- data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +41 -14
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +3 -2
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/retry_filter.h +1 -0
- data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
- data/src/core/ext/filters/client_channel/subchannel.cc +9 -5
- data/src/core/ext/filters/client_channel/subchannel.h +8 -2
- data/src/core/ext/filters/deadline/deadline_filter.cc +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -0
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +1 -0
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -1
- data/src/core/ext/filters/message_size/message_size_filter.cc +1 -0
- data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +4 -7
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +8 -12
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +357 -358
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -18
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +63 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +7 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +30 -57
- data/src/core/ext/transport/chttp2/transport/parsing.cc +16 -7
- data/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc +80 -0
- data/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h +55 -0
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +98 -0
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +73 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +81 -89
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -0
- data/src/core/ext/xds/xds_client_grpc.cc +1 -0
- data/src/core/ext/xds/xds_http_fault_filter.cc +1 -2
- data/src/core/ext/xds/xds_http_fault_filter.h +1 -2
- data/src/core/ext/xds/xds_http_filters.h +2 -4
- data/src/core/ext/xds/xds_http_rbac_filter.cc +3 -8
- data/src/core/ext/xds/xds_http_rbac_filter.h +1 -2
- data/src/core/ext/xds/xds_http_stateful_session_filter.cc +1 -2
- data/src/core/ext/xds/xds_http_stateful_session_filter.h +1 -2
- data/src/core/ext/xds/xds_lb_policy_registry.cc +3 -6
- data/src/core/ext/xds/xds_routing.cc +2 -2
- data/src/core/ext/xds/xds_transport_grpc.cc +1 -0
- data/src/core/lib/avl/avl.h +10 -173
- data/src/core/lib/channel/call_tracer.cc +289 -0
- data/src/core/lib/channel/call_tracer.h +35 -0
- data/src/core/lib/channel/channel_args.cc +84 -79
- data/src/core/lib/channel/channel_args.h +29 -17
- data/src/core/lib/channel/connected_channel.cc +0 -1
- data/src/core/lib/channel/promise_based_filter.cc +4 -1
- data/src/core/lib/compression/compression_internal.cc +8 -4
- data/src/core/lib/debug/stats_data.cc +93 -21
- data/src/core/lib/debug/stats_data.h +41 -0
- data/src/core/lib/event_engine/ares_resolver.cc +712 -0
- data/src/core/lib/event_engine/ares_resolver.h +150 -0
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -3
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +2 -2
- data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +229 -0
- data/src/core/lib/event_engine/cf_engine/dns_service_resolver.h +117 -0
- data/src/core/lib/event_engine/forkable.cc +15 -1
- data/src/core/lib/event_engine/forkable.h +15 -0
- data/src/core/lib/event_engine/grpc_polled_fd.h +73 -0
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +25 -3
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +10 -1
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +197 -0
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +3 -3
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +47 -1
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +12 -1
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +1 -0
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +2 -0
- data/src/core/lib/event_engine/thread_pool/thread_count.cc +58 -0
- data/src/core/lib/event_engine/thread_pool/thread_count.h +161 -0
- data/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +7 -0
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +86 -111
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +15 -61
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +3 -4
- data/src/core/lib/experiments/config.cc +14 -0
- data/src/core/lib/experiments/experiments.cc +141 -304
- data/src/core/lib/experiments/experiments.h +16 -17
- data/src/core/lib/gprpp/ref_counted.h +3 -1
- data/src/core/lib/gprpp/ref_counted_string.cc +44 -0
- data/src/core/lib/gprpp/ref_counted_string.h +146 -0
- data/src/core/lib/gprpp/time.h +2 -2
- data/src/core/lib/gprpp/work_serializer.cc +36 -0
- data/src/core/lib/gprpp/work_serializer.h +5 -0
- data/src/core/lib/http/httpcli_security_connector.cc +1 -0
- data/src/core/lib/iomgr/buffer_list.cc +2 -0
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +7 -22
- data/src/core/lib/iomgr/tcp_posix.cc +3 -3
- data/src/core/lib/promise/detail/basic_seq.h +1 -372
- data/src/core/lib/promise/detail/seq_state.h +2076 -0
- data/src/core/lib/promise/seq.h +19 -2
- data/src/core/lib/promise/sleep.h +5 -10
- data/src/core/lib/promise/try_seq.h +34 -2
- data/src/core/lib/resource_quota/api.cc +1 -0
- data/src/core/lib/resource_quota/arena.cc +2 -0
- data/src/core/lib/resource_quota/arena.h +42 -8
- data/src/core/lib/resource_quota/memory_quota.cc +0 -1
- data/src/core/lib/resource_quota/resource_quota.h +1 -0
- data/src/core/lib/security/authorization/authorization_policy_provider.h +1 -1
- data/src/core/lib/security/authorization/rbac_policy.h +1 -1
- data/src/core/lib/security/credentials/external/aws_request_signer.cc +8 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +17 -0
- data/src/core/lib/security/credentials/jwt/json_token.h +4 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +42 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -0
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +1 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +1 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +1 -0
- data/src/core/lib/security/security_connector/ssl_utils.cc +1 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +8 -5
- data/src/core/lib/security/transport/security_handshaker.cc +1 -0
- data/src/core/lib/security/transport/server_auth_filter.cc +2 -0
- data/src/core/lib/surface/call.cc +32 -8
- data/src/core/lib/surface/channel.cc +1 -0
- data/src/core/lib/surface/completion_queue.cc +10 -0
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/server.cc +67 -64
- data/src/core/lib/surface/server.h +1 -15
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/tsi/alts/crypt/aes_gcm.cc +27 -2
- data/src/core/tsi/ssl_transport_security.cc +11 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +9 -14
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/test/client.rb +16 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +3 -3
- data/third_party/abseil-cpp/absl/algorithm/container.h +3 -2
- data/third_party/abseil-cpp/absl/base/attributes.h +58 -5
- data/third_party/abseil-cpp/absl/base/call_once.h +1 -1
- data/third_party/abseil-cpp/absl/base/casts.h +8 -8
- data/third_party/abseil-cpp/absl/base/config.h +89 -106
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +26 -1
- data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +2 -2
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +50 -39
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +2 -1
- data/third_party/abseil-cpp/absl/base/internal/prefetch.h +17 -18
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +32 -3
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +24 -4
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +31 -73
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +9 -8
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +11 -11
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +23 -32
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +2 -3
- data/third_party/abseil-cpp/absl/base/options.h +1 -1
- data/third_party/abseil-cpp/absl/base/policy_checks.h +3 -3
- data/third_party/abseil-cpp/absl/base/prefetch.h +198 -0
- data/third_party/abseil-cpp/absl/container/fixed_array.h +54 -29
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +5 -1
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +6 -2
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +167 -79
- data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +3 -21
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +1 -1
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +46 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +2 -0
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +85 -26
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +35 -18
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +70 -29
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +437 -236
- data/third_party/abseil-cpp/absl/crc/crc32c.h +8 -1
- data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +14 -8
- data/third_party/abseil-cpp/absl/crc/internal/crc.cc +4 -35
- data/third_party/abseil-cpp/absl/crc/internal/crc.h +2 -10
- data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +1 -1
- data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.cc +1 -1
- data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.h +4 -4
- data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +8 -10
- data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_64.cc +17 -19
- data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +8 -8
- data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +2 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +59 -23
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +1 -1
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +1 -1
- data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +1 -1
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +43 -19
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +3 -0
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +1 -1
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc +1 -1
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +2 -2
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +16 -15
- data/third_party/abseil-cpp/absl/flags/internal/flag_msvc.inc +1 -1
- data/third_party/abseil-cpp/absl/flags/marshalling.cc +43 -2
- data/third_party/abseil-cpp/absl/flags/marshalling.h +5 -0
- data/third_party/abseil-cpp/absl/functional/any_invocable.h +9 -1
- data/third_party/abseil-cpp/absl/functional/bind_front.h +1 -1
- data/third_party/abseil-cpp/absl/functional/function_ref.h +3 -3
- data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +37 -24
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +19 -9
- data/third_party/abseil-cpp/absl/hash/hash.h +7 -4
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +38 -15
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +6 -0
- data/third_party/abseil-cpp/absl/meta/type_traits.h +48 -373
- data/third_party/abseil-cpp/absl/numeric/bits.h +4 -4
- data/third_party/abseil-cpp/absl/numeric/int128.cc +20 -8
- data/third_party/abseil-cpp/absl/numeric/int128.h +36 -39
- data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +0 -3
- data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +47 -30
- data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +4 -3
- data/third_party/abseil-cpp/absl/random/internal/generate_real.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/platform.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +4 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +1 -1
- data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +1 -1
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +4 -0
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +12 -24
- data/third_party/abseil-cpp/absl/status/status.cc +11 -7
- data/third_party/abseil-cpp/absl/status/status.h +11 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +22 -8
- data/third_party/abseil-cpp/absl/strings/ascii.cc +54 -6
- data/third_party/abseil-cpp/absl/strings/charconv.cc +21 -4
- data/third_party/abseil-cpp/absl/strings/charconv.h +2 -2
- data/third_party/abseil-cpp/absl/strings/cord.cc +1 -2
- data/third_party/abseil-cpp/absl/strings/cord.h +32 -5
- data/third_party/abseil-cpp/absl/strings/cord_analysis.cc +23 -1
- data/third_party/abseil-cpp/absl/strings/cord_analysis.h +18 -0
- data/third_party/abseil-cpp/absl/strings/cord_buffer.h +2 -5
- data/third_party/abseil-cpp/absl/strings/escaping.cc +10 -32
- data/third_party/abseil-cpp/absl/strings/escaping.h +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +2 -4
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +3 -3
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +0 -1
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +15 -13
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +13 -4
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.h +8 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.cc +5 -3
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.h +4 -7
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +8 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +2 -2
- data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc +46 -20
- data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.h +1 -34
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +2 -1
- data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +23 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.h +1 -0
- data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +2 -77
- data/third_party/abseil-cpp/absl/strings/internal/memutil.h +4 -112
- data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +10 -31
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +8 -8
- data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +5 -20
- data/third_party/abseil-cpp/absl/strings/internal/str_format/constexpr_parser.h +1 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +9 -9
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +56 -6
- data/third_party/abseil-cpp/absl/strings/match.cc +87 -0
- data/third_party/abseil-cpp/absl/strings/match.h +19 -0
- data/third_party/abseil-cpp/absl/strings/numbers.cc +154 -122
- data/third_party/abseil-cpp/absl/strings/numbers.h +1 -6
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +7 -50
- data/third_party/abseil-cpp/absl/strings/str_cat.h +83 -15
- data/third_party/abseil-cpp/absl/strings/str_format.h +6 -3
- data/third_party/abseil-cpp/absl/strings/str_split.cc +9 -6
- data/third_party/abseil-cpp/absl/strings/string_view.cc +26 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +5 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +63 -43
- data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc +111 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.h +63 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +11 -7
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc +225 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +122 -114
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +12 -8
- data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +10 -1
- data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc +167 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.h +60 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc +122 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.h +65 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc +91 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.h +56 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +19 -113
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc +42 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.h +90 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc +151 -0
- data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.h +70 -0
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +407 -411
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +152 -118
- data/third_party/abseil-cpp/absl/time/clock.cc +6 -7
- data/third_party/abseil-cpp/absl/time/duration.cc +24 -26
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +1 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +3 -3
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +8 -6
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +6 -3
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +4 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +4 -0
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +322 -295
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +8 -17
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +51 -33
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +7 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +128 -2
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +5 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +34 -34
- data/third_party/abseil-cpp/absl/time/time.cc +9 -2
- data/third_party/abseil-cpp/absl/time/time.h +115 -15
- data/third_party/abseil-cpp/absl/types/internal/optional.h +0 -52
- data/third_party/abseil-cpp/absl/types/internal/span.h +2 -2
- data/third_party/abseil-cpp/absl/types/internal/variant.h +2 -2
- data/third_party/abseil-cpp/absl/types/optional.h +15 -13
- data/third_party/abseil-cpp/absl/types/span.h +1 -2
- data/third_party/boringssl-with-bazel/err_data.c +15 -14
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +7 -3
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strex.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +7 -3
- data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/bio/errno.c +92 -0
- data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +4 -48
- data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +11 -6
- data/third_party/boringssl-with-bazel/src/crypto/bio/internal.h +16 -6
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +9 -0
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +3 -7
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_fuchsia.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_linux.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_sysreg.c +93 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_win.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_freebsd.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_linux.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/dh_asn1.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/params.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +9 -14
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +4 -6
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +10 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/check.c +37 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +38 -19
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +39 -16
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/service_indicator.c +4 -7
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +13 -21
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +6 -23
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/getentropy.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +1 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +0 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +2 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +9 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +11 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +4 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +7 -9
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +6 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/span.h +22 -20
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +20 -12
- data/third_party/boringssl-with-bazel/src/include/openssl/target.h +50 -3
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -4
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/ssl_file.cc +4 -4
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +2 -0
- metadata +39 -31
- data/src/core/lib/promise/detail/basic_join.h +0 -197
- data/src/core/lib/promise/detail/switch.h +0 -1455
- data/src/core/lib/promise/try_join.h +0 -82
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +0 -403
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_freebsd.c +0 -62
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm.c +0 -38
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +0 -31
- data/third_party/re2/util/benchmark.h +0 -156
- data/third_party/re2/util/flags.h +0 -26
- data/third_party/re2/util/malloc_counter.h +0 -19
- data/third_party/re2/util/pcre.cc +0 -1025
- data/third_party/re2/util/pcre.h +0 -681
- data/third_party/re2/util/test.h +0 -50
- data/third_party/upb/upb/mini_table.h +0 -36
- data/third_party/zlib/gzclose.c +0 -25
- data/third_party/zlib/gzlib.c +0 -639
- data/third_party/zlib/gzread.c +0 -650
- data/third_party/zlib/gzwrite.c +0 -677
@@ -0,0 +1,712 @@
|
|
1
|
+
// Copyright 2023 The gRPC Authors
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
#include <grpc/support/port_platform.h>
|
15
|
+
|
16
|
+
#include "src/core/lib/event_engine/ares_resolver.h"
|
17
|
+
|
18
|
+
#include <stdint.h>
|
19
|
+
|
20
|
+
#include <string>
|
21
|
+
#include <vector>
|
22
|
+
|
23
|
+
#include "src/core/lib/iomgr/port.h"
|
24
|
+
|
25
|
+
// IWYU pragma: no_include <arpa/inet.h>
|
26
|
+
// IWYU pragma: no_include <arpa/nameser.h>
|
27
|
+
// IWYU pragma: no_include <inttypes.h>
|
28
|
+
// IWYU pragma: no_include <netdb.h>
|
29
|
+
// IWYU pragma: no_include <netinet/in.h>
|
30
|
+
// IWYU pragma: no_include <stdlib.h>
|
31
|
+
// IWYU pragma: no_include <sys/socket.h>
|
32
|
+
// IWYU pragma: no_include <ratio>
|
33
|
+
|
34
|
+
#if GRPC_ARES == 1
|
35
|
+
|
36
|
+
#include <ares_nameser.h>
|
37
|
+
#include <string.h>
|
38
|
+
|
39
|
+
#include <algorithm>
|
40
|
+
#include <chrono>
|
41
|
+
#include <initializer_list>
|
42
|
+
#include <memory>
|
43
|
+
#include <type_traits>
|
44
|
+
#include <utility>
|
45
|
+
|
46
|
+
#include "absl/functional/any_invocable.h"
|
47
|
+
#include "absl/hash/hash.h"
|
48
|
+
#include "absl/strings/match.h"
|
49
|
+
#include "absl/strings/numbers.h"
|
50
|
+
#include "absl/strings/str_cat.h"
|
51
|
+
#include "absl/strings/str_format.h"
|
52
|
+
#include "absl/types/optional.h"
|
53
|
+
|
54
|
+
#include <grpc/event_engine/event_engine.h>
|
55
|
+
#include <grpc/support/log.h>
|
56
|
+
|
57
|
+
#include "src/core/lib/address_utils/parse_address.h"
|
58
|
+
#include "src/core/lib/address_utils/sockaddr_utils.h"
|
59
|
+
#include "src/core/lib/event_engine/grpc_polled_fd.h"
|
60
|
+
#include "src/core/lib/event_engine/time_util.h"
|
61
|
+
#include "src/core/lib/gprpp/debug_location.h"
|
62
|
+
#include "src/core/lib/gprpp/host_port.h"
|
63
|
+
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
64
|
+
#include "src/core/lib/iomgr/resolved_address.h"
|
65
|
+
#include "src/core/lib/iomgr/sockaddr.h"
|
66
|
+
#ifdef GRPC_POSIX_SOCKET_ARES_EV_DRIVER
|
67
|
+
#include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h"
|
68
|
+
#endif
|
69
|
+
|
70
|
+
namespace grpc_event_engine {
|
71
|
+
namespace experimental {
|
72
|
+
|
73
|
+
grpc_core::TraceFlag grpc_trace_ares_resolver(false, "cares_resolver");
|
74
|
+
|
75
|
+
namespace {
|
76
|
+
|
77
|
+
absl::Status AresStatusToAbslStatus(int status, absl::string_view error_msg) {
|
78
|
+
switch (status) {
|
79
|
+
case ARES_ECANCELLED:
|
80
|
+
return absl::CancelledError(error_msg);
|
81
|
+
case ARES_ENOTIMP:
|
82
|
+
return absl::UnimplementedError(error_msg);
|
83
|
+
case ARES_ENOTFOUND:
|
84
|
+
return absl::NotFoundError(error_msg);
|
85
|
+
default:
|
86
|
+
return absl::UnknownError(error_msg);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
// An alternative here could be to use ares_timeout to try to be more
|
91
|
+
// accurate, but that would require using "struct timeval"'s, which just
|
92
|
+
// makes things a bit more complicated. So just poll every second, as
|
93
|
+
// suggested by the c-ares code comments.
|
94
|
+
constexpr EventEngine::Duration kAresBackupPollAlarmDuration =
|
95
|
+
std::chrono::seconds(1);
|
96
|
+
|
97
|
+
bool IsIpv6LoopbackAvailable() {
|
98
|
+
#ifdef GRPC_POSIX_SOCKET_ARES_EV_DRIVER
|
99
|
+
return PosixSocketWrapper::IsIpv6LoopbackAvailable();
|
100
|
+
#elif defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER)
|
101
|
+
// TODO(yijiem): implement this for Windows
|
102
|
+
return true;
|
103
|
+
#else
|
104
|
+
#error "Unsupported platform"
|
105
|
+
#endif
|
106
|
+
}
|
107
|
+
|
108
|
+
absl::Status SetRequestDNSServer(absl::string_view dns_server,
|
109
|
+
ares_channel* channel) {
|
110
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("Using DNS server %s", dns_server.data());
|
111
|
+
grpc_resolved_address addr;
|
112
|
+
struct ares_addr_port_node dns_server_addr = {};
|
113
|
+
if (grpc_parse_ipv4_hostport(dns_server, &addr, /*log_errors=*/false)) {
|
114
|
+
dns_server_addr.family = AF_INET;
|
115
|
+
struct sockaddr_in* in = reinterpret_cast<struct sockaddr_in*>(addr.addr);
|
116
|
+
memcpy(&dns_server_addr.addr.addr4, &in->sin_addr, sizeof(struct in_addr));
|
117
|
+
dns_server_addr.tcp_port = grpc_sockaddr_get_port(&addr);
|
118
|
+
dns_server_addr.udp_port = grpc_sockaddr_get_port(&addr);
|
119
|
+
} else if (grpc_parse_ipv6_hostport(dns_server, &addr,
|
120
|
+
/*log_errors=*/false)) {
|
121
|
+
dns_server_addr.family = AF_INET6;
|
122
|
+
struct sockaddr_in6* in6 =
|
123
|
+
reinterpret_cast<struct sockaddr_in6*>(addr.addr);
|
124
|
+
memcpy(&dns_server_addr.addr.addr6, &in6->sin6_addr,
|
125
|
+
sizeof(struct in6_addr));
|
126
|
+
dns_server_addr.tcp_port = grpc_sockaddr_get_port(&addr);
|
127
|
+
dns_server_addr.udp_port = grpc_sockaddr_get_port(&addr);
|
128
|
+
} else {
|
129
|
+
return absl::InvalidArgumentError(
|
130
|
+
absl::StrCat("Cannot parse authority: ", dns_server));
|
131
|
+
}
|
132
|
+
int status = ares_set_servers_ports(*channel, &dns_server_addr);
|
133
|
+
if (status != ARES_SUCCESS) {
|
134
|
+
return AresStatusToAbslStatus(status, ares_strerror(status));
|
135
|
+
}
|
136
|
+
return absl::OkStatus();
|
137
|
+
}
|
138
|
+
|
139
|
+
struct QueryArg {
|
140
|
+
QueryArg(AresResolver* ar, int id, absl::string_view name)
|
141
|
+
: ares_resolver(ar), callback_map_id(id), query_name(name) {}
|
142
|
+
AresResolver* ares_resolver;
|
143
|
+
int callback_map_id;
|
144
|
+
std::string query_name;
|
145
|
+
};
|
146
|
+
|
147
|
+
struct HostnameQueryArg : public QueryArg {
|
148
|
+
HostnameQueryArg(AresResolver* ar, int id, absl::string_view name, int p)
|
149
|
+
: QueryArg(ar, id, name), port(p) {}
|
150
|
+
int port;
|
151
|
+
};
|
152
|
+
|
153
|
+
} // namespace
|
154
|
+
|
155
|
+
absl::StatusOr<grpc_core::OrphanablePtr<AresResolver>>
|
156
|
+
AresResolver::CreateAresResolver(
|
157
|
+
absl::string_view dns_server,
|
158
|
+
std::unique_ptr<GrpcPolledFdFactory> polled_fd_factory,
|
159
|
+
std::shared_ptr<EventEngine> event_engine) {
|
160
|
+
ares_options opts = {};
|
161
|
+
opts.flags |= ARES_FLAG_STAYOPEN;
|
162
|
+
if (g_event_engine_grpc_ares_test_only_force_tcp) {
|
163
|
+
opts.flags |= ARES_FLAG_USEVC;
|
164
|
+
}
|
165
|
+
ares_channel channel;
|
166
|
+
int status = ares_init_options(&channel, &opts, ARES_OPT_FLAGS);
|
167
|
+
if (status != ARES_SUCCESS) {
|
168
|
+
gpr_log(GPR_ERROR, "ares_init_options failed, status: %d", status);
|
169
|
+
return AresStatusToAbslStatus(
|
170
|
+
status,
|
171
|
+
absl::StrCat("Failed to init c-ares channel: ", ares_strerror(status)));
|
172
|
+
}
|
173
|
+
event_engine_grpc_ares_test_only_inject_config(&channel);
|
174
|
+
polled_fd_factory->ConfigureAresChannelLocked(channel);
|
175
|
+
if (!dns_server.empty()) {
|
176
|
+
absl::Status status = SetRequestDNSServer(dns_server, &channel);
|
177
|
+
if (!status.ok()) {
|
178
|
+
return status;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
return grpc_core::MakeOrphanable<AresResolver>(
|
182
|
+
std::move(polled_fd_factory), std::move(event_engine), channel);
|
183
|
+
}
|
184
|
+
|
185
|
+
AresResolver::~AresResolver() {
|
186
|
+
GPR_ASSERT(fd_node_list_.empty());
|
187
|
+
GPR_ASSERT(callback_map_.empty());
|
188
|
+
ares_destroy(channel_);
|
189
|
+
}
|
190
|
+
|
191
|
+
void AresResolver::Orphan() {
|
192
|
+
{
|
193
|
+
grpc_core::MutexLock lock(&mutex_);
|
194
|
+
shutting_down_ = true;
|
195
|
+
if (ares_backup_poll_alarm_handle_.has_value()) {
|
196
|
+
event_engine_->Cancel(*ares_backup_poll_alarm_handle_);
|
197
|
+
ares_backup_poll_alarm_handle_.reset();
|
198
|
+
}
|
199
|
+
for (const auto& fd_node : fd_node_list_) {
|
200
|
+
if (!fd_node->already_shutdown) {
|
201
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver: %p shutdown fd: %s", this,
|
202
|
+
fd_node->polled_fd->GetName());
|
203
|
+
fd_node->polled_fd->ShutdownLocked(
|
204
|
+
absl::CancelledError("AresResolver::Orphan"));
|
205
|
+
fd_node->already_shutdown = true;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
Unref(DEBUG_LOCATION, "Orphan");
|
210
|
+
}
|
211
|
+
|
212
|
+
void AresResolver::LookupHostname(
|
213
|
+
absl::string_view name, absl::string_view default_port,
|
214
|
+
EventEngine::DNSResolver::LookupHostnameCallback callback) {
|
215
|
+
absl::string_view host;
|
216
|
+
absl::string_view port_string;
|
217
|
+
if (!grpc_core::SplitHostPort(name, &host, &port_string)) {
|
218
|
+
event_engine_->Run(
|
219
|
+
[callback = std::move(callback),
|
220
|
+
status = absl::InvalidArgumentError(absl::StrCat(
|
221
|
+
"Unparseable name: ", name))]() mutable { callback(status); });
|
222
|
+
return;
|
223
|
+
}
|
224
|
+
GPR_ASSERT(!host.empty());
|
225
|
+
if (port_string.empty()) {
|
226
|
+
if (default_port.empty()) {
|
227
|
+
event_engine_->Run([callback = std::move(callback),
|
228
|
+
status = absl::InvalidArgumentError(absl::StrFormat(
|
229
|
+
"No port in name %s or default_port argument",
|
230
|
+
name))]() mutable { callback(status); });
|
231
|
+
return;
|
232
|
+
}
|
233
|
+
port_string = default_port;
|
234
|
+
}
|
235
|
+
int port = 0;
|
236
|
+
if (port_string == "http") {
|
237
|
+
port = 80;
|
238
|
+
} else if (port_string == "https") {
|
239
|
+
port = 443;
|
240
|
+
} else if (!absl::SimpleAtoi(port_string, &port)) {
|
241
|
+
event_engine_->Run([callback = std::move(callback),
|
242
|
+
status = absl::InvalidArgumentError(absl::StrCat(
|
243
|
+
"Failed to parse port in name: ",
|
244
|
+
name))]() mutable { callback(status); });
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
// TODO(yijiem): Change this when refactoring code in
|
248
|
+
// src/core/lib/address_utils to use EventEngine::ResolvedAddress.
|
249
|
+
grpc_resolved_address addr;
|
250
|
+
const std::string hostport = grpc_core::JoinHostPort(host, port);
|
251
|
+
if (grpc_parse_ipv4_hostport(hostport.c_str(), &addr,
|
252
|
+
false /* log errors */) ||
|
253
|
+
grpc_parse_ipv6_hostport(hostport.c_str(), &addr,
|
254
|
+
false /* log errors */)) {
|
255
|
+
// Early out if the target is an ipv4 or ipv6 literal.
|
256
|
+
std::vector<EventEngine::ResolvedAddress> result;
|
257
|
+
result.emplace_back(reinterpret_cast<sockaddr*>(addr.addr), addr.len);
|
258
|
+
event_engine_->Run(
|
259
|
+
[callback = std::move(callback), result = std::move(result)]() mutable {
|
260
|
+
callback(std::move(result));
|
261
|
+
});
|
262
|
+
return;
|
263
|
+
}
|
264
|
+
grpc_core::MutexLock lock(&mutex_);
|
265
|
+
callback_map_.emplace(++id_, std::move(callback));
|
266
|
+
auto* resolver_arg = new HostnameQueryArg(this, id_, name, port);
|
267
|
+
if (IsIpv6LoopbackAvailable()) {
|
268
|
+
ares_gethostbyname(channel_, std::string(host).c_str(), AF_UNSPEC,
|
269
|
+
&AresResolver::OnHostbynameDoneLocked, resolver_arg);
|
270
|
+
} else {
|
271
|
+
ares_gethostbyname(channel_, std::string(host).c_str(), AF_INET,
|
272
|
+
&AresResolver::OnHostbynameDoneLocked, resolver_arg);
|
273
|
+
}
|
274
|
+
CheckSocketsLocked();
|
275
|
+
MaybeStartTimerLocked();
|
276
|
+
}
|
277
|
+
|
278
|
+
void AresResolver::LookupSRV(
|
279
|
+
absl::string_view name,
|
280
|
+
EventEngine::DNSResolver::LookupSRVCallback callback) {
|
281
|
+
absl::string_view host;
|
282
|
+
absl::string_view port;
|
283
|
+
if (!grpc_core::SplitHostPort(name, &host, &port)) {
|
284
|
+
event_engine_->Run(
|
285
|
+
[callback = std::move(callback),
|
286
|
+
status = absl::InvalidArgumentError(absl::StrCat(
|
287
|
+
"Unparseable name: ", name))]() mutable { callback(status); });
|
288
|
+
return;
|
289
|
+
}
|
290
|
+
GPR_ASSERT(!host.empty());
|
291
|
+
// Don't query for SRV records if the target is "localhost"
|
292
|
+
if (absl::EqualsIgnoreCase(host, "localhost")) {
|
293
|
+
event_engine_->Run([callback = std::move(callback)]() mutable {
|
294
|
+
callback(std::vector<EventEngine::DNSResolver::SRVRecord>());
|
295
|
+
});
|
296
|
+
return;
|
297
|
+
}
|
298
|
+
grpc_core::MutexLock lock(&mutex_);
|
299
|
+
callback_map_.emplace(++id_, std::move(callback));
|
300
|
+
auto* resolver_arg = new QueryArg(this, id_, host);
|
301
|
+
ares_query(channel_, std::string(host).c_str(), ns_c_in, ns_t_srv,
|
302
|
+
&AresResolver::OnSRVQueryDoneLocked, resolver_arg);
|
303
|
+
CheckSocketsLocked();
|
304
|
+
MaybeStartTimerLocked();
|
305
|
+
}
|
306
|
+
|
307
|
+
void AresResolver::LookupTXT(
|
308
|
+
absl::string_view name,
|
309
|
+
EventEngine::DNSResolver::LookupTXTCallback callback) {
|
310
|
+
absl::string_view host;
|
311
|
+
absl::string_view port;
|
312
|
+
if (!grpc_core::SplitHostPort(name, &host, &port)) {
|
313
|
+
event_engine_->Run(
|
314
|
+
[callback = std::move(callback),
|
315
|
+
status = absl::InvalidArgumentError(absl::StrCat(
|
316
|
+
"Unparseable name: ", name))]() mutable { callback(status); });
|
317
|
+
return;
|
318
|
+
}
|
319
|
+
GPR_ASSERT(!host.empty());
|
320
|
+
// Don't query for TXT records if the target is "localhost"
|
321
|
+
if (absl::EqualsIgnoreCase(host, "localhost")) {
|
322
|
+
event_engine_->Run([callback = std::move(callback)]() mutable {
|
323
|
+
callback(std::vector<std::string>());
|
324
|
+
});
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
grpc_core::MutexLock lock(&mutex_);
|
328
|
+
callback_map_.emplace(++id_, std::move(callback));
|
329
|
+
auto* resolver_arg = new QueryArg(this, id_, host);
|
330
|
+
ares_search(channel_, std::string(host).c_str(), ns_c_in, ns_t_txt,
|
331
|
+
&AresResolver::OnTXTDoneLocked, resolver_arg);
|
332
|
+
CheckSocketsLocked();
|
333
|
+
MaybeStartTimerLocked();
|
334
|
+
}
|
335
|
+
|
336
|
+
AresResolver::AresResolver(
|
337
|
+
std::unique_ptr<GrpcPolledFdFactory> polled_fd_factory,
|
338
|
+
std::shared_ptr<EventEngine> event_engine, ares_channel channel)
|
339
|
+
: grpc_core::InternallyRefCounted<AresResolver>(
|
340
|
+
GRPC_TRACE_FLAG_ENABLED(grpc_trace_ares_resolver) ? "AresResolver"
|
341
|
+
: nullptr),
|
342
|
+
channel_(channel),
|
343
|
+
polled_fd_factory_(std::move(polled_fd_factory)),
|
344
|
+
event_engine_(std::move(event_engine)) {}
|
345
|
+
|
346
|
+
void AresResolver::CheckSocketsLocked() {
|
347
|
+
FdNodeList new_list;
|
348
|
+
if (!shutting_down_) {
|
349
|
+
ares_socket_t socks[ARES_GETSOCK_MAXNUM];
|
350
|
+
int socks_bitmask = ares_getsock(channel_, socks, ARES_GETSOCK_MAXNUM);
|
351
|
+
for (size_t i = 0; i < ARES_GETSOCK_MAXNUM; i++) {
|
352
|
+
if (ARES_GETSOCK_READABLE(socks_bitmask, i) ||
|
353
|
+
ARES_GETSOCK_WRITABLE(socks_bitmask, i)) {
|
354
|
+
auto iter = std::find_if(
|
355
|
+
fd_node_list_.begin(), fd_node_list_.end(),
|
356
|
+
[sock = socks[i]](const auto& node) { return node->as == sock; });
|
357
|
+
if (iter == fd_node_list_.end()) {
|
358
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p new fd: %d", this,
|
359
|
+
socks[i]);
|
360
|
+
new_list.push_back(std::make_unique<FdNode>(
|
361
|
+
socks[i], polled_fd_factory_->NewGrpcPolledFdLocked(socks[i])));
|
362
|
+
} else {
|
363
|
+
new_list.splice(new_list.end(), fd_node_list_, iter);
|
364
|
+
}
|
365
|
+
FdNode* fd_node = new_list.back().get();
|
366
|
+
if (ARES_GETSOCK_READABLE(socks_bitmask, i) &&
|
367
|
+
!fd_node->readable_registered) {
|
368
|
+
fd_node->readable_registered = true;
|
369
|
+
if (fd_node->polled_fd->IsFdStillReadableLocked()) {
|
370
|
+
// If c-ares is interested to read and the socket already has data
|
371
|
+
// available for read, schedules OnReadable directly here. This is
|
372
|
+
// to cope with the edge-triggered poller not getting an event if no
|
373
|
+
// new data arrives and c-ares hasn't read all the data in the
|
374
|
+
// previous ares_process_fd.
|
375
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
376
|
+
"resolver:%p schedule read directly on: %d", this, fd_node->as);
|
377
|
+
event_engine_->Run(
|
378
|
+
[self = Ref(DEBUG_LOCATION, "CheckSocketsLocked"),
|
379
|
+
fd_node]() mutable {
|
380
|
+
self->OnReadable(fd_node, absl::OkStatus());
|
381
|
+
});
|
382
|
+
} else {
|
383
|
+
// Otherwise register with the poller for readable event.
|
384
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p notify read on: %d", this,
|
385
|
+
fd_node->as);
|
386
|
+
fd_node->polled_fd->RegisterForOnReadableLocked(
|
387
|
+
[self = Ref(DEBUG_LOCATION, "CheckSocketsLocked"),
|
388
|
+
fd_node](absl::Status status) mutable {
|
389
|
+
self->OnReadable(fd_node, status);
|
390
|
+
});
|
391
|
+
}
|
392
|
+
}
|
393
|
+
// Register write_closure if the socket is writable and write_closure
|
394
|
+
// has not been registered with this socket.
|
395
|
+
if (ARES_GETSOCK_WRITABLE(socks_bitmask, i) &&
|
396
|
+
!fd_node->writable_registered) {
|
397
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p notify write on: %d", this,
|
398
|
+
fd_node->as);
|
399
|
+
fd_node->writable_registered = true;
|
400
|
+
fd_node->polled_fd->RegisterForOnWriteableLocked(
|
401
|
+
[self = Ref(DEBUG_LOCATION, "CheckSocketsLocked"),
|
402
|
+
fd_node](absl::Status status) mutable {
|
403
|
+
self->OnWritable(fd_node, status);
|
404
|
+
});
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}
|
408
|
+
}
|
409
|
+
// Any remaining fds in fd_node_list_ were not returned by ares_getsock()
|
410
|
+
// and are therefore no longer in use, so they can be shut down and removed
|
411
|
+
// from the list.
|
412
|
+
while (!fd_node_list_.empty()) {
|
413
|
+
FdNode* fd_node = fd_node_list_.front().get();
|
414
|
+
if (!fd_node->already_shutdown) {
|
415
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver: %p shutdown fd: %s", this,
|
416
|
+
fd_node->polled_fd->GetName());
|
417
|
+
fd_node->polled_fd->ShutdownLocked(absl::OkStatus());
|
418
|
+
fd_node->already_shutdown = true;
|
419
|
+
}
|
420
|
+
if (!fd_node->readable_registered && !fd_node->writable_registered) {
|
421
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver: %p delete fd: %s", this,
|
422
|
+
fd_node->polled_fd->GetName());
|
423
|
+
fd_node_list_.pop_front();
|
424
|
+
} else {
|
425
|
+
new_list.splice(new_list.end(), fd_node_list_, fd_node_list_.begin());
|
426
|
+
}
|
427
|
+
}
|
428
|
+
fd_node_list_ = std::move(new_list);
|
429
|
+
}
|
430
|
+
|
431
|
+
void AresResolver::MaybeStartTimerLocked() {
|
432
|
+
if (ares_backup_poll_alarm_handle_.has_value()) {
|
433
|
+
return;
|
434
|
+
}
|
435
|
+
// Initialize the backup poll alarm
|
436
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
437
|
+
"request:%p MaybeStartTimerLocked next ares process poll time in %zu ms",
|
438
|
+
this, Milliseconds(kAresBackupPollAlarmDuration));
|
439
|
+
ares_backup_poll_alarm_handle_ = event_engine_->RunAfter(
|
440
|
+
kAresBackupPollAlarmDuration,
|
441
|
+
[self = Ref(DEBUG_LOCATION, "MaybeStartTimerLocked")]() {
|
442
|
+
self->OnAresBackupPollAlarm();
|
443
|
+
});
|
444
|
+
}
|
445
|
+
|
446
|
+
void AresResolver::OnReadable(FdNode* fd_node, absl::Status status) {
|
447
|
+
grpc_core::MutexLock lock(&mutex_);
|
448
|
+
GPR_ASSERT(fd_node->readable_registered);
|
449
|
+
fd_node->readable_registered = false;
|
450
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("OnReadable: fd: %d; request: %p; status: %s",
|
451
|
+
fd_node->as, this, status.ToString().c_str());
|
452
|
+
if (status.ok() && !shutting_down_) {
|
453
|
+
ares_process_fd(channel_, fd_node->as, ARES_SOCKET_BAD);
|
454
|
+
} else {
|
455
|
+
// If error is not absl::OkStatus() or the resolution was cancelled, it
|
456
|
+
// means the fd has been shutdown or timed out. The pending lookups made
|
457
|
+
// on this request will be cancelled by the following ares_cancel(). The
|
458
|
+
// remaining file descriptors in this request will be cleaned up in the
|
459
|
+
// following Work() method.
|
460
|
+
ares_cancel(channel_);
|
461
|
+
}
|
462
|
+
CheckSocketsLocked();
|
463
|
+
}
|
464
|
+
|
465
|
+
void AresResolver::OnWritable(FdNode* fd_node, absl::Status status) {
|
466
|
+
grpc_core::MutexLock lock(&mutex_);
|
467
|
+
GPR_ASSERT(fd_node->writable_registered);
|
468
|
+
fd_node->writable_registered = false;
|
469
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("OnWritable: fd: %d; request:%p; status: %s",
|
470
|
+
fd_node->as, this, status.ToString().c_str());
|
471
|
+
if (status.ok() && !shutting_down_) {
|
472
|
+
ares_process_fd(channel_, ARES_SOCKET_BAD, fd_node->as);
|
473
|
+
} else {
|
474
|
+
// If error is not absl::OkStatus() or the resolution was cancelled, it
|
475
|
+
// means the fd has been shutdown or timed out. The pending lookups made
|
476
|
+
// on this request will be cancelled by the following ares_cancel(). The
|
477
|
+
// remaining file descriptors in this request will be cleaned up in the
|
478
|
+
// following Work() method.
|
479
|
+
ares_cancel(channel_);
|
480
|
+
}
|
481
|
+
CheckSocketsLocked();
|
482
|
+
}
|
483
|
+
|
484
|
+
// In case of non-responsive DNS servers, dropped packets, etc., c-ares has
|
485
|
+
// intelligent timeout and retry logic, which we can take advantage of by
|
486
|
+
// polling ares_process_fd on time intervals. Overall, the c-ares library is
|
487
|
+
// meant to be called into and given a chance to proceed name resolution:
|
488
|
+
// a) when fd events happen
|
489
|
+
// b) when some time has passed without fd events having happened
|
490
|
+
// For the latter, we use this backup poller. Also see
|
491
|
+
// https://github.com/grpc/grpc/pull/17688 description for more details.
|
492
|
+
void AresResolver::OnAresBackupPollAlarm() {
|
493
|
+
grpc_core::MutexLock lock(&mutex_);
|
494
|
+
ares_backup_poll_alarm_handle_.reset();
|
495
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
496
|
+
"request:%p OnAresBackupPollAlarm shutting_down=%d.", this,
|
497
|
+
shutting_down_);
|
498
|
+
if (!shutting_down_) {
|
499
|
+
for (const auto& fd_node : fd_node_list_) {
|
500
|
+
if (!fd_node->already_shutdown) {
|
501
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
502
|
+
"request:%p OnAresBackupPollAlarm; ares_process_fd. fd=%s", this,
|
503
|
+
fd_node->polled_fd->GetName());
|
504
|
+
ares_socket_t as = fd_node->polled_fd->GetWrappedAresSocketLocked();
|
505
|
+
ares_process_fd(channel_, as, as);
|
506
|
+
}
|
507
|
+
}
|
508
|
+
MaybeStartTimerLocked();
|
509
|
+
CheckSocketsLocked();
|
510
|
+
}
|
511
|
+
}
|
512
|
+
|
513
|
+
void AresResolver::OnHostbynameDoneLocked(void* arg, int status,
|
514
|
+
int /*timeouts*/,
|
515
|
+
struct hostent* hostent) {
|
516
|
+
std::unique_ptr<HostnameQueryArg> hostname_qa(
|
517
|
+
static_cast<HostnameQueryArg*>(arg));
|
518
|
+
auto* ares_resolver = hostname_qa->ares_resolver;
|
519
|
+
auto nh = ares_resolver->callback_map_.extract(hostname_qa->callback_map_id);
|
520
|
+
GPR_ASSERT(!nh.empty());
|
521
|
+
GPR_ASSERT(
|
522
|
+
absl::holds_alternative<EventEngine::DNSResolver::LookupHostnameCallback>(
|
523
|
+
nh.mapped()));
|
524
|
+
auto callback = absl::get<EventEngine::DNSResolver::LookupHostnameCallback>(
|
525
|
+
std::move(nh.mapped()));
|
526
|
+
if (status != ARES_SUCCESS) {
|
527
|
+
std::string error_msg =
|
528
|
+
absl::StrFormat("address lookup failed for %s: %s",
|
529
|
+
hostname_qa->query_name, ares_strerror(status));
|
530
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p OnHostbynameDoneLocked: %s",
|
531
|
+
ares_resolver, error_msg.c_str());
|
532
|
+
ares_resolver->event_engine_->Run(
|
533
|
+
[callback = std::move(callback),
|
534
|
+
status = AresStatusToAbslStatus(status, error_msg)]() mutable {
|
535
|
+
callback(status);
|
536
|
+
});
|
537
|
+
return;
|
538
|
+
}
|
539
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
540
|
+
"resolver:%p OnHostbynameDoneLocked name=%s ARES_SUCCESS", ares_resolver,
|
541
|
+
hostname_qa->query_name.c_str());
|
542
|
+
std::vector<EventEngine::ResolvedAddress> result;
|
543
|
+
for (size_t i = 0; hostent->h_addr_list[i] != nullptr; i++) {
|
544
|
+
switch (hostent->h_addrtype) {
|
545
|
+
case AF_INET6: {
|
546
|
+
size_t addr_len = sizeof(struct sockaddr_in6);
|
547
|
+
struct sockaddr_in6 addr;
|
548
|
+
memset(&addr, 0, addr_len);
|
549
|
+
memcpy(&addr.sin6_addr, hostent->h_addr_list[i],
|
550
|
+
sizeof(struct in6_addr));
|
551
|
+
addr.sin6_family = static_cast<unsigned char>(hostent->h_addrtype);
|
552
|
+
addr.sin6_port = htons(hostname_qa->port);
|
553
|
+
result.emplace_back(reinterpret_cast<const sockaddr*>(&addr), addr_len);
|
554
|
+
char output[INET6_ADDRSTRLEN];
|
555
|
+
ares_inet_ntop(AF_INET6, &addr.sin6_addr, output, INET6_ADDRSTRLEN);
|
556
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
557
|
+
"resolver:%p c-ares resolver gets a AF_INET6 result: \n"
|
558
|
+
" addr: %s\n port: %d\n sin6_scope_id: %d\n",
|
559
|
+
ares_resolver, output, hostname_qa->port, addr.sin6_scope_id);
|
560
|
+
break;
|
561
|
+
}
|
562
|
+
case AF_INET: {
|
563
|
+
size_t addr_len = sizeof(struct sockaddr_in);
|
564
|
+
struct sockaddr_in addr;
|
565
|
+
memset(&addr, 0, addr_len);
|
566
|
+
memcpy(&addr.sin_addr, hostent->h_addr_list[i], sizeof(struct in_addr));
|
567
|
+
addr.sin_family = static_cast<unsigned char>(hostent->h_addrtype);
|
568
|
+
addr.sin_port = htons(hostname_qa->port);
|
569
|
+
result.emplace_back(reinterpret_cast<const sockaddr*>(&addr), addr_len);
|
570
|
+
char output[INET_ADDRSTRLEN];
|
571
|
+
ares_inet_ntop(AF_INET, &addr.sin_addr, output, INET_ADDRSTRLEN);
|
572
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
573
|
+
"resolver:%p c-ares resolver gets a AF_INET result: \n"
|
574
|
+
" addr: %s\n port: %d\n",
|
575
|
+
ares_resolver, output, hostname_qa->port);
|
576
|
+
break;
|
577
|
+
}
|
578
|
+
}
|
579
|
+
}
|
580
|
+
ares_resolver->event_engine_->Run(
|
581
|
+
[callback = std::move(callback), result = std::move(result)]() mutable {
|
582
|
+
callback(std::move(result));
|
583
|
+
});
|
584
|
+
}
|
585
|
+
|
586
|
+
void AresResolver::OnSRVQueryDoneLocked(void* arg, int status, int /*timeouts*/,
|
587
|
+
unsigned char* abuf, int alen) {
|
588
|
+
std::unique_ptr<QueryArg> qa(static_cast<QueryArg*>(arg));
|
589
|
+
auto* ares_resolver = qa->ares_resolver;
|
590
|
+
auto nh = ares_resolver->callback_map_.extract(qa->callback_map_id);
|
591
|
+
GPR_ASSERT(!nh.empty());
|
592
|
+
GPR_ASSERT(
|
593
|
+
absl::holds_alternative<EventEngine::DNSResolver::LookupSRVCallback>(
|
594
|
+
nh.mapped()));
|
595
|
+
auto callback = absl::get<EventEngine::DNSResolver::LookupSRVCallback>(
|
596
|
+
std::move(nh.mapped()));
|
597
|
+
auto fail = [&](absl::string_view prefix) {
|
598
|
+
std::string error_message = absl::StrFormat(
|
599
|
+
"%s for %s: %s", prefix, qa->query_name, ares_strerror(status));
|
600
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("OnSRVQueryDoneLocked: %s",
|
601
|
+
error_message.c_str());
|
602
|
+
ares_resolver->event_engine_->Run(
|
603
|
+
[callback = std::move(callback),
|
604
|
+
status = AresStatusToAbslStatus(status, error_message)]() mutable {
|
605
|
+
callback(status);
|
606
|
+
});
|
607
|
+
};
|
608
|
+
if (status != ARES_SUCCESS) {
|
609
|
+
fail("SRV lookup failed");
|
610
|
+
return;
|
611
|
+
}
|
612
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
613
|
+
"resolver:%p OnSRVQueryDoneLocked name=%s ARES_SUCCESS", ares_resolver,
|
614
|
+
qa->query_name.c_str());
|
615
|
+
struct ares_srv_reply* reply = nullptr;
|
616
|
+
status = ares_parse_srv_reply(abuf, alen, &reply);
|
617
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p ares_parse_srv_reply: %d",
|
618
|
+
ares_resolver, status);
|
619
|
+
if (status != ARES_SUCCESS) {
|
620
|
+
fail("Failed to parse SRV reply");
|
621
|
+
return;
|
622
|
+
}
|
623
|
+
std::vector<EventEngine::DNSResolver::SRVRecord> result;
|
624
|
+
for (struct ares_srv_reply* srv_it = reply; srv_it != nullptr;
|
625
|
+
srv_it = srv_it->next) {
|
626
|
+
EventEngine::DNSResolver::SRVRecord record;
|
627
|
+
record.host = srv_it->host;
|
628
|
+
record.port = srv_it->port;
|
629
|
+
record.priority = srv_it->priority;
|
630
|
+
record.weight = srv_it->weight;
|
631
|
+
result.push_back(std::move(record));
|
632
|
+
}
|
633
|
+
if (reply != nullptr) {
|
634
|
+
ares_free_data(reply);
|
635
|
+
}
|
636
|
+
ares_resolver->event_engine_->Run(
|
637
|
+
[callback = std::move(callback), result = std::move(result)]() mutable {
|
638
|
+
callback(std::move(result));
|
639
|
+
});
|
640
|
+
}
|
641
|
+
|
642
|
+
void AresResolver::OnTXTDoneLocked(void* arg, int status, int /*timeouts*/,
|
643
|
+
unsigned char* buf, int len) {
|
644
|
+
std::unique_ptr<QueryArg> qa(static_cast<QueryArg*>(arg));
|
645
|
+
auto* ares_resolver = qa->ares_resolver;
|
646
|
+
auto nh = ares_resolver->callback_map_.extract(qa->callback_map_id);
|
647
|
+
GPR_ASSERT(!nh.empty());
|
648
|
+
GPR_ASSERT(
|
649
|
+
absl::holds_alternative<EventEngine::DNSResolver::LookupTXTCallback>(
|
650
|
+
nh.mapped()));
|
651
|
+
auto callback = absl::get<EventEngine::DNSResolver::LookupTXTCallback>(
|
652
|
+
std::move(nh.mapped()));
|
653
|
+
auto fail = [&](absl::string_view prefix) {
|
654
|
+
std::string error_message = absl::StrFormat(
|
655
|
+
"%s for %s: %s", prefix, qa->query_name, ares_strerror(status));
|
656
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p OnTXTDoneLocked: %s",
|
657
|
+
ares_resolver, error_message.c_str());
|
658
|
+
ares_resolver->event_engine_->Run(
|
659
|
+
[callback = std::move(callback),
|
660
|
+
status = AresStatusToAbslStatus(status, error_message)]() mutable {
|
661
|
+
callback(status);
|
662
|
+
});
|
663
|
+
};
|
664
|
+
if (status != ARES_SUCCESS) {
|
665
|
+
fail("TXT lookup failed");
|
666
|
+
return;
|
667
|
+
}
|
668
|
+
GRPC_ARES_RESOLVER_TRACE_LOG(
|
669
|
+
"resolver:%p OnTXTDoneLocked name=%s ARES_SUCCESS", ares_resolver,
|
670
|
+
qa->query_name.c_str());
|
671
|
+
struct ares_txt_ext* reply = nullptr;
|
672
|
+
status = ares_parse_txt_reply_ext(buf, len, &reply);
|
673
|
+
if (status != ARES_SUCCESS) {
|
674
|
+
fail("Failed to parse TXT result");
|
675
|
+
return;
|
676
|
+
}
|
677
|
+
std::vector<std::string> result;
|
678
|
+
for (struct ares_txt_ext* part = reply; part != nullptr; part = part->next) {
|
679
|
+
if (part->record_start) {
|
680
|
+
result.emplace_back(reinterpret_cast<char*>(part->txt), part->length);
|
681
|
+
} else {
|
682
|
+
absl::StrAppend(
|
683
|
+
&result.back(),
|
684
|
+
std::string(reinterpret_cast<char*>(part->txt), part->length));
|
685
|
+
}
|
686
|
+
}
|
687
|
+
GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p Got %zu TXT records", ares_resolver,
|
688
|
+
result.size());
|
689
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_ares_resolver)) {
|
690
|
+
for (const auto& record : result) {
|
691
|
+
gpr_log(GPR_INFO, "%s", record.c_str());
|
692
|
+
}
|
693
|
+
}
|
694
|
+
// Clean up.
|
695
|
+
ares_free_data(reply);
|
696
|
+
ares_resolver->event_engine_->Run(
|
697
|
+
[callback = std::move(callback), result = std::move(result)]() mutable {
|
698
|
+
callback(std::move(result));
|
699
|
+
});
|
700
|
+
}
|
701
|
+
|
702
|
+
} // namespace experimental
|
703
|
+
} // namespace grpc_event_engine
|
704
|
+
|
705
|
+
void noop_inject_channel_config(ares_channel* /*channel*/) {}
|
706
|
+
|
707
|
+
void (*event_engine_grpc_ares_test_only_inject_config)(ares_channel* channel) =
|
708
|
+
noop_inject_channel_config;
|
709
|
+
|
710
|
+
bool g_event_engine_grpc_ares_test_only_force_tcp = false;
|
711
|
+
|
712
|
+
#endif // GRPC_ARES == 1
|