grpc 1.49.1-x86_64-linux → 1.50.0.pre1-x86_64-linux
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 +54 -153
- data/include/grpc/event_engine/endpoint_config.h +11 -5
- data/include/grpc/event_engine/event_engine.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
- data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
- data/include/grpc/impl/codegen/atm_windows.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
- data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
- data/src/core/ext/filters/client_channel/client_channel.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
- data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
- data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
- data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
- data/src/core/ext/filters/client_channel/subchannel.h +12 -3
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
- data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
- data/src/core/ext/xds/certificate_provider_store.cc +63 -3
- data/src/core/ext/xds/certificate_provider_store.h +9 -1
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/xds_api.cc +21 -17
- data/src/core/ext/xds/xds_api.h +7 -0
- data/src/core/ext/xds/xds_bootstrap.cc +5 -537
- data/src/core/ext/xds/xds_bootstrap.h +39 -111
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
- data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
- data/src/core/ext/xds/xds_client.cc +219 -145
- data/src/core/ext/xds/xds_client.h +19 -17
- data/src/core/ext/xds/xds_client_grpc.cc +18 -80
- data/src/core/ext/xds/xds_client_grpc.h +2 -25
- data/src/core/ext/xds/xds_client_stats.cc +4 -4
- data/src/core/ext/xds/xds_cluster.cc +87 -79
- data/src/core/ext/xds/xds_cluster.h +5 -5
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
- data/src/core/ext/xds/xds_common_types.cc +13 -5
- data/src/core/ext/xds/xds_endpoint.cc +8 -6
- data/src/core/ext/xds/xds_endpoint.h +3 -4
- data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
- data/src/core/ext/xds/xds_listener.cc +25 -20
- data/src/core/ext/xds/xds_listener.h +3 -4
- data/src/core/ext/xds/xds_resource_type.h +11 -8
- data/src/core/ext/xds/xds_route_config.cc +15 -16
- data/src/core/ext/xds/xds_route_config.h +3 -3
- data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
- data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
- data/src/core/lib/backoff/backoff.cc +2 -4
- data/src/core/lib/channel/call_finalization.h +1 -3
- data/src/core/lib/channel/channel_args.h +114 -14
- data/src/core/lib/channel/channel_trace.cc +3 -4
- data/src/core/lib/channel/promise_based_filter.cc +18 -19
- data/src/core/lib/channel/status_util.cc +27 -0
- data/src/core/lib/channel/status_util.h +10 -0
- data/src/core/lib/config/core_configuration.cc +5 -1
- data/src/core/lib/config/core_configuration.h +33 -0
- data/src/core/lib/debug/stats.cc +26 -30
- data/src/core/lib/debug/stats.h +2 -12
- data/src/core/lib/debug/stats_data.cc +118 -614
- data/src/core/lib/debug/stats_data.h +67 -465
- data/src/core/lib/debug/trace.cc +0 -2
- data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
- data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
- data/src/core/lib/event_engine/forkable.cc +1 -1
- data/src/core/lib/event_engine/poller.h +14 -12
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
- data/src/core/lib/event_engine/thread_pool.cc +131 -94
- data/src/core/lib/event_engine/thread_pool.h +56 -23
- data/src/core/lib/event_engine/time_util.cc +30 -0
- data/src/core/lib/event_engine/time_util.h +32 -0
- data/src/core/lib/event_engine/utils.cc +0 -5
- data/src/core/lib/event_engine/utils.h +0 -4
- data/src/core/lib/event_engine/windows/iocp.cc +13 -7
- data/src/core/lib/event_engine/windows/iocp.h +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
- data/src/core/lib/experiments/config.cc +146 -0
- data/src/core/lib/experiments/config.h +43 -0
- data/src/core/lib/experiments/experiments.cc +75 -0
- data/src/core/lib/experiments/experiments.h +56 -0
- data/src/core/lib/gpr/alloc.cc +1 -9
- data/src/core/lib/gpr/log_windows.cc +0 -1
- data/src/core/lib/gpr/string_util_windows.cc +3 -30
- data/src/core/lib/gpr/sync_abseil.cc +0 -14
- data/src/core/lib/gpr/sync_posix.cc +0 -14
- data/src/core/lib/gpr/time_posix.cc +0 -6
- data/src/core/lib/gpr/time_precise.h +1 -1
- data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
- data/src/core/lib/gpr/useful.h +11 -0
- data/src/core/lib/{gpr → gprpp}/env.h +25 -12
- data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
- data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
- data/src/core/lib/gprpp/env_windows.cc +56 -0
- data/src/core/lib/gprpp/fork.cc +14 -22
- data/src/core/lib/gprpp/fork.h +0 -8
- data/src/core/lib/gprpp/global_config_env.cc +7 -6
- data/src/core/lib/gprpp/notification.h +67 -0
- data/src/core/lib/gprpp/packed_table.h +40 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
- data/src/core/lib/gprpp/sorted_pack.h +98 -0
- data/src/core/lib/gprpp/status_helper.h +6 -0
- data/src/core/lib/gprpp/table.h +9 -1
- data/src/core/lib/gprpp/tchar.cc +49 -0
- data/src/core/lib/gprpp/tchar.h +33 -0
- data/src/core/lib/gprpp/time.cc +21 -0
- data/src/core/lib/gprpp/time.h +55 -0
- data/src/core/lib/gprpp/validation_errors.cc +61 -0
- data/src/core/lib/gprpp/validation_errors.h +110 -0
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
- data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
- data/src/core/lib/iomgr/call_combiner.cc +0 -8
- data/src/core/lib/iomgr/closure.h +0 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
- data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
- data/src/core/lib/iomgr/exec_ctx.cc +0 -10
- data/src/core/lib/iomgr/exec_ctx.h +7 -31
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +6 -8
- data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_set.h +0 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -0
- data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
- data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
- data/src/core/lib/iomgr/tcp_client.cc +6 -7
- data/src/core/lib/iomgr/tcp_client.h +11 -11
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
- data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
- data/src/core/lib/iomgr/tcp_posix.cc +131 -114
- data/src/core/lib/iomgr/tcp_posix.h +3 -1
- data/src/core/lib/iomgr/tcp_server.cc +5 -4
- data/src/core/lib/iomgr/tcp_server.h +9 -6
- data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
- data/src/core/lib/iomgr/tcp_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_windows.h +0 -1
- data/src/core/lib/iomgr/timer_generic.cc +4 -4
- data/src/core/lib/iomgr/timer_manager.cc +1 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
- data/src/core/lib/json/json_object_loader.cc +21 -52
- data/src/core/lib/json/json_object_loader.h +56 -76
- data/src/core/lib/json/json_util.cc +2 -1
- data/src/core/lib/load_balancing/lb_policy.h +5 -5
- data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
- data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
- data/src/core/lib/promise/activity.h +2 -3
- data/src/core/lib/promise/context.h +1 -1
- data/src/core/lib/promise/sleep.cc +16 -4
- data/src/core/lib/promise/sleep.h +8 -2
- data/src/core/lib/resolver/resolver.h +13 -3
- data/src/core/lib/resource_quota/api.cc +9 -0
- data/src/core/lib/resource_quota/api.h +6 -0
- data/src/core/lib/resource_quota/arena.cc +1 -3
- data/src/core/lib/resource_quota/memory_quota.cc +8 -24
- data/src/core/lib/resource_quota/memory_quota.h +6 -19
- data/src/core/lib/resource_quota/periodic_update.cc +2 -3
- data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
- data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
- data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
- data/src/core/lib/surface/call.cc +1 -11
- data/src/core/lib/surface/channel.cc +3 -2
- data/src/core/lib/surface/completion_queue.cc +16 -28
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +5 -0
- data/src/core/lib/surface/init.cc +16 -11
- data/src/core/lib/surface/init_internally.cc +24 -0
- data/src/core/lib/surface/init_internally.h +28 -0
- data/src/core/lib/surface/server.cc +1 -7
- data/src/core/lib/surface/server.h +4 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +1 -3
- data/src/core/lib/transport/metadata_batch.cc +2 -3
- data/src/core/lib/transport/metadata_batch.h +9 -7
- data/src/core/lib/transport/parsed_metadata.h +4 -2
- data/src/core/lib/transport/status_conversion.cc +1 -3
- data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
- data/src/core/lib/transport/transport.h +0 -1
- data/src/core/lib/transport/transport_impl.h +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
- data/src/ruby/lib/grpc/2.6/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.0/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.1/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_spec.rb +5 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
- data/src/ruby/spec/user_agent_spec.rb +1 -1
- metadata +33 -19
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
- data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
- data/src/core/ext/xds/certificate_provider_registry.h +0 -59
- data/src/core/lib/event_engine/promise.h +0 -78
- data/src/core/lib/gpr/env_windows.cc +0 -74
- data/src/core/lib/gpr/string_windows.h +0 -32
- data/src/core/lib/profiling/basic_timers.cc +0 -295
- data/src/core/lib/profiling/stap_timers.cc +0 -50
- data/src/core/lib/profiling/timers.h +0 -94
@@ -20,6 +20,7 @@
|
|
20
20
|
|
21
21
|
#include <grpc/impl/codegen/grpc_types.h>
|
22
22
|
|
23
|
+
#include "src/core/lib/gprpp/global_config_generic.h"
|
23
24
|
#include "src/core/lib/iomgr/port.h"
|
24
25
|
|
25
26
|
#ifdef GRPC_POSIX_SOCKET_TCP
|
@@ -47,9 +48,9 @@
|
|
47
48
|
#include <grpc/support/time.h>
|
48
49
|
|
49
50
|
#include "src/core/lib/address_utils/sockaddr_utils.h"
|
50
|
-
#include "src/core/lib/channel/channel_args.h"
|
51
51
|
#include "src/core/lib/debug/stats.h"
|
52
52
|
#include "src/core/lib/debug/trace.h"
|
53
|
+
#include "src/core/lib/experiments/experiments.h"
|
53
54
|
#include "src/core/lib/gpr/string.h"
|
54
55
|
#include "src/core/lib/gpr/useful.h"
|
55
56
|
#include "src/core/lib/gprpp/sync.h"
|
@@ -58,7 +59,6 @@
|
|
58
59
|
#include "src/core/lib/iomgr/executor.h"
|
59
60
|
#include "src/core/lib/iomgr/socket_utils_posix.h"
|
60
61
|
#include "src/core/lib/iomgr/tcp_posix.h"
|
61
|
-
#include "src/core/lib/profiling/timers.h"
|
62
62
|
#include "src/core/lib/resource_quota/api.h"
|
63
63
|
#include "src/core/lib/resource_quota/memory_quota.h"
|
64
64
|
#include "src/core/lib/resource_quota/trace.h"
|
@@ -97,8 +97,6 @@ typedef size_t msg_iovlen_type;
|
|
97
97
|
|
98
98
|
extern grpc_core::TraceFlag grpc_tcp_trace;
|
99
99
|
|
100
|
-
GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_experimental_enable_tcp_frame_size_tuning);
|
101
|
-
|
102
100
|
namespace grpc_core {
|
103
101
|
|
104
102
|
class TcpZerocopySendRecord {
|
@@ -466,22 +464,20 @@ using grpc_core::TcpZerocopySendRecord;
|
|
466
464
|
|
467
465
|
namespace {
|
468
466
|
|
469
|
-
bool ExperimentalTcpFrameSizeTuningEnabled() {
|
470
|
-
static const bool kEnableTcpFrameSizeTuning =
|
471
|
-
GPR_GLOBAL_CONFIG_GET(grpc_experimental_enable_tcp_frame_size_tuning);
|
472
|
-
return kEnableTcpFrameSizeTuning;
|
473
|
-
}
|
474
|
-
|
475
467
|
struct grpc_tcp {
|
476
|
-
grpc_tcp(
|
477
|
-
:
|
468
|
+
explicit grpc_tcp(const grpc_core::PosixTcpOptions& tcp_options)
|
469
|
+
: min_read_chunk_size(tcp_options.tcp_min_read_chunk_size),
|
470
|
+
max_read_chunk_size(tcp_options.tcp_max_read_chunk_size),
|
471
|
+
tcp_zerocopy_send_ctx(
|
472
|
+
tcp_options.tcp_tx_zerocopy_max_simultaneous_sends,
|
473
|
+
tcp_options.tcp_tx_zerocopy_send_bytes_threshold) {}
|
478
474
|
grpc_endpoint base;
|
479
475
|
grpc_fd* em_fd;
|
480
476
|
int fd;
|
481
477
|
/* Used by the endpoint read function to distinguish the very first read call
|
482
478
|
* from the rest */
|
483
479
|
bool is_first_read;
|
484
|
-
bool has_posted_reclaimer;
|
480
|
+
bool has_posted_reclaimer ABSL_GUARDED_BY(read_mu) = false;
|
485
481
|
double target_length;
|
486
482
|
double bytes_read_this_round;
|
487
483
|
grpc_core::RefCount refcount;
|
@@ -489,6 +485,7 @@ struct grpc_tcp {
|
|
489
485
|
|
490
486
|
int min_read_chunk_size;
|
491
487
|
int max_read_chunk_size;
|
488
|
+
int set_rcvlowat = 0;
|
492
489
|
|
493
490
|
/* garbage after the last read */
|
494
491
|
grpc_slice_buffer last_read_buffer;
|
@@ -585,8 +582,7 @@ static void run_poller(void* bp, grpc_error_handle /*error_ignored*/) {
|
|
585
582
|
}
|
586
583
|
gpr_mu_lock(p->pollset_mu);
|
587
584
|
grpc_core::Timestamp deadline =
|
588
|
-
grpc_core::
|
589
|
-
GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS();
|
585
|
+
grpc_core::Timestamp::Now() + grpc_core::Duration::Seconds(10);
|
590
586
|
GRPC_LOG_IF_ERROR(
|
591
587
|
"backup_poller:pollset_work",
|
592
588
|
grpc_pollset_work(BACKUP_POLLER_POLLSET(p), nullptr, deadline));
|
@@ -647,7 +643,6 @@ static void cover_self(grpc_tcp* tcp) {
|
|
647
643
|
g_backup_poller = p;
|
648
644
|
grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
|
649
645
|
g_backup_poller_mu->Unlock();
|
650
|
-
GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED();
|
651
646
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
|
652
647
|
gpr_log(GPR_INFO, "BACKUP_POLLER:%p create", p);
|
653
648
|
}
|
@@ -793,8 +788,8 @@ static void perform_reclamation(grpc_tcp* tcp)
|
|
793
788
|
if (tcp->incoming_buffer != nullptr) {
|
794
789
|
grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
|
795
790
|
}
|
796
|
-
tcp->read_mu.Unlock();
|
797
791
|
tcp->has_posted_reclaimer = false;
|
792
|
+
tcp->read_mu.Unlock();
|
798
793
|
}
|
799
794
|
|
800
795
|
static void maybe_post_reclaimer(grpc_tcp* tcp)
|
@@ -829,11 +824,54 @@ static void tcp_trace_read(grpc_tcp* tcp, grpc_error_handle error)
|
|
829
824
|
}
|
830
825
|
}
|
831
826
|
|
827
|
+
static void update_rcvlowat(grpc_tcp* tcp)
|
828
|
+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(tcp->read_mu) {
|
829
|
+
if (!grpc_core::IsTcpRcvLowatEnabled()) return;
|
830
|
+
|
831
|
+
// TODO(ctiller): Check if supported by OS.
|
832
|
+
// TODO(ctiller): Allow some adjustments instead of hardcoding things.
|
833
|
+
|
834
|
+
static constexpr int kRcvLowatMax = 16 * 1024 * 1024;
|
835
|
+
static constexpr int kRcvLowatThreshold = 16 * 1024;
|
836
|
+
|
837
|
+
int remaining = std::min(static_cast<int>(tcp->incoming_buffer->length),
|
838
|
+
tcp->min_progress_size);
|
839
|
+
remaining = std::min(remaining, kRcvLowatMax);
|
840
|
+
|
841
|
+
// Setting SO_RCVLOWAT for small quantities does not save on CPU.
|
842
|
+
if (remaining < kRcvLowatThreshold) {
|
843
|
+
remaining = 0;
|
844
|
+
}
|
845
|
+
|
846
|
+
// If zerocopy is off, wake shortly before the full RPC is here. More can
|
847
|
+
// show up partway through recvmsg() since it takes a while to copy data.
|
848
|
+
// So an early wakeup aids latency.
|
849
|
+
if (!tcp->tcp_zerocopy_send_ctx.enabled() && remaining > 0) {
|
850
|
+
remaining -= kRcvLowatThreshold;
|
851
|
+
}
|
852
|
+
|
853
|
+
// We still do not know the RPC size. Do not set SO_RCVLOWAT.
|
854
|
+
if (tcp->set_rcvlowat <= 1 && remaining <= 1) return;
|
855
|
+
|
856
|
+
// Previous value is still valid. No change needed in SO_RCVLOWAT.
|
857
|
+
if (tcp->set_rcvlowat == remaining) {
|
858
|
+
return;
|
859
|
+
}
|
860
|
+
if (setsockopt(tcp->fd, SOL_SOCKET, SO_RCVLOWAT, &remaining,
|
861
|
+
sizeof(remaining)) != 0) {
|
862
|
+
gpr_log(GPR_ERROR, "%s",
|
863
|
+
absl::StrCat("Cannot set SO_RCVLOWAT on fd=", tcp->fd,
|
864
|
+
" err=", strerror(errno))
|
865
|
+
.c_str());
|
866
|
+
return;
|
867
|
+
}
|
868
|
+
tcp->set_rcvlowat = remaining;
|
869
|
+
}
|
870
|
+
|
832
871
|
/* Returns true if data available to read or error other than EAGAIN. */
|
833
|
-
#define MAX_READ_IOVEC
|
872
|
+
#define MAX_READ_IOVEC 64
|
834
873
|
static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
|
835
874
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(tcp->read_mu) {
|
836
|
-
GPR_TIMER_SCOPE("tcp_do_read", 0);
|
837
875
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
|
838
876
|
gpr_log(GPR_INFO, "TCP:%p do_read", tcp);
|
839
877
|
}
|
@@ -881,7 +919,6 @@ static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
|
|
881
919
|
GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(tcp->incoming_buffer->count);
|
882
920
|
|
883
921
|
do {
|
884
|
-
GPR_TIMER_SCOPE("recvmsg", 0);
|
885
922
|
GRPC_STATS_INC_SYSCALL_READ();
|
886
923
|
read_bytes = recvmsg(tcp->fd, &msg, 0);
|
887
924
|
} while (read_bytes < 0 && errno == EINTR);
|
@@ -1010,31 +1047,66 @@ static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
|
|
1010
1047
|
|
1011
1048
|
static void maybe_make_read_slices(grpc_tcp* tcp)
|
1012
1049
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(tcp->read_mu) {
|
1013
|
-
if (
|
1014
|
-
|
1015
|
-
|
1016
|
-
if (
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1050
|
+
if (grpc_core::IsTcpReadChunksEnabled()) {
|
1051
|
+
static const int kBigAlloc = 64 * 1024;
|
1052
|
+
static const int kSmallAlloc = 8 * 1024;
|
1053
|
+
if (tcp->incoming_buffer->length <
|
1054
|
+
static_cast<size_t>(tcp->min_progress_size)) {
|
1055
|
+
size_t allocate_length = tcp->min_progress_size;
|
1056
|
+
const size_t target_length = static_cast<size_t>(tcp->target_length);
|
1057
|
+
// If memory pressure is low and we think there will be more than
|
1058
|
+
// min_progress_size bytes to read, allocate a bit more.
|
1059
|
+
const bool low_memory_pressure =
|
1060
|
+
tcp->memory_owner.GetPressureInfo().pressure_control_value < 0.8;
|
1061
|
+
if (low_memory_pressure && target_length > allocate_length) {
|
1062
|
+
allocate_length = target_length;
|
1063
|
+
}
|
1064
|
+
int extra_wanted =
|
1065
|
+
allocate_length - static_cast<int>(tcp->incoming_buffer->length);
|
1066
|
+
if (extra_wanted >=
|
1067
|
+
(low_memory_pressure ? kSmallAlloc * 3 / 2 : kBigAlloc)) {
|
1068
|
+
while (extra_wanted > 0) {
|
1069
|
+
extra_wanted -= kBigAlloc;
|
1070
|
+
grpc_slice_buffer_add_indexed(tcp->incoming_buffer,
|
1071
|
+
tcp->memory_owner.MakeSlice(kBigAlloc));
|
1072
|
+
GRPC_STATS_INC_TCP_READ_ALLOC_64K();
|
1073
|
+
}
|
1074
|
+
} else {
|
1075
|
+
while (extra_wanted > 0) {
|
1076
|
+
extra_wanted -= kSmallAlloc;
|
1077
|
+
grpc_slice_buffer_add_indexed(
|
1078
|
+
tcp->incoming_buffer, tcp->memory_owner.MakeSlice(kSmallAlloc));
|
1079
|
+
GRPC_STATS_INC_TCP_READ_ALLOC_8K();
|
1080
|
+
}
|
1081
|
+
}
|
1082
|
+
maybe_post_reclaimer(tcp);
|
1083
|
+
}
|
1084
|
+
} else {
|
1085
|
+
if (tcp->incoming_buffer->length <
|
1086
|
+
static_cast<size_t>(tcp->min_progress_size) &&
|
1087
|
+
tcp->incoming_buffer->count < MAX_READ_IOVEC) {
|
1088
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
|
1089
|
+
gpr_log(GPR_INFO,
|
1090
|
+
"TCP:%p alloc_slices; min_chunk=%d max_chunk=%d target=%lf "
|
1091
|
+
"buf_len=%" PRIdPTR,
|
1092
|
+
tcp, tcp->min_read_chunk_size, tcp->max_read_chunk_size,
|
1093
|
+
tcp->target_length, tcp->incoming_buffer->length);
|
1094
|
+
}
|
1095
|
+
int target_length = std::max(static_cast<int>(tcp->target_length),
|
1096
|
+
tcp->min_progress_size);
|
1097
|
+
int extra_wanted =
|
1098
|
+
target_length - static_cast<int>(tcp->incoming_buffer->length);
|
1099
|
+
int min_read_chunk_size =
|
1100
|
+
std::max(tcp->min_read_chunk_size, tcp->min_progress_size);
|
1101
|
+
int max_read_chunk_size =
|
1102
|
+
std::max(tcp->max_read_chunk_size, tcp->min_progress_size);
|
1103
|
+
grpc_slice slice = tcp->memory_owner.MakeSlice(grpc_core::MemoryRequest(
|
1104
|
+
min_read_chunk_size,
|
1105
|
+
grpc_core::Clamp(extra_wanted, min_read_chunk_size,
|
1106
|
+
max_read_chunk_size)));
|
1107
|
+
grpc_slice_buffer_add_indexed(tcp->incoming_buffer, slice);
|
1108
|
+
maybe_post_reclaimer(tcp);
|
1022
1109
|
}
|
1023
|
-
int target_length =
|
1024
|
-
std::max(static_cast<int>(tcp->target_length), tcp->min_progress_size);
|
1025
|
-
int extra_wanted =
|
1026
|
-
target_length - static_cast<int>(tcp->incoming_buffer->length);
|
1027
|
-
int min_read_chunk_size =
|
1028
|
-
std::max(tcp->min_read_chunk_size, tcp->min_progress_size);
|
1029
|
-
int max_read_chunk_size =
|
1030
|
-
std::max(tcp->max_read_chunk_size, tcp->min_progress_size);
|
1031
|
-
grpc_slice_buffer_add_indexed(
|
1032
|
-
tcp->incoming_buffer,
|
1033
|
-
tcp->memory_owner.MakeSlice(grpc_core::MemoryRequest(
|
1034
|
-
min_read_chunk_size,
|
1035
|
-
grpc_core::Clamp(extra_wanted, min_read_chunk_size,
|
1036
|
-
max_read_chunk_size))));
|
1037
|
-
maybe_post_reclaimer(tcp);
|
1038
1110
|
}
|
1039
1111
|
}
|
1040
1112
|
|
@@ -1050,6 +1122,7 @@ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error_handle error) {
|
|
1050
1122
|
maybe_make_read_slices(tcp);
|
1051
1123
|
if (!tcp_do_read(tcp, &tcp_read_error)) {
|
1052
1124
|
/* We've consumed the edge, request a new one */
|
1125
|
+
update_rcvlowat(tcp);
|
1053
1126
|
tcp->read_mu.Unlock();
|
1054
1127
|
notify_on_read(tcp);
|
1055
1128
|
return;
|
@@ -1079,19 +1152,23 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
|
|
1079
1152
|
tcp->frame_size_tuning_enabled ? min_progress_size : 1;
|
1080
1153
|
grpc_slice_buffer_reset_and_unref_internal(incoming_buffer);
|
1081
1154
|
grpc_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer);
|
1082
|
-
tcp->read_mu.Unlock();
|
1083
1155
|
TCP_REF(tcp, "read");
|
1084
1156
|
if (tcp->is_first_read) {
|
1157
|
+
update_rcvlowat(tcp);
|
1158
|
+
tcp->read_mu.Unlock();
|
1085
1159
|
/* Endpoint read called for the very first time. Register read callback with
|
1086
1160
|
* the polling engine */
|
1087
1161
|
tcp->is_first_read = false;
|
1088
1162
|
notify_on_read(tcp);
|
1089
1163
|
} else if (!urgent && tcp->inq == 0) {
|
1164
|
+
update_rcvlowat(tcp);
|
1165
|
+
tcp->read_mu.Unlock();
|
1090
1166
|
/* Upper layer asked to read more but we know there is no pending data
|
1091
1167
|
* to read from previous reads. So, wait for POLLIN.
|
1092
1168
|
*/
|
1093
1169
|
notify_on_read(tcp);
|
1094
1170
|
} else {
|
1171
|
+
tcp->read_mu.Unlock();
|
1095
1172
|
/* Not the first time. We may or may not have more bytes available. In any
|
1096
1173
|
* case call tcp->read_done_closure (i.e tcp_handle_read()) which does the
|
1097
1174
|
* right thing (i.e calls tcp_do_read() which either reads the available
|
@@ -1106,7 +1183,6 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
|
|
1106
1183
|
* of bytes sent. */
|
1107
1184
|
ssize_t tcp_send(int fd, const struct msghdr* msg, int* saved_errno,
|
1108
1185
|
int additional_flags = 0) {
|
1109
|
-
GPR_TIMER_SCOPE("sendmsg", 1);
|
1110
1186
|
ssize_t sent_length;
|
1111
1187
|
do {
|
1112
1188
|
/* TODO(klempner): Cork if this is a partial write */
|
@@ -1748,7 +1824,6 @@ static void tcp_handle_write(void* arg /* grpc_tcp */,
|
|
1748
1824
|
|
1749
1825
|
static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
|
1750
1826
|
grpc_closure* cb, void* arg, int /*max_frame_size*/) {
|
1751
|
-
GPR_TIMER_SCOPE("tcp_write", 0);
|
1752
1827
|
grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep);
|
1753
1828
|
grpc_error_handle error = GRPC_ERROR_NONE;
|
1754
1829
|
TcpZerocopySendRecord* zerocopy_send_record = nullptr;
|
@@ -1869,72 +1944,16 @@ static const grpc_endpoint_vtable vtable = {tcp_read,
|
|
1869
1944
|
tcp_get_fd,
|
1870
1945
|
tcp_can_track_err};
|
1871
1946
|
|
1872
|
-
#define MAX_CHUNK_SIZE (32 * 1024 * 1024)
|
1873
|
-
|
1874
1947
|
grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
|
1875
|
-
const
|
1948
|
+
const grpc_core::PosixTcpOptions& options,
|
1876
1949
|
absl::string_view peer_string) {
|
1877
|
-
|
1878
|
-
int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
|
1879
|
-
int tcp_max_read_chunk_size = 4 * 1024 * 1024;
|
1880
|
-
int tcp_min_read_chunk_size = 256;
|
1881
|
-
bool tcp_tx_zerocopy_enabled = kZerocpTxEnabledDefault;
|
1882
|
-
int tcp_tx_zerocopy_send_bytes_thresh =
|
1883
|
-
grpc_core::TcpZerocopySendCtx::kDefaultSendBytesThreshold;
|
1884
|
-
int tcp_tx_zerocopy_max_simult_sends =
|
1885
|
-
grpc_core::TcpZerocopySendCtx::kDefaultMaxSends;
|
1886
|
-
if (channel_args != nullptr) {
|
1887
|
-
for (size_t i = 0; i < channel_args->num_args; i++) {
|
1888
|
-
if (0 ==
|
1889
|
-
strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) {
|
1890
|
-
grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE};
|
1891
|
-
tcp_read_chunk_size =
|
1892
|
-
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
1893
|
-
} else if (0 == strcmp(channel_args->args[i].key,
|
1894
|
-
GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE)) {
|
1895
|
-
grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE};
|
1896
|
-
tcp_min_read_chunk_size =
|
1897
|
-
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
1898
|
-
} else if (0 == strcmp(channel_args->args[i].key,
|
1899
|
-
GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE)) {
|
1900
|
-
grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE};
|
1901
|
-
tcp_max_read_chunk_size =
|
1902
|
-
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
1903
|
-
} else if (0 == strcmp(channel_args->args[i].key,
|
1904
|
-
GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED)) {
|
1905
|
-
tcp_tx_zerocopy_enabled = grpc_channel_arg_get_bool(
|
1906
|
-
&channel_args->args[i], kZerocpTxEnabledDefault);
|
1907
|
-
} else if (0 == strcmp(channel_args->args[i].key,
|
1908
|
-
GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD)) {
|
1909
|
-
grpc_integer_options options = {
|
1910
|
-
grpc_core::TcpZerocopySendCtx::kDefaultSendBytesThreshold, 0,
|
1911
|
-
INT_MAX};
|
1912
|
-
tcp_tx_zerocopy_send_bytes_thresh =
|
1913
|
-
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
1914
|
-
} else if (0 == strcmp(channel_args->args[i].key,
|
1915
|
-
GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS)) {
|
1916
|
-
grpc_integer_options options = {
|
1917
|
-
grpc_core::TcpZerocopySendCtx::kDefaultMaxSends, 0, INT_MAX};
|
1918
|
-
tcp_tx_zerocopy_max_simult_sends =
|
1919
|
-
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
1920
|
-
}
|
1921
|
-
}
|
1922
|
-
}
|
1923
|
-
|
1924
|
-
if (tcp_min_read_chunk_size > tcp_max_read_chunk_size) {
|
1925
|
-
tcp_min_read_chunk_size = tcp_max_read_chunk_size;
|
1926
|
-
}
|
1927
|
-
tcp_read_chunk_size = grpc_core::Clamp(
|
1928
|
-
tcp_read_chunk_size, tcp_min_read_chunk_size, tcp_max_read_chunk_size);
|
1929
|
-
|
1930
|
-
grpc_tcp* tcp = new grpc_tcp(tcp_tx_zerocopy_max_simult_sends,
|
1931
|
-
tcp_tx_zerocopy_send_bytes_thresh);
|
1950
|
+
grpc_tcp* tcp = new grpc_tcp(options);
|
1932
1951
|
tcp->base.vtable = &vtable;
|
1933
1952
|
tcp->peer_string = std::string(peer_string);
|
1934
1953
|
tcp->fd = grpc_fd_wrapped_fd(em_fd);
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1954
|
+
GPR_ASSERT(options.resource_quota != nullptr);
|
1955
|
+
tcp->memory_owner =
|
1956
|
+
options.resource_quota->memory_quota()->CreateMemoryOwner(peer_string);
|
1938
1957
|
tcp->self_reservation = tcp->memory_owner.MakeReservation(sizeof(grpc_tcp));
|
1939
1958
|
grpc_resolved_address resolved_local_addr;
|
1940
1959
|
memset(&resolved_local_addr, 0, sizeof(resolved_local_addr));
|
@@ -1953,20 +1972,18 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
|
|
1953
1972
|
tcp->current_zerocopy_send = nullptr;
|
1954
1973
|
tcp->release_fd_cb = nullptr;
|
1955
1974
|
tcp->release_fd = nullptr;
|
1956
|
-
tcp->target_length = static_cast<double>(tcp_read_chunk_size);
|
1957
|
-
tcp->min_read_chunk_size = tcp_min_read_chunk_size;
|
1958
|
-
tcp->max_read_chunk_size = tcp_max_read_chunk_size;
|
1975
|
+
tcp->target_length = static_cast<double>(options.tcp_read_chunk_size);
|
1959
1976
|
tcp->bytes_read_this_round = 0;
|
1960
1977
|
/* Will be set to false by the very first endpoint read function */
|
1961
1978
|
tcp->is_first_read = true;
|
1962
|
-
tcp->has_posted_reclaimer = false;
|
1963
1979
|
tcp->bytes_counter = -1;
|
1964
1980
|
tcp->socket_ts_enabled = false;
|
1965
1981
|
tcp->ts_capable = true;
|
1966
1982
|
tcp->outgoing_buffer_arg = nullptr;
|
1967
|
-
tcp->frame_size_tuning_enabled =
|
1983
|
+
tcp->frame_size_tuning_enabled = grpc_core::IsTcpFrameSizeTuningEnabled();
|
1968
1984
|
tcp->min_progress_size = 1;
|
1969
|
-
if (
|
1985
|
+
if (options.tcp_tx_zero_copy_enabled &&
|
1986
|
+
!tcp->tcp_zerocopy_send_ctx.memory_limited()) {
|
1970
1987
|
#ifdef GRPC_LINUX_ERRQUEUE
|
1971
1988
|
const int enable = 1;
|
1972
1989
|
auto err =
|
@@ -36,12 +36,14 @@
|
|
36
36
|
#include "src/core/lib/iomgr/endpoint.h"
|
37
37
|
#include "src/core/lib/iomgr/ev_posix.h"
|
38
38
|
#include "src/core/lib/iomgr/port.h"
|
39
|
+
#include "src/core/lib/iomgr/socket_utils_posix.h"
|
39
40
|
|
40
41
|
extern grpc_core::TraceFlag grpc_tcp_trace;
|
41
42
|
|
42
43
|
/// Create a tcp endpoint given a file desciptor and a read slice size.
|
43
44
|
/// Takes ownership of \a fd. Takes ownership of the \a slice_allocator.
|
44
|
-
grpc_endpoint* grpc_tcp_create(grpc_fd* fd,
|
45
|
+
grpc_endpoint* grpc_tcp_create(grpc_fd* fd,
|
46
|
+
const grpc_core::PosixTcpOptions& options,
|
45
47
|
absl::string_view peer_string);
|
46
48
|
|
47
49
|
/// Return the tcp endpoint's fd, or -1 if this is not available. Does not
|
@@ -22,10 +22,11 @@
|
|
22
22
|
|
23
23
|
grpc_tcp_server_vtable* grpc_tcp_server_impl;
|
24
24
|
|
25
|
-
grpc_error_handle grpc_tcp_server_create(
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
grpc_error_handle grpc_tcp_server_create(
|
26
|
+
grpc_closure* shutdown_complete,
|
27
|
+
const grpc_event_engine::experimental::EndpointConfig& config,
|
28
|
+
grpc_tcp_server** server) {
|
29
|
+
return grpc_tcp_server_impl->create(shutdown_complete, config, server);
|
29
30
|
}
|
30
31
|
|
31
32
|
void grpc_tcp_server_start(grpc_tcp_server* server,
|
@@ -23,6 +23,7 @@
|
|
23
23
|
|
24
24
|
#include <vector>
|
25
25
|
|
26
|
+
#include <grpc/event_engine/endpoint_config.h>
|
26
27
|
#include <grpc/grpc.h>
|
27
28
|
#include <grpc/impl/codegen/grpc_types.h>
|
28
29
|
|
@@ -63,9 +64,10 @@ class TcpServerFdHandler {
|
|
63
64
|
} // namespace grpc_core
|
64
65
|
|
65
66
|
typedef struct grpc_tcp_server_vtable {
|
66
|
-
grpc_error_handle (*create)(
|
67
|
-
|
68
|
-
|
67
|
+
grpc_error_handle (*create)(
|
68
|
+
grpc_closure* shutdown_complete,
|
69
|
+
const grpc_event_engine::experimental::EndpointConfig& config,
|
70
|
+
grpc_tcp_server** server);
|
69
71
|
void (*start)(grpc_tcp_server* server,
|
70
72
|
const std::vector<grpc_pollset*>* pollsets,
|
71
73
|
grpc_tcp_server_cb on_accept_cb, void* cb_arg);
|
@@ -86,9 +88,10 @@ typedef struct grpc_tcp_server_vtable {
|
|
86
88
|
If shutdown_complete is not NULL, it will be used by
|
87
89
|
grpc_tcp_server_unref() when the ref count reaches zero.
|
88
90
|
Takes ownership of the slice_allocator_factory. */
|
89
|
-
grpc_error_handle grpc_tcp_server_create(
|
90
|
-
|
91
|
-
|
91
|
+
grpc_error_handle grpc_tcp_server_create(
|
92
|
+
grpc_closure* shutdown_complete,
|
93
|
+
const grpc_event_engine::experimental::EndpointConfig& config,
|
94
|
+
grpc_tcp_server** server);
|
92
95
|
|
93
96
|
/* Start listening to bound ports */
|
94
97
|
void grpc_tcp_server_start(grpc_tcp_server* server,
|
@@ -43,13 +43,13 @@
|
|
43
43
|
#include "absl/strings/str_cat.h"
|
44
44
|
#include "absl/strings/str_format.h"
|
45
45
|
|
46
|
+
#include <grpc/event_engine/endpoint_config.h>
|
46
47
|
#include <grpc/support/alloc.h>
|
47
48
|
#include <grpc/support/log.h>
|
48
49
|
#include <grpc/support/sync.h>
|
49
50
|
#include <grpc/support/time.h>
|
50
51
|
|
51
52
|
#include "src/core/lib/address_utils/sockaddr_utils.h"
|
52
|
-
#include "src/core/lib/channel/channel_args.h"
|
53
53
|
#include "src/core/lib/gpr/string.h"
|
54
54
|
#include "src/core/lib/gprpp/memory.h"
|
55
55
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
@@ -64,31 +64,21 @@
|
|
64
64
|
|
65
65
|
static std::atomic<int64_t> num_dropped_connections{0};
|
66
66
|
|
67
|
+
using ::grpc_event_engine::experimental::EndpointConfig;
|
68
|
+
|
67
69
|
static grpc_error_handle tcp_server_create(grpc_closure* shutdown_complete,
|
68
|
-
const
|
70
|
+
const EndpointConfig& config,
|
69
71
|
grpc_tcp_server** server) {
|
70
72
|
grpc_tcp_server* s = new grpc_tcp_server;
|
71
73
|
s->so_reuseport = grpc_is_socket_reuse_port_supported();
|
72
74
|
s->expand_wildcard_addrs = false;
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(GRPC_ARG_ALLOW_REUSEPORT
|
81
|
-
" must be an integer");
|
82
|
-
}
|
83
|
-
} else if (0 == strcmp(GRPC_ARG_EXPAND_WILDCARD_ADDRS, args->args[i].key)) {
|
84
|
-
if (args->args[i].type == GRPC_ARG_INTEGER) {
|
85
|
-
s->expand_wildcard_addrs = (args->args[i].value.integer != 0);
|
86
|
-
} else {
|
87
|
-
gpr_free(s);
|
88
|
-
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
89
|
-
GRPC_ARG_EXPAND_WILDCARD_ADDRS " must be an integer");
|
90
|
-
}
|
91
|
-
}
|
75
|
+
auto value = config.GetInt(GRPC_ARG_ALLOW_REUSEPORT);
|
76
|
+
if (value.has_value()) {
|
77
|
+
s->so_reuseport = (grpc_is_socket_reuse_port_supported() && *value != 0);
|
78
|
+
}
|
79
|
+
value = config.GetInt(GRPC_ARG_EXPAND_WILDCARD_ADDRS);
|
80
|
+
if (value.has_value()) {
|
81
|
+
s->expand_wildcard_addrs = (*value != 0);
|
92
82
|
}
|
93
83
|
gpr_ref_init(&s->refs, 1);
|
94
84
|
gpr_mu_init(&s->mu);
|
@@ -103,10 +93,10 @@ static grpc_error_handle tcp_server_create(grpc_closure* shutdown_complete,
|
|
103
93
|
s->head = nullptr;
|
104
94
|
s->tail = nullptr;
|
105
95
|
s->nports = 0;
|
106
|
-
s->
|
96
|
+
s->options = TcpOptionsFromEndpointConfig(config);
|
107
97
|
s->fd_handler = nullptr;
|
108
|
-
s->
|
109
|
-
|
98
|
+
GPR_ASSERT(s->options.resource_quota != nullptr);
|
99
|
+
s->memory_quota = s->options.resource_quota->memory_quota();
|
110
100
|
gpr_atm_no_barrier_store(&s->next_pollset_to_assign, 0);
|
111
101
|
*server = s;
|
112
102
|
return GRPC_ERROR_NONE;
|
@@ -126,7 +116,6 @@ static void finish_shutdown(grpc_tcp_server* s) {
|
|
126
116
|
s->head = sp->next;
|
127
117
|
gpr_free(sp);
|
128
118
|
}
|
129
|
-
grpc_channel_args_destroy(s->channel_args);
|
130
119
|
delete s->fd_handler;
|
131
120
|
delete s;
|
132
121
|
}
|
@@ -252,7 +241,7 @@ static void on_read(void* arg, grpc_error_handle err) {
|
|
252
241
|
(void)grpc_set_socket_no_sigpipe_if_possible(fd);
|
253
242
|
|
254
243
|
err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_CONNECTION_USAGE,
|
255
|
-
sp->server->
|
244
|
+
sp->server->options);
|
256
245
|
if (!GRPC_ERROR_IS_NONE(err)) {
|
257
246
|
goto error;
|
258
247
|
}
|
@@ -287,7 +276,7 @@ static void on_read(void* arg, grpc_error_handle err) {
|
|
287
276
|
acceptor->external_connection = false;
|
288
277
|
sp->server->on_accept_cb(
|
289
278
|
sp->server->on_accept_cb_arg,
|
290
|
-
grpc_tcp_create(fdobj, sp->server->
|
279
|
+
grpc_tcp_create(fdobj, sp->server->options, addr_uri.value()),
|
291
280
|
read_notifier_pollset, acceptor);
|
292
281
|
}
|
293
282
|
|
@@ -639,7 +628,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler {
|
|
639
628
|
acceptor->listener_fd = listener_fd;
|
640
629
|
acceptor->pending_data = buf;
|
641
630
|
s_->on_accept_cb(s_->on_accept_cb_arg,
|
642
|
-
grpc_tcp_create(fdobj, s_->
|
631
|
+
grpc_tcp_create(fdobj, s_->options, addr_uri.value()),
|
643
632
|
read_notifier_pollset, acceptor);
|
644
633
|
}
|
645
634
|
|
@@ -90,8 +90,8 @@ struct grpc_tcp_server {
|
|
90
90
|
/* next pollset to assign a channel to */
|
91
91
|
gpr_atm next_pollset_to_assign = 0;
|
92
92
|
|
93
|
-
/* channel args for this server */
|
94
|
-
|
93
|
+
/* Contains config extracted from channel args for this server */
|
94
|
+
grpc_core::PosixTcpOptions options;
|
95
95
|
|
96
96
|
/* a handler for external connections, owned */
|
97
97
|
grpc_core::TcpServerFdHandler* fd_handler = nullptr;
|
@@ -178,15 +178,15 @@ grpc_error_handle grpc_tcp_server_prepare_socket(
|
|
178
178
|
if (!GRPC_ERROR_IS_NONE(err)) goto error;
|
179
179
|
err = grpc_set_socket_reuse_addr(fd, 1);
|
180
180
|
if (!GRPC_ERROR_IS_NONE(err)) goto error;
|
181
|
-
err =
|
182
|
-
|
181
|
+
err =
|
182
|
+
grpc_set_socket_tcp_user_timeout(fd, s->options, false /* is_client */);
|
183
183
|
if (!GRPC_ERROR_IS_NONE(err)) goto error;
|
184
184
|
}
|
185
185
|
err = grpc_set_socket_no_sigpipe_if_possible(fd);
|
186
186
|
if (!GRPC_ERROR_IS_NONE(err)) goto error;
|
187
187
|
|
188
188
|
err = grpc_apply_socket_mutator_in_args(fd, GRPC_FD_SERVER_LISTENER_USAGE,
|
189
|
-
s->
|
189
|
+
s->options);
|
190
190
|
if (!GRPC_ERROR_IS_NONE(err)) goto error;
|
191
191
|
|
192
192
|
if (bind(fd, reinterpret_cast<grpc_sockaddr*>(const_cast<char*>(addr->addr)),
|