From 672f31c6ac18e527062b3b029b5a5fc032904696 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 22 Nov 2021 15:24:39 -0800 Subject: [PATCH] Channel args preconditioning (#28132) * Channel args preconditioning * docs * fixes * Automated change: Fix sanity tests * fix * fix this again after merge error Co-authored-by: ctiller --- BUILD | 41 +++++++++++- CMakeLists.txt | 4 ++ Makefile | 2 + build_autogenerated.yaml | 8 +++ config.m4 | 1 + config.w32 | 1 + gRPC-C++.podspec | 2 + gRPC-Core.podspec | 3 + grpc.gemspec | 2 + grpc.gyp | 2 + package.xml | 2 + .../chttp2/client/insecure/channel_create.cc | 6 +- .../client/insecure/channel_create_posix.cc | 5 +- .../client/secure/secure_channel_create.cc | 9 ++- .../client/secure/cronet_channel_create.cc | 4 +- .../ext/transport/inproc/inproc_transport.cc | 7 ++- .../ext/transport/inproc/inproc_transport.h | 2 +- src/core/ext/xds/xds_server_config_fetcher.cc | 5 +- src/core/lib/channel/channel_args.cc | 34 +++++----- src/core/lib/channel/channel_args.h | 21 ++++--- .../channel/channel_args_preconditioning.cc | 47 ++++++++++++++ .../channel/channel_args_preconditioning.h | 62 +++++++++++++++++++ src/core/lib/compression/compression_args.cc | 12 ++-- src/core/lib/compression/compression_args.h | 10 +-- src/core/lib/config/core_configuration.cc | 4 +- src/core/lib/config/core_configuration.h | 11 ++++ src/core/lib/http/httpcli.cc | 9 ++- src/core/lib/iomgr/endpoint_pair_posix.cc | 10 +-- src/core/lib/resource_quota/api.cc | 11 ++-- src/core/lib/resource_quota/api.h | 15 +---- src/core/lib/surface/lame_client.cc | 4 +- src/core/lib/surface/server.cc | 7 +-- .../plugin_registry/grpc_plugin_registry.cc | 6 +- .../grpc_unsecure_plugin_registry.cc | 2 + src/cpp/thread_manager/thread_manager.cc | 2 +- src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/bad_client/bad_client.cc | 5 +- .../resolvers/binder_resolver_test.cc | 1 + .../resolvers/dns_resolver_test.cc | 1 + .../resolvers/sockaddr_resolver_test.cc | 1 + test/core/compression/compression_test.cc | 8 ++- test/core/end2end/end2end_tests.h | 9 +-- test/core/end2end/fixtures/h2_census.cc | 7 ++- test/core/end2end/fixtures/h2_compress.cc | 15 ++--- test/core/end2end/fixtures/h2_fakesec.cc | 13 ++-- test/core/end2end/fixtures/h2_fd.cc | 11 ++-- test/core/end2end/fixtures/h2_full+pipe.cc | 7 ++- test/core/end2end/fixtures/h2_full+trace.cc | 7 ++- test/core/end2end/fixtures/h2_full.cc | 7 ++- test/core/end2end/fixtures/h2_http_proxy.cc | 7 ++- test/core/end2end/fixtures/h2_insecure.cc | 7 ++- .../h2_local_abstract_uds_percent_encoded.cc | 11 ++-- test/core/end2end/fixtures/h2_local_ipv4.cc | 11 ++-- test/core/end2end/fixtures/h2_local_ipv6.cc | 11 ++-- test/core/end2end/fixtures/h2_local_uds.cc | 11 ++-- .../fixtures/h2_local_uds_percent_encoded.cc | 11 ++-- test/core/end2end/fixtures/h2_oauth2.cc | 22 ++++--- test/core/end2end/fixtures/h2_proxy.cc | 11 ++-- .../end2end/fixtures/h2_sockpair+trace.cc | 23 ++++--- test/core/end2end/fixtures/h2_sockpair.cc | 23 ++++--- .../end2end/fixtures/h2_sockpair_1byte.cc | 23 ++++--- test/core/end2end/fixtures/h2_ssl.cc | 22 ++++--- .../end2end/fixtures/h2_ssl_cred_reload.cc | 22 ++++--- test/core/end2end/fixtures/h2_ssl_proxy.cc | 21 ++++--- test/core/end2end/fixtures/h2_tls.cc | 24 +++---- test/core/end2end/fixtures/h2_uds.cc | 10 +-- .../end2end/fixtures/http_proxy_fixture.cc | 13 ++-- .../end2end/fixtures/http_proxy_fixture.h | 2 +- test/core/end2end/fixtures/inproc.cc | 7 ++- test/core/end2end/fixtures/local_util.cc | 6 +- test/core/end2end/fixtures/local_util.h | 4 +- test/core/end2end/fixtures/proxy.cc | 8 +-- test/core/end2end/fixtures/proxy.h | 10 +-- test/core/end2end/fuzzers/client_fuzzer.cc | 5 +- test/core/end2end/fuzzers/server_fuzzer.cc | 6 +- test/core/end2end/inproc_callback_test.cc | 15 ++--- test/core/end2end/tests/binary_metadata.cc | 12 +++- test/core/end2end/tests/compressed_payload.cc | 25 ++++---- .../stream_compression_compressed_payload.cc | 16 ++--- .../tests/stream_compression_payload.cc | 12 ++-- .../stream_compression_ping_pong_streaming.cc | 12 ++-- .../ios/CFStreamTests/CFStreamClientTests.mm | 8 ++- .../CFStreamTests/CFStreamEndpointTests.mm | 4 +- test/core/iomgr/tcp_client_posix_test.cc | 5 +- test/core/iomgr/tcp_server_posix_test.cc | 26 +++++--- .../surface/concurrent_connectivity_test.cc | 5 +- .../transport/chttp2/context_list_test.cc | 8 ++- .../transport/chttp2/settings_timeout_test.cc | 4 +- test/core/util/test_tcp_server.cc | 5 +- .../microbenchmarks/bm_chttp2_transport.cc | 5 +- tools/doxygen/Doxyfile.c++.internal | 2 + tools/doxygen/Doxyfile.core.internal | 2 + 92 files changed, 624 insertions(+), 339 deletions(-) create mode 100644 src/core/lib/channel/channel_args_preconditioning.cc create mode 100644 src/core/lib/channel/channel_args_preconditioning.h diff --git a/BUILD b/BUILD index b4ce0fb9692..cecfdba453f 100644 --- a/BUILD +++ b/BUILD @@ -968,6 +968,7 @@ grpc_cc_library( "src/core/lib/config/core_configuration.h", ], deps = [ + "channel_args_preconditioning", "channel_init", "gpr_base", "handshaker_registry", @@ -1679,13 +1680,47 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "channel_args", + srcs = [ + "src/core/lib/channel/channel_args.cc", + ], + hdrs = [ + "src/core/lib/channel/channel_args.h", + ], + external_deps = [ + "absl/strings", + "absl/strings:str_format", + ], + deps = [ + "channel_stack_type", + "gpr_base", + "gpr_codegen", + "grpc_codegen", + "useful", + ], +) + +grpc_cc_library( + name = "channel_args_preconditioning", + srcs = [ + "src/core/lib/channel/channel_args_preconditioning.cc", + ], + hdrs = [ + "src/core/lib/channel/channel_args_preconditioning.h", + ], + deps = [ + "channel_args", + "gpr_base", + ], +) + grpc_cc_library( name = "grpc_base", srcs = [ "src/core/lib/address_utils/parse_address.cc", "src/core/lib/address_utils/sockaddr_utils.cc", "src/core/lib/backoff/backoff.cc", - "src/core/lib/channel/channel_args.cc", "src/core/lib/channel/channel_stack.cc", "src/core/lib/channel/channel_stack_builder.cc", "src/core/lib/channel/channel_trace.cc", @@ -1847,7 +1882,6 @@ grpc_cc_library( "src/core/lib/address_utils/sockaddr_utils.h", "src/core/lib/backoff/backoff.h", "src/core/lib/channel/call_tracer.h", - "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/channel_trace.h", @@ -1980,6 +2014,7 @@ grpc_cc_library( "src/core/lib/iomgr/executor.h", "src/core/lib/iomgr/combiner.h", "src/core/lib/iomgr/iomgr_internal.h", + "src/core/lib/channel/channel_args.h", ] + # TODO(hork): delete the iomgr glue code when EventEngine is fully # integrated, or when it becomes obvious the glue code is unnecessary. @@ -2008,6 +2043,7 @@ grpc_cc_library( deps = [ "avl", "bitset", + "channel_args", "channel_stack_type", "chunked_vector", "closure", @@ -2660,6 +2696,7 @@ grpc_cc_library( ], language = "c++", deps = [ + "config", "gpr_base", "grpc_base", "grpc_server_config_selector", diff --git a/CMakeLists.txt b/CMakeLists.txt index 11164d6e737..b7b930eaaa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1820,6 +1820,7 @@ add_library(grpc src/core/lib/address_utils/sockaddr_utils.cc src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc + src/core/lib/channel/channel_args_preconditioning.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc @@ -2465,6 +2466,7 @@ add_library(grpc_unsecure src/core/lib/address_utils/sockaddr_utils.cc src/core/lib/backoff/backoff.cc src/core/lib/channel/channel_args.cc + src/core/lib/channel/channel_args_preconditioning.cc src/core/lib/channel/channel_stack.cc src/core/lib/channel/channel_stack_builder.cc src/core/lib/channel/channel_trace.cc @@ -9813,6 +9815,8 @@ add_executable(core_configuration_test src/core/ext/upb-generated/google/protobuf/timestamp.upb.c src/core/ext/upb-generated/google/protobuf/wrappers.upb.c src/core/ext/upb-generated/google/rpc/status.upb.c + src/core/lib/channel/channel_args.cc + src/core/lib/channel/channel_args_preconditioning.cc src/core/lib/channel/handshaker_registry.cc src/core/lib/config/core_configuration.cc src/core/lib/gpr/alloc.cc diff --git a/Makefile b/Makefile index 757ca7bcca9..d390312bea7 100644 --- a/Makefile +++ b/Makefile @@ -1362,6 +1362,7 @@ LIBGRPC_SRC = \ src/core/lib/address_utils/sockaddr_utils.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ + src/core/lib/channel/channel_args_preconditioning.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ @@ -1855,6 +1856,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/address_utils/sockaddr_utils.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ + src/core/lib/channel/channel_args_preconditioning.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 93210d9c393..f3f968aef14 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -732,6 +732,7 @@ libs: - src/core/lib/backoff/backoff.h - src/core/lib/channel/call_tracer.h - src/core/lib/channel/channel_args.h + - src/core/lib/channel/channel_args_preconditioning.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - src/core/lib/channel/channel_trace.h @@ -1299,6 +1300,7 @@ libs: - src/core/lib/address_utils/sockaddr_utils.cc - src/core/lib/backoff/backoff.cc - src/core/lib/channel/channel_args.cc + - src/core/lib/channel/channel_args_preconditioning.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc @@ -1811,6 +1813,7 @@ libs: - src/core/lib/backoff/backoff.h - src/core/lib/channel/call_tracer.h - src/core/lib/channel/channel_args.h + - src/core/lib/channel/channel_args_preconditioning.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - src/core/lib/channel/channel_trace.h @@ -2095,6 +2098,7 @@ libs: - src/core/lib/address_utils/sockaddr_utils.cc - src/core/lib/backoff/backoff.cc - src/core/lib/channel/channel_args.cc + - src/core/lib/channel/channel_args_preconditioning.cc - src/core/lib/channel/channel_stack.cc - src/core/lib/channel/channel_stack_builder.cc - src/core/lib/channel/channel_trace.cc @@ -5424,6 +5428,8 @@ targets: - src/core/ext/upb-generated/google/protobuf/timestamp.upb.h - src/core/ext/upb-generated/google/protobuf/wrappers.upb.h - src/core/ext/upb-generated/google/rpc/status.upb.h + - src/core/lib/channel/channel_args.h + - src/core/lib/channel/channel_args_preconditioning.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h - src/core/lib/config/core_configuration.h @@ -5470,6 +5476,8 @@ targets: - src/core/ext/upb-generated/google/protobuf/timestamp.upb.c - src/core/ext/upb-generated/google/protobuf/wrappers.upb.c - src/core/ext/upb-generated/google/rpc/status.upb.c + - src/core/lib/channel/channel_args.cc + - src/core/lib/channel/channel_args_preconditioning.cc - src/core/lib/channel/handshaker_registry.cc - src/core/lib/config/core_configuration.cc - src/core/lib/gpr/alloc.cc diff --git a/config.m4 b/config.m4 index a4229ef2cff..625c1e7b853 100644 --- a/config.m4 +++ b/config.m4 @@ -370,6 +370,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/address_utils/sockaddr_utils.cc \ src/core/lib/backoff/backoff.cc \ src/core/lib/channel/channel_args.cc \ + src/core/lib/channel/channel_args_preconditioning.cc \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack_builder.cc \ src/core/lib/channel/channel_trace.cc \ diff --git a/config.w32 b/config.w32 index 146906a68d6..0af864e685d 100644 --- a/config.w32 +++ b/config.w32 @@ -336,6 +336,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\address_utils\\sockaddr_utils.cc " + "src\\core\\lib\\backoff\\backoff.cc " + "src\\core\\lib\\channel\\channel_args.cc " + + "src\\core\\lib\\channel\\channel_args_preconditioning.cc " + "src\\core\\lib\\channel\\channel_stack.cc " + "src\\core\\lib\\channel\\channel_stack_builder.cc " + "src\\core\\lib\\channel\\channel_trace.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 7b986a360d4..21a6ac2c577 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -562,6 +562,7 @@ Pod::Spec.new do |s| 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/call_tracer.h', 'src/core/lib/channel/channel_args.h', + 'src/core/lib/channel/channel_args_preconditioning.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', @@ -1275,6 +1276,7 @@ Pod::Spec.new do |s| 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/call_tracer.h', 'src/core/lib/channel/channel_args.h', + 'src/core/lib/channel/channel_args_preconditioning.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b24e51958c6..f19734bf2c8 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -831,6 +831,8 @@ Pod::Spec.new do |s| 'src/core/lib/channel/call_tracer.h', 'src/core/lib/channel/channel_args.cc', 'src/core/lib/channel/channel_args.h', + 'src/core/lib/channel/channel_args_preconditioning.cc', + 'src/core/lib/channel/channel_args_preconditioning.h', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.cc', @@ -1802,6 +1804,7 @@ Pod::Spec.new do |s| 'src/core/lib/backoff/backoff.h', 'src/core/lib/channel/call_tracer.h', 'src/core/lib/channel/channel_args.h', + 'src/core/lib/channel/channel_args_preconditioning.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/channel_trace.h', diff --git a/grpc.gemspec b/grpc.gemspec index b3ec69dbfac..e8152e1979a 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -751,6 +751,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/call_tracer.h ) s.files += %w( src/core/lib/channel/channel_args.cc ) s.files += %w( src/core/lib/channel/channel_args.h ) + s.files += %w( src/core/lib/channel/channel_args_preconditioning.cc ) + s.files += %w( src/core/lib/channel/channel_args_preconditioning.h ) s.files += %w( src/core/lib/channel/channel_stack.cc ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.cc ) diff --git a/grpc.gyp b/grpc.gyp index 6ca4bc85ddc..b6ba0f99881 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -803,6 +803,7 @@ 'src/core/lib/address_utils/sockaddr_utils.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', + 'src/core/lib/channel/channel_args_preconditioning.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', @@ -1268,6 +1269,7 @@ 'src/core/lib/address_utils/sockaddr_utils.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', + 'src/core/lib/channel/channel_args_preconditioning.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', diff --git a/package.xml b/package.xml index 1f0d3eecc62..0175b58d90e 100644 --- a/package.xml +++ b/package.xml @@ -731,6 +731,8 @@ + + diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc index e3097504276..66129d92b36 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc @@ -60,7 +60,9 @@ grpc_channel* CreateChannel(const char* target, const grpc_channel_args* args, const char* to_remove[] = {GRPC_ARG_SERVER_URI}; grpc_channel_args* new_args0 = grpc_channel_args_copy_and_add_and_remove(args, to_remove, 1, &arg, 1); - grpc_channel_args* new_args = EnsureResourceQuotaInChannelArgs(new_args0); + const grpc_channel_args* new_args = CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(new_args0); grpc_channel_args_destroy(new_args0); grpc_channel* channel = grpc_channel_create( target, new_args, GRPC_CLIENT_CHANNEL, nullptr, error); @@ -91,7 +93,6 @@ grpc_channel* grpc_insecure_channel_create(const char* target, const grpc_channel_args* args, void* reserved) { grpc_core::ExecCtx exec_ctx; - args = grpc_channel_args_remove_grpc_internal(args); GRPC_API_TRACE( "grpc_insecure_channel_create(target=%s, args=%p, reserved=%p)", 3, (target, args, reserved)); @@ -107,7 +108,6 @@ grpc_channel* grpc_insecure_channel_create(const char* target, grpc_channel* channel = grpc_core::CreateChannel(target, new_args, &error); // Clean up. grpc_channel_args_destroy(new_args); - grpc_channel_args_destroy(args); if (channel == nullptr) { intptr_t integer; grpc_status_code status = GRPC_STATUS_INTERNAL; diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc index ed3cf57dd9f..ba821d049e7 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc @@ -46,8 +46,9 @@ grpc_channel* grpc_insecure_channel_create_from_fd( const_cast(GRPC_ARG_DEFAULT_AUTHORITY), const_cast("test.authority")); args = grpc_channel_args_copy_and_add(args, &default_authority_arg, 1); - grpc_channel_args* final_args = - grpc_core::EnsureResourceQuotaInChannelArgs(args); + const grpc_channel_args* final_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args); grpc_channel_args_destroy(args); int flags = fcntl(fd, F_GETFL, 0); diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc index 74f80e8cc2e..c5fb03b82b1 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc @@ -155,7 +155,9 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds, "reserved=%p)", 4, ((void*)creds, target, (void*)args, (void*)reserved)); GPR_ASSERT(reserved == nullptr); - args = grpc_channel_args_remove_grpc_internal(args); + args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args); grpc_channel* channel = nullptr; grpc_error_handle error = GRPC_ERROR_NONE; if (creds != nullptr) { @@ -167,11 +169,8 @@ grpc_channel* grpc_secure_channel_create(grpc_channel_credentials* creds, grpc_arg args_to_add[] = {channel_factory_arg, grpc_channel_credentials_to_arg(creds)}; const char* arg_to_remove = channel_factory_arg.key; - grpc_channel_args* updated_args = grpc_channel_args_copy_and_add_and_remove( + grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove( args, &arg_to_remove, 1, args_to_add, GPR_ARRAY_SIZE(args_to_add)); - grpc_channel_args* new_args = - grpc_core::EnsureResourceQuotaInChannelArgs(updated_args); - grpc_channel_args_destroy(updated_args); new_args = creds->update_arguments(new_args); // Create channel. channel = grpc_core::CreateChannel(target, new_args, &error); diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc index 3207eda8c1d..d027e16f604 100644 --- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc +++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc @@ -53,7 +53,9 @@ GRPCAPI grpc_channel* grpc_cronet_secure_channel_create( const_cast(GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER); disable_client_authority_filter_arg.type = GRPC_ARG_INTEGER; disable_client_authority_filter_arg.value.integer = 1; - args = grpc_core::EnsureResourceQuotaInChannelArgs(args); + args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args); grpc_channel_args* new_args = grpc_channel_args_copy_and_add( args, &disable_client_authority_filter_arg, 1); diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 8dbdb8f37b3..251bf01ccf5 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -1281,7 +1281,7 @@ void grpc_inproc_transport_init(void) { } grpc_channel* grpc_inproc_channel_create(grpc_server* server, - grpc_channel_args* args, + const grpc_channel_args* args, void* /*reserved*/) { GRPC_API_TRACE("grpc_inproc_channel_create(server=%p, args=%p)", 2, (server, args)); @@ -1302,8 +1302,9 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server, default_authority_arg.key = const_cast(GRPC_ARG_DEFAULT_AUTHORITY); default_authority_arg.value.string = const_cast("inproc.authority"); args = grpc_channel_args_copy_and_add(args, &default_authority_arg, 1); - grpc_channel_args* client_args = - grpc_core::EnsureResourceQuotaInChannelArgs(args); + const grpc_channel_args* client_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args); grpc_channel_args_destroy(args); grpc_transport* server_transport; grpc_transport* client_transport; diff --git a/src/core/ext/transport/inproc/inproc_transport.h b/src/core/ext/transport/inproc/inproc_transport.h index 049d1402afe..7a5b3bb627d 100644 --- a/src/core/ext/transport/inproc/inproc_transport.h +++ b/src/core/ext/transport/inproc/inproc_transport.h @@ -24,7 +24,7 @@ #include "src/core/lib/transport/transport_impl.h" grpc_channel* grpc_inproc_channel_create(grpc_server* server, - grpc_channel_args* args, + const grpc_channel_args* args, void* reserved); extern grpc_core::TraceFlag grpc_inproc_trace; diff --git a/src/core/ext/xds/xds_server_config_fetcher.cc b/src/core/ext/xds/xds_server_config_fetcher.cc index 51446f72a54..315efa0ff54 100644 --- a/src/core/ext/xds/xds_server_config_fetcher.cc +++ b/src/core/ext/xds/xds_server_config_fetcher.cc @@ -29,6 +29,7 @@ #include "src/core/ext/xds/xds_routing.h" #include "src/core/lib/address_utils/sockaddr_utils.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/gprpp/host_port.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/socket_utils.h" @@ -1231,7 +1232,9 @@ grpc_server_config_fetcher* grpc_server_config_fetcher_xds_create( grpc_server_xds_status_notifier notifier, const grpc_channel_args* args) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; - args = grpc_channel_args_remove_grpc_internal(args); + args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args); GRPC_API_TRACE("grpc_server_config_fetcher_xds_create()", 0, ()); grpc_error_handle error = GRPC_ERROR_NONE; grpc_core::RefCountedPtr xds_client = diff --git a/src/core/lib/channel/channel_args.cc b/src/core/lib/channel/channel_args.cc index 4cd015bb49c..fc4ea8b3a26 100644 --- a/src/core/lib/channel/channel_args.cc +++ b/src/core/lib/channel/channel_args.cc @@ -29,7 +29,6 @@ #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" -#include #include #include #include @@ -73,22 +72,6 @@ grpc_channel_args* grpc_channel_args_copy_and_remove( num_to_remove, nullptr, 0); } -grpc_channel_args* grpc_channel_args_remove_grpc_internal( - const grpc_channel_args* src) { - if (src == nullptr) return nullptr; - // Create result. - grpc_channel_args* dst = - static_cast(gpr_malloc(sizeof(grpc_channel_args))); - dst->args = - static_cast(gpr_malloc(sizeof(grpc_arg) * src->num_args)); - dst->num_args = 0; - for (size_t i = 0; i < src->num_args; ++i) { - if (absl::StartsWith(src->args[i].key, "grpc.internal.")) continue; - dst->args[dst->num_args++] = copy_arg(&src->args[i]); - } - return dst; -} - static bool should_remove_arg(const grpc_arg* arg, const char** to_remove, size_t num_to_remove) { for (size_t i = 0; i < num_to_remove; ++i) { @@ -385,6 +368,23 @@ std::string grpc_channel_args_string(const grpc_channel_args* args) { return absl::StrJoin(arg_strings, ", "); } +namespace grpc_core { +const grpc_channel_args* RemoveGrpcInternalArgs(const grpc_channel_args* src) { + if (src == nullptr) return nullptr; + // Create result. + grpc_channel_args* dst = + static_cast(gpr_malloc(sizeof(grpc_channel_args))); + dst->args = + static_cast(gpr_malloc(sizeof(grpc_arg) * src->num_args)); + dst->num_args = 0; + for (size_t i = 0; i < src->num_args; ++i) { + if (absl::StartsWith(src->args[i].key, "grpc.internal.")) continue; + dst->args[dst->num_args++] = copy_arg(&src->args[i]); + } + return dst; +} +} // namespace grpc_core + namespace { grpc_channel_args_client_channel_creation_mutator g_mutator = nullptr; } // namespace diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h index 436e7989f84..2fcbd3e59f0 100644 --- a/src/core/lib/channel/channel_args.h +++ b/src/core/lib/channel/channel_args.h @@ -23,7 +23,7 @@ #include -#include +#include #include "src/core/lib/surface/channel_stack_type.h" @@ -41,15 +41,6 @@ grpc_channel_args* grpc_channel_args_copy_and_add(const grpc_channel_args* src, const grpc_arg* to_add, size_t num_to_add); -/** Remove any channel args prefixed with 'grpc.internal.' - * These are used for internal implementation details and are not intended to - * be exposed to users. - * Returns a new channel args instance. - * Does not take ownership of \a src. - * Should be called by any public API that receives channel args. */ -grpc_channel_args* grpc_channel_args_remove_grpc_internal( - const grpc_channel_args* src); - /** Copies the arguments in \a src except for those whose keys are in \a to_remove. */ grpc_channel_args* grpc_channel_args_copy_and_remove( @@ -128,6 +119,16 @@ grpc_arg grpc_channel_arg_pointer_create(char* name, void* value, // Returns a string representing channel args in human-readable form. std::string grpc_channel_args_string(const grpc_channel_args* args); +namespace grpc_core { +/** Remove any channel args prefixed with 'grpc.internal.' + * These are used for internal implementation details and are not intended to + * be exposed to users. + * Returns a new channel args instance. + * Does not take ownership of \a src. + * Should be called by any public API that receives channel args. */ +const grpc_channel_args* RemoveGrpcInternalArgs(const grpc_channel_args* src); +} // namespace grpc_core + // Takes ownership of the old_args typedef grpc_channel_args* (*grpc_channel_args_client_channel_creation_mutator)( const char* target, grpc_channel_args* old_args, diff --git a/src/core/lib/channel/channel_args_preconditioning.cc b/src/core/lib/channel/channel_args_preconditioning.cc new file mode 100644 index 00000000000..d078499ac9e --- /dev/null +++ b/src/core/lib/channel/channel_args_preconditioning.cc @@ -0,0 +1,47 @@ +// Copyright 2021 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "src/core/lib/channel/channel_args_preconditioning.h" + +#include + +namespace grpc_core { + +void ChannelArgsPreconditioning::Builder::RegisterStage(Stage stage) { + stages_.emplace_back(std::move(stage)); +} + +ChannelArgsPreconditioning ChannelArgsPreconditioning::Builder::Build() { + // TODO(ctiller): should probably make this registered too. + stages_.emplace_back(RemoveGrpcInternalArgs); + + ChannelArgsPreconditioning preconditioning; + preconditioning.stages_ = std::move(stages_); + return preconditioning; +} + +const grpc_channel_args* ChannelArgsPreconditioning::PreconditionChannelArgs( + const grpc_channel_args* args) const { + const grpc_channel_args* owned_args = nullptr; + for (auto& stage : stages_) { + args = stage(args); + grpc_channel_args_destroy(owned_args); + owned_args = args; + } + return args; +} + +} // namespace grpc_core diff --git a/src/core/lib/channel/channel_args_preconditioning.h b/src/core/lib/channel/channel_args_preconditioning.h new file mode 100644 index 00000000000..224399fb549 --- /dev/null +++ b/src/core/lib/channel/channel_args_preconditioning.h @@ -0,0 +1,62 @@ +// Copyright 2021 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_PRECONDITIONING_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_PRECONDITIONING_H + +#include + +#include +#include + +#include "src/core/lib/channel/channel_args.h" + +namespace grpc_core { + +// Registry of mutators for channel args. +// Surface APIs should call into this with channel args received from outside +// of gRPC, in order to prepare those channel args for the expections of the +// gRPC internals. +class ChannelArgsPreconditioning { + public: + // Take channel args and mutate them. + // Does not take ownership of the channel args passed in. + // Returns a new channel args object that is owned by the caller. + using Stage = + std::function; + + class Builder { + public: + // Register a new channel args preconditioner. + void RegisterStage(Stage stage); + // Build out the preconditioners. + ChannelArgsPreconditioning Build(); + + private: + std::vector stages_; + }; + + // Take channel args and precondition them. + // Does not take ownership of the channel args passed in. + // Returns a new channel args object that is owned by the caller. + const grpc_channel_args* PreconditionChannelArgs( + const grpc_channel_args* args) const; + + private: + std::vector stages_; +}; + +} // namespace grpc_core + +#endif // GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_PRECONDITIONING_H diff --git a/src/core/lib/compression/compression_args.cc b/src/core/lib/compression/compression_args.cc index ee55c2f3866..0db9eb266aa 100644 --- a/src/core/lib/compression/compression_args.cc +++ b/src/core/lib/compression/compression_args.cc @@ -51,8 +51,9 @@ grpc_channel_args_get_channel_default_compression_algorithm( return GRPC_COMPRESS_NONE; } -grpc_channel_args* grpc_channel_args_set_channel_default_compression_algorithm( - grpc_channel_args* a, grpc_compression_algorithm algorithm) { +const grpc_channel_args* +grpc_channel_args_set_channel_default_compression_algorithm( + const grpc_channel_args* a, grpc_compression_algorithm algorithm) { GPR_ASSERT(algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT); grpc_arg tmp; tmp.type = GRPC_ARG_INTEGER; @@ -83,10 +84,11 @@ static int find_compression_algorithm_states_bitset(const grpc_channel_args* a, return 0; /* GPR_FALSE */ } -grpc_channel_args* grpc_channel_args_compression_algorithm_set_state( - grpc_channel_args** a, grpc_compression_algorithm algorithm, int state) { +const grpc_channel_args* grpc_channel_args_compression_algorithm_set_state( + const grpc_channel_args** a, grpc_compression_algorithm algorithm, + int state) { int* states_arg = nullptr; - grpc_channel_args* result = *a; + const grpc_channel_args* result = *a; const int states_arg_found = find_compression_algorithm_states_bitset(*a, &states_arg); diff --git a/src/core/lib/compression/compression_args.h b/src/core/lib/compression/compression_args.h index f1abc122cea..bd203384ef6 100644 --- a/src/core/lib/compression/compression_args.h +++ b/src/core/lib/compression/compression_args.h @@ -32,8 +32,9 @@ grpc_channel_args_get_channel_default_compression_algorithm( /** Returns a channel arg instance with compression enabled. If \a a is * non-NULL, its args are copied. N.B. GRPC_COMPRESS_NONE disables compression * for the channel. */ -grpc_channel_args* grpc_channel_args_set_channel_default_compression_algorithm( - grpc_channel_args* a, grpc_compression_algorithm algorithm); +const grpc_channel_args* +grpc_channel_args_set_channel_default_compression_algorithm( + const grpc_channel_args* a, grpc_compression_algorithm algorithm); /** Sets the support for the given compression algorithm. By default, all * compression algorithms are enabled. It's an error to disable an algorithm set @@ -42,8 +43,9 @@ grpc_channel_args* grpc_channel_args_set_channel_default_compression_algorithm( * Returns an instance with the updated algorithm states. The \a a pointer is * modified to point to the returned instance (which may be different from the * input value of \a a). */ -grpc_channel_args* grpc_channel_args_compression_algorithm_set_state( - grpc_channel_args** a, grpc_compression_algorithm algorithm, int state); +const grpc_channel_args* grpc_channel_args_compression_algorithm_set_state( + const grpc_channel_args** a, grpc_compression_algorithm algorithm, + int state); /** Returns the bitset representing the support state (true for enabled, false * for disabled) for compression algorithms. diff --git a/src/core/lib/config/core_configuration.cc b/src/core/lib/config/core_configuration.cc index f37672d0dcc..e8bcc1e7e7a 100644 --- a/src/core/lib/config/core_configuration.cc +++ b/src/core/lib/config/core_configuration.cc @@ -31,7 +31,9 @@ CoreConfiguration* CoreConfiguration::Builder::Build() { } CoreConfiguration::CoreConfiguration(Builder* builder) - : channel_init_(builder->channel_init_.Build()), + : channel_args_preconditioning_( + builder->channel_args_preconditioning_.Build()), + channel_init_(builder->channel_init_.Build()), handshaker_registry_(builder->handshaker_registry_.Build()) {} void CoreConfiguration::RegisterBuilder(std::function builder) { diff --git a/src/core/lib/config/core_configuration.h b/src/core/lib/config/core_configuration.h index 0247d8bc191..b3fed2100b8 100644 --- a/src/core/lib/config/core_configuration.h +++ b/src/core/lib/config/core_configuration.h @@ -19,6 +19,7 @@ #include +#include "src/core/lib/channel/channel_args_preconditioning.h" #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/surface/channel_init.h" @@ -35,6 +36,10 @@ class CoreConfiguration { // their configuration and assemble the published CoreConfiguration. class Builder { public: + ChannelArgsPreconditioning::Builder* channel_args_preconditioning() { + return &channel_args_preconditioning_; + } + ChannelInit::Builder* channel_init() { return &channel_init_; } HandshakerRegistry::Builder* handshaker_registry() { @@ -44,6 +49,7 @@ class CoreConfiguration { private: friend class CoreConfiguration; + ChannelArgsPreconditioning::Builder channel_args_preconditioning_; ChannelInit::Builder channel_init_; HandshakerRegistry::Builder handshaker_registry_; @@ -111,6 +117,10 @@ class CoreConfiguration { // Accessors + const ChannelArgsPreconditioning& channel_args_preconditioning() const { + return channel_args_preconditioning_; + } + const ChannelInit& channel_init() const { return channel_init_; } const HandshakerRegistry& handshaker_registry() const { @@ -135,6 +145,7 @@ class CoreConfiguration { // Extra registered builders static std::atomic builders_; + ChannelArgsPreconditioning channel_args_preconditioning_; ChannelInit channel_init_; HandshakerRegistry handshaker_registry_; }; diff --git a/src/core/lib/http/httpcli.cc b/src/core/lib/http/httpcli.cc index 1f821ce6f23..071f8bfad4a 100644 --- a/src/core/lib/http/httpcli.cc +++ b/src/core/lib/http/httpcli.cc @@ -27,6 +27,7 @@ #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" +#include #include #include #include @@ -204,7 +205,13 @@ class InternalRequest { addr = &addresses_->addrs[next_address_++]; GRPC_CLOSURE_INIT(&connected_, OnConnected, this, grpc_schedule_on_exec_ctx); - grpc_channel_args* args = ChannelArgsWrappingResourceQuota(resource_quota_); + grpc_arg rq_arg = grpc_channel_arg_pointer_create( + const_cast(GRPC_ARG_RESOURCE_QUOTA), resource_quota_->c_ptr(), + grpc_resource_quota_arg_vtable()); + grpc_channel_args channel_args{1, &rq_arg}; + auto* args = CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(&channel_args); grpc_tcp_client_connect(&connected_, &ep_, context_->pollset_set, args, addr, deadline_); grpc_channel_args_destroy(args); diff --git a/src/core/lib/iomgr/endpoint_pair_posix.cc b/src/core/lib/iomgr/endpoint_pair_posix.cc index e45401a2208..1acf241b06a 100644 --- a/src/core/lib/iomgr/endpoint_pair_posix.cc +++ b/src/core/lib/iomgr/endpoint_pair_posix.cc @@ -60,13 +60,15 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name, create_sockets(sv); grpc_core::ExecCtx exec_ctx; std::string final_name = absl::StrCat(name, ":client"); - args = grpc_core::EnsureResourceQuotaInChannelArgs(args); + const grpc_channel_args* new_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args); p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name.c_str(), false), - args, "socketpair-server"); + new_args, "socketpair-server"); final_name = absl::StrCat(name, ":server"); p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name.c_str(), false), - args, "socketpair-client"); - grpc_channel_args_destroy(args); + new_args, "socketpair-client"); + grpc_channel_args_destroy(new_args); return p; } diff --git a/src/core/lib/resource_quota/api.cc b/src/core/lib/resource_quota/api.cc index 364b10c811a..3c2918601c0 100644 --- a/src/core/lib/resource_quota/api.cc +++ b/src/core/lib/resource_quota/api.cc @@ -36,9 +36,8 @@ grpc_arg MakeArg(ResourceQuota* quota) { const_cast(GRPC_ARG_RESOURCE_QUOTA), quota, grpc_resource_quota_arg_vtable()); } -} // namespace -grpc_channel_args* EnsureResourceQuotaInChannelArgs( +const grpc_channel_args* EnsureResourceQuotaInChannelArgs( const grpc_channel_args* args) { const grpc_arg* existing = grpc_channel_args_find(args, GRPC_ARG_RESOURCE_QUOTA); @@ -54,11 +53,11 @@ grpc_channel_args* EnsureResourceQuotaInChannelArgs( return grpc_channel_args_copy_and_add_and_remove(args, remove, 1, &new_arg, 1); } +} // namespace -grpc_channel_args* ChannelArgsWrappingResourceQuota( - ResourceQuotaRefPtr resource_quota) { - auto new_arg = MakeArg(resource_quota.get()); - return grpc_channel_args_copy_and_add(nullptr, &new_arg, 1); +void RegisterResourceQuota(CoreConfiguration::Builder* builder) { + builder->channel_args_preconditioning()->RegisterStage( + EnsureResourceQuotaInChannelArgs); } } // namespace grpc_core diff --git a/src/core/lib/resource_quota/api.h b/src/core/lib/resource_quota/api.h index fd6c58cd5c7..c531813038f 100644 --- a/src/core/lib/resource_quota/api.h +++ b/src/core/lib/resource_quota/api.h @@ -18,6 +18,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/resource_quota/resource_quota.h" typedef struct grpc_resource_quota grpc_resource_quota; @@ -33,19 +34,7 @@ constexpr size_t kResourceQuotaChannelSize = 50 * 1024; // UB if not set. ResourceQuotaRefPtr ResourceQuotaFromChannelArgs(const grpc_channel_args* args); -// Take some channel args: -// If there is a resource quota set, copy args and return that. -// If there is no resource quota set, set a default, and return new -// channel args. Call grpc_channel_args_destroy on the input args. -grpc_channel_args* EnsureResourceQuotaInChannelArgs( - const grpc_channel_args* args); - -// Create channel args with just the passed in resource quota -grpc_channel_args* ChannelArgsWrappingResourceQuota(ResourceQuotaRefPtr); - -inline ResourceQuota* ResourceQuotaFromC(grpc_resource_quota* quota) { - return reinterpret_cast(quota); -} +void RegisterResourceQuota(CoreConfiguration::Builder* builder); } // namespace grpc_core diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index aca456975db..a9a564a1282 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -187,7 +187,9 @@ grpc_channel* grpc_lame_client_channel_create(const char* target, grpc_arg error_arg = grpc_core::MakeLameClientErrorArg(&error); grpc_channel_args* args0 = grpc_channel_args_copy_and_add(nullptr, &error_arg, 1); - grpc_channel_args* args = grpc_core::EnsureResourceQuotaInChannelArgs(args0); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args0); grpc_channel_args_destroy(args0); grpc_channel* channel = grpc_channel_create( target, args, GRPC_CLIENT_LAME_CHANNEL, nullptr, nullptr); diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 9248dea31f8..2596f137f6c 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1474,13 +1474,12 @@ void Server::CallData::StartTransportStreamOpBatch( grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) { grpc_core::ExecCtx exec_ctx; - args = grpc_channel_args_remove_grpc_internal(args); GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved)); - grpc_channel_args* new_args = - grpc_core::EnsureResourceQuotaInChannelArgs(args); + const grpc_channel_args* new_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args); grpc_core::Server* server = new grpc_core::Server(new_args); grpc_channel_args_destroy(new_args); - grpc_channel_args_destroy(args); return server->c_ptr(); } diff --git a/src/core/plugin_registry/grpc_plugin_registry.cc b/src/core/plugin_registry/grpc_plugin_registry.cc index 8fb0d54ff7c..8a31816e40c 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_plugin_registry.cc @@ -169,6 +169,7 @@ extern void RegisterMessageSizeFilter(CoreConfiguration::Builder* builder); extern void RegisterSecurityFilters(CoreConfiguration::Builder* builder); extern void RegisterServiceConfigChannelArgFilter( CoreConfiguration::Builder* builder); +extern void RegisterResourceQuota(CoreConfiguration::Builder* builder); #ifndef GRPC_NO_XDS extern void RegisterXdsChannelStackModifier( CoreConfiguration::Builder* builder); @@ -185,9 +186,10 @@ void BuildCoreConfiguration(CoreConfiguration::Builder* builder) { RegisterDeadlineFilter(builder); RegisterMessageSizeFilter(builder); RegisterServiceConfigChannelArgFilter(builder); - #ifndef GRPC_NO_XDS + RegisterResourceQuota(builder); +#ifndef GRPC_NO_XDS RegisterXdsChannelStackModifier(builder); - #endif +#endif // Run last so it gets a consistent location. // TODO(ctiller): Is this actually necessary? RegisterSecurityFilters(builder); diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc index e8a75567be6..fe653356a39 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.cc @@ -104,6 +104,7 @@ extern void RegisterMessageSizeFilter(CoreConfiguration::Builder* builder); extern void RegisterSecurityFilters(CoreConfiguration::Builder* builder); extern void RegisterServiceConfigChannelArgFilter( CoreConfiguration::Builder* builder); +extern void RegisterResourceQuota(CoreConfiguration::Builder* builder); void BuildCoreConfiguration(CoreConfiguration::Builder* builder) { BuildClientChannelConfiguration(builder); @@ -115,6 +116,7 @@ void BuildCoreConfiguration(CoreConfiguration::Builder* builder) { RegisterDeadlineFilter(builder); RegisterMessageSizeFilter(builder); RegisterServiceConfigChannelArgFilter(builder); + RegisterResourceQuota(builder); // Run last so it gets a consistent location. // TODO(ctiller): Is this actually necessary? RegisterBuiltins(builder); diff --git a/src/cpp/thread_manager/thread_manager.cc b/src/cpp/thread_manager/thread_manager.cc index ee7eed1d632..25c065588ee 100644 --- a/src/cpp/thread_manager/thread_manager.cc +++ b/src/cpp/thread_manager/thread_manager.cc @@ -54,7 +54,7 @@ ThreadManager::ThreadManager(const char*, grpc_resource_quota* resource_quota, int min_pollers, int max_pollers) : shutdown_(false), thread_quota_( - grpc_core::ResourceQuotaFromC(resource_quota)->thread_quota()), + grpc_core::ResourceQuota::FromC(resource_quota)->thread_quota()), num_pollers_(0), min_pollers_(min_pollers), max_pollers_(max_pollers == -1 ? INT_MAX : max_pollers), diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index f36e3bb5b59..aebe92fb239 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -345,6 +345,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/address_utils/sockaddr_utils.cc', 'src/core/lib/backoff/backoff.cc', 'src/core/lib/channel/channel_args.cc', + 'src/core/lib/channel/channel_args_preconditioning.cc', 'src/core/lib/channel/channel_stack.cc', 'src/core/lib/channel/channel_stack_builder.cc', 'src/core/lib/channel/channel_trace.cc', diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc index 129446d838a..09a91d19cbe 100644 --- a/test/core/bad_client/bad_client.cc +++ b/test/core/bad_client/bad_client.cc @@ -212,8 +212,9 @@ void grpc_run_bad_client_test( GRPC_BAD_CLIENT_REGISTERED_HOST, GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0); grpc_server_start(a.server); - grpc_channel_args* channel_args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* channel_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); transport = grpc_create_chttp2_transport(channel_args, sfd.server, false); grpc_channel_args_destroy(channel_args); server_setup_transport(&a, transport); diff --git a/test/core/client_channel/resolvers/binder_resolver_test.cc b/test/core/client_channel/resolvers/binder_resolver_test.cc index 4065a393891..10431378625 100644 --- a/test/core/client_channel/resolvers/binder_resolver_test.cc +++ b/test/core/client_channel/resolvers/binder_resolver_test.cc @@ -23,6 +23,7 @@ #include +#include #include #include #include diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index 7bc867eb541..1e176c493db 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -18,6 +18,7 @@ #include +#include #include #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc index 5c77d311226..bdb2830b246 100644 --- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc +++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc @@ -18,6 +18,7 @@ #include +#include #include #include #include diff --git a/test/core/compression/compression_test.cc b/test/core/compression/compression_test.cc index 2bc5ad206dd..87316f08c33 100644 --- a/test/core/compression/compression_test.cc +++ b/test/core/compression/compression_test.cc @@ -263,7 +263,7 @@ static void test_compression_enable_disable_algorithm(void) { static void test_channel_args_set_compression_algorithm(void) { grpc_core::ExecCtx exec_ctx; - grpc_channel_args* ch_args; + const grpc_channel_args* ch_args; ch_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, GRPC_COMPRESS_GZIP); @@ -277,8 +277,10 @@ static void test_channel_args_set_compression_algorithm(void) { static void test_channel_args_compression_algorithm_states(void) { grpc_core::ExecCtx exec_ctx; - grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate, - *ch_args_wo_gzip_deflate_gzip; + const grpc_channel_args* ch_args; + const grpc_channel_args* ch_args_wo_gzip; + const grpc_channel_args* ch_args_wo_gzip_deflate; + const grpc_channel_args* ch_args_wo_gzip_deflate_gzip; unsigned states_bitset; size_t i; diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index ea85fe37f91..1a0e4bac5b0 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -63,12 +63,13 @@ struct grpc_end2end_test_config { * expect to find in call_details.host */ const char* overridden_call_host; - grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args* client_args, - grpc_channel_args* server_args); + grpc_end2end_test_fixture (*create_fixture)( + const grpc_channel_args* client_args, + const grpc_channel_args* server_args); void (*init_client)(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args); + const grpc_channel_args* client_args); void (*init_server)(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args); + const grpc_channel_args* server_args); void (*tear_down_data)(grpc_end2end_test_fixture* f); }; diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index 6ab374e7db4..47a88506ae3 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -39,7 +39,8 @@ struct fullstack_fixture_data { }; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_fixture_data* ffd = new fullstack_fixture_data(); @@ -62,7 +63,7 @@ static grpc_arg make_census_enable_arg(void) { } void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); grpc_arg arg = make_census_enable_arg(); @@ -77,7 +78,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); grpc_arg arg = make_census_enable_arg(); diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index f0de5c6b41e..d0b68d39c09 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -41,12 +41,13 @@ struct fullstack_compression_fixture_data { grpc_channel_args_destroy(server_args_compression); } std::string localaddr; - grpc_channel_args* client_args_compression = nullptr; - grpc_channel_args* server_args_compression = nullptr; + const grpc_channel_args* client_args_compression = nullptr; + const grpc_channel_args* server_args_compression = nullptr; }; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_compression_fixture_data* ffd = @@ -61,8 +62,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( return f; } -void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +void chttp2_init_client_fullstack_compression( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { fullstack_compression_fixture_data* ffd = static_cast(f->fixture_data); if (ffd->client_args_compression != nullptr) { @@ -76,8 +77,8 @@ void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture* f, ffd->localaddr.c_str(), ffd->client_args_compression, nullptr); } -void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { +void chttp2_init_server_fullstack_compression( + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { fullstack_compression_fixture_data* ffd = static_cast(f->fixture_data); if (ffd->server_args_compression != nullptr) { diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index 156185aa3b1..14156190832 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -34,7 +34,8 @@ struct fullstack_secure_fixture_data { }; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); @@ -58,7 +59,7 @@ static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args, grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -69,7 +70,7 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args, grpc_server_credentials* server_creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -91,13 +92,13 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { } static void chttp2_init_client_fake_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_channel_credentials* fake_ts_creds = grpc_fake_transport_security_credentials_create(); chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds); } -static int fail_server_auth_check(grpc_channel_args* server_args) { +static int fail_server_auth_check(const grpc_channel_args* server_args) { size_t i; if (server_args == nullptr) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -110,7 +111,7 @@ static int fail_server_auth_check(grpc_channel_args* server_args) { } static void chttp2_init_server_fake_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_server_credentials* fake_ts_creds = grpc_fake_transport_security_server_credentials_create(); if (fail_server_auth_check(server_args)) { diff --git a/test/core/end2end/fixtures/h2_fd.cc b/test/core/end2end/fixtures/h2_fd.cc index bd977c9f8c5..8a460d5e62b 100644 --- a/test/core/end2end/fixtures/h2_fd.cc +++ b/test/core/end2end/fixtures/h2_fd.cc @@ -51,7 +51,8 @@ static void create_sockets(int sv[2]) { } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { sp_fixture_data* fixture_data = static_cast(gpr_malloc(sizeof(*fixture_data))); @@ -66,8 +67,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( return f; } -static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_socketpair( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_core::ExecCtx exec_ctx; sp_fixture_data* sfd = static_cast(f->fixture_data); @@ -77,8 +78,8 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, GPR_ASSERT(f->client); } -static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { +static void chttp2_init_server_socketpair( + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_core::ExecCtx exec_ctx; sp_fixture_data* sfd = static_cast(f->fixture_data); GPR_ASSERT(!f->server); diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index f26c390d2f0..a07c8f54c28 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -44,7 +44,8 @@ struct fullstack_fixture_data { }; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_fixture_data* ffd = new fullstack_fixture_data(); @@ -60,7 +61,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( } void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr.c_str(), client_args, @@ -69,7 +70,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); if (f->server) { diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index 48085e9315c..7dfd84db83f 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -43,7 +43,8 @@ struct fullstack_fixture_data { }; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_fixture_data* ffd = new fullstack_fixture_data(); @@ -59,7 +60,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( } void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr.c_str(), client_args, @@ -68,7 +69,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); if (f->server) { diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index 074ec7f8643..a141908b648 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -38,7 +38,8 @@ struct fullstack_fixture_data { }; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_fixture_data* ffd = new fullstack_fixture_data(); @@ -54,7 +55,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( } void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr.c_str(), client_args, @@ -63,7 +64,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); if (f->server) { diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index a4b389c86fe..681a67fd797 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -47,7 +47,8 @@ struct fullstack_fixture_data { }; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args* client_args, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* client_args, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); fullstack_fixture_data* ffd = new fullstack_fixture_data(); @@ -66,7 +67,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( } void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); /* If testing for proxy auth, add credentials to proxy uri */ @@ -90,7 +91,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); if (f->server) { diff --git a/test/core/end2end/fixtures/h2_insecure.cc b/test/core/end2end/fixtures/h2_insecure.cc index 13ac3e8fe79..3e9c4f8958f 100644 --- a/test/core/end2end/fixtures/h2_insecure.cc +++ b/test/core/end2end/fixtures/h2_insecure.cc @@ -35,7 +35,8 @@ struct Chttp2InsecureFullstackFixtureData { }; grpc_end2end_test_fixture Chttp2CreateFixtureInsecureFullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); Chttp2InsecureFullstackFixtureData* ffd = @@ -50,7 +51,7 @@ grpc_end2end_test_fixture Chttp2CreateFixtureInsecureFullstack( } void Chttp2InitClientInsecureFullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { Chttp2InsecureFullstackFixtureData* ffd = static_cast(f->fixture_data); grpc_channel_credentials* creds = grpc_insecure_credentials_create(); @@ -69,7 +70,7 @@ void ProcessAuthFailure(void* state, grpc_auth_context* /*ctx*/, } void Chttp2InitServerInsecureFullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { Chttp2InsecureFullstackFixtureData* ffd = static_cast(f->fixture_data); if (f->server) { diff --git a/test/core/end2end/fixtures/h2_local_abstract_uds_percent_encoded.cc b/test/core/end2end/fixtures/h2_local_abstract_uds_percent_encoded.cc index 1245b9ff1c2..d3c17d2ce8d 100644 --- a/test/core/end2end/fixtures/h2_local_abstract_uds_percent_encoded.cc +++ b/test/core/end2end/fixtures/h2_local_abstract_uds_percent_encoded.cc @@ -25,7 +25,8 @@ static int unique{0}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); @@ -36,13 +37,13 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( return f; } -static void chttp2_init_client_fullstack_uds(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_fullstack_uds( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_client_fullstack(f, client_args, UDS); } -static void chttp2_init_server_fullstack_uds(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_server_fullstack_uds( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_server_fullstack(f, client_args, UDS); } diff --git a/test/core/end2end/fixtures/h2_local_ipv4.cc b/test/core/end2end/fixtures/h2_local_ipv4.cc index f1748078e03..d4cd24898d3 100644 --- a/test/core/end2end/fixtures/h2_local_ipv4.cc +++ b/test/core/end2end/fixtures/h2_local_ipv4.cc @@ -27,7 +27,8 @@ #include "test/core/util/test_config.h" static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv4( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); int port = grpc_pick_unused_port_or_die(); @@ -36,13 +37,13 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv4( return f; } -static void chttp2_init_client_fullstack_ipv4(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_fullstack_ipv4( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_client_fullstack(f, client_args, LOCAL_TCP); } -static void chttp2_init_server_fullstack_ipv4(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_server_fullstack_ipv4( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_server_fullstack(f, client_args, LOCAL_TCP); } diff --git a/test/core/end2end/fixtures/h2_local_ipv6.cc b/test/core/end2end/fixtures/h2_local_ipv6.cc index b074659de6c..dafd5981732 100644 --- a/test/core/end2end/fixtures/h2_local_ipv6.cc +++ b/test/core/end2end/fixtures/h2_local_ipv6.cc @@ -27,7 +27,8 @@ #include "test/core/util/test_config.h" static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv6( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); int port = grpc_pick_unused_port_or_die(); @@ -36,13 +37,13 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_ipv6( return f; } -static void chttp2_init_client_fullstack_ipv6(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_fullstack_ipv6( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_client_fullstack(f, client_args, LOCAL_TCP); } -static void chttp2_init_server_fullstack_ipv6(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_server_fullstack_ipv6( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_server_fullstack(f, client_args, LOCAL_TCP); } diff --git a/test/core/end2end/fixtures/h2_local_uds.cc b/test/core/end2end/fixtures/h2_local_uds.cc index f612cc244b3..cc1ae0d7bfa 100644 --- a/test/core/end2end/fixtures/h2_local_uds.cc +++ b/test/core/end2end/fixtures/h2_local_uds.cc @@ -30,7 +30,8 @@ static int unique = 1; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); @@ -41,13 +42,13 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( return f; } -static void chttp2_init_client_fullstack_uds(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_fullstack_uds( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_client_fullstack(f, client_args, UDS); } -static void chttp2_init_server_fullstack_uds(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_server_fullstack_uds( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_server_fullstack(f, client_args, UDS); } diff --git a/test/core/end2end/fixtures/h2_local_uds_percent_encoded.cc b/test/core/end2end/fixtures/h2_local_uds_percent_encoded.cc index da93a7efb30..8309a0a571c 100644 --- a/test/core/end2end/fixtures/h2_local_uds_percent_encoded.cc +++ b/test/core/end2end/fixtures/h2_local_uds_percent_encoded.cc @@ -30,7 +30,8 @@ static int unique = 1; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f = grpc_end2end_local_chttp2_create_fixture_fullstack(); gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); @@ -41,13 +42,13 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_uds( return f; } -static void chttp2_init_client_fullstack_uds(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_fullstack_uds( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_client_fullstack(f, client_args, UDS); } -static void chttp2_init_server_fullstack_uds(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_server_fullstack_uds( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_end2end_local_chttp2_init_server_fullstack(f, client_args, UDS); } diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc index 1f71fda3018..68cee3baec6 100644 --- a/test/core/end2end/fixtures/h2_oauth2.cc +++ b/test/core/end2end/fixtures/h2_oauth2.cc @@ -96,8 +96,8 @@ static void process_oauth2_failure(void* state, grpc_auth_context* /*ctx*/, } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/, - grpc_tls_version tls_version) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/, grpc_tls_version tls_version) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); @@ -111,19 +111,21 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack_tls1_2( - grpc_channel_args* client_args, grpc_channel_args* server_args) { + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { return chttp2_create_fixture_secure_fullstack(client_args, server_args, grpc_tls_version::TLS1_2); } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack_tls1_3( - grpc_channel_args* client_args, grpc_channel_args* server_args) { + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { return chttp2_create_fixture_secure_fullstack(client_args, server_args, grpc_tls_version::TLS1_3); } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args, grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -134,7 +136,7 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args, grpc_server_credentials* server_creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -156,7 +158,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { } static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_core::ExecCtx exec_ctx; grpc_slice ca_slice; GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", @@ -183,7 +185,7 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( GRPC_ARG_STRING, const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), {const_cast("foo.test.google.fr")}}; - grpc_channel_args* new_client_args = + const grpc_channel_args* new_client_args = grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds); grpc_channel_args_destroy(new_client_args); @@ -192,7 +194,7 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( grpc_slice_unref(ca_slice); } -static int fail_server_auth_check(grpc_channel_args* server_args) { +static int fail_server_auth_check(const grpc_channel_args* server_args) { size_t i; if (server_args == nullptr) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -226,7 +228,7 @@ static grpc_auth_metadata_processor test_processor_create(int failing) { } static void chttp2_init_server_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_slice cert_slice, key_slice; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(SERVER_CERT_PATH, 1, &cert_slice))); diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc index 134a65cd3fe..8b3f96a07f5 100644 --- a/test/core/end2end/fixtures/h2_proxy.cc +++ b/test/core/end2end/fixtures/h2_proxy.cc @@ -38,14 +38,14 @@ typedef struct fullstack_fixture_data { } fullstack_fixture_data; static grpc_server* create_proxy_server(const char* port, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { grpc_server* s = grpc_server_create(server_args, nullptr); GPR_ASSERT(grpc_server_add_insecure_http2_port(s, port)); return s; } static grpc_channel* create_proxy_client(const char* target, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { return grpc_insecure_channel_create(target, client_args, nullptr); } @@ -53,7 +53,8 @@ static const grpc_end2end_proxy_def proxy_def = {create_proxy_server, create_proxy_client}; static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args* client_args, grpc_channel_args* server_args) { + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { grpc_end2end_test_fixture f; fullstack_fixture_data* ffd = static_cast( gpr_malloc(sizeof(fullstack_fixture_data))); @@ -69,7 +70,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( } void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = grpc_insecure_channel_create( @@ -78,7 +79,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); if (f->server) { diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index aca42dda76b..07b8ec46622 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -69,7 +69,7 @@ static void server_setup_transport(void* ts, grpc_transport* transport) { typedef struct { grpc_end2end_test_fixture* f; - grpc_channel_args* client_args; + const grpc_channel_args* client_args; } sp_client_setup; static void client_setup_transport(void* ts, grpc_transport* transport) { @@ -77,7 +77,7 @@ static void client_setup_transport(void* ts, grpc_transport* transport) { grpc_arg authority_arg = grpc_channel_arg_string_create( const_cast(GRPC_ARG_DEFAULT_AUTHORITY), const_cast("test-authority")); - grpc_channel_args* args = + const grpc_channel_args* args = grpc_channel_args_copy_and_add(cs->client_args, &authority_arg, 1); grpc_error_handle error = GRPC_ERROR_NONE; cs->f->client = grpc_channel_create( @@ -99,7 +99,8 @@ static void client_setup_transport(void* ts, grpc_transport* transport) { } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { custom_fixture_data* fixture_data = static_cast( gpr_malloc(sizeof(custom_fixture_data))); grpc_end2end_test_fixture f; @@ -111,15 +112,17 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( return f; } -static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_socketpair( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_core::ExecCtx exec_ctx; auto* fixture_data = static_cast(f->fixture_data); grpc_transport* transport; sp_client_setup cs; cs.client_args = client_args; cs.f = f; - client_args = grpc_core::EnsureResourceQuotaInChannelArgs(client_args); + client_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(client_args); transport = grpc_create_chttp2_transport(client_args, fixture_data->ep.client, true); grpc_channel_args_destroy(client_args); @@ -127,8 +130,8 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, GPR_ASSERT(f->client); } -static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { +static void chttp2_init_server_socketpair( + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_core::ExecCtx exec_ctx; auto* fixture_data = static_cast(f->fixture_data); grpc_transport* transport; @@ -136,7 +139,9 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); grpc_server_start(f->server); - server_args = grpc_core::EnsureResourceQuotaInChannelArgs(server_args); + server_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(server_args); transport = grpc_create_chttp2_transport(server_args, fixture_data->ep.server, false); grpc_channel_args_destroy(server_args); diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc index 53cc7252945..794becf5760 100644 --- a/test/core/end2end/fixtures/h2_sockpair.cc +++ b/test/core/end2end/fixtures/h2_sockpair.cc @@ -64,7 +64,7 @@ static void server_setup_transport(void* ts, grpc_transport* transport) { typedef struct { grpc_end2end_test_fixture* f; - grpc_channel_args* client_args; + const grpc_channel_args* client_args; } sp_client_setup; static void client_setup_transport(void* ts, grpc_transport* transport) { @@ -73,7 +73,7 @@ static void client_setup_transport(void* ts, grpc_transport* transport) { grpc_arg authority_arg = grpc_channel_arg_string_create( const_cast(GRPC_ARG_DEFAULT_AUTHORITY), const_cast("test-authority")); - grpc_channel_args* args = + const grpc_channel_args* args = grpc_channel_args_copy_and_add(cs->client_args, &authority_arg, 1); grpc_error_handle error = GRPC_ERROR_NONE; cs->f->client = grpc_channel_create( @@ -95,7 +95,8 @@ static void client_setup_transport(void* ts, grpc_transport* transport) { } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { custom_fixture_data* fixture_data = static_cast( gpr_malloc(sizeof(custom_fixture_data))); grpc_end2end_test_fixture f; @@ -107,15 +108,17 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( return f; } -static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_socketpair( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_core::ExecCtx exec_ctx; auto* fixture_data = static_cast(f->fixture_data); grpc_transport* transport; sp_client_setup cs; cs.client_args = client_args; cs.f = f; - client_args = grpc_core::EnsureResourceQuotaInChannelArgs(client_args); + client_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(client_args); transport = grpc_create_chttp2_transport(client_args, fixture_data->ep.client, true); grpc_channel_args_destroy(client_args); @@ -123,8 +126,8 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, GPR_ASSERT(f->client); } -static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { +static void chttp2_init_server_socketpair( + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_core::ExecCtx exec_ctx; auto* fixture_data = static_cast(f->fixture_data); grpc_transport* transport; @@ -132,7 +135,9 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); grpc_server_start(f->server); - server_args = grpc_core::EnsureResourceQuotaInChannelArgs(server_args); + server_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(server_args); transport = grpc_create_chttp2_transport(server_args, fixture_data->ep.server, false); grpc_channel_args_destroy(server_args); diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc index 35963907ceb..b9616d0199a 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc @@ -64,7 +64,7 @@ static void server_setup_transport(void* ts, grpc_transport* transport) { typedef struct { grpc_end2end_test_fixture* f; - grpc_channel_args* client_args; + const grpc_channel_args* client_args; } sp_client_setup; static void client_setup_transport(void* ts, grpc_transport* transport) { @@ -73,7 +73,7 @@ static void client_setup_transport(void* ts, grpc_transport* transport) { grpc_arg authority_arg = grpc_channel_arg_string_create( const_cast(GRPC_ARG_DEFAULT_AUTHORITY), const_cast("test-authority")); - grpc_channel_args* args = + const grpc_channel_args* args = grpc_channel_args_copy_and_add(cs->client_args, &authority_arg, 1); grpc_error_handle error = GRPC_ERROR_NONE; cs->f->client = grpc_channel_create( @@ -95,7 +95,8 @@ static void client_setup_transport(void* ts, grpc_transport* transport) { } static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { custom_fixture_data* fixture_data = static_cast( gpr_malloc(sizeof(custom_fixture_data))); grpc_end2end_test_fixture f; @@ -118,15 +119,17 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( return f; } -static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { +static void chttp2_init_client_socketpair( + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_core::ExecCtx exec_ctx; auto* fixture_data = static_cast(f->fixture_data); grpc_transport* transport; sp_client_setup cs; cs.client_args = client_args; cs.f = f; - client_args = grpc_core::EnsureResourceQuotaInChannelArgs(client_args); + client_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(client_args); transport = grpc_create_chttp2_transport(client_args, fixture_data->ep.client, true); grpc_channel_args_destroy(client_args); @@ -134,8 +137,8 @@ static void chttp2_init_client_socketpair(grpc_end2end_test_fixture* f, GPR_ASSERT(f->client); } -static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { +static void chttp2_init_server_socketpair( + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_core::ExecCtx exec_ctx; auto* fixture_data = static_cast(f->fixture_data); grpc_transport* transport; @@ -143,7 +146,9 @@ static void chttp2_init_server_socketpair(grpc_end2end_test_fixture* f, f->server = grpc_server_create(server_args, nullptr); grpc_server_register_completion_queue(f->server, f->cq, nullptr); grpc_server_start(f->server); - server_args = grpc_core::EnsureResourceQuotaInChannelArgs(server_args); + server_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(server_args); transport = grpc_create_chttp2_transport(server_args, fixture_data->ep.server, false); grpc_channel_args_destroy(server_args); diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index e66565f1e49..83a7132fd3a 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -44,8 +44,8 @@ struct fullstack_secure_fixture_data { }; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/, - grpc_tls_version tls_version) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/, grpc_tls_version tls_version) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); @@ -62,13 +62,15 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack_tls1_2( - grpc_channel_args* client_args, grpc_channel_args* server_args) { + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { return chttp2_create_fixture_secure_fullstack(client_args, server_args, grpc_tls_version::TLS1_2); } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack_tls1_3( - grpc_channel_args* client_args, grpc_channel_args* server_args) { + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { return chttp2_create_fixture_secure_fullstack(client_args, server_args, grpc_tls_version::TLS1_3); } @@ -83,7 +85,7 @@ static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args, grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -94,7 +96,7 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args, grpc_server_credentials* server_creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -116,7 +118,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { } static void chttp2_init_client_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr); if (f != nullptr && ssl_creds != nullptr) { @@ -132,13 +134,13 @@ static void chttp2_init_client_simple_ssl_secure_fullstack( GRPC_ARG_STRING, const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), {const_cast("foo.test.google.fr")}}; - grpc_channel_args* new_client_args = + const grpc_channel_args* new_client_args = grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); grpc_channel_args_destroy(new_client_args); } -static int fail_server_auth_check(grpc_channel_args* server_args) { +static int fail_server_auth_check(const grpc_channel_args* server_args) { size_t i; if (server_args == nullptr) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -151,7 +153,7 @@ static int fail_server_auth_check(grpc_channel_args* server_args) { } static void chttp2_init_server_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_slice cert_slice, key_slice; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(SERVER_CERT_PATH, 1, &cert_slice))); diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index 433e44337bb..8580e87f0cd 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -80,8 +80,8 @@ ssl_server_certificate_config_callback( } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/, - grpc_tls_version tls_version) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/, grpc_tls_version tls_version) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); @@ -97,13 +97,15 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack_tls1_2( - grpc_channel_args* client_args, grpc_channel_args* server_args) { + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { return chttp2_create_fixture_secure_fullstack(client_args, server_args, grpc_tls_version::TLS1_2); } static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack_tls1_3( - grpc_channel_args* client_args, grpc_channel_args* server_args) { + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { return chttp2_create_fixture_secure_fullstack(client_args, server_args, grpc_tls_version::TLS1_3); } @@ -118,7 +120,7 @@ static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args, grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -129,7 +131,7 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args, grpc_server_credentials* server_creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -152,7 +154,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { } static void chttp2_init_client_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr); if (f != nullptr && ssl_creds != nullptr) { @@ -168,13 +170,13 @@ static void chttp2_init_client_simple_ssl_secure_fullstack( GRPC_ARG_STRING, const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), {const_cast("foo.test.google.fr")}}; - grpc_channel_args* new_client_args = + const grpc_channel_args* new_client_args = grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); grpc_channel_args_destroy(new_client_args); } -static int fail_server_auth_check(grpc_channel_args* server_args) { +static int fail_server_auth_check(const grpc_channel_args* server_args) { size_t i; if (server_args == nullptr) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -187,7 +189,7 @@ static int fail_server_auth_check(grpc_channel_args* server_args) { } static void chttp2_init_server_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_ssl_server_credentials_options* options = grpc_ssl_server_credentials_create_options_using_config_fetcher( GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index 9980c0957ee..45516aec04c 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -42,7 +42,7 @@ typedef struct fullstack_secure_fixture_data { } fullstack_secure_fixture_data; static grpc_server* create_proxy_server(const char* port, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { grpc_server* s = grpc_server_create(server_args, nullptr); grpc_slice cert_slice, key_slice; GPR_ASSERT(GRPC_LOG_IF_ERROR( @@ -64,7 +64,7 @@ static grpc_server* create_proxy_server(const char* port, } static grpc_channel* create_proxy_client(const char* target, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { grpc_channel* channel; grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr); @@ -72,7 +72,7 @@ static grpc_channel* create_proxy_client(const char* target, GRPC_ARG_STRING, const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), {const_cast("foo.test.google.fr")}}; - grpc_channel_args* new_client_args = + const grpc_channel_args* new_client_args = grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); channel = grpc_secure_channel_create(ssl_creds, target, new_client_args, nullptr); @@ -88,7 +88,8 @@ static const grpc_end2end_proxy_def proxy_def = {create_proxy_server, create_proxy_client}; static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( - grpc_channel_args* client_args, grpc_channel_args* server_args) { + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { grpc_end2end_test_fixture f; fullstack_secure_fixture_data* ffd = static_cast( @@ -114,7 +115,7 @@ static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args, grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -126,7 +127,7 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args, grpc_server_credentials* server_creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -149,14 +150,14 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { } static void chttp2_init_client_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args) { grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr); grpc_arg ssl_name_override = { GRPC_ARG_STRING, const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), {const_cast("foo.test.google.fr")}}; - grpc_channel_args* new_client_args = + const grpc_channel_args* new_client_args = grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); { @@ -165,7 +166,7 @@ static void chttp2_init_client_simple_ssl_secure_fullstack( } } -static int fail_server_auth_check(grpc_channel_args* server_args) { +static int fail_server_auth_check(const grpc_channel_args* server_args) { size_t i; if (server_args == nullptr) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -178,7 +179,7 @@ static int fail_server_auth_check(grpc_channel_args* server_args) { } static void chttp2_init_server_simple_ssl_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args) { + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args) { grpc_slice cert_slice, key_slice; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(SERVER_CERT_PATH, 1, &cert_slice))); diff --git a/test/core/end2end/fixtures/h2_tls.cc b/test/core/end2end/fixtures/h2_tls.cc index 11f1a3b0aa3..3c1af73e909 100644 --- a/test/core/end2end/fixtures/h2_tls.cc +++ b/test/core/end2end/fixtures/h2_tls.cc @@ -173,7 +173,7 @@ static void SetCertificateVerifier( } static grpc_end2end_test_fixture chttp2_create_fixture_simple_fullstack( - grpc_channel_args*, grpc_channel_args*) { + const grpc_channel_args*, const grpc_channel_args*) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); @@ -191,7 +191,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_simple_fullstack( } static grpc_end2end_test_fixture chttp2_create_fixture_async_verifier( - grpc_channel_args*, grpc_channel_args*) { + const grpc_channel_args*, const grpc_channel_args*) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); @@ -209,8 +209,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_async_verifier( } static grpc_end2end_test_fixture -chttp2_create_fixture_hostname_verifier_cert_watcher(grpc_channel_args*, - grpc_channel_args*) { +chttp2_create_fixture_hostname_verifier_cert_watcher(const grpc_channel_args*, + const grpc_channel_args*) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); @@ -227,8 +227,8 @@ chttp2_create_fixture_hostname_verifier_cert_watcher(grpc_channel_args*, } static grpc_end2end_test_fixture -chttp2_create_fixture_async_verifier_cert_watcher(grpc_channel_args*, - grpc_channel_args*) { +chttp2_create_fixture_async_verifier_cert_watcher(const grpc_channel_args*, + const grpc_channel_args*) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); @@ -254,7 +254,7 @@ static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, } static void chttp2_init_client_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args, grpc_channel_credentials* creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -265,7 +265,7 @@ static void chttp2_init_client_secure_fullstack( } static void chttp2_init_server_secure_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args, grpc_server_credentials* server_creds) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); @@ -331,20 +331,20 @@ static grpc_server_credentials* create_tls_server_credentials( } static void chttp2_init_client(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { grpc_channel_credentials* ssl_creds = create_tls_channel_credentials( static_cast(f->fixture_data)); grpc_arg ssl_name_override = { GRPC_ARG_STRING, const_cast(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), {const_cast("foo.test.google.fr")}}; - grpc_channel_args* new_client_args = + const grpc_channel_args* new_client_args = grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); grpc_channel_args_destroy(new_client_args); } -static int fail_server_auth_check(grpc_channel_args* server_args) { +static int fail_server_auth_check(const grpc_channel_args* server_args) { size_t i; if (server_args == nullptr) return 0; for (i = 0; i < server_args->num_args; i++) { @@ -357,7 +357,7 @@ static int fail_server_auth_check(grpc_channel_args* server_args) { } static void chttp2_init_server(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { grpc_server_credentials* ssl_creds = create_tls_server_credentials( static_cast(f->fixture_data)); if (fail_server_auth_check(server_args)) { diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc index f42667e849b..a2231a6bdaf 100644 --- a/test/core/end2end/fixtures/h2_uds.cc +++ b/test/core/end2end/fixtures/h2_uds.cc @@ -61,7 +61,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_base( } static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); const std::string localaddr = absl::StrFormat( "unix:/tmp/grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 ".%d", getpid(), @@ -71,7 +72,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_abstract_namespace( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); const std::string localaddr = absl::StrFormat( "unix-abstract:grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 ".%d", @@ -80,7 +82,7 @@ chttp2_create_fixture_fullstack_abstract_namespace( } void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); f->client = grpc_insecure_channel_create(ffd->localaddr.c_str(), client_args, @@ -88,7 +90,7 @@ void chttp2_init_client_fullstack(grpc_end2end_test_fixture* f, } void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); if (f->server) { diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index 4d3a9d7b4e9..1c46122e7d1 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -62,7 +62,7 @@ struct grpc_end2end_http_proxy { std::string proxy_name; grpc_core::Thread thd; grpc_tcp_server* server; - grpc_channel_args* channel_args; + const grpc_channel_args* channel_args; gpr_mu* mu; std::vector pollset; gpr_refcount users; @@ -536,8 +536,9 @@ static void on_read_request_done_locked(void* arg, grpc_error_handle error) { grpc_core::ExecCtx::Get()->Now() + 10 * GPR_MS_PER_SEC; GRPC_CLOSURE_INIT(&conn->on_server_connect_done, on_server_connect_done, conn, grpc_schedule_on_exec_ctx); - grpc_channel_args* args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_tcp_client_connect(&conn->on_server_connect_done, &conn->server_endpoint, conn->pollset_set, args, &resolved_addresses->addrs[0], deadline); @@ -604,7 +605,7 @@ static void thread_main(void* arg) { } grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( - grpc_channel_args* args) { + const grpc_channel_args* args) { grpc_core::ExecCtx exec_ctx; grpc_end2end_http_proxy* proxy = new grpc_end2end_http_proxy(); // Construct proxy address. @@ -612,7 +613,9 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( proxy->proxy_name = grpc_core::JoinHostPort("localhost", proxy_port); gpr_log(GPR_INFO, "Proxy address: %s", proxy->proxy_name.c_str()); // Create TCP server. - proxy->channel_args = grpc_core::EnsureResourceQuotaInChannelArgs(args); + proxy->channel_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(args); grpc_error_handle error = grpc_tcp_server_create(nullptr, proxy->channel_args, &proxy->server); GPR_ASSERT(error == GRPC_ERROR_NONE); diff --git a/test/core/end2end/fixtures/http_proxy_fixture.h b/test/core/end2end/fixtures/http_proxy_fixture.h index 103bd08196c..2bc20fa3c17 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.h +++ b/test/core/end2end/fixtures/http_proxy_fixture.h @@ -33,7 +33,7 @@ typedef struct grpc_end2end_http_proxy grpc_end2end_http_proxy; grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( - grpc_channel_args* args); + const grpc_channel_args* args); void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy); diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc index 71f8d352ed0..c2035bac85a 100644 --- a/test/core/end2end/fixtures/inproc.cc +++ b/test/core/end2end/fixtures/inproc.cc @@ -37,7 +37,8 @@ typedef struct inproc_fixture_data { } inproc_fixture_data; static grpc_end2end_test_fixture inproc_create_fixture( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; inproc_fixture_data* ffd = static_cast( gpr_malloc(sizeof(inproc_fixture_data))); @@ -51,13 +52,13 @@ static grpc_end2end_test_fixture inproc_create_fixture( } void inproc_init_client(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { f->client = grpc_inproc_channel_create(f->server, client_args, nullptr); GPR_ASSERT(f->client); } void inproc_init_server(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { if (f->server) { grpc_server_destroy(f->server); } diff --git a/test/core/end2end/fixtures/local_util.cc b/test/core/end2end/fixtures/local_util.cc index d7431f5dad0..23dcc752e79 100644 --- a/test/core/end2end/fixtures/local_util.cc +++ b/test/core/end2end/fixtures/local_util.cc @@ -45,7 +45,7 @@ grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack() { } void grpc_end2end_local_chttp2_init_client_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args, grpc_local_connect_type type) { grpc_channel_credentials* creds = grpc_local_credentials_create(type); grpc_end2end_local_fullstack_fixture_data* ffd = @@ -61,7 +61,7 @@ void grpc_end2end_local_chttp2_init_client_fullstack( * processor will be installed that always fails in processing client's * metadata. */ -static bool fail_server_auth_check(grpc_channel_args* server_args) { +static bool fail_server_auth_check(const grpc_channel_args* server_args) { size_t i; if (server_args == nullptr) return false; for (i = 0; i < server_args->num_args; i++) { @@ -83,7 +83,7 @@ static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, } void grpc_end2end_local_chttp2_init_server_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args, grpc_local_connect_type type) { grpc_server_credentials* creds = grpc_local_server_credentials_create(type); grpc_end2end_local_fullstack_fixture_data* ffd = diff --git a/test/core/end2end/fixtures/local_util.h b/test/core/end2end/fixtures/local_util.h index 9775a996e03..2d17b2b4577 100644 --- a/test/core/end2end/fixtures/local_util.h +++ b/test/core/end2end/fixtures/local_util.h @@ -29,11 +29,11 @@ struct grpc_end2end_local_fullstack_fixture_data { grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack(); void grpc_end2end_local_chttp2_init_client_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* client_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* client_args, grpc_local_connect_type type); void grpc_end2end_local_chttp2_init_server_fullstack( - grpc_end2end_test_fixture* f, grpc_channel_args* server_args, + grpc_end2end_test_fixture* f, const grpc_channel_args* server_args, grpc_local_connect_type type); void grpc_end2end_local_chttp2_tear_down_fullstack( diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index 84f6bf4b1d4..e11df81be05 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -84,9 +84,9 @@ typedef struct { static void thread_main(void* arg); static void request_call(grpc_end2end_proxy* proxy); -grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, - grpc_channel_args* client_args, - grpc_channel_args* server_args) { +grpc_end2end_proxy* grpc_end2end_proxy_create( + const grpc_end2end_proxy_def* def, const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { int proxy_port = grpc_pick_unused_port_or_die(); int server_port = grpc_pick_unused_port_or_die(); @@ -104,7 +104,7 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, const char* arg_to_remove = GRPC_ARG_ENABLE_RETRIES; grpc_arg arg_to_add = grpc_channel_arg_integer_create( const_cast(GRPC_ARG_ENABLE_RETRIES), 0); - grpc_channel_args* proxy_client_args = + const grpc_channel_args* proxy_client_args = grpc_channel_args_copy_and_add_and_remove(client_args, &arg_to_remove, 1, &arg_to_add, 1); proxy->client = diff --git a/test/core/end2end/fixtures/proxy.h b/test/core/end2end/fixtures/proxy.h index 18ad763ea7c..8f18888e9bd 100644 --- a/test/core/end2end/fixtures/proxy.h +++ b/test/core/end2end/fixtures/proxy.h @@ -27,14 +27,14 @@ typedef struct grpc_end2end_proxy grpc_end2end_proxy; typedef struct grpc_end2end_proxy_def { grpc_server* (*create_server)(const char* port, - grpc_channel_args* server_args); + const grpc_channel_args* server_args); grpc_channel* (*create_client)(const char* target, - grpc_channel_args* client_args); + const grpc_channel_args* client_args); } grpc_end2end_proxy_def; -grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, - grpc_channel_args* client_args, - grpc_channel_args* server_args); +grpc_end2end_proxy* grpc_end2end_proxy_create( + const grpc_end2end_proxy_def* def, const grpc_channel_args* client_args, + const grpc_channel_args* server_args); void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy); const char* grpc_end2end_proxy_get_client_target(grpc_end2end_proxy* proxy); diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc index 9f157f95b04..39fbf24fc6c 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.cc +++ b/test/core/end2end/fuzzers/client_fuzzer.cc @@ -50,8 +50,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_resource_quota_create("context_list_test"); grpc_endpoint* mock_endpoint = grpc_mock_endpoint_create(discard_write); grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); - grpc_channel_args* args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_transport* transport = grpc_create_chttp2_transport(args, mock_endpoint, true); grpc_channel_args_destroy(args); diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc index 32e05a16112..7e70f2b5b4e 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.cc +++ b/test/core/end2end/fuzzers/server_fuzzer.cc @@ -52,8 +52,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // TODO(ctiller): add more registered methods (one for POST, one for PUT) grpc_server_register_method(server, "/reg", nullptr, {}, 0); grpc_server_start(server); - grpc_channel_args* channel_args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* channel_args = + grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_transport* transport = grpc_create_chttp2_transport(channel_args, mock_endpoint, false); grpc_channel_args_destroy(channel_args); diff --git a/test/core/end2end/inproc_callback_test.cc b/test/core/end2end/inproc_callback_test.cc index be36993ca39..8c10f282c04 100644 --- a/test/core/end2end/inproc_callback_test.cc +++ b/test/core/end2end/inproc_callback_test.cc @@ -205,7 +205,8 @@ static grpc_completion_queue_functor* tag(intptr_t t) { } static grpc_end2end_test_fixture inproc_create_fixture( - grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { + const grpc_channel_args* /*client_args*/, + const grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; inproc_fixture_data* ffd = static_cast( gpr_malloc(sizeof(inproc_fixture_data))); @@ -221,13 +222,13 @@ static grpc_end2end_test_fixture inproc_create_fixture( } void inproc_init_client(grpc_end2end_test_fixture* f, - grpc_channel_args* client_args) { + const grpc_channel_args* client_args) { f->client = grpc_inproc_channel_create(f->server, client_args, nullptr); GPR_ASSERT(f->client); } void inproc_init_server(grpc_end2end_test_fixture* f, - grpc_channel_args* server_args) { + const grpc_channel_args* server_args) { if (f->server) { grpc_server_destroy(f->server); } @@ -241,10 +242,10 @@ void inproc_tear_down(grpc_end2end_test_fixture* f) { gpr_free(ffd); } -static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char* test_name, - grpc_channel_args* client_args, - grpc_channel_args* server_args) { +static grpc_end2end_test_fixture begin_test( + grpc_end2end_test_config config, const char* test_name, + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); diff --git a/test/core/end2end/tests/binary_metadata.cc b/test/core/end2end/tests/binary_metadata.cc index 67066e1407e..f2989e645c0 100644 --- a/test/core/end2end/tests/binary_metadata.cc +++ b/test/core/end2end/tests/binary_metadata.cc @@ -24,7 +24,7 @@ #include #include -#include "src/core/lib/resource_quota/api.h" +#include "src/core/lib/config/core_configuration.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/end2end_tests.h" @@ -36,8 +36,14 @@ static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); - client_args = grpc_core::EnsureResourceQuotaInChannelArgs(client_args); - server_args = grpc_core::EnsureResourceQuotaInChannelArgs(server_args); + client_args = + const_cast(grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(client_args)); + server_args = + const_cast(grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(server_args)); f = config.create_fixture(client_args, server_args); config.init_server(&f, server_args); config.init_client(&f, client_args); diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc index cd9be9b4455..afbbf7b1512 100644 --- a/test/core/end2end/tests/compressed_payload.cc +++ b/test/core/end2end/tests/compressed_payload.cc @@ -40,11 +40,10 @@ static void* tag(intptr_t t) { return reinterpret_cast(t); } -static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char* test_name, - grpc_channel_args* client_args, - grpc_channel_args* server_args, - bool decompress_in_core) { +static grpc_end2end_test_fixture begin_test( + grpc_end2end_test_config config, const char* test_name, + const grpc_channel_args* client_args, const grpc_channel_args* server_args, + bool decompress_in_core) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s%s/%s", test_name, decompress_in_core ? "" : "_with_decompression_disabled", @@ -108,8 +107,8 @@ static void request_for_disabled_algorithm( grpc_call* s; grpc_slice request_payload_slice; grpc_byte_buffer* request_payload; - grpc_channel_args* client_args; - grpc_channel_args* server_args; + const grpc_channel_args* client_args; + const grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; grpc_op* op; @@ -140,8 +139,8 @@ static void request_for_disabled_algorithm( grpc_arg disable_decompression_in_core_arg = grpc_channel_arg_integer_create( const_cast(GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION), 0); - grpc_channel_args* old_client_args = client_args; - grpc_channel_args* old_server_args = server_args; + const grpc_channel_args* old_client_args = client_args; + const grpc_channel_args* old_server_args = server_args; client_args = grpc_channel_args_copy_and_add( client_args, &disable_decompression_in_core_arg, 1); server_args = grpc_channel_args_copy_and_add( @@ -288,8 +287,8 @@ static void request_with_payload_template_inner( grpc_call* s; grpc_slice request_payload_slice; grpc_byte_buffer* request_payload = nullptr; - grpc_channel_args* client_args; - grpc_channel_args* server_args; + const grpc_channel_args* client_args; + const grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; grpc_op* op; @@ -326,8 +325,8 @@ static void request_with_payload_template_inner( grpc_arg disable_decompression_in_core_arg = grpc_channel_arg_integer_create( const_cast(GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION), 0); - grpc_channel_args* old_client_args = client_args; - grpc_channel_args* old_server_args = server_args; + const grpc_channel_args* old_client_args = client_args; + const grpc_channel_args* old_server_args = server_args; client_args = grpc_channel_args_copy_and_add( client_args, &disable_decompression_in_core_arg, 1); server_args = grpc_channel_args_copy_and_add( diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc index 35aba3fd4b2..04d56459e9c 100644 --- a/test/core/end2end/tests/stream_compression_compressed_payload.cc +++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc @@ -40,10 +40,10 @@ static void* tag(intptr_t t) { return reinterpret_cast(t); } -static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char* test_name, - grpc_channel_args* client_args, - grpc_channel_args* server_args) { +static grpc_end2end_test_fixture begin_test( + grpc_end2end_test_config config, const char* test_name, + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -104,8 +104,8 @@ static void request_for_disabled_algorithm( grpc_call* s; grpc_slice request_payload_slice; grpc_byte_buffer* request_payload; - grpc_channel_args* client_args; - grpc_channel_args* server_args; + const grpc_channel_args* client_args; + const grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; grpc_op* op; @@ -280,8 +280,8 @@ static void request_with_payload_template( grpc_call* s; grpc_slice request_payload_slice; grpc_byte_buffer* request_payload = nullptr; - grpc_channel_args* client_args; - grpc_channel_args* server_args; + const grpc_channel_args* client_args; + const grpc_channel_args* server_args; grpc_end2end_test_fixture f; grpc_op ops[6]; grpc_op* op; diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc index f552294900b..f180da6c51f 100644 --- a/test/core/end2end/tests/stream_compression_payload.cc +++ b/test/core/end2end/tests/stream_compression_payload.cc @@ -33,10 +33,10 @@ static void* tag(intptr_t t) { return reinterpret_cast(t); } -static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char* test_name, - grpc_channel_args* client_args, - grpc_channel_args* server_args) { +static grpc_end2end_test_fixture begin_test( + grpc_end2end_test_config config, const char* test_name, + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -263,10 +263,10 @@ static void request_response_with_payload(grpc_end2end_test_config /*config*/, payload and status. */ static void test_invoke_request_response_with_payload( grpc_end2end_test_config config) { - grpc_channel_args* client_args = + const grpc_channel_args* client_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, GRPC_COMPRESS_STREAM_GZIP); - grpc_channel_args* server_args = + const grpc_channel_args* server_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, GRPC_COMPRESS_STREAM_GZIP); grpc_end2end_test_fixture f = diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc index c7e131af994..e9318d190a6 100644 --- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc +++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc @@ -33,10 +33,10 @@ static void* tag(intptr_t t) { return reinterpret_cast(t); } -static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, - const char* test_name, - grpc_channel_args* client_args, - grpc_channel_args* server_args) { +static grpc_end2end_test_fixture begin_test( + grpc_end2end_test_config config, const char* test_name, + const grpc_channel_args* client_args, + const grpc_channel_args* server_args) { grpc_end2end_test_fixture f; gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); f = config.create_fixture(client_args, server_args); @@ -90,10 +90,10 @@ static void end_test(grpc_end2end_test_fixture* f) { /* Client pings and server pongs. Repeat messages rounds before finishing. */ static void test_pingpong_streaming(grpc_end2end_test_config config, int messages) { - grpc_channel_args* client_args = + const grpc_channel_args* client_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, GRPC_COMPRESS_STREAM_GZIP); - grpc_channel_args* server_args = + const grpc_channel_args* server_args = grpc_channel_args_set_channel_default_compression_algorithm( nullptr, GRPC_COMPRESS_STREAM_GZIP); grpc_end2end_test_fixture f = diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm index 4b247ac1add..393770c8699 100644 --- a/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamClientTests.mm @@ -103,7 +103,9 @@ static void must_fail(void* arg, grpc_error_handle error) { /* connect to it */ GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len) == 0); GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx); - grpc_channel_args* args = grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + grpc_channel_args* args = + grpc_core::CoreConfiguration::Get().channel_args_preconditioning().PreconditionChannelArgs( + nullptr); grpc_tcp_client_connect(&done, &g_connecting, nullptr, args, &resolved_addr, GRPC_MILLIS_INF_FUTURE); grpc_channel_args_destroy(args); @@ -160,7 +162,9 @@ static void must_fail(void* arg, grpc_error_handle error) { /* connect to a broken address */ GRPC_CLOSURE_INIT(&done, must_fail, nullptr, grpc_schedule_on_exec_ctx); - grpc_channel_args* args = grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + grpc_channel_args* args = + grpc_core::CoreConfiguration::Get().channel_args_preconditioning().PreconditionChannelArgs( + nullptr); grpc_tcp_client_connect(&done, &g_connecting, nullptr, args, &resolved_addr, GRPC_MILLIS_INF_FUTURE); grpc_channel_args_destroy(args); diff --git a/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm b/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm index 1db7ffa8e25..bf7cfc2dc71 100644 --- a/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm +++ b/test/core/iomgr/ios/CFStreamTests/CFStreamEndpointTests.mm @@ -127,7 +127,9 @@ static bool compare_slice_buffer_with_buffer(grpc_slice_buffer *slices, const ch /* connect to it */ XCTAssertEqual(getsockname(svr_fd, (struct sockaddr *)addr, (socklen_t *)&resolved_addr.len), 0); init_event_closure(&done, &connected); - grpc_channel_args *args = grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + grpc_channel_args *args = + grpc_core::CoreConfiguration::Get().channel_args_preconditioning().PreconditionChannelArgs( + nullptr); grpc_tcp_client_connect(&done, &ep_, nullptr, args, &resolved_addr, GRPC_MILLIS_INF_FUTURE); grpc_channel_args_destroy(args); diff --git a/test/core/iomgr/tcp_client_posix_test.cc b/test/core/iomgr/tcp_client_posix_test.cc index 3124ca5edb3..e74d605ac37 100644 --- a/test/core/iomgr/tcp_client_posix_test.cc +++ b/test/core/iomgr/tcp_client_posix_test.cc @@ -106,8 +106,9 @@ void test_succeeds(void) { GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len) == 0); GRPC_CLOSURE_INIT(&done, must_succeed, nullptr, grpc_schedule_on_exec_ctx); - grpc_channel_args* args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_tcp_client_connect(&done, &g_connecting, g_pollset_set, args, &resolved_addr, GRPC_MILLIS_INF_FUTURE); grpc_channel_args_destroy(args); diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc index c9e09183020..476925c05d5 100644 --- a/test/core/iomgr/tcp_server_posix_test.cc +++ b/test/core/iomgr/tcp_server_posix_test.cc @@ -164,8 +164,9 @@ static void on_connect(void* /*arg*/, grpc_endpoint* tcp, static void test_no_op(void) { grpc_core::ExecCtx exec_ctx; grpc_tcp_server* s; - grpc_channel_args* args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, args, &s)); grpc_channel_args_destroy(args); grpc_tcp_server_unref(s); @@ -174,8 +175,9 @@ static void test_no_op(void) { static void test_no_op_with_start(void) { grpc_core::ExecCtx exec_ctx; grpc_tcp_server* s; - grpc_channel_args* args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, args, &s)); grpc_channel_args_destroy(args); LOG_TEST("test_no_op_with_start"); @@ -190,8 +192,9 @@ static void test_no_op_with_port(void) { struct sockaddr_in* addr = reinterpret_cast(resolved_addr.addr); grpc_tcp_server* s; - grpc_channel_args* args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, args, &s)); grpc_channel_args_destroy(args); LOG_TEST("test_no_op_with_port"); @@ -213,8 +216,9 @@ static void test_no_op_with_port_and_start(void) { struct sockaddr_in* addr = reinterpret_cast(resolved_addr.addr); grpc_tcp_server* s; - grpc_channel_args* args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, args, &s)); grpc_channel_args_destroy(args); LOG_TEST("test_no_op_with_port_and_start"); @@ -312,8 +316,10 @@ static void test_connect(size_t num_connects, int svr1_port; grpc_tcp_server* s; const unsigned num_ports = 2; - grpc_channel_args* new_channel_args = - grpc_core::EnsureResourceQuotaInChannelArgs(channel_args); + const grpc_channel_args* new_channel_args = + grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(channel_args); GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, new_channel_args, &s)); grpc_channel_args_destroy(new_channel_args); diff --git a/test/core/surface/concurrent_connectivity_test.cc b/test/core/surface/concurrent_connectivity_test.cc index 689792d2afe..17dd195a7dd 100644 --- a/test/core/surface/concurrent_connectivity_test.cc +++ b/test/core/surface/concurrent_connectivity_test.cc @@ -132,8 +132,9 @@ void bad_server_thread(void* vargs) { grpc_sockaddr* addr = reinterpret_cast(resolved_addr.addr); int port; grpc_tcp_server* s; - grpc_channel_args* channel_args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* channel_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_error_handle error = grpc_tcp_server_create(nullptr, channel_args, &s); grpc_channel_args_destroy(channel_args); GPR_ASSERT(error == GRPC_ERROR_NONE); diff --git a/test/core/transport/chttp2/context_list_test.cc b/test/core/transport/chttp2/context_list_test.cc index 3b77d03a64e..839d88668a9 100644 --- a/test/core/transport/chttp2/context_list_test.cc +++ b/test/core/transport/chttp2/context_list_test.cc @@ -72,7 +72,9 @@ TEST_F(ContextListTest, ExecuteFlushesList) { grpc_stream_refcount ref; GRPC_STREAM_REF_INIT(&ref, 1, nullptr, nullptr, "phony ref"); grpc_endpoint* mock_endpoint = grpc_mock_endpoint_create(discard_write); - grpc_channel_args* args = EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_transport* t = grpc_create_chttp2_transport(args, mock_endpoint, true); grpc_channel_args_destroy(args); std::vector s; @@ -125,7 +127,9 @@ TEST_F(ContextListTest, NonEmptyListEmptyTimestamp) { grpc_stream_refcount ref; GRPC_STREAM_REF_INIT(&ref, 1, nullptr, nullptr, "phony ref"); grpc_endpoint* mock_endpoint = grpc_mock_endpoint_create(discard_write); - grpc_channel_args* args = EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_transport* t = grpc_create_chttp2_transport(args, mock_endpoint, true); grpc_channel_args_destroy(args); std::vector s; diff --git a/test/core/transport/chttp2/settings_timeout_test.cc b/test/core/transport/chttp2/settings_timeout_test.cc index 7f249cd48de..b36c309aa2a 100644 --- a/test/core/transport/chttp2/settings_timeout_test.cc +++ b/test/core/transport/chttp2/settings_timeout_test.cc @@ -119,7 +119,9 @@ class Client { grpc_pollset_set* pollset_set = grpc_pollset_set_create(); grpc_pollset_set_add_pollset(pollset_set, pollset_); EventState state; - grpc_channel_args* args = EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_tcp_client_connect(state.closure(), &endpoint_, pollset_set, args, server_addresses->addrs, ExecCtx::Get()->Now() + 1000); diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index 4cb63516044..57d6c213747 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -66,8 +66,9 @@ void test_tcp_server_start(test_tcp_server* server, int port) { memset(&addr->sin_addr, 0, sizeof(addr->sin_addr)); resolved_addr.len = static_cast(sizeof(grpc_sockaddr_in)); - grpc_channel_args* args = - grpc_core::EnsureResourceQuotaInChannelArgs(nullptr); + const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(nullptr); grpc_error_handle error = grpc_tcp_server_create(&server->shutdown_complete, args, &server->tcp_server); grpc_channel_args_destroy(args); diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 542dd68bb7c..29ae1696b96 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -133,8 +133,9 @@ class Fixture { Fixture(const grpc::ChannelArguments& args, bool client) { grpc_channel_args c_args = args.c_channel_args(); ep_ = new PhonyEndpoint; - grpc_channel_args* final_args = - grpc_core::EnsureResourceQuotaInChannelArgs(&c_args); + const grpc_channel_args* final_args = grpc_core::CoreConfiguration::Get() + .channel_args_preconditioning() + .PreconditionChannelArgs(&c_args); t_ = grpc_create_chttp2_transport(final_args, ep_, client); grpc_channel_args_destroy(final_args); grpc_chttp2_transport_start_reading(t_, nullptr, nullptr, nullptr); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index fe9bf0887c1..6234711106e 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1726,6 +1726,8 @@ src/core/lib/backoff/backoff.h \ src/core/lib/channel/call_tracer.h \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_args.h \ +src/core/lib/channel/channel_args_preconditioning.cc \ +src/core/lib/channel/channel_args_preconditioning.h \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 4928cdcf790..b9549a8ac30 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1522,6 +1522,8 @@ src/core/lib/channel/README.md \ src/core/lib/channel/call_tracer.h \ src/core/lib/channel/channel_args.cc \ src/core/lib/channel/channel_args.h \ +src/core/lib/channel/channel_args_preconditioning.cc \ +src/core/lib/channel/channel_args_preconditioning.h \ src/core/lib/channel/channel_stack.cc \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.cc \