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
@@ -0,0 +1,188 @@
|
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 2023 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
|
+
#include "ares_private.h"
|
27
|
+
#include "ares_htable.h"
|
28
|
+
#include "ares_htable_szvp.h"
|
29
|
+
|
30
|
+
struct ares_htable_szvp {
|
31
|
+
ares_htable_szvp_val_free_t free_val;
|
32
|
+
ares_htable_t *hash;
|
33
|
+
};
|
34
|
+
|
35
|
+
typedef struct {
|
36
|
+
size_t key;
|
37
|
+
void *val;
|
38
|
+
ares_htable_szvp_t *parent;
|
39
|
+
} ares_htable_szvp_bucket_t;
|
40
|
+
|
41
|
+
void ares_htable_szvp_destroy(ares_htable_szvp_t *htable)
|
42
|
+
{
|
43
|
+
if (htable == NULL) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
ares_htable_destroy(htable->hash);
|
48
|
+
ares_free(htable);
|
49
|
+
}
|
50
|
+
|
51
|
+
static unsigned int hash_func(const void *key, unsigned int seed)
|
52
|
+
{
|
53
|
+
const size_t *arg = key;
|
54
|
+
return ares_htable_hash_FNV1a((const unsigned char *)arg, sizeof(*arg), seed);
|
55
|
+
}
|
56
|
+
|
57
|
+
static const void *bucket_key(const void *bucket)
|
58
|
+
{
|
59
|
+
const ares_htable_szvp_bucket_t *arg = bucket;
|
60
|
+
return &arg->key;
|
61
|
+
}
|
62
|
+
|
63
|
+
static void bucket_free(void *bucket)
|
64
|
+
{
|
65
|
+
ares_htable_szvp_bucket_t *arg = bucket;
|
66
|
+
|
67
|
+
if (arg->parent->free_val) {
|
68
|
+
arg->parent->free_val(arg->val);
|
69
|
+
}
|
70
|
+
|
71
|
+
ares_free(arg);
|
72
|
+
}
|
73
|
+
|
74
|
+
static ares_bool_t key_eq(const void *key1, const void *key2)
|
75
|
+
{
|
76
|
+
const size_t *k1 = key1;
|
77
|
+
const size_t *k2 = key2;
|
78
|
+
|
79
|
+
if (*k1 == *k2) {
|
80
|
+
return ARES_TRUE;
|
81
|
+
}
|
82
|
+
|
83
|
+
return ARES_FALSE;
|
84
|
+
}
|
85
|
+
|
86
|
+
ares_htable_szvp_t *
|
87
|
+
ares_htable_szvp_create(ares_htable_szvp_val_free_t val_free)
|
88
|
+
{
|
89
|
+
ares_htable_szvp_t *htable = ares_malloc(sizeof(*htable));
|
90
|
+
if (htable == NULL) {
|
91
|
+
goto fail;
|
92
|
+
}
|
93
|
+
|
94
|
+
htable->hash = ares_htable_create(hash_func, bucket_key, bucket_free, key_eq);
|
95
|
+
if (htable->hash == NULL) {
|
96
|
+
goto fail;
|
97
|
+
}
|
98
|
+
|
99
|
+
htable->free_val = val_free;
|
100
|
+
|
101
|
+
return htable;
|
102
|
+
|
103
|
+
fail:
|
104
|
+
if (htable) {
|
105
|
+
ares_htable_destroy(htable->hash);
|
106
|
+
ares_free(htable);
|
107
|
+
}
|
108
|
+
return NULL;
|
109
|
+
}
|
110
|
+
|
111
|
+
ares_bool_t ares_htable_szvp_insert(ares_htable_szvp_t *htable, size_t key,
|
112
|
+
void *val)
|
113
|
+
{
|
114
|
+
ares_htable_szvp_bucket_t *bucket = NULL;
|
115
|
+
|
116
|
+
if (htable == NULL) {
|
117
|
+
goto fail;
|
118
|
+
}
|
119
|
+
|
120
|
+
bucket = ares_malloc(sizeof(*bucket));
|
121
|
+
if (bucket == NULL) {
|
122
|
+
goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
|
123
|
+
}
|
124
|
+
|
125
|
+
bucket->parent = htable;
|
126
|
+
bucket->key = key;
|
127
|
+
bucket->val = val;
|
128
|
+
|
129
|
+
if (!ares_htable_insert(htable->hash, bucket)) {
|
130
|
+
goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
|
131
|
+
}
|
132
|
+
|
133
|
+
return ARES_TRUE;
|
134
|
+
|
135
|
+
fail:
|
136
|
+
if (bucket) {
|
137
|
+
ares_free(bucket); /* LCOV_EXCL_LINE: OutOfMemory */
|
138
|
+
}
|
139
|
+
return ARES_FALSE;
|
140
|
+
}
|
141
|
+
|
142
|
+
ares_bool_t ares_htable_szvp_get(const ares_htable_szvp_t *htable, size_t key,
|
143
|
+
void **val)
|
144
|
+
{
|
145
|
+
ares_htable_szvp_bucket_t *bucket = NULL;
|
146
|
+
|
147
|
+
if (val) {
|
148
|
+
*val = NULL;
|
149
|
+
}
|
150
|
+
|
151
|
+
if (htable == NULL) {
|
152
|
+
return ARES_FALSE;
|
153
|
+
}
|
154
|
+
|
155
|
+
bucket = ares_htable_get(htable->hash, &key);
|
156
|
+
if (bucket == NULL) {
|
157
|
+
return ARES_FALSE;
|
158
|
+
}
|
159
|
+
|
160
|
+
if (val) {
|
161
|
+
*val = bucket->val;
|
162
|
+
}
|
163
|
+
return ARES_TRUE;
|
164
|
+
}
|
165
|
+
|
166
|
+
void *ares_htable_szvp_get_direct(const ares_htable_szvp_t *htable, size_t key)
|
167
|
+
{
|
168
|
+
void *val = NULL;
|
169
|
+
ares_htable_szvp_get(htable, key, &val);
|
170
|
+
return val;
|
171
|
+
}
|
172
|
+
|
173
|
+
ares_bool_t ares_htable_szvp_remove(ares_htable_szvp_t *htable, size_t key)
|
174
|
+
{
|
175
|
+
if (htable == NULL) {
|
176
|
+
return ARES_FALSE;
|
177
|
+
}
|
178
|
+
|
179
|
+
return ares_htable_remove(htable->hash, &key);
|
180
|
+
}
|
181
|
+
|
182
|
+
size_t ares_htable_szvp_num_keys(const ares_htable_szvp_t *htable)
|
183
|
+
{
|
184
|
+
if (htable == NULL) {
|
185
|
+
return 0;
|
186
|
+
}
|
187
|
+
return ares_htable_num_keys(htable->hash);
|
188
|
+
}
|
@@ -0,0 +1,186 @@
|
|
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
|
+
#include "ares_private.h"
|
27
|
+
#include "ares_htable.h"
|
28
|
+
#include "ares_htable_vpstr.h"
|
29
|
+
|
30
|
+
struct ares_htable_vpstr {
|
31
|
+
ares_htable_t *hash;
|
32
|
+
};
|
33
|
+
|
34
|
+
typedef struct {
|
35
|
+
void *key;
|
36
|
+
char *val;
|
37
|
+
ares_htable_vpstr_t *parent;
|
38
|
+
} ares_htable_vpstr_bucket_t;
|
39
|
+
|
40
|
+
void ares_htable_vpstr_destroy(ares_htable_vpstr_t *htable)
|
41
|
+
{
|
42
|
+
if (htable == NULL) {
|
43
|
+
return; /* LCOV_EXCL_LINE: DefensiveCoding */
|
44
|
+
}
|
45
|
+
|
46
|
+
ares_htable_destroy(htable->hash);
|
47
|
+
ares_free(htable);
|
48
|
+
}
|
49
|
+
|
50
|
+
static unsigned int hash_func(const void *key, unsigned int seed)
|
51
|
+
{
|
52
|
+
return ares_htable_hash_FNV1a((const unsigned char *)&key, sizeof(key), seed);
|
53
|
+
}
|
54
|
+
|
55
|
+
static const void *bucket_key(const void *bucket)
|
56
|
+
{
|
57
|
+
const ares_htable_vpstr_bucket_t *arg = bucket;
|
58
|
+
return arg->key;
|
59
|
+
}
|
60
|
+
|
61
|
+
static void bucket_free(void *bucket)
|
62
|
+
{
|
63
|
+
ares_htable_vpstr_bucket_t *arg = bucket;
|
64
|
+
|
65
|
+
ares_free(arg->val);
|
66
|
+
|
67
|
+
ares_free(arg);
|
68
|
+
}
|
69
|
+
|
70
|
+
static ares_bool_t key_eq(const void *key1, const void *key2)
|
71
|
+
{
|
72
|
+
if (key1 == key2) {
|
73
|
+
return ARES_TRUE;
|
74
|
+
}
|
75
|
+
|
76
|
+
return ARES_FALSE;
|
77
|
+
}
|
78
|
+
|
79
|
+
ares_htable_vpstr_t *ares_htable_vpstr_create(void)
|
80
|
+
{
|
81
|
+
ares_htable_vpstr_t *htable = ares_malloc(sizeof(*htable));
|
82
|
+
if (htable == NULL) {
|
83
|
+
goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
|
84
|
+
}
|
85
|
+
|
86
|
+
htable->hash = ares_htable_create(hash_func, bucket_key, bucket_free, key_eq);
|
87
|
+
if (htable->hash == NULL) {
|
88
|
+
goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
|
89
|
+
}
|
90
|
+
|
91
|
+
return htable;
|
92
|
+
|
93
|
+
/* LCOV_EXCL_START: OutOfMemory */
|
94
|
+
fail:
|
95
|
+
if (htable) {
|
96
|
+
ares_htable_destroy(htable->hash);
|
97
|
+
ares_free(htable);
|
98
|
+
}
|
99
|
+
return NULL;
|
100
|
+
/* LCOV_EXCL_STOP */
|
101
|
+
}
|
102
|
+
|
103
|
+
ares_bool_t ares_htable_vpstr_insert(ares_htable_vpstr_t *htable, void *key,
|
104
|
+
const char *val)
|
105
|
+
{
|
106
|
+
ares_htable_vpstr_bucket_t *bucket = NULL;
|
107
|
+
|
108
|
+
if (htable == NULL) {
|
109
|
+
goto fail;
|
110
|
+
}
|
111
|
+
|
112
|
+
bucket = ares_malloc(sizeof(*bucket));
|
113
|
+
if (bucket == NULL) {
|
114
|
+
goto fail;
|
115
|
+
}
|
116
|
+
|
117
|
+
bucket->parent = htable;
|
118
|
+
bucket->key = key;
|
119
|
+
bucket->val = ares_strdup(val);
|
120
|
+
if (bucket->val == NULL) {
|
121
|
+
goto fail;
|
122
|
+
}
|
123
|
+
|
124
|
+
if (!ares_htable_insert(htable->hash, bucket)) {
|
125
|
+
goto fail;
|
126
|
+
}
|
127
|
+
|
128
|
+
return ARES_TRUE;
|
129
|
+
|
130
|
+
fail:
|
131
|
+
if (bucket) {
|
132
|
+
ares_free(bucket->val);
|
133
|
+
ares_free(bucket);
|
134
|
+
}
|
135
|
+
return ARES_FALSE;
|
136
|
+
}
|
137
|
+
|
138
|
+
ares_bool_t ares_htable_vpstr_get(const ares_htable_vpstr_t *htable,
|
139
|
+
const void *key, const char **val)
|
140
|
+
{
|
141
|
+
const ares_htable_vpstr_bucket_t *bucket = NULL;
|
142
|
+
|
143
|
+
if (val) {
|
144
|
+
*val = NULL;
|
145
|
+
}
|
146
|
+
|
147
|
+
if (htable == NULL) {
|
148
|
+
return ARES_FALSE;
|
149
|
+
}
|
150
|
+
|
151
|
+
bucket = ares_htable_get(htable->hash, key);
|
152
|
+
if (bucket == NULL) {
|
153
|
+
return ARES_FALSE;
|
154
|
+
}
|
155
|
+
|
156
|
+
if (val) {
|
157
|
+
*val = bucket->val;
|
158
|
+
}
|
159
|
+
return ARES_TRUE;
|
160
|
+
}
|
161
|
+
|
162
|
+
const char *ares_htable_vpstr_get_direct(const ares_htable_vpstr_t *htable,
|
163
|
+
const void *key)
|
164
|
+
{
|
165
|
+
const char *val = NULL;
|
166
|
+
ares_htable_vpstr_get(htable, key, &val);
|
167
|
+
return val;
|
168
|
+
}
|
169
|
+
|
170
|
+
ares_bool_t ares_htable_vpstr_remove(ares_htable_vpstr_t *htable,
|
171
|
+
const void *key)
|
172
|
+
{
|
173
|
+
if (htable == NULL) {
|
174
|
+
return ARES_FALSE;
|
175
|
+
}
|
176
|
+
|
177
|
+
return ares_htable_remove(htable->hash, key);
|
178
|
+
}
|
179
|
+
|
180
|
+
size_t ares_htable_vpstr_num_keys(const ares_htable_vpstr_t *htable)
|
181
|
+
{
|
182
|
+
if (htable == NULL) {
|
183
|
+
return 0;
|
184
|
+
}
|
185
|
+
return ares_htable_num_keys(htable->hash);
|
186
|
+
}
|
@@ -0,0 +1,194 @@
|
|
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
|
+
#include "ares_private.h"
|
27
|
+
#include "ares_htable.h"
|
28
|
+
#include "ares_htable_vpvp.h"
|
29
|
+
|
30
|
+
struct ares_htable_vpvp {
|
31
|
+
ares_htable_vpvp_key_free_t free_key;
|
32
|
+
ares_htable_vpvp_val_free_t free_val;
|
33
|
+
ares_htable_t *hash;
|
34
|
+
};
|
35
|
+
|
36
|
+
typedef struct {
|
37
|
+
void *key;
|
38
|
+
void *val;
|
39
|
+
ares_htable_vpvp_t *parent;
|
40
|
+
} ares_htable_vpvp_bucket_t;
|
41
|
+
|
42
|
+
void ares_htable_vpvp_destroy(ares_htable_vpvp_t *htable)
|
43
|
+
{
|
44
|
+
if (htable == NULL) {
|
45
|
+
return; /* LCOV_EXCL_LINE: DefensiveCoding */
|
46
|
+
}
|
47
|
+
|
48
|
+
ares_htable_destroy(htable->hash);
|
49
|
+
ares_free(htable);
|
50
|
+
}
|
51
|
+
|
52
|
+
static unsigned int hash_func(const void *key, unsigned int seed)
|
53
|
+
{
|
54
|
+
return ares_htable_hash_FNV1a((const unsigned char *)&key, sizeof(key), seed);
|
55
|
+
}
|
56
|
+
|
57
|
+
static const void *bucket_key(const void *bucket)
|
58
|
+
{
|
59
|
+
const ares_htable_vpvp_bucket_t *arg = bucket;
|
60
|
+
return arg->key;
|
61
|
+
}
|
62
|
+
|
63
|
+
static void bucket_free(void *bucket)
|
64
|
+
{
|
65
|
+
ares_htable_vpvp_bucket_t *arg = bucket;
|
66
|
+
|
67
|
+
if (arg->parent->free_key) {
|
68
|
+
arg->parent->free_key(arg->key);
|
69
|
+
}
|
70
|
+
|
71
|
+
if (arg->parent->free_val) {
|
72
|
+
arg->parent->free_val(arg->val);
|
73
|
+
}
|
74
|
+
|
75
|
+
ares_free(arg);
|
76
|
+
}
|
77
|
+
|
78
|
+
static ares_bool_t key_eq(const void *key1, const void *key2)
|
79
|
+
{
|
80
|
+
if (key1 == key2) {
|
81
|
+
return ARES_TRUE;
|
82
|
+
}
|
83
|
+
|
84
|
+
return ARES_FALSE;
|
85
|
+
}
|
86
|
+
|
87
|
+
ares_htable_vpvp_t *
|
88
|
+
ares_htable_vpvp_create(ares_htable_vpvp_key_free_t key_free,
|
89
|
+
ares_htable_vpvp_val_free_t val_free)
|
90
|
+
{
|
91
|
+
ares_htable_vpvp_t *htable = ares_malloc(sizeof(*htable));
|
92
|
+
if (htable == NULL) {
|
93
|
+
goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
|
94
|
+
}
|
95
|
+
|
96
|
+
htable->hash = ares_htable_create(hash_func, bucket_key, bucket_free, key_eq);
|
97
|
+
if (htable->hash == NULL) {
|
98
|
+
goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
|
99
|
+
}
|
100
|
+
|
101
|
+
htable->free_key = key_free;
|
102
|
+
htable->free_val = val_free;
|
103
|
+
|
104
|
+
return htable;
|
105
|
+
|
106
|
+
/* LCOV_EXCL_START: OutOfMemory */
|
107
|
+
fail:
|
108
|
+
if (htable) {
|
109
|
+
ares_htable_destroy(htable->hash);
|
110
|
+
ares_free(htable);
|
111
|
+
}
|
112
|
+
return NULL;
|
113
|
+
/* LCOV_EXCL_STOP */
|
114
|
+
}
|
115
|
+
|
116
|
+
ares_bool_t ares_htable_vpvp_insert(ares_htable_vpvp_t *htable, void *key,
|
117
|
+
void *val)
|
118
|
+
{
|
119
|
+
ares_htable_vpvp_bucket_t *bucket = NULL;
|
120
|
+
|
121
|
+
if (htable == NULL) {
|
122
|
+
goto fail;
|
123
|
+
}
|
124
|
+
|
125
|
+
bucket = ares_malloc(sizeof(*bucket));
|
126
|
+
if (bucket == NULL) {
|
127
|
+
goto fail;
|
128
|
+
}
|
129
|
+
|
130
|
+
bucket->parent = htable;
|
131
|
+
bucket->key = key;
|
132
|
+
bucket->val = val;
|
133
|
+
|
134
|
+
if (!ares_htable_insert(htable->hash, bucket)) {
|
135
|
+
goto fail;
|
136
|
+
}
|
137
|
+
|
138
|
+
return ARES_TRUE;
|
139
|
+
|
140
|
+
fail:
|
141
|
+
if (bucket) {
|
142
|
+
ares_free(bucket);
|
143
|
+
}
|
144
|
+
return ARES_FALSE;
|
145
|
+
}
|
146
|
+
|
147
|
+
ares_bool_t ares_htable_vpvp_get(const ares_htable_vpvp_t *htable,
|
148
|
+
const void *key, void **val)
|
149
|
+
{
|
150
|
+
ares_htable_vpvp_bucket_t *bucket = NULL;
|
151
|
+
|
152
|
+
if (val) {
|
153
|
+
*val = NULL;
|
154
|
+
}
|
155
|
+
|
156
|
+
if (htable == NULL) {
|
157
|
+
return ARES_FALSE;
|
158
|
+
}
|
159
|
+
|
160
|
+
bucket = ares_htable_get(htable->hash, key);
|
161
|
+
if (bucket == NULL) {
|
162
|
+
return ARES_FALSE;
|
163
|
+
}
|
164
|
+
|
165
|
+
if (val) {
|
166
|
+
*val = bucket->val;
|
167
|
+
}
|
168
|
+
return ARES_TRUE;
|
169
|
+
}
|
170
|
+
|
171
|
+
void *ares_htable_vpvp_get_direct(const ares_htable_vpvp_t *htable,
|
172
|
+
const void *key)
|
173
|
+
{
|
174
|
+
void *val = NULL;
|
175
|
+
ares_htable_vpvp_get(htable, key, &val);
|
176
|
+
return val;
|
177
|
+
}
|
178
|
+
|
179
|
+
ares_bool_t ares_htable_vpvp_remove(ares_htable_vpvp_t *htable, const void *key)
|
180
|
+
{
|
181
|
+
if (htable == NULL) {
|
182
|
+
return ARES_FALSE;
|
183
|
+
}
|
184
|
+
|
185
|
+
return ares_htable_remove(htable->hash, key);
|
186
|
+
}
|
187
|
+
|
188
|
+
size_t ares_htable_vpvp_num_keys(const ares_htable_vpvp_t *htable)
|
189
|
+
{
|
190
|
+
if (htable == NULL) {
|
191
|
+
return 0;
|
192
|
+
}
|
193
|
+
return ares_htable_num_keys(htable->hash);
|
194
|
+
}
|