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
@@ -90,7 +90,7 @@ grpc_error *grpc_set_socket_no_sigpipe_if_possible(int fd) {
|
|
90
90
|
return GRPC_OS_ERROR(errno, "getsockopt(SO_NOSIGPIPE)");
|
91
91
|
}
|
92
92
|
if ((newval != 0) != (val != 0)) {
|
93
|
-
return
|
93
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set SO_NOSIGPIPE");
|
94
94
|
}
|
95
95
|
#endif
|
96
96
|
return GRPC_ERROR_NONE;
|
@@ -164,7 +164,7 @@ grpc_error *grpc_set_socket_reuse_addr(int fd, int reuse) {
|
|
164
164
|
return GRPC_OS_ERROR(errno, "getsockopt(SO_REUSEADDR)");
|
165
165
|
}
|
166
166
|
if ((newval != 0) != val) {
|
167
|
-
return
|
167
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set SO_REUSEADDR");
|
168
168
|
}
|
169
169
|
|
170
170
|
return GRPC_ERROR_NONE;
|
@@ -173,7 +173,8 @@ grpc_error *grpc_set_socket_reuse_addr(int fd, int reuse) {
|
|
173
173
|
/* set a socket to reuse old addresses */
|
174
174
|
grpc_error *grpc_set_socket_reuse_port(int fd, int reuse) {
|
175
175
|
#ifndef SO_REUSEPORT
|
176
|
-
return
|
176
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
177
|
+
"SO_REUSEPORT unavailable on compiling system");
|
177
178
|
#else
|
178
179
|
int val = (reuse != 0);
|
179
180
|
int newval;
|
@@ -185,7 +186,7 @@ grpc_error *grpc_set_socket_reuse_port(int fd, int reuse) {
|
|
185
186
|
return GRPC_OS_ERROR(errno, "getsockopt(SO_REUSEPORT)");
|
186
187
|
}
|
187
188
|
if ((newval != 0) != val) {
|
188
|
-
return
|
189
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set SO_REUSEPORT");
|
189
190
|
}
|
190
191
|
|
191
192
|
return GRPC_ERROR_NONE;
|
@@ -204,7 +205,7 @@ grpc_error *grpc_set_socket_low_latency(int fd, int low_latency) {
|
|
204
205
|
return GRPC_OS_ERROR(errno, "getsockopt(TCP_NODELAY)");
|
205
206
|
}
|
206
207
|
if ((newval != 0) != val) {
|
207
|
-
return
|
208
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Failed to set TCP_NODELAY");
|
208
209
|
}
|
209
210
|
return GRPC_ERROR_NONE;
|
210
211
|
}
|
@@ -213,7 +214,7 @@ grpc_error *grpc_set_socket_low_latency(int fd, int low_latency) {
|
|
213
214
|
grpc_error *grpc_set_socket_with_mutator(int fd, grpc_socket_mutator *mutator) {
|
214
215
|
GPR_ASSERT(mutator);
|
215
216
|
if (!grpc_socket_mutator_mutate_fd(mutator, fd)) {
|
216
|
-
return
|
217
|
+
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("grpc_socket_mutator failed.");
|
217
218
|
}
|
218
219
|
return GRPC_ERROR_NONE;
|
219
220
|
}
|
@@ -268,7 +269,8 @@ static grpc_error *error_for_fd(int fd, const grpc_resolved_address *addr) {
|
|
268
269
|
char *addr_str;
|
269
270
|
grpc_sockaddr_to_string(&addr_str, addr, 0);
|
270
271
|
grpc_error *err = grpc_error_set_str(GRPC_OS_ERROR(errno, "socket"),
|
271
|
-
GRPC_ERROR_STR_TARGET_ADDRESS,
|
272
|
+
GRPC_ERROR_STR_TARGET_ADDRESS,
|
273
|
+
grpc_slice_from_copied_string(addr_str));
|
272
274
|
gpr_free(addr_str);
|
273
275
|
return err;
|
274
276
|
}
|
@@ -276,11 +278,25 @@ static grpc_error *error_for_fd(int fd, const grpc_resolved_address *addr) {
|
|
276
278
|
grpc_error *grpc_create_dualstack_socket(
|
277
279
|
const grpc_resolved_address *resolved_addr, int type, int protocol,
|
278
280
|
grpc_dualstack_mode *dsmode, int *newfd) {
|
281
|
+
return grpc_create_dualstack_socket_using_factory(NULL, resolved_addr, type,
|
282
|
+
protocol, dsmode, newfd);
|
283
|
+
}
|
284
|
+
|
285
|
+
static int create_socket(grpc_socket_factory *factory, int domain, int type,
|
286
|
+
int protocol) {
|
287
|
+
return (factory != NULL)
|
288
|
+
? grpc_socket_factory_socket(factory, domain, type, protocol)
|
289
|
+
: socket(domain, type, protocol);
|
290
|
+
}
|
291
|
+
|
292
|
+
grpc_error *grpc_create_dualstack_socket_using_factory(
|
293
|
+
grpc_socket_factory *factory, const grpc_resolved_address *resolved_addr,
|
294
|
+
int type, int protocol, grpc_dualstack_mode *dsmode, int *newfd) {
|
279
295
|
const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
|
280
296
|
int family = addr->sa_family;
|
281
297
|
if (family == AF_INET6) {
|
282
298
|
if (grpc_ipv6_loopback_available()) {
|
283
|
-
*newfd =
|
299
|
+
*newfd = create_socket(factory, family, type, protocol);
|
284
300
|
} else {
|
285
301
|
*newfd = -1;
|
286
302
|
errno = EAFNOSUPPORT;
|
@@ -302,7 +318,7 @@ grpc_error *grpc_create_dualstack_socket(
|
|
302
318
|
family = AF_INET;
|
303
319
|
}
|
304
320
|
*dsmode = family == AF_INET ? GRPC_DSMODE_IPV4 : GRPC_DSMODE_NONE;
|
305
|
-
*newfd =
|
321
|
+
*newfd = create_socket(factory, family, type, protocol);
|
306
322
|
return error_for_fd(*newfd, resolved_addr);
|
307
323
|
}
|
308
324
|
|
@@ -41,6 +41,7 @@
|
|
41
41
|
|
42
42
|
#include <grpc/impl/codegen/grpc_types.h>
|
43
43
|
#include "src/core/lib/iomgr/error.h"
|
44
|
+
#include "src/core/lib/iomgr/socket_factory_posix.h"
|
44
45
|
#include "src/core/lib/iomgr/socket_mutator.h"
|
45
46
|
|
46
47
|
/* a wrapper for accept or accept4 */
|
@@ -137,4 +138,10 @@ grpc_error *grpc_create_dualstack_socket(const grpc_resolved_address *addr,
|
|
137
138
|
grpc_dualstack_mode *dsmode,
|
138
139
|
int *newfd);
|
139
140
|
|
141
|
+
/* Same as grpc_create_dualstack_socket(), but use the given socket factory (if
|
142
|
+
non-null) to create the socket, rather than calling socket() directly. */
|
143
|
+
grpc_error *grpc_create_dualstack_socket_using_factory(
|
144
|
+
grpc_socket_factory *factory, const grpc_resolved_address *addr, int type,
|
145
|
+
int protocol, grpc_dualstack_mode *dsmode, int *newfd);
|
146
|
+
|
140
147
|
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */
|
@@ -40,10 +40,6 @@
|
|
40
40
|
#include "src/core/lib/iomgr/pollset_set.h"
|
41
41
|
#include "src/core/lib/iomgr/resolve_address.h"
|
42
42
|
|
43
|
-
/* Channel arg (integer) setting how large a slice to try and read from the wire
|
44
|
-
each time recvmsg (or equivalent) is called */
|
45
|
-
#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size"
|
46
|
-
|
47
43
|
/* Asynchronously connect to an address (specified as (addr, len)), and call
|
48
44
|
cb with arg and the completed connection when done (or call cb with arg and
|
49
45
|
NULL on failure).
|
@@ -121,8 +121,8 @@ static void tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
|
|
121
121
|
}
|
122
122
|
gpr_mu_lock(&ac->mu);
|
123
123
|
if (ac->fd != NULL) {
|
124
|
-
grpc_fd_shutdown(exec_ctx, ac->fd,
|
125
|
-
|
124
|
+
grpc_fd_shutdown(exec_ctx, ac->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
125
|
+
"connect() timed out"));
|
126
126
|
}
|
127
127
|
done = (--ac->refs == 0);
|
128
128
|
gpr_mu_unlock(&ac->mu);
|
@@ -137,29 +137,7 @@ static void tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
|
|
137
137
|
grpc_endpoint *grpc_tcp_client_create_from_fd(
|
138
138
|
grpc_exec_ctx *exec_ctx, grpc_fd *fd, const grpc_channel_args *channel_args,
|
139
139
|
const char *addr_str) {
|
140
|
-
|
141
|
-
grpc_resource_quota *resource_quota = grpc_resource_quota_create(NULL);
|
142
|
-
if (channel_args != NULL) {
|
143
|
-
for (size_t i = 0; i < channel_args->num_args; i++) {
|
144
|
-
if (0 ==
|
145
|
-
strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) {
|
146
|
-
grpc_integer_options options = {(int)tcp_read_chunk_size, 1,
|
147
|
-
8 * 1024 * 1024};
|
148
|
-
tcp_read_chunk_size = (size_t)grpc_channel_arg_get_integer(
|
149
|
-
&channel_args->args[i], options);
|
150
|
-
} else if (0 ==
|
151
|
-
strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
|
152
|
-
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
153
|
-
resource_quota = grpc_resource_quota_ref_internal(
|
154
|
-
channel_args->args[i].value.pointer.p);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
}
|
158
|
-
|
159
|
-
grpc_endpoint *ep =
|
160
|
-
grpc_tcp_create(fd, resource_quota, tcp_read_chunk_size, addr_str);
|
161
|
-
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
162
|
-
return ep;
|
140
|
+
return grpc_tcp_create(exec_ctx, fd, channel_args, addr_str);
|
163
141
|
}
|
164
142
|
|
165
143
|
static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
|
@@ -191,7 +169,8 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
|
|
191
169
|
gpr_mu_lock(&ac->mu);
|
192
170
|
if (error != GRPC_ERROR_NONE) {
|
193
171
|
error =
|
194
|
-
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
|
172
|
+
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
|
173
|
+
grpc_slice_from_static_string("Timeout occurred"));
|
195
174
|
goto finish;
|
196
175
|
}
|
197
176
|
|
@@ -252,12 +231,17 @@ finish:
|
|
252
231
|
gpr_mu_unlock(&ac->mu);
|
253
232
|
if (error != GRPC_ERROR_NONE) {
|
254
233
|
char *error_descr;
|
255
|
-
|
256
|
-
|
257
|
-
|
234
|
+
grpc_slice str;
|
235
|
+
bool ret = grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &str);
|
236
|
+
GPR_ASSERT(ret);
|
237
|
+
char *desc = grpc_slice_to_c_string(str);
|
238
|
+
gpr_asprintf(&error_descr, "Failed to connect to remote host: %s", desc);
|
239
|
+
error = grpc_error_set_str(error, GRPC_ERROR_STR_DESCRIPTION,
|
240
|
+
grpc_slice_from_copied_string(error_descr));
|
258
241
|
gpr_free(error_descr);
|
259
|
-
|
260
|
-
|
242
|
+
gpr_free(desc);
|
243
|
+
error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS,
|
244
|
+
grpc_slice_from_copied_string(ac->addr_str));
|
261
245
|
}
|
262
246
|
if (done) {
|
263
247
|
gpr_mu_destroy(&ac->mu);
|
@@ -100,17 +100,21 @@ static void uv_tc_on_connect(uv_connect_t *req, int status) {
|
|
100
100
|
*connect->endpoint = grpc_tcp_create(
|
101
101
|
connect->tcp_handle, connect->resource_quota, connect->addr_name);
|
102
102
|
} else {
|
103
|
-
error =
|
103
|
+
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
104
|
+
"Failed to connect to remote host");
|
104
105
|
error = grpc_error_set_int(error, GRPC_ERROR_INT_ERRNO, -status);
|
105
106
|
error =
|
106
|
-
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
|
107
|
+
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
|
108
|
+
grpc_slice_from_static_string(uv_strerror(status)));
|
107
109
|
if (status == UV_ECANCELED) {
|
108
|
-
error =
|
109
|
-
|
110
|
+
error =
|
111
|
+
grpc_error_set_str(error, GRPC_ERROR_STR_OS_ERROR,
|
112
|
+
grpc_slice_from_static_string("Timeout occurred"));
|
110
113
|
// This should only happen if the handle is already closed
|
111
114
|
} else {
|
112
|
-
error = grpc_error_set_str(
|
113
|
-
|
115
|
+
error = grpc_error_set_str(
|
116
|
+
error, GRPC_ERROR_STR_OS_ERROR,
|
117
|
+
grpc_slice_from_static_string(uv_strerror(status)));
|
114
118
|
uv_close((uv_handle_t *)connect->tcp_handle, tcp_close_callback);
|
115
119
|
}
|
116
120
|
}
|
@@ -63,7 +63,7 @@ typedef struct {
|
|
63
63
|
int refs;
|
64
64
|
grpc_closure on_connect;
|
65
65
|
grpc_endpoint **endpoint;
|
66
|
-
|
66
|
+
grpc_channel_args *channel_args;
|
67
67
|
} async_connect;
|
68
68
|
|
69
69
|
static void async_connect_unlock_and_cleanup(grpc_exec_ctx *exec_ctx,
|
@@ -72,7 +72,7 @@ static void async_connect_unlock_and_cleanup(grpc_exec_ctx *exec_ctx,
|
|
72
72
|
int done = (--ac->refs == 0);
|
73
73
|
gpr_mu_unlock(&ac->mu);
|
74
74
|
if (done) {
|
75
|
-
|
75
|
+
grpc_channel_args_destroy(exec_ctx, ac->channel_args);
|
76
76
|
gpr_mu_destroy(&ac->mu);
|
77
77
|
gpr_free(ac->addr_name);
|
78
78
|
gpr_free(ac);
|
@@ -119,11 +119,12 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
|
|
119
119
|
if (!wsa_success) {
|
120
120
|
error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx");
|
121
121
|
} else {
|
122
|
-
*ep =
|
122
|
+
*ep =
|
123
|
+
grpc_tcp_create(exec_ctx, socket, ac->channel_args, ac->addr_name);
|
123
124
|
socket = NULL;
|
124
125
|
}
|
125
126
|
} else {
|
126
|
-
error =
|
127
|
+
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("socket is null");
|
127
128
|
}
|
128
129
|
}
|
129
130
|
|
@@ -152,17 +153,6 @@ static void tcp_client_connect_impl(
|
|
152
153
|
grpc_winsocket_callback_info *info;
|
153
154
|
grpc_error *error = GRPC_ERROR_NONE;
|
154
155
|
|
155
|
-
grpc_resource_quota *resource_quota = grpc_resource_quota_create(NULL);
|
156
|
-
if (channel_args != NULL) {
|
157
|
-
for (size_t i = 0; i < channel_args->num_args; i++) {
|
158
|
-
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
|
159
|
-
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
160
|
-
resource_quota = grpc_resource_quota_ref_internal(
|
161
|
-
channel_args->args[i].value.pointer.p);
|
162
|
-
}
|
163
|
-
}
|
164
|
-
}
|
165
|
-
|
166
156
|
*endpoint = NULL;
|
167
157
|
|
168
158
|
/* Use dualstack sockets where available. */
|
@@ -225,7 +215,7 @@ static void tcp_client_connect_impl(
|
|
225
215
|
ac->refs = 2;
|
226
216
|
ac->addr_name = grpc_sockaddr_to_uri(addr);
|
227
217
|
ac->endpoint = endpoint;
|
228
|
-
ac->
|
218
|
+
ac->channel_args = grpc_channel_args_copy(channel_args);
|
229
219
|
grpc_closure_init(&ac->on_connect, on_connect, ac, grpc_schedule_on_exec_ctx);
|
230
220
|
|
231
221
|
grpc_closure_init(&ac->on_alarm, on_alarm, ac, grpc_schedule_on_exec_ctx);
|
@@ -238,15 +228,15 @@ failure:
|
|
238
228
|
GPR_ASSERT(error != GRPC_ERROR_NONE);
|
239
229
|
char *target_uri = grpc_sockaddr_to_uri(addr);
|
240
230
|
grpc_error *final_error = grpc_error_set_str(
|
241
|
-
|
242
|
-
|
231
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Failed to connect",
|
232
|
+
&error, 1),
|
233
|
+
GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(target_uri));
|
243
234
|
GRPC_ERROR_UNREF(error);
|
244
235
|
if (socket != NULL) {
|
245
236
|
grpc_winsocket_destroy(socket);
|
246
237
|
} else if (sock != INVALID_SOCKET) {
|
247
238
|
closesocket(sock);
|
248
239
|
}
|
249
|
-
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
250
240
|
grpc_closure_sched(exec_ctx, on_done, final_error);
|
251
241
|
}
|
252
242
|
|
@@ -52,7 +52,9 @@
|
|
52
52
|
#include <grpc/support/string_util.h>
|
53
53
|
#include <grpc/support/sync.h>
|
54
54
|
#include <grpc/support/time.h>
|
55
|
+
#include <grpc/support/useful.h>
|
55
56
|
|
57
|
+
#include "src/core/lib/channel/channel_args.h"
|
56
58
|
#include "src/core/lib/debug/trace.h"
|
57
59
|
#include "src/core/lib/iomgr/ev_posix.h"
|
58
60
|
#include "src/core/lib/profiling/timers.h"
|
@@ -80,10 +82,14 @@ typedef struct {
|
|
80
82
|
int fd;
|
81
83
|
bool finished_edge;
|
82
84
|
msg_iovlen_type iov_size; /* Number of slices to allocate per read attempt */
|
83
|
-
|
85
|
+
double target_length;
|
86
|
+
double bytes_read_this_round;
|
84
87
|
gpr_refcount refcount;
|
85
88
|
gpr_atm shutdown_count;
|
86
89
|
|
90
|
+
int min_read_chunk_size;
|
91
|
+
int max_read_chunk_size;
|
92
|
+
|
87
93
|
/* garbage after the last read */
|
88
94
|
grpc_slice_buffer last_read_buffer;
|
89
95
|
|
@@ -108,10 +114,47 @@ typedef struct {
|
|
108
114
|
grpc_resource_user_slice_allocator slice_allocator;
|
109
115
|
} grpc_tcp;
|
110
116
|
|
117
|
+
static void add_to_estimate(grpc_tcp *tcp, size_t bytes) {
|
118
|
+
tcp->bytes_read_this_round += (double)bytes;
|
119
|
+
}
|
120
|
+
|
121
|
+
static void finish_estimate(grpc_tcp *tcp) {
|
122
|
+
/* If we read >80% of the target buffer in one read loop, increase the size
|
123
|
+
of the target buffer to either the amount read, or twice its previous
|
124
|
+
value */
|
125
|
+
if (tcp->bytes_read_this_round > tcp->target_length * 0.8) {
|
126
|
+
tcp->target_length =
|
127
|
+
GPR_MAX(2 * tcp->target_length, tcp->bytes_read_this_round);
|
128
|
+
} else {
|
129
|
+
tcp->target_length =
|
130
|
+
0.99 * tcp->target_length + 0.01 * tcp->bytes_read_this_round;
|
131
|
+
}
|
132
|
+
tcp->bytes_read_this_round = 0;
|
133
|
+
}
|
134
|
+
|
135
|
+
static size_t get_target_read_size(grpc_tcp *tcp) {
|
136
|
+
grpc_resource_quota *rq = grpc_resource_user_quota(tcp->resource_user);
|
137
|
+
double pressure = grpc_resource_quota_get_memory_pressure(rq);
|
138
|
+
double target =
|
139
|
+
tcp->target_length * (pressure > 0.8 ? (1.0 - pressure) / 0.2 : 1.0);
|
140
|
+
size_t sz = (((size_t)GPR_CLAMP(target, tcp->min_read_chunk_size,
|
141
|
+
tcp->max_read_chunk_size)) +
|
142
|
+
255) &
|
143
|
+
~(size_t)255;
|
144
|
+
/* don't use more than 1/16th of the overall resource quota for a single read
|
145
|
+
* alloc */
|
146
|
+
size_t rqmax = grpc_resource_quota_peek_size(rq);
|
147
|
+
if (sz > rqmax / 16 && rqmax > 1024) {
|
148
|
+
sz = rqmax / 16;
|
149
|
+
}
|
150
|
+
return sz;
|
151
|
+
}
|
152
|
+
|
111
153
|
static grpc_error *tcp_annotate_error(grpc_error *src_error, grpc_tcp *tcp) {
|
112
154
|
return grpc_error_set_str(
|
113
155
|
grpc_error_set_int(src_error, GRPC_ERROR_INT_FD, tcp->fd),
|
114
|
-
GRPC_ERROR_STR_TARGET_ADDRESS,
|
156
|
+
GRPC_ERROR_STR_TARGET_ADDRESS,
|
157
|
+
grpc_slice_from_copied_string(tcp->peer_string));
|
115
158
|
}
|
116
159
|
|
117
160
|
static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */,
|
@@ -231,9 +274,7 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
|
231
274
|
/* NB: After calling call_read_cb a parallel call of the read handler may
|
232
275
|
* be running. */
|
233
276
|
if (errno == EAGAIN) {
|
234
|
-
|
235
|
-
tcp->iov_size /= 2;
|
236
|
-
}
|
277
|
+
finish_estimate(tcp);
|
237
278
|
/* We've consumed the edge, request a new one */
|
238
279
|
grpc_fd_notify_on_read(exec_ctx, tcp->em_fd, &tcp->read_closure);
|
239
280
|
} else {
|
@@ -246,18 +287,19 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
|
246
287
|
} else if (read_bytes == 0) {
|
247
288
|
/* 0 read size ==> end of stream */
|
248
289
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, tcp->incoming_buffer);
|
249
|
-
call_read_cb(
|
250
|
-
|
290
|
+
call_read_cb(
|
291
|
+
exec_ctx, tcp,
|
292
|
+
tcp_annotate_error(
|
293
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
|
251
294
|
TCP_UNREF(exec_ctx, tcp, "read");
|
252
295
|
} else {
|
296
|
+
add_to_estimate(tcp, (size_t)read_bytes);
|
253
297
|
GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length);
|
254
298
|
if ((size_t)read_bytes < tcp->incoming_buffer->length) {
|
255
299
|
grpc_slice_buffer_trim_end(
|
256
300
|
tcp->incoming_buffer,
|
257
301
|
tcp->incoming_buffer->length - (size_t)read_bytes,
|
258
302
|
&tcp->last_read_buffer);
|
259
|
-
} else if (tcp->iov_size < MAX_READ_IOVEC) {
|
260
|
-
++tcp->iov_size;
|
261
303
|
}
|
262
304
|
GPR_ASSERT((size_t)read_bytes == tcp->incoming_buffer->length);
|
263
305
|
call_read_cb(exec_ctx, tcp, GRPC_ERROR_NONE);
|
@@ -282,11 +324,11 @@ static void tcp_read_allocation_done(grpc_exec_ctx *exec_ctx, void *tcpp,
|
|
282
324
|
}
|
283
325
|
|
284
326
|
static void tcp_continue_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
327
|
+
size_t target_read_size = get_target_read_size(tcp);
|
328
|
+
if (tcp->incoming_buffer->length < target_read_size &&
|
329
|
+
tcp->incoming_buffer->count < MAX_READ_IOVEC) {
|
330
|
+
grpc_resource_user_alloc_slices(exec_ctx, &tcp->slice_allocator,
|
331
|
+
target_read_size, 1, tcp->incoming_buffer);
|
290
332
|
} else {
|
291
333
|
tcp_do_read(exec_ctx, tcp);
|
292
334
|
}
|
@@ -464,10 +506,12 @@ static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
|
|
464
506
|
|
465
507
|
if (buf->length == 0) {
|
466
508
|
GPR_TIMER_END("tcp_write", 0);
|
467
|
-
grpc_closure_sched(
|
468
|
-
|
469
|
-
|
470
|
-
|
509
|
+
grpc_closure_sched(
|
510
|
+
exec_ctx, cb,
|
511
|
+
grpc_fd_is_shutdown(tcp->em_fd)
|
512
|
+
? tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"),
|
513
|
+
tcp)
|
514
|
+
: GRPC_ERROR_NONE);
|
471
515
|
return;
|
472
516
|
}
|
473
517
|
tcp->outgoing_buffer = buf;
|
@@ -535,9 +579,50 @@ static const grpc_endpoint_vtable vtable = {tcp_read,
|
|
535
579
|
tcp_get_peer,
|
536
580
|
tcp_get_fd};
|
537
581
|
|
538
|
-
|
539
|
-
|
540
|
-
|
582
|
+
#define MAX_CHUNK_SIZE 32 * 1024 * 1024
|
583
|
+
|
584
|
+
grpc_endpoint *grpc_tcp_create(grpc_exec_ctx *exec_ctx, grpc_fd *em_fd,
|
585
|
+
const grpc_channel_args *channel_args,
|
586
|
+
const char *peer_string) {
|
587
|
+
int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
|
588
|
+
int tcp_max_read_chunk_size = 4 * 1024 * 1024;
|
589
|
+
int tcp_min_read_chunk_size = 256;
|
590
|
+
grpc_resource_quota *resource_quota = grpc_resource_quota_create(NULL);
|
591
|
+
if (channel_args != NULL) {
|
592
|
+
for (size_t i = 0; i < channel_args->num_args; i++) {
|
593
|
+
if (0 ==
|
594
|
+
strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) {
|
595
|
+
grpc_integer_options options = {(int)tcp_read_chunk_size, 1,
|
596
|
+
MAX_CHUNK_SIZE};
|
597
|
+
tcp_read_chunk_size =
|
598
|
+
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
599
|
+
} else if (0 == strcmp(channel_args->args[i].key,
|
600
|
+
GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE)) {
|
601
|
+
grpc_integer_options options = {(int)tcp_read_chunk_size, 1,
|
602
|
+
MAX_CHUNK_SIZE};
|
603
|
+
tcp_min_read_chunk_size =
|
604
|
+
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
605
|
+
} else if (0 == strcmp(channel_args->args[i].key,
|
606
|
+
GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE)) {
|
607
|
+
grpc_integer_options options = {(int)tcp_read_chunk_size, 1,
|
608
|
+
MAX_CHUNK_SIZE};
|
609
|
+
tcp_max_read_chunk_size =
|
610
|
+
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
611
|
+
} else if (0 ==
|
612
|
+
strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
|
613
|
+
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
614
|
+
resource_quota = grpc_resource_quota_ref_internal(
|
615
|
+
channel_args->args[i].value.pointer.p);
|
616
|
+
}
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
if (tcp_min_read_chunk_size > tcp_max_read_chunk_size) {
|
621
|
+
tcp_min_read_chunk_size = tcp_max_read_chunk_size;
|
622
|
+
}
|
623
|
+
tcp_read_chunk_size = GPR_CLAMP(tcp_read_chunk_size, tcp_min_read_chunk_size,
|
624
|
+
tcp_max_read_chunk_size);
|
625
|
+
|
541
626
|
grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp));
|
542
627
|
tcp->base.vtable = &vtable;
|
543
628
|
tcp->peer_string = gpr_strdup(peer_string);
|
@@ -547,7 +632,10 @@ grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd,
|
|
547
632
|
tcp->release_fd_cb = NULL;
|
548
633
|
tcp->release_fd = NULL;
|
549
634
|
tcp->incoming_buffer = NULL;
|
550
|
-
tcp->
|
635
|
+
tcp->target_length = (double)tcp_read_chunk_size;
|
636
|
+
tcp->min_read_chunk_size = tcp_min_read_chunk_size;
|
637
|
+
tcp->max_read_chunk_size = tcp_max_read_chunk_size;
|
638
|
+
tcp->bytes_read_this_round = 0;
|
551
639
|
tcp->iov_size = 1;
|
552
640
|
tcp->finished_edge = true;
|
553
641
|
/* paired with unref in grpc_tcp_destroy */
|
@@ -564,6 +652,7 @@ grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd,
|
|
564
652
|
&tcp->slice_allocator, tcp->resource_user, tcp_read_allocation_done, tcp);
|
565
653
|
/* Tell network status tracker about new endpoint */
|
566
654
|
grpc_network_status_register_endpoint(&tcp->base);
|
655
|
+
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
567
656
|
|
568
657
|
return &tcp->base;
|
569
658
|
}
|