grpc 1.18.0 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +4731 -7404
- data/etc/roots.pem +146 -0
- data/include/grpc/grpc.h +11 -6
- data/include/grpc/grpc_security.h +297 -4
- data/include/grpc/grpc_security_constants.h +1 -1
- data/include/grpc/impl/codegen/byte_buffer.h +13 -0
- data/include/grpc/impl/codegen/gpr_types.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +30 -7
- data/include/grpc/impl/codegen/port_platform.h +88 -7
- data/include/grpc/impl/codegen/slice.h +2 -22
- data/include/grpc/impl/codegen/status.h +2 -1
- data/include/grpc/impl/codegen/sync_posix.h +18 -0
- data/include/grpc/slice.h +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +21 -16
- data/src/core/ext/filters/client_channel/backup_poller.h +8 -2
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +3 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +2435 -1557
- data/src/core/ext/filters/client_channel/client_channel.h +2 -10
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +6 -89
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +8 -33
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +22 -34
- data/src/core/ext/filters/client_channel/client_channel_factory.h +19 -38
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +9 -11
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +179 -0
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +59 -55
- data/src/core/ext/filters/client_channel/health/health_check_client.h +20 -9
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +146 -157
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +29 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +844 -859
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +2 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +14 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +16 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +185 -312
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +143 -375
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +192 -245
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +1554 -955
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +0 -43
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +14 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy.cc +115 -22
- data/src/core/ext/filters/client_channel/lb_policy.h +260 -129
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +5 -2
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +107 -4
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -3
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +56 -0
- data/src/core/ext/filters/client_channel/parse_address.cc +24 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +121 -122
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +84 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +179 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +24 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +111 -47
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +7 -13
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +39 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +0 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +2 -64
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
- data/src/core/{lib/iomgr/network_status_tracker.cc → ext/filters/client_channel/resolver/dns/dns_resolver_selection.h} +8 -15
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +36 -82
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +111 -72
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +13 -8
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +28 -63
- data/src/core/ext/filters/client_channel/resolver.cc +54 -1
- data/src/core/ext/filters/client_channel/resolver.h +52 -23
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -1
- data/src/core/ext/filters/client_channel/resolver_registry.cc +5 -2
- data/src/core/ext/filters/client_channel/resolver_registry.h +5 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +368 -241
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +58 -76
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +543 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +139 -0
- data/src/core/ext/filters/client_channel/server_address.cc +4 -54
- data/src/core/ext/filters/client_channel/server_address.h +1 -13
- data/src/core/ext/filters/client_channel/service_config.cc +329 -0
- data/src/core/ext/filters/client_channel/service_config.h +205 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +803 -838
- data/src/core/ext/filters/client_channel/subchannel.h +295 -128
- data/src/core/ext/filters/client_channel/subchannel_interface.h +113 -0
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +94 -0
- data/src/core/ext/filters/deadline/deadline_filter.cc +3 -4
- data/src/core/ext/filters/deadline/deadline_filter.h +3 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +7 -5
- data/src/core/ext/filters/http/client/http_client_filter.h +1 -1
- data/src/core/ext/filters/http/client_authority_filter.cc +6 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -3
- data/src/core/ext/filters/http/server/http_server_filter.cc +18 -12
- data/src/core/ext/filters/max_age/max_age_filter.cc +5 -2
- data/src/core/ext/filters/message_size/message_size_filter.cc +119 -77
- data/src/core/ext/filters/message_size/message_size_filter.h +33 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.h +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -12
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +45 -47
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +134 -143
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +68 -21
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +4 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +9 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +156 -94
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +33 -37
- data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +8 -6
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -4
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +74 -55
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +33 -11
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -2
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +7 -14
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -1
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +9 -5
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +9 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +43 -30
- data/src/core/ext/transport/chttp2/transport/parsing.cc +52 -70
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +70 -33
- data/src/core/ext/transport/inproc/inproc_transport.cc +26 -18
- data/src/core/lib/channel/channel_args.cc +2 -101
- data/src/core/lib/channel/channel_args.h +3 -37
- data/src/core/lib/channel/channel_stack.h +10 -6
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channel_trace.h +4 -4
- data/src/core/lib/channel/channelz.cc +168 -38
- data/src/core/lib/channel/channelz.h +40 -44
- data/src/core/lib/channel/channelz_registry.cc +75 -107
- data/src/core/lib/channel/channelz_registry.h +10 -28
- data/src/core/lib/channel/connected_channel.cc +2 -2
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/channel/handshaker.cc +151 -218
- data/src/core/lib/channel/handshaker.h +110 -101
- data/src/core/lib/channel/handshaker_factory.h +11 -19
- data/src/core/lib/channel/handshaker_registry.cc +67 -51
- data/src/core/lib/channel/handshaker_registry.h +21 -16
- data/src/core/lib/compression/algorithm_metadata.h +3 -3
- data/src/core/lib/compression/compression.cc +14 -9
- data/src/core/lib/compression/compression_args.cc +127 -0
- data/src/core/lib/compression/compression_args.h +55 -0
- data/src/core/lib/compression/compression_internal.cc +16 -12
- data/src/core/lib/compression/compression_internal.h +1 -1
- data/src/core/lib/compression/stream_compression.cc +3 -2
- data/src/core/lib/compression/stream_compression.h +2 -2
- data/src/core/lib/compression/stream_compression_gzip.cc +9 -9
- data/src/core/lib/debug/trace.cc +13 -7
- data/src/core/lib/debug/trace.h +14 -1
- data/src/core/lib/gpr/arena.h +13 -9
- data/src/core/lib/gpr/cpu_posix.cc +5 -3
- data/src/core/lib/gpr/env.h +3 -6
- data/src/core/lib/gpr/env_linux.cc +6 -1
- data/src/core/lib/gpr/env_posix.cc +5 -0
- data/src/core/lib/gpr/env_windows.cc +7 -5
- data/src/core/lib/gpr/log.cc +9 -13
- data/src/core/lib/gpr/log_posix.cc +2 -1
- data/src/core/lib/gpr/string.cc +20 -7
- data/src/core/lib/gpr/string.h +10 -3
- data/src/core/lib/gpr/sync_posix.cc +65 -4
- data/src/core/lib/gpr/time.cc +8 -0
- data/src/core/lib/gpr/time_posix.cc +21 -2
- data/src/core/lib/gprpp/arena.cc +103 -0
- data/src/core/lib/gprpp/arena.h +121 -0
- data/src/core/lib/gprpp/atomic.h +75 -5
- data/src/core/lib/gprpp/fork.cc +13 -32
- data/src/core/lib/gprpp/fork.h +5 -1
- data/src/core/lib/gprpp/global_config.h +96 -0
- data/src/core/lib/gprpp/global_config_custom.h +29 -0
- data/src/core/lib/gprpp/global_config_env.cc +135 -0
- data/src/core/lib/gprpp/global_config_env.h +131 -0
- data/src/core/lib/gprpp/global_config_generic.h +44 -0
- data/src/core/lib/gprpp/inlined_vector.h +8 -0
- data/src/core/lib/gprpp/map.h +436 -0
- data/src/core/lib/gprpp/memory.h +2 -2
- data/src/core/lib/gprpp/optional.h +48 -0
- data/src/core/lib/gprpp/orphanable.h +6 -5
- data/src/core/lib/gprpp/{mutex_lock.h → pair.h} +15 -19
- data/src/core/lib/gprpp/ref_counted.h +36 -17
- data/src/core/lib/gprpp/sync.h +126 -0
- data/src/core/lib/gprpp/thd.h +42 -7
- data/src/core/lib/gprpp/thd_posix.cc +31 -13
- data/src/core/lib/gprpp/thd_windows.cc +47 -34
- data/src/core/lib/http/httpcli.cc +6 -5
- data/src/core/lib/http/httpcli_security_connector.cc +13 -15
- data/src/core/lib/http/parser.cc +3 -2
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/buffer_list.cc +182 -24
- data/src/core/lib/iomgr/buffer_list.h +72 -10
- data/src/core/lib/iomgr/call_combiner.cc +84 -90
- data/src/core/lib/iomgr/call_combiner.h +75 -82
- data/src/core/lib/iomgr/cfstream_handle.cc +203 -0
- data/src/core/lib/iomgr/cfstream_handle.h +86 -0
- data/src/core/lib/iomgr/combiner.cc +11 -3
- data/src/core/lib/iomgr/combiner.h +1 -1
- data/src/core/lib/iomgr/endpoint.cc +2 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +375 -0
- data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/error.cc +21 -17
- data/src/core/lib/iomgr/error.h +36 -6
- data/src/core/lib/iomgr/error_cfstream.cc +52 -0
- data/src/core/lib/iomgr/error_cfstream.h +31 -0
- data/src/core/lib/iomgr/error_internal.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +44 -28
- data/src/core/lib/iomgr/ev_epollex_linux.cc +173 -194
- data/src/core/lib/iomgr/ev_poll_posix.cc +16 -487
- data/src/core/lib/iomgr/ev_posix.cc +29 -19
- data/src/core/lib/iomgr/ev_posix.h +19 -3
- data/src/core/lib/iomgr/ev_windows.cc +2 -2
- data/src/core/lib/iomgr/exec_ctx.cc +1 -0
- data/src/core/lib/iomgr/exec_ctx.h +137 -8
- data/src/core/lib/iomgr/executor.cc +147 -95
- data/src/core/lib/iomgr/executor.h +55 -49
- data/src/core/lib/iomgr/fork_posix.cc +6 -5
- data/src/core/lib/{gprpp/atomic_with_std.h → iomgr/grpc_if_nametoindex.h} +8 -13
- data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
- data/src/core/lib/iomgr/{network_status_tracker.h → grpc_if_nametoindex_unsupported.cc} +15 -9
- data/src/core/lib/iomgr/internal_errqueue.cc +3 -5
- data/src/core/lib/iomgr/internal_errqueue.h +105 -3
- data/src/core/lib/iomgr/iomgr.cc +20 -13
- data/src/core/lib/iomgr/iomgr.h +15 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +17 -3
- data/src/core/lib/iomgr/iomgr_custom.h +2 -0
- data/src/core/lib/iomgr/iomgr_internal.cc +10 -0
- data/src/core/lib/iomgr/iomgr_internal.h +12 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +19 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +93 -0
- data/src/core/lib/iomgr/iomgr_windows.cc +18 -2
- data/src/core/lib/iomgr/lockfree_event.cc +4 -4
- data/src/core/lib/iomgr/port.h +35 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +4 -3
- data/src/core/lib/iomgr/resolve_address_windows.cc +2 -1
- data/src/core/lib/iomgr/resource_quota.cc +40 -37
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +6 -2
- data/src/core/lib/iomgr/socket_windows.cc +19 -0
- data/src/core/lib/iomgr/socket_windows.h +8 -0
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +216 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_client_windows.cc +7 -5
- data/src/core/lib/iomgr/tcp_custom.cc +10 -14
- data/src/core/lib/iomgr/tcp_posix.cc +256 -140
- data/src/core/lib/iomgr/tcp_server.cc +5 -0
- data/src/core/lib/iomgr/tcp_server.h +24 -0
- data/src/core/lib/iomgr/tcp_server_custom.cc +14 -12
- data/src/core/lib/iomgr/tcp_server_posix.cc +86 -12
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +13 -11
- data/src/core/lib/iomgr/tcp_uv.cc +5 -7
- data/src/core/lib/iomgr/tcp_windows.cc +8 -14
- data/src/core/lib/iomgr/timer.h +2 -1
- data/src/core/lib/iomgr/timer_generic.cc +16 -16
- data/src/core/lib/iomgr/timer_manager.cc +20 -11
- data/src/core/lib/iomgr/udp_server.cc +8 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -19
- data/src/core/lib/json/json.cc +1 -4
- data/src/core/lib/profiling/basic_timers.cc +10 -4
- data/src/core/lib/security/context/security_context.cc +6 -7
- data/src/core/lib/security/context/security_context.h +3 -4
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
- data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
- data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -0
- data/src/core/lib/security/credentials/credentials.h +9 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -3
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +2 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +10 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +3 -3
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +9 -8
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +192 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +210 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +129 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.h +62 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +10 -8
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -12
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +7 -5
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +10 -8
- data/src/core/lib/security/security_connector/security_connector.cc +0 -1
- data/src/core/lib/security/security_connector/security_connector.h +3 -3
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +39 -38
- data/src/core/lib/security/security_connector/ssl_utils.cc +164 -26
- data/src/core/lib/security/security_connector/ssl_utils.h +70 -1
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +426 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +122 -0
- data/src/core/lib/security/transport/auth_filters.h +5 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +55 -50
- data/src/core/lib/security/transport/secure_endpoint.cc +6 -6
- data/src/core/lib/security/transport/security_handshaker.cc +271 -303
- data/src/core/lib/security/transport/security_handshaker.h +11 -2
- data/src/core/lib/security/transport/server_auth_filter.cc +3 -3
- data/src/core/lib/slice/b64.h +2 -2
- data/src/core/lib/slice/percent_encoding.cc +3 -3
- data/src/core/lib/slice/percent_encoding.h +3 -3
- data/src/core/lib/slice/slice.cc +174 -122
- data/src/core/lib/slice/slice_buffer.cc +54 -21
- data/src/core/lib/slice/slice_hash_table.h +4 -4
- data/src/core/lib/slice/slice_intern.cc +49 -107
- data/src/core/lib/slice/slice_internal.h +264 -3
- data/src/core/lib/slice/slice_string_helpers.cc +10 -1
- data/src/core/lib/slice/slice_string_helpers.h +3 -1
- data/src/core/lib/slice/slice_utils.h +50 -0
- data/src/core/lib/slice/slice_weak_hash_table.h +6 -6
- data/src/core/lib/surface/api_trace.h +1 -1
- data/src/core/lib/surface/byte_buffer_reader.cc +17 -0
- data/src/core/lib/surface/call.cc +67 -46
- data/src/core/lib/surface/call.h +7 -2
- data/src/core/lib/surface/call_details.cc +0 -1
- data/src/core/lib/surface/channel.cc +89 -97
- data/src/core/lib/surface/channel.h +60 -6
- data/src/core/lib/surface/channel_init.h +5 -0
- data/src/core/lib/surface/completion_queue.cc +221 -216
- data/src/core/lib/surface/completion_queue.h +2 -1
- data/src/core/lib/surface/init.cc +82 -33
- data/src/core/lib/surface/init.h +1 -0
- data/src/core/lib/surface/init_secure.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +5 -7
- data/src/core/lib/surface/server.cc +42 -47
- data/src/core/lib/surface/validate_metadata.cc +14 -8
- data/src/core/lib/surface/validate_metadata.h +13 -2
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/bdp_estimator.cc +3 -3
- data/src/core/lib/transport/bdp_estimator.h +2 -2
- data/src/core/lib/transport/connectivity_state.cc +10 -40
- data/src/core/lib/transport/connectivity_state.h +0 -8
- data/src/core/lib/transport/error_utils.cc +12 -0
- data/src/core/lib/transport/metadata.cc +258 -267
- data/src/core/lib/transport/metadata.h +227 -16
- data/src/core/lib/transport/metadata_batch.cc +1 -1
- data/src/core/lib/transport/metadata_batch.h +1 -1
- data/src/core/lib/transport/static_metadata.cc +477 -399
- data/src/core/lib/transport/static_metadata.h +273 -182
- data/src/core/lib/transport/status_metadata.cc +3 -3
- data/src/core/lib/transport/timeout_encoding.cc +1 -1
- data/src/core/lib/transport/timeout_encoding.h +1 -1
- data/src/core/lib/transport/transport.cc +39 -72
- data/src/core/lib/transport/transport.h +59 -24
- data/src/core/lib/transport/transport_impl.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_shared_resource.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +4 -3
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -1
- data/src/core/tsi/fake_transport_security.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +12 -10
- data/src/core/tsi/ssl_transport_security.h +24 -4
- data/src/ruby/bin/math_pb.rb +18 -16
- data/src/ruby/ext/grpc/extconf.rb +12 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +8 -5
- data/src/ruby/ext/grpc/rb_channel.c +14 -10
- data/src/ruby/ext/grpc/rb_channel_credentials.c +8 -4
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -7
- data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc.c +23 -24
- data/src/ruby/ext/grpc/rb_grpc.h +4 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +24 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +36 -0
- data/src/ruby/ext/grpc/rb_server.c +8 -4
- data/src/ruby/lib/grpc/errors.rb +22 -3
- data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +13 -10
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +18 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +3 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +58 -56
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -0
- data/src/ruby/spec/errors_spec.rb +141 -0
- data/third_party/cares/cares/ares.h +12 -0
- data/third_party/cares/cares/ares_create_query.c +5 -1
- data/third_party/cares/cares/ares_data.c +74 -73
- data/third_party/cares/cares/ares_destroy.c +6 -1
- data/third_party/cares/cares/ares_gethostbyaddr.c +5 -5
- data/third_party/cares/cares/ares_gethostbyname.c +15 -4
- data/third_party/cares/cares/ares_getnameinfo.c +11 -0
- data/third_party/cares/cares/ares_init.c +274 -173
- data/third_party/cares/cares/ares_library_init.c +21 -3
- data/third_party/cares/cares/ares_options.c +6 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +7 -6
- data/third_party/cares/cares/ares_parse_ptr_reply.c +4 -2
- data/third_party/cares/cares/ares_platform.c +7 -0
- data/third_party/cares/cares/ares_private.h +19 -11
- data/third_party/cares/cares/ares_process.c +27 -2
- data/third_party/cares/cares/ares_rules.h +1 -1
- data/third_party/cares/cares/ares_search.c +7 -0
- data/third_party/cares/cares/ares_send.c +6 -0
- data/third_party/cares/cares/ares_strsplit.c +174 -0
- data/third_party/cares/cares/ares_strsplit.h +43 -0
- data/third_party/cares/cares/ares_version.h +4 -4
- data/third_party/cares/cares/config-win32.h +1 -1
- data/third_party/cares/cares/inet_ntop.c +2 -3
- data/third_party/cares/config_darwin/ares_config.h +3 -0
- data/third_party/cares/config_freebsd/ares_config.h +3 -0
- data/third_party/cares/config_linux/ares_config.h +3 -0
- data/third_party/cares/config_openbsd/ares_config.h +3 -0
- metadata +83 -48
- data/src/core/ext/filters/client_channel/request_routing.cc +0 -936
- data/src/core/ext/filters/client_channel/request_routing.h +0 -177
- data/src/core/ext/filters/client_channel/subchannel_index.cc +0 -248
- data/src/core/ext/filters/client_channel/subchannel_index.h +0 -76
- data/src/core/lib/channel/handshaker_factory.cc +0 -42
- data/src/core/lib/gpr/arena.cc +0 -192
- data/src/core/lib/gprpp/atomic_with_atm.h +0 -57
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +0 -107
- data/src/core/lib/iomgr/wakeup_fd_cv.h +0 -69
- data/src/core/lib/transport/service_config.cc +0 -106
- data/src/core/lib/transport/service_config.h +0 -249
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include <grpc/support/port_platform.h>
|
20
20
|
|
21
|
-
#if GRPC_ARES == 1
|
21
|
+
#if GRPC_ARES == 1
|
22
22
|
|
23
23
|
#include <limits.h>
|
24
24
|
#include <stdio.h>
|
@@ -32,20 +32,21 @@
|
|
32
32
|
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
|
33
33
|
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
34
34
|
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
|
35
|
+
#include "src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h"
|
35
36
|
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
36
37
|
#include "src/core/ext/filters/client_channel/server_address.h"
|
38
|
+
#include "src/core/ext/filters/client_channel/service_config.h"
|
37
39
|
#include "src/core/lib/backoff/backoff.h"
|
38
40
|
#include "src/core/lib/channel/channel_args.h"
|
39
|
-
#include "src/core/lib/gpr/env.h"
|
40
41
|
#include "src/core/lib/gpr/host_port.h"
|
41
42
|
#include "src/core/lib/gpr/string.h"
|
42
43
|
#include "src/core/lib/gprpp/manual_constructor.h"
|
43
44
|
#include "src/core/lib/iomgr/combiner.h"
|
44
45
|
#include "src/core/lib/iomgr/gethostname.h"
|
46
|
+
#include "src/core/lib/iomgr/iomgr_custom.h"
|
45
47
|
#include "src/core/lib/iomgr/resolve_address.h"
|
46
48
|
#include "src/core/lib/iomgr/timer.h"
|
47
49
|
#include "src/core/lib/json/json.h"
|
48
|
-
#include "src/core/lib/transport/service_config.h"
|
49
50
|
|
50
51
|
#define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1
|
51
52
|
#define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6
|
@@ -60,10 +61,9 @@ const char kDefaultPort[] = "https";
|
|
60
61
|
|
61
62
|
class AresDnsResolver : public Resolver {
|
62
63
|
public:
|
63
|
-
explicit AresDnsResolver(
|
64
|
+
explicit AresDnsResolver(ResolverArgs args);
|
64
65
|
|
65
|
-
void
|
66
|
-
grpc_closure* on_complete) override;
|
66
|
+
void StartLocked() override;
|
67
67
|
|
68
68
|
void RequestReresolutionLocked() override;
|
69
69
|
|
@@ -76,7 +76,6 @@ class AresDnsResolver : public Resolver {
|
|
76
76
|
|
77
77
|
void MaybeStartResolvingLocked();
|
78
78
|
void StartResolvingLocked();
|
79
|
-
void MaybeFinishNextLocked();
|
80
79
|
|
81
80
|
static void OnNextResolutionLocked(void* arg, grpc_error* error);
|
82
81
|
static void OnResolvedLocked(void* arg, grpc_error* error);
|
@@ -98,16 +97,6 @@ class AresDnsResolver : public Resolver {
|
|
98
97
|
bool resolving_ = false;
|
99
98
|
/// the pending resolving request
|
100
99
|
grpc_ares_request* pending_request_ = nullptr;
|
101
|
-
/// which version of the result have we published?
|
102
|
-
int published_version_ = 0;
|
103
|
-
/// which version of the result is current?
|
104
|
-
int resolved_version_ = 0;
|
105
|
-
/// pending next completion, or NULL
|
106
|
-
grpc_closure* next_completion_ = nullptr;
|
107
|
-
/// target result address for next completion
|
108
|
-
grpc_channel_args** target_result_ = nullptr;
|
109
|
-
/// current (fully resolved) result
|
110
|
-
grpc_channel_args* resolved_result_ = nullptr;
|
111
100
|
/// next resolution timer
|
112
101
|
bool have_next_resolution_timer_ = false;
|
113
102
|
grpc_timer next_resolution_timer_;
|
@@ -125,10 +114,12 @@ class AresDnsResolver : public Resolver {
|
|
125
114
|
bool shutdown_initiated_ = false;
|
126
115
|
// timeout in milliseconds for active DNS queries
|
127
116
|
int query_timeout_ms_;
|
117
|
+
// whether or not to enable SRV DNS queries
|
118
|
+
bool enable_srv_queries_;
|
128
119
|
};
|
129
120
|
|
130
|
-
AresDnsResolver::AresDnsResolver(
|
131
|
-
: Resolver(args.combiner),
|
121
|
+
AresDnsResolver::AresDnsResolver(ResolverArgs args)
|
122
|
+
: Resolver(args.combiner, std::move(args.result_handler)),
|
132
123
|
backoff_(
|
133
124
|
BackOff::Options()
|
134
125
|
.set_initial_backoff(GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS *
|
@@ -146,14 +137,18 @@ AresDnsResolver::AresDnsResolver(const ResolverArgs& args)
|
|
146
137
|
dns_server_ = gpr_strdup(args.uri->authority);
|
147
138
|
}
|
148
139
|
channel_args_ = grpc_channel_args_copy(args.args);
|
140
|
+
// Disable service config option
|
149
141
|
const grpc_arg* arg = grpc_channel_args_find(
|
150
142
|
channel_args_, GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION);
|
151
|
-
|
152
|
-
|
143
|
+
request_service_config_ = !grpc_channel_arg_get_bool(arg, true);
|
144
|
+
// Min time b/t resolutions option
|
153
145
|
arg = grpc_channel_args_find(channel_args_,
|
154
146
|
GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS);
|
155
147
|
min_time_between_resolutions_ =
|
156
148
|
grpc_channel_arg_get_integer(arg, {1000, 0, INT_MAX});
|
149
|
+
// Enable SRV queries option
|
150
|
+
arg = grpc_channel_args_find(channel_args_, GRPC_ARG_DNS_ENABLE_SRV_QUERIES);
|
151
|
+
enable_srv_queries_ = grpc_channel_arg_get_bool(arg, false);
|
157
152
|
interested_parties_ = grpc_pollset_set_create();
|
158
153
|
if (args.pollset_set != nullptr) {
|
159
154
|
grpc_pollset_set_add_pollset_set(interested_parties_, args.pollset_set);
|
@@ -171,27 +166,16 @@ AresDnsResolver::AresDnsResolver(const ResolverArgs& args)
|
|
171
166
|
|
172
167
|
AresDnsResolver::~AresDnsResolver() {
|
173
168
|
GRPC_CARES_TRACE_LOG("resolver:%p destroying AresDnsResolver", this);
|
174
|
-
if (resolved_result_ != nullptr) {
|
175
|
-
grpc_channel_args_destroy(resolved_result_);
|
176
|
-
}
|
177
169
|
grpc_pollset_set_destroy(interested_parties_);
|
178
170
|
gpr_free(dns_server_);
|
179
171
|
gpr_free(name_to_resolve_);
|
180
172
|
grpc_channel_args_destroy(channel_args_);
|
181
173
|
}
|
182
174
|
|
183
|
-
void AresDnsResolver::
|
184
|
-
|
185
|
-
GRPC_CARES_TRACE_LOG("resolver:%p AresDnsResolver::NextLocked() is called.",
|
175
|
+
void AresDnsResolver::StartLocked() {
|
176
|
+
GRPC_CARES_TRACE_LOG("resolver:%p AresDnsResolver::StartLocked() is called.",
|
186
177
|
this);
|
187
|
-
|
188
|
-
next_completion_ = on_complete;
|
189
|
-
target_result_ = target_result;
|
190
|
-
if (resolved_version_ == 0 && !resolving_) {
|
191
|
-
MaybeStartResolvingLocked();
|
192
|
-
} else {
|
193
|
-
MaybeFinishNextLocked();
|
194
|
-
}
|
178
|
+
MaybeStartResolvingLocked();
|
195
179
|
}
|
196
180
|
|
197
181
|
void AresDnsResolver::RequestReresolutionLocked() {
|
@@ -215,12 +199,6 @@ void AresDnsResolver::ShutdownLocked() {
|
|
215
199
|
if (pending_request_ != nullptr) {
|
216
200
|
grpc_cancel_ares_request_locked(pending_request_);
|
217
201
|
}
|
218
|
-
if (next_completion_ != nullptr) {
|
219
|
-
*target_result_ = nullptr;
|
220
|
-
GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
221
|
-
"Resolver Shutdown"));
|
222
|
-
next_completion_ = nullptr;
|
223
|
-
}
|
224
202
|
}
|
225
203
|
|
226
204
|
void AresDnsResolver::OnNextResolutionLocked(void* arg, grpc_error* error) {
|
@@ -249,105 +227,137 @@ bool ValueInJsonArray(grpc_json* array, const char* value) {
|
|
249
227
|
return false;
|
250
228
|
}
|
251
229
|
|
252
|
-
char* ChooseServiceConfig(char* service_config_choice_json
|
230
|
+
char* ChooseServiceConfig(char* service_config_choice_json,
|
231
|
+
grpc_error** error) {
|
253
232
|
grpc_json* choices_json = grpc_json_parse_string(service_config_choice_json);
|
254
|
-
if (choices_json == nullptr
|
255
|
-
|
233
|
+
if (choices_json == nullptr) {
|
234
|
+
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
235
|
+
"Service Config JSON Parsing, error: could not parse");
|
236
|
+
return nullptr;
|
237
|
+
}
|
238
|
+
if (choices_json->type != GRPC_JSON_ARRAY) {
|
239
|
+
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
240
|
+
"Service Config Choices, error: should be of type array");
|
256
241
|
return nullptr;
|
257
242
|
}
|
258
243
|
char* service_config = nullptr;
|
244
|
+
InlinedVector<grpc_error*, 4> error_list;
|
245
|
+
bool found_choice = false; // have we found a choice?
|
259
246
|
for (grpc_json* choice = choices_json->child; choice != nullptr;
|
260
247
|
choice = choice->next) {
|
261
248
|
if (choice->type != GRPC_JSON_OBJECT) {
|
262
|
-
|
263
|
-
|
249
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
250
|
+
"Service Config Choice, error: should be of type object"));
|
251
|
+
continue;
|
264
252
|
}
|
265
253
|
grpc_json* service_config_json = nullptr;
|
254
|
+
bool selected = true; // has this choice been rejected?
|
266
255
|
for (grpc_json* field = choice->child; field != nullptr;
|
267
256
|
field = field->next) {
|
268
257
|
// Check client language, if specified.
|
269
258
|
if (strcmp(field->key, "clientLanguage") == 0) {
|
270
|
-
if (field->type != GRPC_JSON_ARRAY
|
271
|
-
|
272
|
-
|
259
|
+
if (field->type != GRPC_JSON_ARRAY) {
|
260
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
261
|
+
"field:clientLanguage error:should be of type array"));
|
262
|
+
} else if (!ValueInJsonArray(field, "c++")) {
|
263
|
+
selected = false;
|
273
264
|
}
|
274
265
|
}
|
275
266
|
// Check client hostname, if specified.
|
276
267
|
if (strcmp(field->key, "clientHostname") == 0) {
|
268
|
+
if (field->type != GRPC_JSON_ARRAY) {
|
269
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
270
|
+
"field:clientHostname error:should be of type array"));
|
271
|
+
continue;
|
272
|
+
}
|
277
273
|
char* hostname = grpc_gethostname();
|
278
|
-
if (hostname == nullptr || field
|
279
|
-
|
280
|
-
service_config_json = nullptr;
|
281
|
-
break;
|
274
|
+
if (hostname == nullptr || !ValueInJsonArray(field, hostname)) {
|
275
|
+
selected = false;
|
282
276
|
}
|
283
277
|
}
|
284
278
|
// Check percentage, if specified.
|
285
279
|
if (strcmp(field->key, "percentage") == 0) {
|
286
280
|
if (field->type != GRPC_JSON_NUMBER) {
|
287
|
-
|
288
|
-
|
281
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
282
|
+
"field:percentage error:should be of type number"));
|
283
|
+
continue;
|
289
284
|
}
|
290
285
|
int random_pct = rand() % 100;
|
291
286
|
int percentage;
|
292
|
-
if (sscanf(field->value, "%d", &percentage) != 1
|
293
|
-
|
294
|
-
|
295
|
-
|
287
|
+
if (sscanf(field->value, "%d", &percentage) != 1) {
|
288
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
289
|
+
"field:percentage error:should be of type integer"));
|
290
|
+
continue;
|
291
|
+
}
|
292
|
+
if (random_pct > percentage || percentage == 0) {
|
293
|
+
selected = false;
|
296
294
|
}
|
297
295
|
}
|
298
296
|
// Save service config.
|
299
297
|
if (strcmp(field->key, "serviceConfig") == 0) {
|
300
298
|
if (field->type == GRPC_JSON_OBJECT) {
|
301
299
|
service_config_json = field;
|
300
|
+
} else {
|
301
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
302
|
+
"field:serviceConfig error:should be of type object"));
|
302
303
|
}
|
303
304
|
}
|
304
305
|
}
|
305
|
-
if (service_config_json != nullptr) {
|
306
|
+
if (!found_choice && selected && service_config_json != nullptr) {
|
306
307
|
service_config = grpc_json_dump_to_string(service_config_json, 0);
|
307
|
-
|
308
|
+
found_choice = true;
|
308
309
|
}
|
309
310
|
}
|
310
311
|
grpc_json_destroy(choices_json);
|
312
|
+
if (!error_list.empty()) {
|
313
|
+
gpr_free(service_config);
|
314
|
+
service_config = nullptr;
|
315
|
+
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Service Config Choices Parser",
|
316
|
+
&error_list);
|
317
|
+
}
|
311
318
|
return service_config;
|
312
319
|
}
|
313
320
|
|
314
321
|
void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
|
315
322
|
AresDnsResolver* r = static_cast<AresDnsResolver*>(arg);
|
316
|
-
grpc_channel_args* result = nullptr;
|
317
323
|
GPR_ASSERT(r->resolving_);
|
318
324
|
r->resolving_ = false;
|
319
325
|
gpr_free(r->pending_request_);
|
320
326
|
r->pending_request_ = nullptr;
|
327
|
+
if (r->shutdown_initiated_) {
|
328
|
+
r->Unref(DEBUG_LOCATION, "OnResolvedLocked() shutdown");
|
329
|
+
return;
|
330
|
+
}
|
321
331
|
if (r->addresses_ != nullptr) {
|
322
|
-
|
323
|
-
|
324
|
-
grpc_arg args_to_add[2];
|
325
|
-
size_t num_args_to_add = 0;
|
326
|
-
args_to_add[num_args_to_add++] =
|
327
|
-
CreateServerAddressListChannelArg(r->addresses_.get());
|
328
|
-
char* service_config_string = nullptr;
|
332
|
+
Result result;
|
333
|
+
result.addresses = std::move(*r->addresses_);
|
329
334
|
if (r->service_config_json_ != nullptr) {
|
330
|
-
service_config_string = ChooseServiceConfig(
|
335
|
+
char* service_config_string = ChooseServiceConfig(
|
336
|
+
r->service_config_json_, &result.service_config_error);
|
331
337
|
gpr_free(r->service_config_json_);
|
332
|
-
if (
|
338
|
+
if (result.service_config_error == GRPC_ERROR_NONE &&
|
339
|
+
service_config_string != nullptr) {
|
333
340
|
GRPC_CARES_TRACE_LOG("resolver:%p selected service config choice: %s",
|
334
341
|
r, service_config_string);
|
335
|
-
|
336
|
-
|
337
|
-
(char*)GRPC_ARG_SERVICE_CONFIG, service_config_string);
|
342
|
+
result.service_config = ServiceConfig::Create(
|
343
|
+
service_config_string, &result.service_config_error);
|
338
344
|
}
|
345
|
+
gpr_free(service_config_string);
|
339
346
|
}
|
340
|
-
result =
|
341
|
-
|
342
|
-
num_args_to_add);
|
343
|
-
gpr_free(service_config_string);
|
347
|
+
result.args = grpc_channel_args_copy(r->channel_args_);
|
348
|
+
r->result_handler()->ReturnResult(std::move(result));
|
344
349
|
r->addresses_.reset();
|
345
350
|
// Reset backoff state so that we start from the beginning when the
|
346
351
|
// next request gets triggered.
|
347
352
|
r->backoff_.Reset();
|
348
|
-
} else
|
349
|
-
|
350
|
-
|
353
|
+
} else {
|
354
|
+
GRPC_CARES_TRACE_LOG("resolver:%p dns resolution failed: %s", r,
|
355
|
+
grpc_error_string(error));
|
356
|
+
r->result_handler()->ReturnError(grpc_error_set_int(
|
357
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
358
|
+
"DNS resolution failed", &error, 1),
|
359
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
|
360
|
+
// Set retry timer.
|
351
361
|
grpc_millis next_try = r->backoff_.NextAttemptTime();
|
352
362
|
grpc_millis timeout = next_try - ExecCtx::Get()->Now();
|
353
363
|
GRPC_CARES_TRACE_LOG("resolver:%p dns resolution failed (will retry): %s",
|
@@ -357,8 +367,7 @@ void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
|
|
357
367
|
// TODO(roth): We currently deal with this ref manually. Once the
|
358
368
|
// new closure API is done, find a way to track this ref with the timer
|
359
369
|
// callback as part of the type system.
|
360
|
-
|
361
|
-
self.release();
|
370
|
+
r->Ref(DEBUG_LOCATION, "retry-timer").release();
|
362
371
|
if (timeout > 0) {
|
363
372
|
GRPC_CARES_TRACE_LOG("resolver:%p retrying in %" PRId64 " milliseconds",
|
364
373
|
r, timeout);
|
@@ -368,12 +377,6 @@ void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
|
|
368
377
|
grpc_timer_init(&r->next_resolution_timer_, next_try,
|
369
378
|
&r->on_next_resolution_);
|
370
379
|
}
|
371
|
-
if (r->resolved_result_ != nullptr) {
|
372
|
-
grpc_channel_args_destroy(r->resolved_result_);
|
373
|
-
}
|
374
|
-
r->resolved_result_ = result;
|
375
|
-
++r->resolved_version_;
|
376
|
-
r->MaybeFinishNextLocked();
|
377
380
|
r->Unref(DEBUG_LOCATION, "dns-resolving");
|
378
381
|
}
|
379
382
|
|
@@ -397,9 +400,7 @@ void AresDnsResolver::MaybeStartResolvingLocked() {
|
|
397
400
|
// TODO(roth): We currently deal with this ref manually. Once the
|
398
401
|
// new closure API is done, find a way to track this ref with the timer
|
399
402
|
// callback as part of the type system.
|
400
|
-
|
401
|
-
Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown");
|
402
|
-
self.release();
|
403
|
+
Ref(DEBUG_LOCATION, "next_resolution_timer_cooldown").release();
|
403
404
|
grpc_timer_init(&next_resolution_timer_, ms_until_next_resolution,
|
404
405
|
&on_next_resolution_);
|
405
406
|
return;
|
@@ -412,14 +413,13 @@ void AresDnsResolver::StartResolvingLocked() {
|
|
412
413
|
// TODO(roth): We currently deal with this ref manually. Once the
|
413
414
|
// new closure API is done, find a way to track this ref with the timer
|
414
415
|
// callback as part of the type system.
|
415
|
-
|
416
|
-
self.release();
|
416
|
+
Ref(DEBUG_LOCATION, "dns-resolving").release();
|
417
417
|
GPR_ASSERT(!resolving_);
|
418
418
|
resolving_ = true;
|
419
419
|
service_config_json_ = nullptr;
|
420
420
|
pending_request_ = grpc_dns_lookup_ares_locked(
|
421
421
|
dns_server_, name_to_resolve_, kDefaultPort, interested_parties_,
|
422
|
-
&on_resolved_, &addresses_,
|
422
|
+
&on_resolved_, &addresses_, enable_srv_queries_ /* check_grpclb */,
|
423
423
|
request_service_config_ ? &service_config_json_ : nullptr,
|
424
424
|
query_timeout_ms_, combiner());
|
425
425
|
last_resolution_timestamp_ = grpc_core::ExecCtx::Get()->Now();
|
@@ -427,28 +427,14 @@ void AresDnsResolver::StartResolvingLocked() {
|
|
427
427
|
this, pending_request_);
|
428
428
|
}
|
429
429
|
|
430
|
-
void AresDnsResolver::MaybeFinishNextLocked() {
|
431
|
-
if (next_completion_ != nullptr && resolved_version_ != published_version_) {
|
432
|
-
*target_result_ = resolved_result_ == nullptr
|
433
|
-
? nullptr
|
434
|
-
: grpc_channel_args_copy(resolved_result_);
|
435
|
-
GRPC_CARES_TRACE_LOG("resolver:%p AresDnsResolver::MaybeFinishNextLocked()",
|
436
|
-
this);
|
437
|
-
GRPC_CLOSURE_SCHED(next_completion_, GRPC_ERROR_NONE);
|
438
|
-
next_completion_ = nullptr;
|
439
|
-
published_version_ = resolved_version_;
|
440
|
-
}
|
441
|
-
}
|
442
|
-
|
443
430
|
//
|
444
431
|
// Factory
|
445
432
|
//
|
446
433
|
|
447
434
|
class AresDnsResolverFactory : public ResolverFactory {
|
448
435
|
public:
|
449
|
-
OrphanablePtr<Resolver> CreateResolver(
|
450
|
-
|
451
|
-
return OrphanablePtr<Resolver>(New<AresDnsResolver>(args));
|
436
|
+
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
|
437
|
+
return OrphanablePtr<Resolver>(New<AresDnsResolver>(std::move(args)));
|
452
438
|
}
|
453
439
|
|
454
440
|
const char* scheme() const override { return "dns"; }
|
@@ -471,20 +457,34 @@ static grpc_error* blocking_resolve_address_ares(
|
|
471
457
|
static grpc_address_resolver_vtable ares_resolver = {
|
472
458
|
grpc_resolve_address_ares, blocking_resolve_address_ares};
|
473
459
|
|
460
|
+
#ifdef GRPC_UV
|
461
|
+
/* TODO(murgatroid99): Remove this when we want the cares resolver to be the
|
462
|
+
* default when using libuv */
|
474
463
|
static bool should_use_ares(const char* resolver_env) {
|
475
464
|
return resolver_env != nullptr && gpr_stricmp(resolver_env, "ares") == 0;
|
476
465
|
}
|
466
|
+
#else /* GRPC_UV */
|
467
|
+
static bool should_use_ares(const char* resolver_env) {
|
468
|
+
// TODO(lidiz): Remove the "g_custom_iomgr_enabled" flag once c-ares support
|
469
|
+
// custom IO managers (e.g. gevent).
|
470
|
+
return !g_custom_iomgr_enabled &&
|
471
|
+
(resolver_env == nullptr || strlen(resolver_env) == 0 ||
|
472
|
+
gpr_stricmp(resolver_env, "ares") == 0);
|
473
|
+
}
|
474
|
+
#endif /* GRPC_UV */
|
475
|
+
|
476
|
+
static bool g_use_ares_dns_resolver;
|
477
477
|
|
478
478
|
void grpc_resolver_dns_ares_init() {
|
479
|
-
char
|
480
|
-
|
481
|
-
|
482
|
-
|
479
|
+
grpc_core::UniquePtr<char> resolver =
|
480
|
+
GPR_GLOBAL_CONFIG_GET(grpc_dns_resolver);
|
481
|
+
if (should_use_ares(resolver.get())) {
|
482
|
+
g_use_ares_dns_resolver = true;
|
483
483
|
gpr_log(GPR_DEBUG, "Using ares dns resolver");
|
484
484
|
address_sorting_init();
|
485
485
|
grpc_error* error = grpc_ares_init();
|
486
486
|
if (error != GRPC_ERROR_NONE) {
|
487
|
-
GRPC_LOG_IF_ERROR("
|
487
|
+
GRPC_LOG_IF_ERROR("grpc_ares_init() failed", error);
|
488
488
|
return;
|
489
489
|
}
|
490
490
|
if (default_resolver == nullptr) {
|
@@ -494,23 +494,22 @@ void grpc_resolver_dns_ares_init() {
|
|
494
494
|
grpc_core::ResolverRegistry::Builder::RegisterResolverFactory(
|
495
495
|
grpc_core::UniquePtr<grpc_core::ResolverFactory>(
|
496
496
|
grpc_core::New<grpc_core::AresDnsResolverFactory>()));
|
497
|
+
} else {
|
498
|
+
g_use_ares_dns_resolver = false;
|
497
499
|
}
|
498
|
-
gpr_free(resolver_env);
|
499
500
|
}
|
500
501
|
|
501
502
|
void grpc_resolver_dns_ares_shutdown() {
|
502
|
-
|
503
|
-
if (should_use_ares(resolver_env)) {
|
503
|
+
if (g_use_ares_dns_resolver) {
|
504
504
|
address_sorting_shutdown();
|
505
505
|
grpc_ares_cleanup();
|
506
506
|
}
|
507
|
-
gpr_free(resolver_env);
|
508
507
|
}
|
509
508
|
|
510
|
-
#else /* GRPC_ARES == 1
|
509
|
+
#else /* GRPC_ARES == 1 */
|
511
510
|
|
512
511
|
void grpc_resolver_dns_ares_init(void) {}
|
513
512
|
|
514
513
|
void grpc_resolver_dns_ares_shutdown(void) {}
|
515
514
|
|
516
|
-
#endif /* GRPC_ARES == 1
|
515
|
+
#endif /* GRPC_ARES == 1 */
|
@@ -18,7 +18,7 @@
|
|
18
18
|
#include <grpc/support/port_platform.h>
|
19
19
|
|
20
20
|
#include "src/core/lib/iomgr/port.h"
|
21
|
-
#if GRPC_ARES == 1
|
21
|
+
#if GRPC_ARES == 1
|
22
22
|
|
23
23
|
#include <ares.h>
|
24
24
|
#include <string.h>
|
@@ -84,6 +84,10 @@ struct grpc_ares_ev_driver {
|
|
84
84
|
grpc_timer query_timeout;
|
85
85
|
/** cancels queries on a timeout */
|
86
86
|
grpc_closure on_timeout_locked;
|
87
|
+
/** alarm to poll ares_process on in case fd events don't happen */
|
88
|
+
grpc_timer ares_backup_poll_alarm;
|
89
|
+
/** polls ares_process on a periodic timer */
|
90
|
+
grpc_closure on_ares_backup_poll_alarm_locked;
|
87
91
|
};
|
88
92
|
|
89
93
|
static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver);
|
@@ -130,6 +134,13 @@ static void fd_node_shutdown_locked(fd_node* fdn, const char* reason) {
|
|
130
134
|
|
131
135
|
static void on_timeout_locked(void* arg, grpc_error* error);
|
132
136
|
|
137
|
+
static void on_ares_backup_poll_alarm_locked(void* arg, grpc_error* error);
|
138
|
+
|
139
|
+
static void noop_inject_channel_config(ares_channel channel) {}
|
140
|
+
|
141
|
+
void (*grpc_ares_test_only_inject_config)(ares_channel channel) =
|
142
|
+
noop_inject_channel_config;
|
143
|
+
|
133
144
|
grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver,
|
134
145
|
grpc_pollset_set* pollset_set,
|
135
146
|
int query_timeout_ms,
|
@@ -140,6 +151,7 @@ grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver,
|
|
140
151
|
memset(&opts, 0, sizeof(opts));
|
141
152
|
opts.flags |= ARES_FLAG_STAYOPEN;
|
142
153
|
int status = ares_init_options(&(*ev_driver)->channel, &opts, ARES_OPT_FLAGS);
|
154
|
+
grpc_ares_test_only_inject_config((*ev_driver)->channel);
|
143
155
|
GRPC_CARES_TRACE_LOG("request:%p grpc_ares_ev_driver_create_locked", request);
|
144
156
|
if (status != ARES_SUCCESS) {
|
145
157
|
char* err_msg;
|
@@ -163,6 +175,9 @@ grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver,
|
|
163
175
|
->polled_fd_factory->ConfigureAresChannelLocked((*ev_driver)->channel);
|
164
176
|
GRPC_CLOSURE_INIT(&(*ev_driver)->on_timeout_locked, on_timeout_locked,
|
165
177
|
*ev_driver, grpc_combiner_scheduler(combiner));
|
178
|
+
GRPC_CLOSURE_INIT(&(*ev_driver)->on_ares_backup_poll_alarm_locked,
|
179
|
+
on_ares_backup_poll_alarm_locked, *ev_driver,
|
180
|
+
grpc_combiner_scheduler(combiner));
|
166
181
|
(*ev_driver)->query_timeout_ms = query_timeout_ms;
|
167
182
|
return GRPC_ERROR_NONE;
|
168
183
|
}
|
@@ -174,6 +189,7 @@ void grpc_ares_ev_driver_on_queries_complete_locked(
|
|
174
189
|
// fds; if it's not working, there are no fds to shut down.
|
175
190
|
ev_driver->shutting_down = true;
|
176
191
|
grpc_timer_cancel(&ev_driver->query_timeout);
|
192
|
+
grpc_timer_cancel(&ev_driver->ares_backup_poll_alarm);
|
177
193
|
grpc_ares_ev_driver_unref(ev_driver);
|
178
194
|
}
|
179
195
|
|
@@ -204,6 +220,21 @@ static fd_node* pop_fd_node_locked(fd_node** head, ares_socket_t as) {
|
|
204
220
|
return nullptr;
|
205
221
|
}
|
206
222
|
|
223
|
+
static grpc_millis calculate_next_ares_backup_poll_alarm_ms(
|
224
|
+
grpc_ares_ev_driver* driver) {
|
225
|
+
// An alternative here could be to use ares_timeout to try to be more
|
226
|
+
// accurate, but that would require using "struct timeval"'s, which just makes
|
227
|
+
// things a bit more complicated. So just poll every second, as suggested
|
228
|
+
// by the c-ares code comments.
|
229
|
+
grpc_millis ms_until_next_ares_backup_poll_alarm = 1000;
|
230
|
+
GRPC_CARES_TRACE_LOG(
|
231
|
+
"request:%p ev_driver=%p. next ares process poll time in "
|
232
|
+
"%" PRId64 " ms",
|
233
|
+
driver->request, driver, ms_until_next_ares_backup_poll_alarm);
|
234
|
+
return ms_until_next_ares_backup_poll_alarm +
|
235
|
+
grpc_core::ExecCtx::Get()->Now();
|
236
|
+
}
|
237
|
+
|
207
238
|
static void on_timeout_locked(void* arg, grpc_error* error) {
|
208
239
|
grpc_ares_ev_driver* driver = static_cast<grpc_ares_ev_driver*>(arg);
|
209
240
|
GRPC_CARES_TRACE_LOG(
|
@@ -216,8 +247,50 @@ static void on_timeout_locked(void* arg, grpc_error* error) {
|
|
216
247
|
grpc_ares_ev_driver_unref(driver);
|
217
248
|
}
|
218
249
|
|
250
|
+
/* In case of non-responsive DNS servers, dropped packets, etc., c-ares has
|
251
|
+
* intelligent timeout and retry logic, which we can take advantage of by
|
252
|
+
* polling ares_process_fd on time intervals. Overall, the c-ares library is
|
253
|
+
* meant to be called into and given a chance to proceed name resolution:
|
254
|
+
* a) when fd events happen
|
255
|
+
* b) when some time has passed without fd events having happened
|
256
|
+
* For the latter, we use this backup poller. Also see
|
257
|
+
* https://github.com/grpc/grpc/pull/17688 description for more details. */
|
258
|
+
static void on_ares_backup_poll_alarm_locked(void* arg, grpc_error* error) {
|
259
|
+
grpc_ares_ev_driver* driver = static_cast<grpc_ares_ev_driver*>(arg);
|
260
|
+
GRPC_CARES_TRACE_LOG(
|
261
|
+
"request:%p ev_driver=%p on_ares_backup_poll_alarm_locked. "
|
262
|
+
"driver->shutting_down=%d. "
|
263
|
+
"err=%s",
|
264
|
+
driver->request, driver, driver->shutting_down, grpc_error_string(error));
|
265
|
+
if (!driver->shutting_down && error == GRPC_ERROR_NONE) {
|
266
|
+
fd_node* fdn = driver->fds;
|
267
|
+
while (fdn != nullptr) {
|
268
|
+
if (!fdn->already_shutdown) {
|
269
|
+
GRPC_CARES_TRACE_LOG(
|
270
|
+
"request:%p ev_driver=%p on_ares_backup_poll_alarm_locked; "
|
271
|
+
"ares_process_fd. fd=%s",
|
272
|
+
driver->request, driver, fdn->grpc_polled_fd->GetName());
|
273
|
+
ares_socket_t as = fdn->grpc_polled_fd->GetWrappedAresSocketLocked();
|
274
|
+
ares_process_fd(driver->channel, as, as);
|
275
|
+
}
|
276
|
+
fdn = fdn->next;
|
277
|
+
}
|
278
|
+
if (!driver->shutting_down) {
|
279
|
+
grpc_millis next_ares_backup_poll_alarm =
|
280
|
+
calculate_next_ares_backup_poll_alarm_ms(driver);
|
281
|
+
grpc_ares_ev_driver_ref(driver);
|
282
|
+
grpc_timer_init(&driver->ares_backup_poll_alarm,
|
283
|
+
next_ares_backup_poll_alarm,
|
284
|
+
&driver->on_ares_backup_poll_alarm_locked);
|
285
|
+
}
|
286
|
+
grpc_ares_notify_on_event_locked(driver);
|
287
|
+
}
|
288
|
+
grpc_ares_ev_driver_unref(driver);
|
289
|
+
}
|
290
|
+
|
219
291
|
static void on_readable_locked(void* arg, grpc_error* error) {
|
220
292
|
fd_node* fdn = static_cast<fd_node*>(arg);
|
293
|
+
GPR_ASSERT(fdn->readable_registered);
|
221
294
|
grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
|
222
295
|
const ares_socket_t as = fdn->grpc_polled_fd->GetWrappedAresSocketLocked();
|
223
296
|
fdn->readable_registered = false;
|
@@ -242,6 +315,7 @@ static void on_readable_locked(void* arg, grpc_error* error) {
|
|
242
315
|
|
243
316
|
static void on_writable_locked(void* arg, grpc_error* error) {
|
244
317
|
fd_node* fdn = static_cast<fd_node*>(arg);
|
318
|
+
GPR_ASSERT(fdn->writable_registered);
|
245
319
|
grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
|
246
320
|
const ares_socket_t as = fdn->grpc_polled_fd->GetWrappedAresSocketLocked();
|
247
321
|
fdn->writable_registered = false;
|
@@ -351,6 +425,7 @@ void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver) {
|
|
351
425
|
if (!ev_driver->working) {
|
352
426
|
ev_driver->working = true;
|
353
427
|
grpc_ares_notify_on_event_locked(ev_driver);
|
428
|
+
// Initialize overall DNS resolution timeout alarm
|
354
429
|
grpc_millis timeout =
|
355
430
|
ev_driver->query_timeout_ms == 0
|
356
431
|
? GRPC_MILLIS_INF_FUTURE
|
@@ -362,7 +437,14 @@ void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver) {
|
|
362
437
|
grpc_ares_ev_driver_ref(ev_driver);
|
363
438
|
grpc_timer_init(&ev_driver->query_timeout, timeout,
|
364
439
|
&ev_driver->on_timeout_locked);
|
440
|
+
// Initialize the backup poll alarm
|
441
|
+
grpc_millis next_ares_backup_poll_alarm =
|
442
|
+
calculate_next_ares_backup_poll_alarm_ms(ev_driver);
|
443
|
+
grpc_ares_ev_driver_ref(ev_driver);
|
444
|
+
grpc_timer_init(&ev_driver->ares_backup_poll_alarm,
|
445
|
+
next_ares_backup_poll_alarm,
|
446
|
+
&ev_driver->on_ares_backup_poll_alarm_locked);
|
365
447
|
}
|
366
448
|
}
|
367
449
|
|
368
|
-
#endif /* GRPC_ARES == 1
|
450
|
+
#endif /* GRPC_ARES == 1 */
|
@@ -54,6 +54,9 @@ void grpc_ares_ev_driver_on_queries_complete_locked(
|
|
54
54
|
/* Shutdown all the grpc_fds used by \a ev_driver */
|
55
55
|
void grpc_ares_ev_driver_shutdown_locked(grpc_ares_ev_driver* ev_driver);
|
56
56
|
|
57
|
+
/* Exposed in this header for C-core tests only */
|
58
|
+
extern void (*grpc_ares_test_only_inject_config)(ares_channel channel);
|
59
|
+
|
57
60
|
namespace grpc_core {
|
58
61
|
|
59
62
|
/* A wrapped fd that integrates with the grpc iomgr of the current platform.
|