grpc 1.2.5 → 1.3.4
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 +1434 -399
- data/etc/roots.pem +34 -150
- data/include/grpc/grpc.h +71 -0
- data/include/grpc/impl/codegen/atm.h +5 -0
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +6 -0
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +11 -0
- data/include/grpc/impl/codegen/grpc_types.h +54 -13
- data/include/grpc/impl/codegen/port_platform.h +15 -1
- data/include/grpc/support/alloc.h +2 -1
- data/include/grpc/support/sync.h +4 -0
- data/include/grpc/support/tls.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.h +1 -1
- data/src/core/ext/census/grpc_filter.c +14 -10
- data/src/core/ext/census/grpc_plugin.c +3 -1
- data/src/core/ext/census/trace_label.h +1 -1
- data/src/core/ext/census/trace_propagation.h +1 -1
- data/src/core/ext/census/trace_status.h +1 -1
- data/src/core/ext/census/trace_string.h +1 -1
- data/src/core/ext/census/tracing.h +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/channel_connectivity.c +56 -27
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel.c +407 -202
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel.h +10 -6
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_plugin.c +12 -7
- data/src/core/ext/{client_channel → filters/client_channel}/connector.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/connector.h +3 -5
- data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.c +6 -6
- data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.c +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.h +4 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.c +22 -20
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.h +4 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel.h +5 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel_secure.c +2 -2
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.c +1 -1
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.h +6 -5
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +1 -1
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -0
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/pick_first/pick_first.c +20 -15
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/round_robin/round_robin.c +21 -16
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.h +5 -5
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/parse_address.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/parse_address.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.c +10 -4
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/resolver.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/resolver.h +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
- data/src/core/ext/{resolver → filters/client_channel/resolver}/dns/native/dns_resolver.c +21 -5
- data/src/core/ext/{resolver → filters/client_channel/resolver}/sockaddr/sockaddr_resolver.c +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.h +6 -6
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.c +1 -2
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.h +4 -4
- data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
- data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel.c +49 -43
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel.h +21 -7
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.h +5 -5
- data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.h +3 -3
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.c +4 -2
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.h +3 -3
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.c +17 -14
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.h +4 -4
- data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
- data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +6 -41
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +2 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +3 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +2 -5
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +449 -204
- data/src/core/ext/transport/chttp2/transport/frame_data.c +10 -7
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +37 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +4 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +18 -38
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -29
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +64 -37
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +11 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +60 -39
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
- data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +22 -43
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +8 -10
- data/src/core/ext/transport/chttp2/transport/internal.h +24 -2
- data/src/core/ext/transport/chttp2/transport/parsing.c +33 -15
- data/src/core/ext/transport/chttp2/transport/writing.c +56 -10
- data/src/core/lib/channel/channel_args.c +7 -0
- data/src/core/lib/channel/channel_args.h +2 -0
- data/src/core/lib/channel/channel_stack.c +20 -27
- data/src/core/lib/channel/channel_stack.h +18 -16
- data/src/core/lib/channel/compress_filter.c +20 -18
- data/src/core/lib/channel/connected_channel.c +9 -8
- data/src/core/lib/channel/deadline_filter.c +28 -24
- data/src/core/lib/channel/deadline_filter.h +3 -3
- data/src/core/lib/channel/handshaker.c +3 -2
- data/src/core/lib/channel/http_client_filter.c +119 -61
- data/src/core/lib/channel/http_server_filter.c +124 -69
- data/src/core/lib/channel/message_size_filter.c +23 -19
- data/src/core/lib/http/httpcli.c +8 -6
- data/src/core/lib/http/httpcli_security_connector.c +5 -5
- data/src/core/lib/http/parser.c +57 -31
- data/src/core/lib/iomgr/closure.c +15 -0
- data/src/core/lib/iomgr/closure.h +4 -0
- data/src/core/lib/iomgr/combiner.c +8 -0
- data/src/core/lib/iomgr/endpoint_pair.h +2 -3
- data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -7
- data/src/core/lib/iomgr/endpoint_pair_uv.c +2 -3
- data/src/core/lib/iomgr/endpoint_pair_windows.c +9 -6
- data/src/core/lib/iomgr/error.c +360 -177
- data/src/core/lib/iomgr/error.h +31 -33
- data/src/core/lib/iomgr/error_internal.h +30 -9
- data/src/core/lib/iomgr/ev_epoll_linux.c +25 -239
- data/src/core/lib/iomgr/ev_poll_posix.c +11 -7
- data/src/core/lib/iomgr/ev_posix.c +6 -0
- data/src/core/lib/iomgr/ev_posix.h +3 -0
- data/src/core/lib/iomgr/exec_ctx.c +6 -0
- data/src/core/lib/iomgr/executor.c +8 -2
- data/src/core/lib/iomgr/load_file.c +6 -3
- data/src/core/lib/iomgr/lockfree_event.c +238 -0
- data/src/core/{ext/client_channel/initial_connect_string.h → lib/iomgr/lockfree_event.h} +17 -13
- data/src/core/lib/iomgr/pollset.h +4 -0
- data/src/core/lib/iomgr/pollset_windows.c +2 -2
- data/src/core/lib/iomgr/port.h +9 -0
- data/src/core/lib/iomgr/resolve_address_posix.c +15 -9
- data/src/core/lib/iomgr/resolve_address_uv.c +8 -6
- data/src/core/lib/iomgr/resolve_address_windows.c +2 -2
- data/src/core/lib/iomgr/resource_quota.c +19 -4
- data/src/core/lib/iomgr/resource_quota.h +2 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +3 -1
- data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
- data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.c +25 -9
- data/src/core/lib/iomgr/socket_utils_posix.h +7 -0
- data/src/core/lib/iomgr/tcp_client.h +0 -4
- data/src/core/lib/iomgr/tcp_client_posix.c +15 -31
- data/src/core/lib/iomgr/tcp_client_uv.c +10 -6
- data/src/core/lib/iomgr/tcp_client_windows.c +9 -19
- data/src/core/lib/iomgr/tcp_posix.c +111 -22
- data/src/core/lib/iomgr/tcp_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_server_posix.c +39 -417
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
- data/src/core/lib/iomgr/tcp_server_uv.c +43 -16
- data/src/core/lib/iomgr/tcp_server_windows.c +10 -22
- data/src/core/lib/iomgr/tcp_uv.c +16 -13
- data/src/core/lib/iomgr/tcp_windows.c +24 -12
- data/src/core/lib/iomgr/tcp_windows.h +2 -2
- data/src/core/lib/iomgr/timer.h +3 -0
- data/src/core/lib/iomgr/timer_generic.c +257 -72
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_heap.c +8 -8
- data/src/core/lib/iomgr/udp_server.c +54 -24
- data/src/core/lib/iomgr/udp_server.h +7 -7
- data/src/core/lib/iomgr/unix_sockets_posix.c +1 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +2 -1
- data/src/core/lib/iomgr/wakeup_fd_posix.h +1 -1
- data/src/core/lib/profiling/basic_timers.c +1 -1
- data/src/core/lib/security/credentials/credentials.h +1 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +10 -9
- data/src/core/lib/security/credentials/jwt/json_token.c +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +2 -2
- data/src/core/lib/security/transport/client_auth_filter.c +33 -26
- data/src/core/lib/security/transport/secure_endpoint.c +8 -5
- data/src/core/lib/security/transport/security_connector.c +37 -37
- data/src/core/lib/security/transport/security_connector.h +1 -1
- data/src/core/lib/security/transport/security_handshaker.c +15 -12
- data/src/core/lib/security/transport/server_auth_filter.c +20 -18
- data/src/core/lib/security/transport/tsi_error.c +5 -3
- data/src/core/lib/security/transport/tsi_error.h +1 -1
- data/src/core/lib/{security/util → slice}/b64.c +21 -6
- data/src/core/lib/{security/util → slice}/b64.h +16 -4
- data/src/core/lib/slice/slice.c +4 -2
- data/src/core/lib/slice/slice_buffer.c +16 -14
- data/src/core/lib/support/arena.c +98 -0
- data/src/core/{ext/client_channel/initial_connect_string.c → lib/support/arena.h} +17 -15
- data/src/core/{ext/client_channel/default_initial_connect_string.c → lib/support/atm.c} +14 -5
- data/src/core/lib/support/cpu_linux.c +5 -0
- data/src/core/lib/support/sync.c +4 -0
- data/src/core/lib/support/time.c +4 -10
- data/src/core/lib/support/wrap_memcpy.c +3 -1
- data/src/core/lib/surface/call.c +252 -221
- data/src/core/lib/surface/channel.c +72 -21
- data/src/core/lib/surface/channel.h +8 -0
- data/src/core/lib/surface/completion_queue.c +2 -3
- data/src/core/lib/surface/completion_queue_factory.c +77 -0
- data/src/core/lib/surface/completion_queue_factory.h +51 -0
- data/src/core/lib/surface/init_secure.c +3 -1
- data/src/core/lib/surface/lame_client.c +18 -14
- data/src/core/lib/surface/server.c +43 -41
- data/src/core/lib/surface/validate_metadata.c +8 -4
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.h +1 -1
- data/src/core/lib/transport/connectivity_state.c +2 -1
- data/src/core/lib/transport/error_utils.c +17 -17
- data/src/core/lib/transport/error_utils.h +1 -1
- data/src/core/lib/transport/metadata_batch.c +6 -7
- data/src/core/lib/transport/pid_controller.c +1 -0
- data/src/core/lib/transport/service_config.c +12 -0
- data/src/core/lib/transport/service_config.h +6 -0
- data/src/core/lib/transport/transport.c +29 -17
- data/src/core/lib/transport/transport.h +85 -42
- data/src/core/lib/transport/transport_impl.h +5 -3
- data/src/core/lib/transport/transport_op_string.c +20 -14
- data/src/core/plugin_registry/grpc_plugin_registry.c +8 -0
- data/src/core/{lib/tsi → tsi}/fake_transport_security.c +2 -2
- data/src/core/{lib/tsi → tsi}/fake_transport_security.h +4 -4
- data/src/core/{lib/tsi → tsi}/ssl_transport_security.c +40 -79
- data/src/core/{lib/tsi → tsi}/ssl_transport_security.h +44 -21
- data/src/core/{lib/tsi → tsi}/ssl_types.h +3 -3
- data/src/core/{lib/tsi → tsi}/transport_security.c +2 -2
- data/src/core/{lib/tsi → tsi}/transport_security.h +4 -4
- data/src/core/{lib/tsi → tsi}/transport_security_interface.h +3 -3
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +2 -2
- data/src/ruby/ext/grpc/rb_channel.c +520 -93
- data/src/ruby/ext/grpc/rb_channel.h +2 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +5 -2
- data/src/ruby/ext/grpc/rb_event_thread.c +6 -6
- data/src/ruby/ext/grpc/rb_grpc.c +29 -7
- data/src/ruby/ext/grpc/rb_grpc.h +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_connection_spec.rb +173 -0
- data/src/ruby/spec/channel_spec.rb +29 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +27 -17
- data/third_party/cares/ares_build.h +264 -0
- data/third_party/cares/cares/ares.h +636 -0
- data/third_party/cares/cares/ares__close_sockets.c +61 -0
- data/third_party/cares/cares/ares__get_hostent.c +261 -0
- data/third_party/cares/cares/ares__read_line.c +73 -0
- data/third_party/cares/cares/ares__timeval.c +111 -0
- data/third_party/cares/cares/ares_cancel.c +63 -0
- data/third_party/cares/cares/ares_create_query.c +202 -0
- data/third_party/cares/cares/ares_data.c +221 -0
- data/third_party/cares/cares/ares_data.h +72 -0
- data/third_party/cares/cares/ares_destroy.c +108 -0
- data/third_party/cares/cares/ares_dns.h +103 -0
- data/third_party/cares/cares/ares_expand_name.c +205 -0
- data/third_party/cares/cares/ares_expand_string.c +70 -0
- data/third_party/cares/cares/ares_fds.c +59 -0
- data/third_party/cares/cares/ares_free_hostent.c +41 -0
- data/third_party/cares/cares/ares_free_string.c +25 -0
- data/third_party/cares/cares/ares_getenv.c +30 -0
- data/third_party/cares/cares/ares_getenv.h +26 -0
- data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
- data/third_party/cares/cares/ares_gethostbyname.c +518 -0
- data/third_party/cares/cares/ares_getnameinfo.c +422 -0
- data/third_party/cares/cares/ares_getopt.c +122 -0
- data/third_party/cares/cares/ares_getopt.h +53 -0
- data/third_party/cares/cares/ares_getsock.c +66 -0
- data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
- data/third_party/cares/cares/ares_init.c +2146 -0
- data/third_party/cares/cares/ares_iphlpapi.h +221 -0
- data/third_party/cares/cares/ares_ipv6.h +78 -0
- data/third_party/cares/cares/ares_library_init.c +167 -0
- data/third_party/cares/cares/ares_library_init.h +42 -0
- data/third_party/cares/cares/ares_llist.c +63 -0
- data/third_party/cares/cares/ares_llist.h +39 -0
- data/third_party/cares/cares/ares_mkquery.c +24 -0
- data/third_party/cares/cares/ares_nowarn.c +260 -0
- data/third_party/cares/cares/ares_nowarn.h +61 -0
- data/third_party/cares/cares/ares_options.c +402 -0
- data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
- data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
- data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
- data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
- data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
- data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
- data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
- data/third_party/cares/cares/ares_platform.c +11035 -0
- data/third_party/cares/cares/ares_platform.h +43 -0
- data/third_party/cares/cares/ares_private.h +363 -0
- data/third_party/cares/cares/ares_process.c +1359 -0
- data/third_party/cares/cares/ares_query.c +186 -0
- data/third_party/cares/cares/ares_rules.h +125 -0
- data/third_party/cares/cares/ares_search.c +316 -0
- data/third_party/cares/cares/ares_send.c +131 -0
- data/third_party/cares/cares/ares_setup.h +217 -0
- data/third_party/cares/cares/ares_strcasecmp.c +66 -0
- data/third_party/cares/cares/ares_strcasecmp.h +30 -0
- data/third_party/cares/cares/ares_strdup.c +49 -0
- data/third_party/cares/cares/ares_strdup.h +24 -0
- data/third_party/cares/cares/ares_strerror.c +56 -0
- data/third_party/cares/cares/ares_timeout.c +88 -0
- data/third_party/cares/cares/ares_version.c +11 -0
- data/third_party/cares/cares/ares_version.h +24 -0
- data/third_party/cares/cares/ares_writev.c +79 -0
- data/third_party/cares/cares/bitncmp.c +59 -0
- data/third_party/cares/cares/bitncmp.h +26 -0
- data/third_party/cares/cares/config-win32.h +377 -0
- data/third_party/cares/cares/inet_net_pton.c +450 -0
- data/third_party/cares/cares/inet_ntop.c +208 -0
- data/third_party/cares/cares/setup_once.h +554 -0
- data/third_party/cares/cares/windows_port.c +22 -0
- data/third_party/cares/config_darwin/ares_config.h +523 -0
- data/third_party/cares/config_linux/ares_config.h +524 -0
- metadata +164 -68
File without changes
|
@@ -35,8 +35,8 @@
|
|
35
35
|
|
36
36
|
#include <grpc/support/alloc.h>
|
37
37
|
|
38
|
-
#include "src/core/ext/client_channel/lb_policy_registry.h"
|
39
|
-
#include "src/core/ext/client_channel/subchannel.h"
|
38
|
+
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
39
|
+
#include "src/core/ext/filters/client_channel/subchannel.h"
|
40
40
|
#include "src/core/lib/channel/channel_args.h"
|
41
41
|
#include "src/core/lib/iomgr/combiner.h"
|
42
42
|
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
@@ -101,7 +101,7 @@ static void pf_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
101
101
|
p->pending_picks = NULL;
|
102
102
|
grpc_connectivity_state_set(
|
103
103
|
exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
|
104
|
-
|
104
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown"), "shutdown");
|
105
105
|
/* cancel subscription */
|
106
106
|
if (p->selected != NULL) {
|
107
107
|
grpc_connected_subchannel_notify_on_state_change(
|
@@ -131,9 +131,9 @@ static void pf_cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
131
131
|
pending_pick *next = pp->next;
|
132
132
|
if (pp->target == target) {
|
133
133
|
*target = NULL;
|
134
|
-
grpc_closure_sched(
|
135
|
-
|
136
|
-
|
134
|
+
grpc_closure_sched(exec_ctx, pp->on_complete,
|
135
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
136
|
+
"Pick Cancelled", &error, 1));
|
137
137
|
gpr_free(pp);
|
138
138
|
} else {
|
139
139
|
pp->next = p->pending_picks;
|
@@ -156,9 +156,9 @@ static void pf_cancel_picks_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
156
156
|
pending_pick *next = pp->next;
|
157
157
|
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
|
158
158
|
initial_metadata_flags_eq) {
|
159
|
-
grpc_closure_sched(
|
160
|
-
|
161
|
-
|
159
|
+
grpc_closure_sched(exec_ctx, pp->on_complete,
|
160
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
161
|
+
"Pick Cancelled", &error, 1));
|
162
162
|
gpr_free(pp);
|
163
163
|
} else {
|
164
164
|
pp->next = p->pending_picks;
|
@@ -325,8 +325,8 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
|
325
325
|
if (p->num_subchannels == 0) {
|
326
326
|
grpc_connectivity_state_set(
|
327
327
|
exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
|
328
|
-
|
329
|
-
|
328
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
329
|
+
"Pick first exhausted channels", &error, 1),
|
330
330
|
"no_more_channels");
|
331
331
|
while ((pp = p->pending_picks)) {
|
332
332
|
p->pending_picks = pp->next;
|
@@ -373,7 +373,8 @@ static void pf_ping_one_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
373
373
|
if (p->selected) {
|
374
374
|
grpc_connected_subchannel_ping(exec_ctx, p->selected, closure);
|
375
375
|
} else {
|
376
|
-
grpc_closure_sched(exec_ctx, closure,
|
376
|
+
grpc_closure_sched(exec_ctx, closure,
|
377
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Not connected"));
|
377
378
|
}
|
378
379
|
}
|
379
380
|
|
@@ -401,7 +402,9 @@ static grpc_lb_policy *create_pick_first(grpc_exec_ctx *exec_ctx,
|
|
401
402
|
* addresses, since we don't know how to handle them. */
|
402
403
|
const grpc_arg *arg =
|
403
404
|
grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
|
404
|
-
|
405
|
+
if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
|
406
|
+
return NULL;
|
407
|
+
}
|
405
408
|
grpc_lb_addresses *addresses = arg->value.pointer.p;
|
406
409
|
size_t num_addrs = 0;
|
407
410
|
for (size_t i = 0; i < addresses->num_addresses; i++) {
|
@@ -423,11 +426,13 @@ static grpc_lb_policy *create_pick_first(grpc_exec_ctx *exec_ctx,
|
|
423
426
|
"This LB policy doesn't support user data. It will be ignored");
|
424
427
|
}
|
425
428
|
|
429
|
+
static const char *keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS};
|
426
430
|
memset(&sc_args, 0, sizeof(grpc_subchannel_args));
|
427
431
|
grpc_arg addr_arg =
|
428
432
|
grpc_create_subchannel_address_arg(&addresses->addresses[i].address);
|
429
|
-
grpc_channel_args *new_args =
|
430
|
-
|
433
|
+
grpc_channel_args *new_args = grpc_channel_args_copy_and_add_and_remove(
|
434
|
+
args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &addr_arg,
|
435
|
+
1);
|
431
436
|
gpr_free(addr_arg.value.string);
|
432
437
|
sc_args.args = new_args;
|
433
438
|
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
|
@@ -63,8 +63,8 @@
|
|
63
63
|
|
64
64
|
#include <grpc/support/alloc.h>
|
65
65
|
|
66
|
-
#include "src/core/ext/client_channel/lb_policy_registry.h"
|
67
|
-
#include "src/core/ext/client_channel/subchannel.h"
|
66
|
+
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
67
|
+
#include "src/core/ext/filters/client_channel/subchannel.h"
|
68
68
|
#include "src/core/lib/channel/channel_args.h"
|
69
69
|
#include "src/core/lib/debug/trace.h"
|
70
70
|
#include "src/core/lib/iomgr/combiner.h"
|
@@ -320,13 +320,14 @@ static void rr_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
|
|
320
320
|
while ((pp = p->pending_picks)) {
|
321
321
|
p->pending_picks = pp->next;
|
322
322
|
*pp->target = NULL;
|
323
|
-
grpc_closure_sched(
|
324
|
-
|
323
|
+
grpc_closure_sched(
|
324
|
+
exec_ctx, pp->on_complete,
|
325
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"));
|
325
326
|
gpr_free(pp);
|
326
327
|
}
|
327
328
|
grpc_connectivity_state_set(
|
328
329
|
exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
|
329
|
-
|
330
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"), "rr_shutdown");
|
330
331
|
for (i = 0; i < p->num_subchannels; i++) {
|
331
332
|
subchannel_data *sd = p->subchannels[i];
|
332
333
|
grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL, NULL,
|
@@ -345,9 +346,9 @@ static void rr_cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
345
346
|
pending_pick *next = pp->next;
|
346
347
|
if (pp->target == target) {
|
347
348
|
*target = NULL;
|
348
|
-
grpc_closure_sched(
|
349
|
-
|
350
|
-
|
349
|
+
grpc_closure_sched(exec_ctx, pp->on_complete,
|
350
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
351
|
+
"Pick cancelled", &error, 1));
|
351
352
|
gpr_free(pp);
|
352
353
|
} else {
|
353
354
|
pp->next = p->pending_picks;
|
@@ -371,9 +372,9 @@ static void rr_cancel_picks_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
371
372
|
if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
|
372
373
|
initial_metadata_flags_eq) {
|
373
374
|
*pp->target = NULL;
|
374
|
-
grpc_closure_sched(
|
375
|
-
|
376
|
-
|
375
|
+
grpc_closure_sched(exec_ctx, pp->on_complete,
|
376
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
377
|
+
"Pick cancelled", &error, 1));
|
377
378
|
gpr_free(pp);
|
378
379
|
} else {
|
379
380
|
pp->next = p->pending_picks;
|
@@ -661,8 +662,8 @@ static void rr_ping_one_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
|
|
661
662
|
grpc_connected_subchannel_ping(exec_ctx, target, closure);
|
662
663
|
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, target, "rr_picked");
|
663
664
|
} else {
|
664
|
-
grpc_closure_sched(exec_ctx, closure,
|
665
|
-
|
665
|
+
grpc_closure_sched(exec_ctx, closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
666
|
+
"Round Robin not connected"));
|
666
667
|
}
|
667
668
|
}
|
668
669
|
|
@@ -690,7 +691,9 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
|
|
690
691
|
* addresses, since we don't know how to handle them. */
|
691
692
|
const grpc_arg *arg =
|
692
693
|
grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
|
693
|
-
|
694
|
+
if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
|
695
|
+
return NULL;
|
696
|
+
}
|
694
697
|
grpc_lb_addresses *addresses = arg->value.pointer.p;
|
695
698
|
size_t num_addrs = 0;
|
696
699
|
for (size_t i = 0; i < addresses->num_addresses; i++) {
|
@@ -709,11 +712,13 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
|
|
709
712
|
/* Skip balancer addresses, since we only know how to handle backends. */
|
710
713
|
if (addresses->addresses[i].is_balancer) continue;
|
711
714
|
|
715
|
+
static const char *keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS};
|
712
716
|
memset(&sc_args, 0, sizeof(grpc_subchannel_args));
|
713
717
|
grpc_arg addr_arg =
|
714
718
|
grpc_create_subchannel_address_arg(&addresses->addresses[i].address);
|
715
|
-
grpc_channel_args *new_args =
|
716
|
-
|
719
|
+
grpc_channel_args *new_args = grpc_channel_args_copy_and_add_and_remove(
|
720
|
+
args->args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove), &addr_arg,
|
721
|
+
1);
|
717
722
|
gpr_free(addr_arg.value.string);
|
718
723
|
sc_args.args = new_args;
|
719
724
|
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
|
@@ -36,7 +36,7 @@
|
|
36
36
|
#include <grpc/support/alloc.h>
|
37
37
|
#include <grpc/support/string_util.h>
|
38
38
|
|
39
|
-
#include "src/core/ext/client_channel/lb_policy_factory.h"
|
39
|
+
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
40
40
|
|
41
41
|
grpc_lb_addresses* grpc_lb_addresses_create(
|
42
42
|
size_t num_addresses, const grpc_lb_user_data_vtable* user_data_vtable) {
|
@@ -31,11 +31,11 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H
|
36
36
|
|
37
|
-
#include "src/core/ext/client_channel/client_channel_factory.h"
|
38
|
-
#include "src/core/ext/client_channel/lb_policy.h"
|
37
|
+
#include "src/core/ext/filters/client_channel/client_channel_factory.h"
|
38
|
+
#include "src/core/ext/filters/client_channel/lb_policy.h"
|
39
39
|
|
40
40
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
41
41
|
#include "src/core/lib/iomgr/resolve_address.h"
|
@@ -131,4 +131,4 @@ grpc_lb_policy *grpc_lb_policy_factory_create_lb_policy(
|
|
131
131
|
grpc_exec_ctx *exec_ctx, grpc_lb_policy_factory *factory,
|
132
132
|
grpc_lb_policy_args *args);
|
133
133
|
|
134
|
-
#endif /*
|
134
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H */
|
@@ -31,10 +31,10 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H
|
36
36
|
|
37
|
-
#include "src/core/ext/client_channel/lb_policy_factory.h"
|
37
|
+
#include "src/core/ext/filters/client_channel/lb_policy_factory.h"
|
38
38
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
39
39
|
|
40
40
|
/** Initialize the registry and set \a default_factory as the factory to be
|
@@ -52,4 +52,4 @@ void grpc_register_lb_policy(grpc_lb_policy_factory *factory);
|
|
52
52
|
grpc_lb_policy *grpc_lb_policy_create(grpc_exec_ctx *exec_ctx, const char *name,
|
53
53
|
grpc_lb_policy_args *args);
|
54
54
|
|
55
|
-
#endif /*
|
55
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */
|
@@ -31,12 +31,12 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H
|
36
36
|
|
37
37
|
#include <stddef.h>
|
38
38
|
|
39
|
-
#include "src/core/ext/client_channel/uri_parser.h"
|
39
|
+
#include "src/core/ext/filters/client_channel/uri_parser.h"
|
40
40
|
#include "src/core/lib/iomgr/resolve_address.h"
|
41
41
|
|
42
42
|
/** Populate \a addr and \a len from \a uri, whose path is expected to contain a
|
@@ -51,4 +51,4 @@ int parse_ipv4(grpc_uri *uri, grpc_resolved_address *resolved_addr);
|
|
51
51
|
* host:port pair. Returns true upon success. */
|
52
52
|
int parse_ipv6(grpc_uri *uri, grpc_resolved_address *resolved_addr);
|
53
53
|
|
54
|
-
#endif /*
|
54
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */
|
@@ -31,8 +31,8 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H
|
36
36
|
|
37
37
|
#include <stdbool.h>
|
38
38
|
|
@@ -86,4 +86,4 @@ bool grpc_proxy_mapper_map_address(grpc_exec_ctx* exec_ctx,
|
|
86
86
|
|
87
87
|
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper);
|
88
88
|
|
89
|
-
#endif /*
|
89
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H */
|
@@ -31,7 +31,7 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#include "src/core/ext/client_channel/proxy_mapper_registry.h"
|
34
|
+
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
|
35
35
|
|
36
36
|
#include <string.h>
|
37
37
|
|
@@ -94,6 +94,14 @@ static void grpc_proxy_mapper_list_destroy(grpc_proxy_mapper_list* list) {
|
|
94
94
|
grpc_proxy_mapper_destroy(list->list[i]);
|
95
95
|
}
|
96
96
|
gpr_free(list->list);
|
97
|
+
// Clean up in case we re-initialze later.
|
98
|
+
// TODO(ctiller): This should ideally live in
|
99
|
+
// grpc_proxy_mapper_registry_init(). However, if we did this there,
|
100
|
+
// then we would do it AFTER we start registering proxy mappers from
|
101
|
+
// third-party plugins, so they'd never show up (and would leak memory).
|
102
|
+
// We probably need some sort of dependency system for plugins to fix
|
103
|
+
// this.
|
104
|
+
memset(list, 0, sizeof(*list));
|
97
105
|
}
|
98
106
|
|
99
107
|
//
|
@@ -102,9 +110,7 @@ static void grpc_proxy_mapper_list_destroy(grpc_proxy_mapper_list* list) {
|
|
102
110
|
|
103
111
|
static grpc_proxy_mapper_list g_proxy_mapper_list;
|
104
112
|
|
105
|
-
void grpc_proxy_mapper_registry_init() {
|
106
|
-
memset(&g_proxy_mapper_list, 0, sizeof(g_proxy_mapper_list));
|
107
|
-
}
|
113
|
+
void grpc_proxy_mapper_registry_init() {}
|
108
114
|
|
109
115
|
void grpc_proxy_mapper_registry_shutdown() {
|
110
116
|
grpc_proxy_mapper_list_destroy(&g_proxy_mapper_list);
|
@@ -31,10 +31,10 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H
|
36
36
|
|
37
|
-
#include "src/core/ext/client_channel/proxy_mapper.h"
|
37
|
+
#include "src/core/ext/filters/client_channel/proxy_mapper.h"
|
38
38
|
|
39
39
|
void grpc_proxy_mapper_registry_init();
|
40
40
|
void grpc_proxy_mapper_registry_shutdown();
|
@@ -56,4 +56,4 @@ bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx,
|
|
56
56
|
grpc_resolved_address** new_address,
|
57
57
|
grpc_channel_args** new_args);
|
58
58
|
|
59
|
-
#endif /*
|
59
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */
|
@@ -31,10 +31,10 @@
|
|
31
31
|
*
|
32
32
|
*/
|
33
33
|
|
34
|
-
#ifndef
|
35
|
-
#define
|
34
|
+
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_H
|
35
|
+
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_H
|
36
36
|
|
37
|
-
#include "src/core/ext/client_channel/subchannel.h"
|
37
|
+
#include "src/core/ext/filters/client_channel/subchannel.h"
|
38
38
|
#include "src/core/lib/iomgr/iomgr.h"
|
39
39
|
|
40
40
|
typedef struct grpc_resolver grpc_resolver;
|
@@ -98,4 +98,4 @@ void grpc_resolver_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
|
|
98
98
|
grpc_channel_args **result,
|
99
99
|
grpc_closure *on_complete);
|
100
100
|
|
101
|
-
#endif /*
|
101
|
+
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_H */
|
@@ -0,0 +1,350 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2015, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#include <grpc/support/port_platform.h>
|
35
|
+
#if GRPC_ARES == 1 && !defined(GRPC_UV)
|
36
|
+
|
37
|
+
#include <string.h>
|
38
|
+
|
39
|
+
#include <grpc/support/alloc.h>
|
40
|
+
#include <grpc/support/host_port.h>
|
41
|
+
#include <grpc/support/string_util.h>
|
42
|
+
|
43
|
+
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
|
44
|
+
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
45
|
+
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
|
46
|
+
#include "src/core/ext/filters/client_channel/resolver_registry.h"
|
47
|
+
#include "src/core/lib/channel/channel_args.h"
|
48
|
+
#include "src/core/lib/iomgr/combiner.h"
|
49
|
+
#include "src/core/lib/iomgr/resolve_address.h"
|
50
|
+
#include "src/core/lib/iomgr/timer.h"
|
51
|
+
#include "src/core/lib/support/backoff.h"
|
52
|
+
#include "src/core/lib/support/env.h"
|
53
|
+
#include "src/core/lib/support/string.h"
|
54
|
+
|
55
|
+
#define GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS 1
|
56
|
+
#define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1
|
57
|
+
#define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6
|
58
|
+
#define GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS 120
|
59
|
+
#define GRPC_DNS_RECONNECT_JITTER 0.2
|
60
|
+
|
61
|
+
typedef struct {
|
62
|
+
/** base class: must be first */
|
63
|
+
grpc_resolver base;
|
64
|
+
/** name to resolve (usually the same as target_name) */
|
65
|
+
char *name_to_resolve;
|
66
|
+
/** default port to use */
|
67
|
+
char *default_port;
|
68
|
+
/** channel args. */
|
69
|
+
grpc_channel_args *channel_args;
|
70
|
+
/** pollset_set to drive the name resolution process */
|
71
|
+
grpc_pollset_set *interested_parties;
|
72
|
+
|
73
|
+
/** Closures used by the combiner */
|
74
|
+
grpc_closure dns_ares_on_retry_timer_locked;
|
75
|
+
grpc_closure dns_ares_on_resolved_locked;
|
76
|
+
|
77
|
+
/** Combiner guarding the rest of the state */
|
78
|
+
grpc_combiner *combiner;
|
79
|
+
/** are we currently resolving? */
|
80
|
+
bool resolving;
|
81
|
+
/** which version of the result have we published? */
|
82
|
+
int published_version;
|
83
|
+
/** which version of the result is current? */
|
84
|
+
int resolved_version;
|
85
|
+
/** pending next completion, or NULL */
|
86
|
+
grpc_closure *next_completion;
|
87
|
+
/** target result address for next completion */
|
88
|
+
grpc_channel_args **target_result;
|
89
|
+
/** current (fully resolved) result */
|
90
|
+
grpc_channel_args *resolved_result;
|
91
|
+
/** retry timer */
|
92
|
+
bool have_retry_timer;
|
93
|
+
grpc_timer retry_timer;
|
94
|
+
/** retry backoff state */
|
95
|
+
gpr_backoff backoff_state;
|
96
|
+
|
97
|
+
/** currently resolving addresses */
|
98
|
+
grpc_resolved_addresses *addresses;
|
99
|
+
} ares_dns_resolver;
|
100
|
+
|
101
|
+
static void dns_ares_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
|
102
|
+
|
103
|
+
static void dns_ares_start_resolving_locked(grpc_exec_ctx *exec_ctx,
|
104
|
+
ares_dns_resolver *r);
|
105
|
+
static void dns_ares_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
|
106
|
+
ares_dns_resolver *r);
|
107
|
+
|
108
|
+
static void dns_ares_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
|
109
|
+
static void dns_ares_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
|
110
|
+
grpc_resolver *r);
|
111
|
+
static void dns_ares_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *r,
|
112
|
+
grpc_channel_args **target_result,
|
113
|
+
grpc_closure *on_complete);
|
114
|
+
|
115
|
+
static const grpc_resolver_vtable dns_ares_resolver_vtable = {
|
116
|
+
dns_ares_destroy, dns_ares_shutdown_locked,
|
117
|
+
dns_ares_channel_saw_error_locked, dns_ares_next_locked};
|
118
|
+
|
119
|
+
static void dns_ares_shutdown_locked(grpc_exec_ctx *exec_ctx,
|
120
|
+
grpc_resolver *resolver) {
|
121
|
+
ares_dns_resolver *r = (ares_dns_resolver *)resolver;
|
122
|
+
if (r->have_retry_timer) {
|
123
|
+
grpc_timer_cancel(exec_ctx, &r->retry_timer);
|
124
|
+
}
|
125
|
+
if (r->next_completion != NULL) {
|
126
|
+
*r->target_result = NULL;
|
127
|
+
grpc_closure_sched(
|
128
|
+
exec_ctx, r->next_completion,
|
129
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resolver Shutdown"));
|
130
|
+
r->next_completion = NULL;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
static void dns_ares_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
|
135
|
+
grpc_resolver *resolver) {
|
136
|
+
ares_dns_resolver *r = (ares_dns_resolver *)resolver;
|
137
|
+
if (!r->resolving) {
|
138
|
+
gpr_backoff_reset(&r->backoff_state);
|
139
|
+
dns_ares_start_resolving_locked(exec_ctx, r);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
static void dns_ares_on_retry_timer_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
144
|
+
grpc_error *error) {
|
145
|
+
ares_dns_resolver *r = arg;
|
146
|
+
r->have_retry_timer = false;
|
147
|
+
if (error == GRPC_ERROR_NONE) {
|
148
|
+
if (!r->resolving) {
|
149
|
+
dns_ares_start_resolving_locked(exec_ctx, r);
|
150
|
+
}
|
151
|
+
}
|
152
|
+
GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "retry-timer");
|
153
|
+
}
|
154
|
+
|
155
|
+
static void dns_ares_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
156
|
+
grpc_error *error) {
|
157
|
+
ares_dns_resolver *r = arg;
|
158
|
+
grpc_channel_args *result = NULL;
|
159
|
+
GPR_ASSERT(r->resolving);
|
160
|
+
r->resolving = false;
|
161
|
+
if (r->addresses != NULL) {
|
162
|
+
grpc_lb_addresses *addresses = grpc_lb_addresses_create(
|
163
|
+
r->addresses->naddrs, NULL /* user_data_vtable */);
|
164
|
+
for (size_t i = 0; i < r->addresses->naddrs; ++i) {
|
165
|
+
grpc_lb_addresses_set_address(
|
166
|
+
addresses, i, &r->addresses->addrs[i].addr,
|
167
|
+
r->addresses->addrs[i].len, false /* is_balancer */,
|
168
|
+
NULL /* balancer_name */, NULL /* user_data */);
|
169
|
+
}
|
170
|
+
grpc_arg new_arg = grpc_lb_addresses_create_channel_arg(addresses);
|
171
|
+
result = grpc_channel_args_copy_and_add(r->channel_args, &new_arg, 1);
|
172
|
+
grpc_resolved_addresses_destroy(r->addresses);
|
173
|
+
grpc_lb_addresses_destroy(exec_ctx, addresses);
|
174
|
+
} else {
|
175
|
+
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
|
176
|
+
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
|
177
|
+
gpr_timespec timeout = gpr_time_sub(next_try, now);
|
178
|
+
gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
|
179
|
+
grpc_error_string(error));
|
180
|
+
GPR_ASSERT(!r->have_retry_timer);
|
181
|
+
r->have_retry_timer = true;
|
182
|
+
GRPC_RESOLVER_REF(&r->base, "retry-timer");
|
183
|
+
if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
|
184
|
+
gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec,
|
185
|
+
timeout.tv_nsec);
|
186
|
+
} else {
|
187
|
+
gpr_log(GPR_DEBUG, "retrying immediately");
|
188
|
+
}
|
189
|
+
grpc_timer_init(exec_ctx, &r->retry_timer, next_try,
|
190
|
+
&r->dns_ares_on_retry_timer_locked, now);
|
191
|
+
}
|
192
|
+
if (r->resolved_result != NULL) {
|
193
|
+
grpc_channel_args_destroy(exec_ctx, r->resolved_result);
|
194
|
+
}
|
195
|
+
r->resolved_result = result;
|
196
|
+
r->resolved_version++;
|
197
|
+
dns_ares_maybe_finish_next_locked(exec_ctx, r);
|
198
|
+
GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving");
|
199
|
+
}
|
200
|
+
|
201
|
+
static void dns_ares_next_locked(grpc_exec_ctx *exec_ctx,
|
202
|
+
grpc_resolver *resolver,
|
203
|
+
grpc_channel_args **target_result,
|
204
|
+
grpc_closure *on_complete) {
|
205
|
+
gpr_log(GPR_DEBUG, "dns_ares_next is called.");
|
206
|
+
ares_dns_resolver *r = (ares_dns_resolver *)resolver;
|
207
|
+
GPR_ASSERT(!r->next_completion);
|
208
|
+
r->next_completion = on_complete;
|
209
|
+
r->target_result = target_result;
|
210
|
+
if (r->resolved_version == 0 && !r->resolving) {
|
211
|
+
gpr_backoff_reset(&r->backoff_state);
|
212
|
+
dns_ares_start_resolving_locked(exec_ctx, r);
|
213
|
+
} else {
|
214
|
+
dns_ares_maybe_finish_next_locked(exec_ctx, r);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
static void dns_ares_start_resolving_locked(grpc_exec_ctx *exec_ctx,
|
219
|
+
ares_dns_resolver *r) {
|
220
|
+
GRPC_RESOLVER_REF(&r->base, "dns-resolving");
|
221
|
+
GPR_ASSERT(!r->resolving);
|
222
|
+
r->resolving = true;
|
223
|
+
r->addresses = NULL;
|
224
|
+
grpc_resolve_address(exec_ctx, r->name_to_resolve, r->default_port,
|
225
|
+
r->interested_parties, &r->dns_ares_on_resolved_locked,
|
226
|
+
&r->addresses);
|
227
|
+
}
|
228
|
+
|
229
|
+
static void dns_ares_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
|
230
|
+
ares_dns_resolver *r) {
|
231
|
+
if (r->next_completion != NULL &&
|
232
|
+
r->resolved_version != r->published_version) {
|
233
|
+
*r->target_result = r->resolved_result == NULL
|
234
|
+
? NULL
|
235
|
+
: grpc_channel_args_copy(r->resolved_result);
|
236
|
+
grpc_closure_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE);
|
237
|
+
r->next_completion = NULL;
|
238
|
+
r->published_version = r->resolved_version;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
static void dns_ares_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
|
243
|
+
gpr_log(GPR_DEBUG, "dns_ares_destroy");
|
244
|
+
ares_dns_resolver *r = (ares_dns_resolver *)gr;
|
245
|
+
if (r->resolved_result != NULL) {
|
246
|
+
grpc_channel_args_destroy(exec_ctx, r->resolved_result);
|
247
|
+
}
|
248
|
+
grpc_pollset_set_destroy(exec_ctx, r->interested_parties);
|
249
|
+
gpr_free(r->name_to_resolve);
|
250
|
+
gpr_free(r->default_port);
|
251
|
+
grpc_channel_args_destroy(exec_ctx, r->channel_args);
|
252
|
+
gpr_free(r);
|
253
|
+
}
|
254
|
+
|
255
|
+
static grpc_resolver *dns_ares_create(grpc_exec_ctx *exec_ctx,
|
256
|
+
grpc_resolver_args *args,
|
257
|
+
const char *default_port) {
|
258
|
+
// Get name from args.
|
259
|
+
const char *path = args->uri->path;
|
260
|
+
if (0 != strcmp(args->uri->authority, "")) {
|
261
|
+
gpr_log(GPR_ERROR, "authority based dns uri's not supported");
|
262
|
+
return NULL;
|
263
|
+
}
|
264
|
+
if (path[0] == '/') ++path;
|
265
|
+
// Create resolver.
|
266
|
+
ares_dns_resolver *r = gpr_zalloc(sizeof(ares_dns_resolver));
|
267
|
+
grpc_resolver_init(&r->base, &dns_ares_resolver_vtable, args->combiner);
|
268
|
+
r->name_to_resolve = gpr_strdup(path);
|
269
|
+
r->default_port = gpr_strdup(default_port);
|
270
|
+
r->channel_args = grpc_channel_args_copy(args->args);
|
271
|
+
r->interested_parties = grpc_pollset_set_create();
|
272
|
+
if (args->pollset_set != NULL) {
|
273
|
+
grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
|
274
|
+
args->pollset_set);
|
275
|
+
}
|
276
|
+
gpr_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS,
|
277
|
+
GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER,
|
278
|
+
GRPC_DNS_RECONNECT_JITTER,
|
279
|
+
GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
|
280
|
+
GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
|
281
|
+
grpc_closure_init(&r->dns_ares_on_retry_timer_locked,
|
282
|
+
dns_ares_on_retry_timer_locked, r,
|
283
|
+
grpc_combiner_scheduler(r->base.combiner, false));
|
284
|
+
grpc_closure_init(&r->dns_ares_on_resolved_locked,
|
285
|
+
dns_ares_on_resolved_locked, r,
|
286
|
+
grpc_combiner_scheduler(r->base.combiner, false));
|
287
|
+
return &r->base;
|
288
|
+
}
|
289
|
+
|
290
|
+
/*
|
291
|
+
* FACTORY
|
292
|
+
*/
|
293
|
+
|
294
|
+
static void dns_ares_factory_ref(grpc_resolver_factory *factory) {}
|
295
|
+
|
296
|
+
static void dns_ares_factory_unref(grpc_resolver_factory *factory) {}
|
297
|
+
|
298
|
+
static grpc_resolver *dns_factory_create_resolver(
|
299
|
+
grpc_exec_ctx *exec_ctx, grpc_resolver_factory *factory,
|
300
|
+
grpc_resolver_args *args) {
|
301
|
+
return dns_ares_create(exec_ctx, args, "https");
|
302
|
+
}
|
303
|
+
|
304
|
+
static char *dns_ares_factory_get_default_host_name(
|
305
|
+
grpc_resolver_factory *factory, grpc_uri *uri) {
|
306
|
+
const char *path = uri->path;
|
307
|
+
if (path[0] == '/') ++path;
|
308
|
+
return gpr_strdup(path);
|
309
|
+
}
|
310
|
+
|
311
|
+
static const grpc_resolver_factory_vtable dns_ares_factory_vtable = {
|
312
|
+
dns_ares_factory_ref, dns_ares_factory_unref, dns_factory_create_resolver,
|
313
|
+
dns_ares_factory_get_default_host_name, "dns"};
|
314
|
+
static grpc_resolver_factory dns_resolver_factory = {&dns_ares_factory_vtable};
|
315
|
+
|
316
|
+
static grpc_resolver_factory *dns_ares_resolver_factory_create() {
|
317
|
+
return &dns_resolver_factory;
|
318
|
+
}
|
319
|
+
|
320
|
+
void grpc_resolver_dns_ares_init(void) {
|
321
|
+
char *resolver = gpr_getenv("GRPC_DNS_RESOLVER");
|
322
|
+
/* TODO(zyc): Turn on c-ares based resolver by default after the address
|
323
|
+
sorter and the CNAME support are added. */
|
324
|
+
if (resolver != NULL && gpr_stricmp(resolver, "ares") == 0) {
|
325
|
+
grpc_error *error = grpc_ares_init();
|
326
|
+
if (error != GRPC_ERROR_NONE) {
|
327
|
+
GRPC_LOG_IF_ERROR("ares_library_init() failed", error);
|
328
|
+
return;
|
329
|
+
}
|
330
|
+
grpc_resolve_address = grpc_resolve_address_ares;
|
331
|
+
grpc_register_resolver_type(dns_ares_resolver_factory_create());
|
332
|
+
}
|
333
|
+
gpr_free(resolver);
|
334
|
+
}
|
335
|
+
|
336
|
+
void grpc_resolver_dns_ares_shutdown(void) {
|
337
|
+
char *resolver = gpr_getenv("GRPC_DNS_RESOLVER");
|
338
|
+
if (resolver != NULL && gpr_stricmp(resolver, "ares") == 0) {
|
339
|
+
grpc_ares_cleanup();
|
340
|
+
}
|
341
|
+
gpr_free(resolver);
|
342
|
+
}
|
343
|
+
|
344
|
+
#else /* GRPC_ARES == 1 && !defined(GRPC_UV) */
|
345
|
+
|
346
|
+
void grpc_resolver_dns_ares_init(void) {}
|
347
|
+
|
348
|
+
void grpc_resolver_dns_ares_shutdown(void) {}
|
349
|
+
|
350
|
+
#endif /* GRPC_ARES == 1 && !defined(GRPC_UV) */
|