grpc 1.74.1 → 1.75.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +83 -41
- data/include/grpc/credentials.h +7 -1
- data/src/core/call/client_call.cc +4 -4
- data/src/core/call/filter_fusion.h +1230 -0
- data/src/core/call/metadata.cc +22 -0
- data/src/core/call/metadata.h +24 -2
- data/src/core/channelz/channelz.cc +10 -17
- data/src/core/channelz/channelz.h +58 -19
- data/src/core/channelz/channelz_registry.cc +0 -162
- data/src/core/channelz/channelz_registry.h +14 -7
- data/src/core/channelz/property_list.cc +19 -23
- data/src/core/channelz/property_list.h +3 -1
- data/src/core/channelz/v2tov1/convert.cc +683 -0
- data/src/core/channelz/v2tov1/convert.h +58 -0
- data/src/core/channelz/v2tov1/legacy_api.cc +425 -0
- data/src/core/channelz/v2tov1/legacy_api.h +32 -0
- data/src/core/channelz/v2tov1/property_list.cc +118 -0
- data/src/core/channelz/v2tov1/property_list.h +52 -0
- data/src/core/client_channel/client_channel_filter.cc +5 -4
- data/src/core/client_channel/client_channel_filter.h +2 -2
- data/src/core/client_channel/client_channel_internal.h +2 -1
- data/src/core/client_channel/load_balanced_call_destination.cc +6 -5
- data/src/core/client_channel/subchannel.cc +14 -6
- data/src/core/client_channel/subchannel.h +2 -0
- data/src/core/config/core_configuration.cc +3 -1
- data/src/core/config/core_configuration.h +12 -0
- data/src/core/credentials/transport/alts/alts_credentials.cc +5 -0
- data/src/core/credentials/transport/alts/check_gcp_environment_windows.cc +2 -0
- data/src/core/credentials/transport/channel_creds_registry_init.cc +3 -1
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +1 -1
- data/src/core/credentials/transport/ssl/ssl_security_connector.cc +8 -3
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -24
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +19 -8
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +96 -54
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +15 -2
- data/src/core/credentials/transport/tls/spiffe_utils.cc +371 -0
- data/src/core/credentials/transport/tls/spiffe_utils.h +171 -0
- data/src/core/credentials/transport/tls/ssl_utils.cc +11 -10
- data/src/core/credentials/transport/tls/ssl_utils.h +4 -2
- data/src/core/credentials/transport/tls/tls_credentials.cc +2 -0
- data/src/core/credentials/transport/tls/tls_security_connector.cc +11 -26
- data/src/core/credentials/transport/tls/tls_security_connector.h +12 -12
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +3 -6
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +8 -8
- data/src/core/ext/filters/http/server/http_server_filter.cc +3 -6
- data/src/core/ext/filters/message_size/message_size_filter.cc +4 -4
- data/src/core/ext/filters/rbac/rbac_filter.cc +1 -1
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame.cc +89 -6
- data/src/core/ext/transport/chttp2/transport/frame.h +38 -0
- data/src/core/ext/transport/chttp2/transport/header_assembler.h +5 -14
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +294 -78
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +128 -9
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +11 -38
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +52 -35
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc +61 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.h +142 -0
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +81 -3
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +12 -1
- data/src/core/ext/transport/chttp2/transport/message_assembler.h +2 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +22 -5
- data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +607 -0
- data/src/core/ext/transport/chttp2/transport/writable_streams.h +254 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +6 -4
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb.h +4959 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.c +1111 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.h +108 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +142 -54
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +18 -14
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +2 -2
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +716 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.h +227 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +86 -88
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +2 -2
- data/src/core/filter/auth/auth_filters.h +2 -2
- data/src/core/filter/fused_filters.cc +154 -0
- data/src/core/handshaker/security/legacy_secure_endpoint.cc +1 -1
- data/src/core/handshaker/security/pipelined_secure_endpoint.cc +965 -0
- data/src/core/handshaker/security/secure_endpoint.cc +28 -13
- data/src/core/handshaker/security/secure_endpoint.h +8 -0
- data/src/core/lib/channel/promise_based_filter.cc +15 -25
- data/src/core/lib/channel/promise_based_filter.h +6 -5
- data/src/core/lib/event_engine/ares_resolver.h +3 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -5
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +2 -1
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +263 -0
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.h +107 -0
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +31 -3
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +12 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +12 -10
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +6 -4
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +15 -14
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -5
- data/src/core/lib/event_engine/posix_engine/event_poller.h +0 -8
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +11 -5
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +3 -2
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +1 -0
- data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +4 -4
- data/src/core/lib/event_engine/posix_engine/lockfree_event.h +3 -4
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +2 -2
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +188 -199
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +30 -45
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +1 -1
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +1 -1
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +2 -1
- data/src/core/lib/experiments/experiments.cc +120 -6
- data/src/core/lib/experiments/experiments.h +46 -3
- data/src/core/lib/iomgr/combiner.cc +1 -1
- data/src/core/lib/iomgr/exec_ctx.h +3 -9
- data/src/core/lib/iomgr/socket_mutator.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +1 -1
- data/src/core/lib/iomgr/tcp_client_posix.cc +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +3 -3
- data/src/core/lib/promise/activity.h +2 -2
- data/src/core/lib/promise/mpsc.cc +8 -8
- data/src/core/lib/promise/party.cc +7 -7
- data/src/core/lib/promise/party.h +4 -4
- data/src/core/lib/promise/poll.h +10 -0
- data/src/core/lib/resource_quota/memory_quota.cc +90 -3
- data/src/core/lib/resource_quota/memory_quota.h +20 -9
- data/src/core/lib/resource_quota/periodic_update.cc +14 -0
- data/src/core/lib/resource_quota/periodic_update.h +8 -0
- data/src/core/lib/resource_quota/resource_quota.cc +15 -4
- data/src/core/lib/resource_quota/resource_quota.h +3 -0
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -2
- data/src/core/lib/surface/call.cc +5 -5
- data/src/core/lib/surface/call.h +6 -5
- data/src/core/lib/surface/completion_queue.cc +2 -4
- data/src/core/lib/surface/filter_stack_call.cc +1 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.h +3 -3
- data/src/core/load_balancing/endpoint_list.cc +29 -2
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +3 -3
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.h +1 -1
- data/src/core/load_balancing/pick_first/pick_first.cc +12 -5
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +5 -3
- data/src/core/net/socket_mutator.cc +19 -0
- data/src/core/net/socket_mutator.h +25 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +6 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +2 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +8 -5
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
- data/src/core/resolver/xds/xds_dependency_manager.cc +1 -1
- data/src/core/server/server.cc +1 -1
- data/src/core/server/server_call_tracer_filter.cc +0 -66
- data/src/core/server/server_call_tracer_filter.h +64 -0
- data/src/core/server/server_config_selector_filter.cc +1 -1
- data/src/core/service_config/service_config_channel_arg_filter.cc +3 -60
- data/src/core/service_config/service_config_channel_arg_filter.h +82 -0
- data/src/core/telemetry/call_tracer.cc +20 -14
- data/src/core/telemetry/call_tracer.h +22 -17
- data/src/core/telemetry/metrics.h +8 -8
- data/src/core/telemetry/stats_data.cc +151 -151
- data/src/core/telemetry/stats_data.h +87 -87
- data/src/core/transport/auth_context.cc +20 -0
- data/src/core/transport/auth_context.h +4 -0
- data/src/core/transport/auth_context_comparator_registry.h +69 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -3
- data/src/core/tsi/ssl_transport_security.cc +202 -32
- data/src/core/tsi/ssl_transport_security.h +19 -10
- data/src/core/tsi/ssl_transport_security_utils.cc +21 -0
- data/src/core/tsi/ssl_transport_security_utils.h +4 -0
- data/src/core/util/http_client/httpcli_security_connector.cc +3 -1
- data/src/core/util/latent_see.cc +178 -146
- data/src/core/util/latent_see.h +245 -188
- data/src/core/util/single_set_ptr.h +5 -2
- data/src/core/util/useful.h +91 -0
- data/src/core/util/windows/directory_reader.cc +1 -0
- data/src/core/util/windows/thd.cc +1 -3
- data/src/core/util/work_serializer.cc +1 -1
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +32 -5
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +5 -0
- data/src/core/xds/grpc/xds_certificate_provider.cc +5 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/cares/cares/include/ares.h +925 -460
- data/third_party/cares/cares/include/ares_dns.h +86 -71
- data/third_party/cares/cares/include/ares_dns_record.h +1118 -0
- data/third_party/cares/cares/include/ares_nameser.h +215 -189
- data/third_party/cares/cares/include/ares_version.h +37 -14
- data/third_party/cares/cares/src/lib/ares_addrinfo2hostent.c +305 -0
- data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +245 -0
- data/third_party/cares/cares/src/lib/ares_android.c +216 -164
- data/third_party/cares/cares/src/lib/ares_android.h +25 -14
- data/third_party/cares/cares/src/lib/ares_cancel.c +68 -44
- data/third_party/cares/cares/src/lib/ares_close_sockets.c +137 -0
- data/third_party/cares/cares/src/lib/ares_conn.c +511 -0
- data/third_party/cares/cares/src/lib/ares_conn.h +196 -0
- data/third_party/cares/cares/src/lib/ares_cookie.c +461 -0
- data/third_party/cares/cares/src/lib/ares_data.c +93 -181
- data/third_party/cares/cares/src/lib/ares_data.h +50 -39
- data/third_party/cares/cares/src/lib/ares_destroy.c +127 -89
- data/third_party/cares/cares/src/lib/ares_free_hostent.c +35 -24
- data/third_party/cares/cares/src/lib/ares_free_string.c +24 -16
- data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +45 -38
- data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +549 -663
- data/third_party/cares/cares/src/lib/ares_getenv.c +25 -15
- data/third_party/cares/cares/src/lib/ares_getenv.h +26 -18
- data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +163 -221
- data/third_party/cares/cares/src/lib/ares_gethostbyname.c +222 -223
- data/third_party/cares/cares/src/lib/ares_getnameinfo.c +328 -338
- data/third_party/cares/cares/src/lib/ares_hosts_file.c +952 -0
- data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +25 -19
- data/third_party/cares/cares/src/lib/ares_init.c +425 -2091
- data/third_party/cares/cares/src/lib/ares_ipv6.h +63 -33
- data/third_party/cares/cares/src/lib/ares_library_init.c +110 -54
- data/third_party/cares/cares/src/lib/ares_metrics.c +261 -0
- data/third_party/cares/cares/src/lib/ares_options.c +418 -332
- data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +179 -0
- data/third_party/cares/cares/src/lib/ares_private.h +558 -356
- data/third_party/cares/cares/src/lib/ares_process.c +1224 -1369
- data/third_party/cares/cares/src/lib/ares_qcache.c +430 -0
- data/third_party/cares/cares/src/lib/ares_query.c +126 -121
- data/third_party/cares/cares/src/lib/ares_search.c +564 -262
- data/third_party/cares/cares/src/lib/ares_send.c +264 -93
- data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +588 -0
- data/third_party/cares/cares/src/lib/ares_setup.h +115 -111
- data/third_party/cares/cares/src/lib/ares_socket.c +425 -0
- data/third_party/cares/cares/src/lib/ares_socket.h +163 -0
- data/third_party/cares/cares/src/lib/ares_sortaddrinfo.c +447 -0
- data/third_party/cares/cares/src/lib/ares_strerror.c +83 -48
- data/third_party/cares/cares/src/lib/ares_sysconfig.c +639 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +839 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_mac.c +373 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +621 -0
- data/third_party/cares/cares/src/lib/ares_timeout.c +136 -73
- data/third_party/cares/cares/src/lib/ares_update_servers.c +1362 -0
- data/third_party/cares/cares/src/lib/ares_version.c +29 -4
- data/third_party/cares/cares/src/lib/config-dos.h +88 -89
- data/third_party/cares/cares/src/lib/config-win32.h +122 -77
- data/third_party/cares/cares/src/lib/dsa/ares_array.c +394 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.c +447 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.h +174 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_asvp.c +224 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +228 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_strvp.c +210 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_szvp.c +188 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpstr.c +186 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpvp.c +194 -0
- data/third_party/cares/cares/src/lib/dsa/ares_llist.c +382 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.c +479 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.h +207 -0
- data/third_party/cares/cares/src/lib/event/ares_event.h +191 -0
- data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +743 -0
- data/third_party/cares/cares/src/lib/event/ares_event_epoll.c +192 -0
- data/third_party/cares/cares/src/lib/event/ares_event_kqueue.c +248 -0
- data/third_party/cares/cares/src/lib/event/ares_event_poll.c +140 -0
- data/third_party/cares/cares/src/lib/event/ares_event_select.c +159 -0
- data/third_party/cares/cares/src/lib/event/ares_event_thread.c +567 -0
- data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +166 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.c +978 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.h +161 -0
- data/third_party/cares/cares/src/lib/include/ares_array.h +276 -0
- data/third_party/cares/cares/src/lib/include/ares_buf.h +732 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_asvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_dict.h +123 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_strvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_szvp.h +118 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpstr.h +111 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpvp.h +128 -0
- data/third_party/cares/cares/src/lib/include/ares_llist.h +239 -0
- data/third_party/cares/cares/src/lib/include/ares_mem.h +38 -0
- data/third_party/cares/cares/src/lib/include/ares_str.h +244 -0
- data/third_party/cares/cares/src/lib/inet_net_pton.c +202 -157
- data/third_party/cares/cares/src/lib/inet_ntop.c +87 -69
- data/third_party/cares/cares/src/lib/legacy/ares_create_query.c +78 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +99 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_string.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_fds.c +80 -0
- data/third_party/cares/cares/src/lib/legacy/ares_getsock.c +85 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +982 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +307 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.h +72 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_name.c +673 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +1329 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_private.h +273 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_record.c +1661 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_write.c +1229 -0
- data/third_party/cares/cares/src/lib/str/ares_buf.c +1498 -0
- data/third_party/cares/cares/src/lib/str/ares_str.c +508 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.c +90 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.h +51 -0
- data/third_party/cares/cares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +628 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +139 -0
- data/third_party/cares/cares/src/lib/util/ares_math.c +158 -0
- data/third_party/cares/cares/src/lib/util/ares_math.h +45 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.c +389 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.h +36 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.c +614 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.h +60 -0
- data/third_party/cares/cares/src/lib/util/ares_time.h +48 -0
- data/third_party/cares/cares/src/lib/util/ares_timeval.c +95 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.c +1626 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.h +252 -0
- data/third_party/cares/cares/src/lib/windows_port.c +16 -9
- metadata +121 -49
- data/src/core/util/ring_buffer.h +0 -122
- data/third_party/cares/cares/include/ares_rules.h +0 -125
- data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +0 -266
- data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +0 -240
- data/third_party/cares/cares/src/lib/ares__close_sockets.c +0 -61
- data/third_party/cares/cares/src/lib/ares__get_hostent.c +0 -260
- data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +0 -229
- data/third_party/cares/cares/src/lib/ares__read_line.c +0 -73
- data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +0 -258
- data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +0 -507
- data/third_party/cares/cares/src/lib/ares__timeval.c +0 -111
- data/third_party/cares/cares/src/lib/ares_create_query.c +0 -197
- data/third_party/cares/cares/src/lib/ares_expand_name.c +0 -311
- data/third_party/cares/cares/src/lib/ares_expand_string.c +0 -67
- data/third_party/cares/cares/src/lib/ares_fds.c +0 -59
- data/third_party/cares/cares/src/lib/ares_getsock.c +0 -66
- data/third_party/cares/cares/src/lib/ares_iphlpapi.h +0 -221
- data/third_party/cares/cares/src/lib/ares_llist.c +0 -63
- data/third_party/cares/cares/src/lib/ares_llist.h +0 -39
- data/third_party/cares/cares/src/lib/ares_mkquery.c +0 -24
- data/third_party/cares/cares/src/lib/ares_nowarn.c +0 -260
- data/third_party/cares/cares/src/lib/ares_nowarn.h +0 -61
- data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +0 -90
- data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +0 -92
- data/third_party/cares/cares/src/lib/ares_parse_caa_reply.c +0 -199
- data/third_party/cares/cares/src/lib/ares_parse_mx_reply.c +0 -164
- data/third_party/cares/cares/src/lib/ares_parse_naptr_reply.c +0 -183
- data/third_party/cares/cares/src/lib/ares_parse_ns_reply.c +0 -177
- data/third_party/cares/cares/src/lib/ares_parse_ptr_reply.c +0 -228
- data/third_party/cares/cares/src/lib/ares_parse_soa_reply.c +0 -179
- data/third_party/cares/cares/src/lib/ares_parse_srv_reply.c +0 -168
- data/third_party/cares/cares/src/lib/ares_parse_txt_reply.c +0 -214
- data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +0 -184
- data/third_party/cares/cares/src/lib/ares_platform.c +0 -11042
- data/third_party/cares/cares/src/lib/ares_platform.h +0 -43
- data/third_party/cares/cares/src/lib/ares_rand.c +0 -279
- data/third_party/cares/cares/src/lib/ares_strcasecmp.c +0 -66
- data/third_party/cares/cares/src/lib/ares_strcasecmp.h +0 -30
- data/third_party/cares/cares/src/lib/ares_strdup.c +0 -42
- data/third_party/cares/cares/src/lib/ares_strdup.h +0 -24
- data/third_party/cares/cares/src/lib/ares_strsplit.c +0 -94
- data/third_party/cares/cares/src/lib/ares_strsplit.h +0 -42
- data/third_party/cares/cares/src/lib/ares_writev.c +0 -79
- data/third_party/cares/cares/src/lib/ares_writev.h +0 -36
- data/third_party/cares/cares/src/lib/bitncmp.c +0 -59
- data/third_party/cares/cares/src/lib/bitncmp.h +0 -26
- data/third_party/cares/cares/src/lib/setup_once.h +0 -554
- data/third_party/cares/cares/src/tools/ares_getopt.h +0 -53
@@ -1,29 +1,51 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 2005 Dominick Meglio
|
4
|
+
*
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
10
|
+
* furnished to do so, subject to the following conditions:
|
11
|
+
*
|
12
|
+
* The above copyright notice and this permission notice (including the next
|
13
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
14
|
+
* Software.
|
3
15
|
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
* this software for any purpose. It is provided "as is"
|
14
|
-
* without express or implied warranty.
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*
|
24
|
+
* SPDX-License-Identifier: MIT
|
15
25
|
*/
|
16
26
|
|
17
27
|
#ifndef ARES_IPV6_H
|
18
28
|
#define ARES_IPV6_H
|
19
29
|
|
30
|
+
#ifdef HAVE_NETINET6_IN6_H
|
31
|
+
# include <netinet6/in6.h>
|
32
|
+
#endif
|
33
|
+
|
34
|
+
#if defined(USE_WINSOCK)
|
35
|
+
# if defined(HAVE_IPHLPAPI_H)
|
36
|
+
# include <iphlpapi.h>
|
37
|
+
# endif
|
38
|
+
# if defined(HAVE_NETIOAPI_H)
|
39
|
+
# include <netioapi.h>
|
40
|
+
# endif
|
41
|
+
#endif
|
42
|
+
|
20
43
|
#ifndef HAVE_PF_INET6
|
21
|
-
#define PF_INET6 AF_INET6
|
44
|
+
# define PF_INET6 AF_INET6
|
22
45
|
#endif
|
23
46
|
|
24
47
|
#ifndef HAVE_STRUCT_SOCKADDR_IN6
|
25
|
-
struct sockaddr_in6
|
26
|
-
{
|
48
|
+
struct sockaddr_in6 {
|
27
49
|
unsigned short sin6_family;
|
28
50
|
unsigned short sin6_port;
|
29
51
|
unsigned long sin6_flowinfo;
|
@@ -32,21 +54,19 @@ struct sockaddr_in6
|
|
32
54
|
};
|
33
55
|
#endif
|
34
56
|
|
35
|
-
typedef union
|
36
|
-
{
|
57
|
+
typedef union {
|
37
58
|
struct sockaddr sa;
|
38
59
|
struct sockaddr_in sa4;
|
39
60
|
struct sockaddr_in6 sa6;
|
40
61
|
} ares_sockaddr;
|
41
62
|
|
42
63
|
#ifndef HAVE_STRUCT_ADDRINFO
|
43
|
-
struct addrinfo
|
44
|
-
{
|
64
|
+
struct addrinfo {
|
45
65
|
int ai_flags;
|
46
66
|
int ai_family;
|
47
67
|
int ai_socktype;
|
48
68
|
int ai_protocol;
|
49
|
-
ares_socklen_t ai_addrlen;
|
69
|
+
ares_socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
|
50
70
|
char *ai_canonname;
|
51
71
|
struct sockaddr *ai_addr;
|
52
72
|
struct addrinfo *ai_next;
|
@@ -54,28 +74,38 @@ struct addrinfo
|
|
54
74
|
#endif
|
55
75
|
|
56
76
|
#ifndef NS_IN6ADDRSZ
|
57
|
-
#ifndef HAVE_STRUCT_IN6_ADDR
|
77
|
+
# ifndef HAVE_STRUCT_IN6_ADDR
|
58
78
|
/* We cannot have it set to zero, so we pick a fixed value here */
|
59
|
-
#define NS_IN6ADDRSZ 16
|
60
|
-
#else
|
61
|
-
#define NS_IN6ADDRSZ sizeof(struct in6_addr)
|
62
|
-
#endif
|
79
|
+
# define NS_IN6ADDRSZ 16
|
80
|
+
# else
|
81
|
+
# define NS_IN6ADDRSZ sizeof(struct in6_addr)
|
82
|
+
# endif
|
63
83
|
#endif
|
64
84
|
|
65
85
|
#ifndef NS_INADDRSZ
|
66
|
-
#define NS_INADDRSZ sizeof(struct in_addr)
|
86
|
+
# define NS_INADDRSZ sizeof(struct in_addr)
|
67
87
|
#endif
|
68
88
|
|
69
89
|
#ifndef NS_INT16SZ
|
70
|
-
#define NS_INT16SZ 2
|
90
|
+
# define NS_INT16SZ 2
|
71
91
|
#endif
|
72
92
|
|
73
|
-
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
93
|
+
/* Windows XP Compatibility with later MSVC/Mingw versions */
|
94
|
+
#if defined(_WIN32)
|
95
|
+
# if !defined(IF_MAX_STRING_SIZE)
|
96
|
+
# define IF_MAX_STRING_SIZE 256 /* =256 in <ifdef.h> */
|
97
|
+
# endif
|
98
|
+
# if !defined(NDIS_IF_MAX_STRING_SIZE)
|
99
|
+
# define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE /* =256 in <ifdef.h> */
|
100
|
+
# endif
|
78
101
|
#endif
|
102
|
+
|
103
|
+
#ifndef IF_NAMESIZE
|
104
|
+
# ifdef IFNAMSIZ
|
105
|
+
# define IF_NAMESIZE IFNAMSIZ
|
106
|
+
# else
|
107
|
+
# define IF_NAMESIZE 32
|
108
|
+
# endif
|
79
109
|
#endif
|
80
110
|
|
81
111
|
/* Defined in inet_net_pton.c for no particular reason. */
|
@@ -1,29 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
* Copyright (
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 1998 Massachusetts Institute of Technology
|
4
|
+
* Copyright (c) 2004 Daniel Stenberg
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice (including the next
|
14
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
15
|
+
* Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
* SOFTWARE.
|
4
24
|
*
|
5
|
-
*
|
6
|
-
* software and its documentation for any purpose and without
|
7
|
-
* fee is hereby granted, provided that the above copyright
|
8
|
-
* notice appear in all copies and that both that copyright
|
9
|
-
* notice and this permission notice appear in supporting
|
10
|
-
* documentation, and that the name of M.I.T. not be used in
|
11
|
-
* advertising or publicity pertaining to distribution of the
|
12
|
-
* software without specific, written prior permission.
|
13
|
-
* M.I.T. makes no representations about the suitability of
|
14
|
-
* this software for any purpose. It is provided "as is"
|
15
|
-
* without express or implied warranty.
|
25
|
+
* SPDX-License-Identifier: MIT
|
16
26
|
*/
|
17
27
|
|
18
|
-
#include "ares_setup.h"
|
19
|
-
|
20
|
-
#include "ares.h"
|
21
28
|
#include "ares_private.h"
|
22
29
|
|
23
30
|
/* library-private global and unique instance vars */
|
24
31
|
|
25
32
|
#if defined(ANDROID) || defined(__ANDROID__)
|
26
|
-
#include "ares_android.h"
|
33
|
+
# include "ares_android.h"
|
27
34
|
#endif
|
28
35
|
|
29
36
|
/* library-private global vars with source visibility restricted to this file */
|
@@ -33,31 +40,77 @@ static int ares_init_flags;
|
|
33
40
|
|
34
41
|
/* library-private global vars with visibility across the whole library */
|
35
42
|
|
36
|
-
/* Some systems may return either NULL or a valid pointer on malloc(0). c-ares
|
37
|
-
* never call malloc(0) so lets return NULL so we're more likely to find
|
38
|
-
* were to occur. */
|
43
|
+
/* Some systems may return either NULL or a valid pointer on malloc(0). c-ares
|
44
|
+
* should never call malloc(0) so lets return NULL so we're more likely to find
|
45
|
+
* an issue if it were to occur. */
|
39
46
|
|
40
|
-
static void
|
47
|
+
static void *default_malloc(size_t size)
|
48
|
+
{
|
49
|
+
if (size == 0) {
|
50
|
+
return NULL;
|
51
|
+
}
|
52
|
+
return malloc(size);
|
53
|
+
}
|
41
54
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
void (*
|
55
|
+
static void *default_realloc(void *p, size_t size)
|
56
|
+
{
|
57
|
+
return realloc(p, size);
|
58
|
+
}
|
59
|
+
|
60
|
+
static void default_free(void *p)
|
61
|
+
{
|
62
|
+
free(p);
|
63
|
+
}
|
64
|
+
|
65
|
+
static void *(*__ares_malloc)(size_t size) = default_malloc;
|
66
|
+
static void *(*__ares_realloc)(void *ptr, size_t size) = default_realloc;
|
67
|
+
static void (*__ares_free)(void *ptr) = default_free;
|
68
|
+
|
69
|
+
void *ares_malloc(size_t size)
|
70
|
+
{
|
71
|
+
return __ares_malloc(size);
|
72
|
+
}
|
73
|
+
|
74
|
+
void *ares_realloc(void *ptr, size_t size)
|
75
|
+
{
|
76
|
+
return __ares_realloc(ptr, size);
|
77
|
+
}
|
78
|
+
|
79
|
+
void ares_free(void *ptr)
|
80
|
+
{
|
81
|
+
__ares_free(ptr);
|
82
|
+
}
|
83
|
+
|
84
|
+
void *ares_malloc_zero(size_t size)
|
85
|
+
{
|
86
|
+
void *ptr = ares_malloc(size);
|
87
|
+
if (ptr != NULL) {
|
88
|
+
memset(ptr, 0, size);
|
89
|
+
}
|
90
|
+
|
91
|
+
return ptr;
|
92
|
+
}
|
93
|
+
|
94
|
+
void *ares_realloc_zero(void *ptr, size_t orig_size, size_t new_size)
|
95
|
+
{
|
96
|
+
void *p = ares_realloc(ptr, new_size);
|
97
|
+
if (p == NULL) {
|
98
|
+
return NULL;
|
99
|
+
}
|
100
|
+
|
101
|
+
if (new_size > orig_size) {
|
102
|
+
memset((unsigned char *)p + orig_size, 0, new_size - orig_size);
|
103
|
+
}
|
104
|
+
|
105
|
+
return p;
|
106
|
+
}
|
53
107
|
|
54
108
|
int ares_library_init(int flags)
|
55
109
|
{
|
56
|
-
if (ares_initialized)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
}
|
110
|
+
if (ares_initialized) {
|
111
|
+
ares_initialized++;
|
112
|
+
return ARES_SUCCESS;
|
113
|
+
}
|
61
114
|
ares_initialized++;
|
62
115
|
|
63
116
|
/* NOTE: ARES_LIB_INIT_WIN32 flag no longer used */
|
@@ -67,28 +120,31 @@ int ares_library_init(int flags)
|
|
67
120
|
return ARES_SUCCESS;
|
68
121
|
}
|
69
122
|
|
70
|
-
int ares_library_init_mem(int flags,
|
71
|
-
void *(*amalloc)(size_t size),
|
123
|
+
int ares_library_init_mem(int flags, void *(*amalloc)(size_t size),
|
72
124
|
void (*afree)(void *ptr),
|
73
125
|
void *(*arealloc)(void *ptr, size_t size))
|
74
126
|
{
|
75
|
-
if (amalloc)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
127
|
+
if (amalloc) {
|
128
|
+
__ares_malloc = amalloc;
|
129
|
+
}
|
130
|
+
if (arealloc) {
|
131
|
+
__ares_realloc = arealloc;
|
132
|
+
}
|
133
|
+
if (afree) {
|
134
|
+
__ares_free = afree;
|
135
|
+
}
|
81
136
|
return ares_library_init(flags);
|
82
137
|
}
|
83
138
|
|
84
|
-
|
85
139
|
void ares_library_cleanup(void)
|
86
140
|
{
|
87
|
-
if (!ares_initialized)
|
141
|
+
if (!ares_initialized) {
|
88
142
|
return;
|
143
|
+
}
|
89
144
|
ares_initialized--;
|
90
|
-
if (ares_initialized)
|
145
|
+
if (ares_initialized) {
|
91
146
|
return;
|
147
|
+
}
|
92
148
|
|
93
149
|
/* NOTE: ARES_LIB_INIT_WIN32 flag no longer used */
|
94
150
|
|
@@ -97,17 +153,17 @@ void ares_library_cleanup(void)
|
|
97
153
|
#endif
|
98
154
|
|
99
155
|
ares_init_flags = ARES_LIB_INIT_NONE;
|
100
|
-
|
101
|
-
|
102
|
-
|
156
|
+
__ares_malloc = default_malloc;
|
157
|
+
__ares_realloc = default_realloc;
|
158
|
+
__ares_free = default_free;
|
103
159
|
}
|
104
160
|
|
105
|
-
|
106
161
|
int ares_library_initialized(void)
|
107
162
|
{
|
108
163
|
#ifdef USE_WINSOCK
|
109
|
-
if (!ares_initialized)
|
164
|
+
if (!ares_initialized) {
|
110
165
|
return ARES_ENOTINITIALIZED;
|
166
|
+
}
|
111
167
|
#endif
|
112
168
|
return ARES_SUCCESS;
|
113
169
|
}
|
@@ -0,0 +1,261 @@
|
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 2024 Brad House
|
4
|
+
*
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
10
|
+
* furnished to do so, subject to the following conditions:
|
11
|
+
*
|
12
|
+
* The above copyright notice and this permission notice (including the next
|
13
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
14
|
+
* Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*
|
24
|
+
* SPDX-License-Identifier: MIT
|
25
|
+
*/
|
26
|
+
|
27
|
+
|
28
|
+
/* IMPLEMENTATION NOTES
|
29
|
+
* ====================
|
30
|
+
*
|
31
|
+
* With very little effort we should be able to determine fairly proper timeouts
|
32
|
+
* we can use based on prior query history. We track in order to be able to
|
33
|
+
* auto-scale when network conditions change (e.g. maybe there is a provider
|
34
|
+
* failover and timings change due to that). Apple appears to do this within
|
35
|
+
* their system resolver in MacOS. Obviously we should have a minimum, maximum,
|
36
|
+
* and initial value to make sure the algorithm doesn't somehow go off the
|
37
|
+
* rails.
|
38
|
+
*
|
39
|
+
* Values:
|
40
|
+
* - Minimum Timeout: 250ms (approximate RTT half-way around the globe)
|
41
|
+
* - Maximum Timeout: 5000ms (Recommended timeout in RFC 1123), can be reduced
|
42
|
+
* by ARES_OPT_MAXTIMEOUTMS, but otherwise the bound specified by the option
|
43
|
+
* caps the retry timeout.
|
44
|
+
* - Initial Timeout: User-specified via configuration or ARES_OPT_TIMEOUTMS
|
45
|
+
* - Average latency multiplier: 5x (a local DNS server returning a cached value
|
46
|
+
* will be quicker than if it needs to recurse so we need to account for this)
|
47
|
+
* - Minimum Count for Average: 3. This is the minimum number of queries we
|
48
|
+
* need to form an average for the bucket.
|
49
|
+
*
|
50
|
+
* Per-server buckets for tracking latency over time (these are ephemeral
|
51
|
+
* meaning they don't persist once a channel is destroyed). We record both the
|
52
|
+
* current timespan for the bucket and the immediate preceding timespan in case
|
53
|
+
* of roll-overs we can still maintain recent metrics for calculations:
|
54
|
+
* - 1 minute
|
55
|
+
* - 15 minutes
|
56
|
+
* - 1 hr
|
57
|
+
* - 1 day
|
58
|
+
* - since inception
|
59
|
+
*
|
60
|
+
* Each bucket would contain:
|
61
|
+
* - timestamp (divided by interval)
|
62
|
+
* - minimum latency
|
63
|
+
* - maximum latency
|
64
|
+
* - total time
|
65
|
+
* - count
|
66
|
+
* NOTE: average latency is (total time / count), we will calculate this
|
67
|
+
* dynamically when needed
|
68
|
+
*
|
69
|
+
* Basic algorithm for calculating timeout to use would be:
|
70
|
+
* - Scan from most recent bucket to least recent
|
71
|
+
* - Check timestamp of bucket, if doesn't match current time, continue to next
|
72
|
+
* bucket
|
73
|
+
* - Check count of bucket, if its not at least the "Minimum Count for Average",
|
74
|
+
* check the previous bucket, otherwise continue to next bucket
|
75
|
+
* - If we reached the end with no bucket match, use "Initial Timeout"
|
76
|
+
* - If bucket is selected, take ("total time" / count) as Average latency,
|
77
|
+
* multiply by "Average Latency Multiplier", bound by "Minimum Timeout" and
|
78
|
+
* "Maximum Timeout"
|
79
|
+
* NOTE: The timeout calculated may not be the timeout used. If we are retrying
|
80
|
+
* the query on the same server another time, then it will use a larger value
|
81
|
+
*
|
82
|
+
* On each query reply where the response is legitimate (proper response or
|
83
|
+
* NXDOMAIN) and not something like a server error:
|
84
|
+
* - Cycle through each bucket in order
|
85
|
+
* - Check timestamp of bucket against current timestamp, if out of date
|
86
|
+
* overwrite previous entry with values, clear current values
|
87
|
+
* - Compare current minimum and maximum recorded latency against query time and
|
88
|
+
* adjust if necessary
|
89
|
+
* - Increment "count" by 1 and "total time" by the query time
|
90
|
+
*
|
91
|
+
* Other Notes:
|
92
|
+
* - This is always-on, the only user-configurable value is the initial
|
93
|
+
* timeout which will simply re-uses the current option.
|
94
|
+
* - Minimum and Maximum latencies for a bucket are currently unused but are
|
95
|
+
* there in case we find a need for them in the future.
|
96
|
+
*/
|
97
|
+
|
98
|
+
#include "ares_private.h"
|
99
|
+
|
100
|
+
/*! Minimum timeout value. Chosen due to it being approximately RTT half-way
|
101
|
+
* around the world */
|
102
|
+
#define MIN_TIMEOUT_MS 250
|
103
|
+
|
104
|
+
/*! Multiplier to apply to average latency to come up with an initial timeout */
|
105
|
+
#define AVG_TIMEOUT_MULTIPLIER 5
|
106
|
+
|
107
|
+
/*! Upper timeout bounds, only used if channel->maxtimeout not set */
|
108
|
+
#define MAX_TIMEOUT_MS 5000
|
109
|
+
|
110
|
+
/*! Minimum queries required to form an average */
|
111
|
+
#define MIN_COUNT_FOR_AVERAGE 3
|
112
|
+
|
113
|
+
static time_t ares_metric_timestamp(ares_server_bucket_t bucket,
|
114
|
+
const ares_timeval_t *now,
|
115
|
+
ares_bool_t is_previous)
|
116
|
+
{
|
117
|
+
time_t divisor = 1; /* Silence bogus MSVC warning by setting default value */
|
118
|
+
|
119
|
+
switch (bucket) {
|
120
|
+
case ARES_METRIC_1MINUTE:
|
121
|
+
divisor = 60;
|
122
|
+
break;
|
123
|
+
case ARES_METRIC_15MINUTES:
|
124
|
+
divisor = 15 * 60;
|
125
|
+
break;
|
126
|
+
case ARES_METRIC_1HOUR:
|
127
|
+
divisor = 60 * 60;
|
128
|
+
break;
|
129
|
+
case ARES_METRIC_1DAY:
|
130
|
+
divisor = 24 * 60 * 60;
|
131
|
+
break;
|
132
|
+
case ARES_METRIC_INCEPTION:
|
133
|
+
return is_previous ? 0 : 1;
|
134
|
+
case ARES_METRIC_COUNT:
|
135
|
+
return 0; /* Invalid! */
|
136
|
+
}
|
137
|
+
|
138
|
+
if (is_previous) {
|
139
|
+
if (divisor >= now->sec) {
|
140
|
+
return 0;
|
141
|
+
}
|
142
|
+
return (time_t)((now->sec - divisor) / divisor);
|
143
|
+
}
|
144
|
+
|
145
|
+
return (time_t)(now->sec / divisor);
|
146
|
+
}
|
147
|
+
|
148
|
+
void ares_metrics_record(const ares_query_t *query, ares_server_t *server,
|
149
|
+
ares_status_t status, const ares_dns_record_t *dnsrec)
|
150
|
+
{
|
151
|
+
ares_timeval_t now;
|
152
|
+
ares_timeval_t tvdiff;
|
153
|
+
unsigned int query_ms;
|
154
|
+
ares_dns_rcode_t rcode;
|
155
|
+
ares_server_bucket_t i;
|
156
|
+
|
157
|
+
if (status != ARES_SUCCESS) {
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
|
161
|
+
if (server == NULL) {
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
|
165
|
+
ares_tvnow(&now);
|
166
|
+
|
167
|
+
rcode = ares_dns_record_get_rcode(dnsrec);
|
168
|
+
if (rcode != ARES_RCODE_NOERROR && rcode != ARES_RCODE_NXDOMAIN) {
|
169
|
+
return;
|
170
|
+
}
|
171
|
+
|
172
|
+
ares_timeval_diff(&tvdiff, &query->ts, &now);
|
173
|
+
query_ms = (unsigned int)((tvdiff.sec * 1000) + (tvdiff.usec / 1000));
|
174
|
+
if (query_ms == 0) {
|
175
|
+
query_ms = 1;
|
176
|
+
}
|
177
|
+
|
178
|
+
/* Place in each bucket */
|
179
|
+
for (i = 0; i < ARES_METRIC_COUNT; i++) {
|
180
|
+
time_t ts = ares_metric_timestamp(i, &now, ARES_FALSE);
|
181
|
+
|
182
|
+
/* Copy metrics to prev and clear */
|
183
|
+
if (ts != server->metrics[i].ts) {
|
184
|
+
server->metrics[i].prev_ts = server->metrics[i].ts;
|
185
|
+
server->metrics[i].prev_total_ms = server->metrics[i].total_ms;
|
186
|
+
server->metrics[i].prev_total_count = server->metrics[i].total_count;
|
187
|
+
server->metrics[i].ts = ts;
|
188
|
+
server->metrics[i].latency_min_ms = 0;
|
189
|
+
server->metrics[i].latency_max_ms = 0;
|
190
|
+
server->metrics[i].total_ms = 0;
|
191
|
+
server->metrics[i].total_count = 0;
|
192
|
+
}
|
193
|
+
|
194
|
+
if (server->metrics[i].latency_min_ms == 0 ||
|
195
|
+
server->metrics[i].latency_min_ms > query_ms) {
|
196
|
+
server->metrics[i].latency_min_ms = query_ms;
|
197
|
+
}
|
198
|
+
|
199
|
+
if (query_ms > server->metrics[i].latency_max_ms) {
|
200
|
+
server->metrics[i].latency_max_ms = query_ms;
|
201
|
+
}
|
202
|
+
|
203
|
+
server->metrics[i].total_count++;
|
204
|
+
server->metrics[i].total_ms += (ares_uint64_t)query_ms;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
size_t ares_metrics_server_timeout(const ares_server_t *server,
|
209
|
+
const ares_timeval_t *now)
|
210
|
+
{
|
211
|
+
const ares_channel_t *channel = server->channel;
|
212
|
+
ares_server_bucket_t i;
|
213
|
+
size_t timeout_ms = 0;
|
214
|
+
size_t max_timeout_ms;
|
215
|
+
|
216
|
+
for (i = 0; i < ARES_METRIC_COUNT; i++) {
|
217
|
+
time_t ts = ares_metric_timestamp(i, now, ARES_FALSE);
|
218
|
+
|
219
|
+
/* This ts has been invalidated, see if we should use the previous
|
220
|
+
* time period */
|
221
|
+
if (ts != server->metrics[i].ts ||
|
222
|
+
server->metrics[i].total_count < MIN_COUNT_FOR_AVERAGE) {
|
223
|
+
time_t prev_ts = ares_metric_timestamp(i, now, ARES_TRUE);
|
224
|
+
if (prev_ts != server->metrics[i].prev_ts ||
|
225
|
+
server->metrics[i].prev_total_count < MIN_COUNT_FOR_AVERAGE) {
|
226
|
+
/* Move onto next bucket */
|
227
|
+
continue;
|
228
|
+
}
|
229
|
+
/* Calculate average time for previous bucket */
|
230
|
+
timeout_ms = (size_t)(server->metrics[i].prev_total_ms /
|
231
|
+
server->metrics[i].prev_total_count);
|
232
|
+
} else {
|
233
|
+
/* Calculate average time for current bucket*/
|
234
|
+
timeout_ms =
|
235
|
+
(size_t)(server->metrics[i].total_ms / server->metrics[i].total_count);
|
236
|
+
}
|
237
|
+
|
238
|
+
/* Multiply average by constant to get timeout value */
|
239
|
+
timeout_ms *= AVG_TIMEOUT_MULTIPLIER;
|
240
|
+
break;
|
241
|
+
}
|
242
|
+
|
243
|
+
/* If we're here, that means its the first query for the server, so we just
|
244
|
+
* use the initial default timeout */
|
245
|
+
if (timeout_ms == 0) {
|
246
|
+
timeout_ms = channel->timeout;
|
247
|
+
}
|
248
|
+
|
249
|
+
/* don't go below lower bounds */
|
250
|
+
if (timeout_ms < MIN_TIMEOUT_MS) {
|
251
|
+
timeout_ms = MIN_TIMEOUT_MS;
|
252
|
+
}
|
253
|
+
|
254
|
+
/* don't go above upper bounds */
|
255
|
+
max_timeout_ms = channel->maxtimeout ? channel->maxtimeout : MAX_TIMEOUT_MS;
|
256
|
+
if (timeout_ms > max_timeout_ms) {
|
257
|
+
timeout_ms = max_timeout_ms;
|
258
|
+
}
|
259
|
+
|
260
|
+
return timeout_ms;
|
261
|
+
}
|