diff --git a/.clang-format b/.clang-format index 608eea1405663..64387e9e51527 100644 --- a/.clang-format +++ b/.clang-format @@ -46,4 +46,8 @@ Language: ObjC BasedOnStyle: Google ColumnLimit: 100 ObjCBlockIndentWidth: 2 +--- +Language: Proto +BasedOnStyle: Google +ColumnLimit: 100 ... diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000..8cd0034b50ce9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +bazel-bin +bazel-grpc +bazel-out +build +.cache +.git diff --git a/.gitignore b/.gitignore index d9a8d08ad412e..bcf82223bee00 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ coverage # vim temp files .*.swp +.*.swo # Makefile's cache cache.mk diff --git a/.gitmodules b/.gitmodules index 55b22264b89f8..99016a3d37d8e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,9 +22,6 @@ [submodule "third_party/googletest"] path = third_party/googletest url = https://github.com/google/googletest.git -[submodule "third_party/libuv"] - path = third_party/libuv - url = https://github.com/libuv/libuv.git [submodule "third_party/opencensus-proto"] path = third_party/opencensus-proto url = https://github.com/census-instrumentation/opencensus-proto.git diff --git a/BUILD b/BUILD index 3ad0906925618..c7a7e844c43c6 100644 --- a/BUILD +++ b/BUILD @@ -211,11 +211,11 @@ config_setting( python_config_settings() # This should be updated along with build_handwritten.yaml -g_stands_for = "grounded" # @unused +g_stands_for = "goku" # @unused -core_version = "33.0.0" # @unused +core_version = "34.0.0" # @unused -version = "1.57.0-dev" # @unused +version = "1.58.0-dev" # @unused GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", @@ -552,6 +552,7 @@ grpc_cc_library( ], visibility = ["@grpc:public"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "exec_ctx", @@ -624,6 +625,7 @@ grpc_cc_library( "@grpc:public", ], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "exec_ctx", @@ -837,7 +839,10 @@ grpc_cc_library( "avoid_dep", "nofixdeps", ], - deps = ["gpr_public_hdrs"], + deps = [ + "channel_arg_names", + "gpr_public_hdrs", + ], ) grpc_cc_library( @@ -860,6 +865,11 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "channel_arg_names", + hdrs = ["include/grpc/impl/channel_arg_names.h"], +) + grpc_cc_library( name = "grpc++", hdrs = [ @@ -1258,6 +1268,7 @@ grpc_cc_library( "nofixdeps", ], deps = [ + "channel_arg_names", "gpr", ], ) @@ -1496,6 +1507,7 @@ grpc_cc_library( public_hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS, visibility = ["@grpc:alt_grpc_base_legacy"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "config_vars", @@ -1522,8 +1534,6 @@ grpc_cc_library( "//src/core:arena", "//src/core:arena_promise", "//src/core:atomic_utils", - "//src/core:basic_join", - "//src/core:basic_seq", "//src/core:bitset", "//src/core:cancel_callback", "//src/core:channel_args", @@ -1566,7 +1576,6 @@ grpc_cc_library( "//src/core:memory_quota", "//src/core:metadata_compression_traits", "//src/core:no_destruct", - "//src/core:notification", "//src/core:packed_table", "//src/core:per_cpu", "//src/core:pipe", @@ -1591,7 +1600,6 @@ grpc_cc_library( "//src/core:thread_quota", "//src/core:time", "//src/core:transport_fwd", - "//src/core:try_join", "//src/core:try_seq", "//src/core:type_list", "//src/core:useful", @@ -1659,6 +1667,7 @@ grpc_cc_library( ], tags = ["nofixdeps"], deps = [ + "channel_arg_names", "gpr", "gpr_platform", "grpc", @@ -1772,6 +1781,7 @@ grpc_cc_library( public_hdrs = GRPC_PUBLIC_HDRS, visibility = ["@grpc:public"], deps = [ + "channel_arg_names", "config", "debug_location", "exec_ctx", @@ -1788,7 +1798,6 @@ grpc_cc_library( "//src/core:activity", "//src/core:arena", "//src/core:arena_promise", - "//src/core:basic_seq", "//src/core:channel_args", "//src/core:channel_fwd", "//src/core:closure", @@ -1922,6 +1931,7 @@ grpc_cc_library( tags = ["nofixdeps"], visibility = ["@grpc:alt_grpc++_base_legacy"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "exec_ctx", @@ -1997,6 +2007,7 @@ grpc_cc_library( ], visibility = ["@grpc:alt_grpc++_base_unsecure_legacy"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "exec_ctx", @@ -3008,6 +3019,7 @@ grpc_cc_library( visibility = ["@grpc:client_channel"], deps = [ "backoff", + "channel_arg_names", "channel_stack_builder", "config", "config_vars", @@ -3110,6 +3122,7 @@ grpc_cc_library( language = "c++", deps = [ "backoff", + "channel_arg_names", "config", "config_vars", "debug_location", @@ -3217,6 +3230,7 @@ grpc_cc_library( visibility = ["@grpc:public"], deps = [ "alts_util", + "channel_arg_names", "debug_location", "exec_ctx", "gpr", @@ -3479,6 +3493,7 @@ grpc_cc_library( language = "c++", visibility = ["@grpc:public"], deps = [ + "channel_arg_names", "config_vars", "gpr", "grpc_base", @@ -3523,6 +3538,7 @@ grpc_cc_library( language = "c++", visibility = ["@grpc:http"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "gpr", @@ -3912,6 +3928,7 @@ grpc_cc_library( language = "c++", visibility = ["@grpc:grpclb"], deps = [ + "channel_arg_names", "chttp2_context_list_entry", "chttp2_frame", "chttp2_varint", @@ -3943,7 +3960,10 @@ grpc_cc_library( "//src/core:init_internally", "//src/core:iomgr_fwd", "//src/core:iomgr_port", + "//src/core:match", "//src/core:memory_quota", + "//src/core:ping_abuse_policy", + "//src/core:ping_rate_policy", "//src/core:poll", "//src/core:ref_counted", "//src/core:resource_quota", @@ -3978,6 +3998,26 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "subprocess", + srcs = [ + "//src/core:lib/gpr/subprocess_posix.cc", + "//src/core:lib/gpr/subprocess_windows.cc", + ], + hdrs = [ + "//src/core:lib/gpr/subprocess.h", + ], + external_deps = [ + "absl/strings", + "absl/types:span", + ], + deps = [ + "gpr", + "//src/core:strerror", + "//src/core:tchar", + ], +) + # TODO(yashykt): Remove the UPB definitions from here once they are no longer needed ### UPB Targets diff --git a/CMakeLists.txt b/CMakeLists.txt index 325581d4b3c6b..74de92e461011 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,13 +25,13 @@ cmake_minimum_required(VERSION 3.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.57.0-dev") -set(gRPC_CORE_VERSION "33.0.0") -set(gRPC_CORE_SOVERSION "33") -set(gRPC_CPP_VERSION "1.57.0-dev") -set(gRPC_CPP_SOVERSION "1.57") -set(gRPC_CSHARP_VERSION "2.57.0-dev") -set(gRPC_CSHARP_SOVERSION "2.57") +set(PACKAGE_VERSION "1.58.0-dev") +set(gRPC_CORE_VERSION "34.0.0") +set(gRPC_CORE_SOVERSION "34") +set(gRPC_CPP_VERSION "1.58.0-dev") +set(gRPC_CPP_SOVERSION "1.58") +set(gRPC_CSHARP_VERSION "2.58.0-dev") +set(gRPC_CSHARP_SOVERSION "2.58") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") @@ -204,6 +204,7 @@ set(gRPC_ABSL_USED_TARGETS absl_str_format absl_str_format_internal absl_strerror + absl_string_view absl_strings absl_strings_internal absl_symbolize @@ -299,7 +300,7 @@ endif() if (gRPC_XDS_USER_AGENT_IS_CSHARP) # The value of the defines needs to contain quotes. # See https://github.com/grpc/grpc/blob/fbf32836a418cc84f58786700273b65cb9174e1d/src/core/ext/xds/xds_api.cc#L854 - add_definitions("-DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"csharp\"" "-DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"2.57.0-dev\"") + add_definitions("-DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"csharp\"" "-DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"2.58.0-dev\"") endif() if(UNIX AND NOT HAIKU) @@ -862,6 +863,7 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx call_creds_test) add_dependencies(buildtests_cxx call_finalization_test) add_dependencies(buildtests_cxx call_host_override_test) + add_dependencies(buildtests_cxx call_tracer_test) add_dependencies(buildtests_cxx cancel_after_accept_test) add_dependencies(buildtests_cxx cancel_after_client_done_test) add_dependencies(buildtests_cxx cancel_after_invoke_test) @@ -898,9 +900,6 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx client_authority_filter_test) add_dependencies(buildtests_cxx client_callback_end2end_test) add_dependencies(buildtests_cxx client_channel_service_config_test) - if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - add_dependencies(buildtests_cxx client_channel_stress_test) - endif() add_dependencies(buildtests_cxx client_channel_test) add_dependencies(buildtests_cxx client_context_test_peer_test) add_dependencies(buildtests_cxx client_interceptors_end2end_test) @@ -968,6 +967,7 @@ if(gRPC_BUILD_TESTS) endif() add_dependencies(buildtests_cxx exception_test) add_dependencies(buildtests_cxx exec_ctx_wakeup_scheduler_test) + add_dependencies(buildtests_cxx experiments_tag_test) add_dependencies(buildtests_cxx experiments_test) add_dependencies(buildtests_cxx factory_test) add_dependencies(buildtests_cxx fake_binder_test) @@ -1138,8 +1138,10 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx periodic_update_test) add_dependencies(buildtests_cxx pick_first_test) add_dependencies(buildtests_cxx pid_controller_test) + add_dependencies(buildtests_cxx ping_abuse_policy_test) add_dependencies(buildtests_cxx ping_configuration_test) add_dependencies(buildtests_cxx ping_pong_streaming_test) + add_dependencies(buildtests_cxx ping_rate_policy_test) add_dependencies(buildtests_cxx ping_test) add_dependencies(buildtests_cxx pipe_test) add_dependencies(buildtests_cxx poll_test) @@ -1455,6 +1457,7 @@ if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx xds_routing_end2end_test) endif() + add_dependencies(buildtests_cxx xds_stats_watcher_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx xds_wrr_end2end_test) endif() @@ -1783,6 +1786,8 @@ add_library(grpc src/core/ext/transport/chttp2/transport/http_trace.cc src/core/ext/transport/chttp2/transport/huffsyms.cc src/core/ext/transport/chttp2/transport/parsing.cc + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc src/core/ext/transport/chttp2/transport/stream_lists.cc src/core/ext/transport/chttp2/transport/varint.cc src/core/ext/transport/chttp2/transport/writing.cc @@ -2153,8 +2158,10 @@ add_library(grpc src/core/lib/debug/stats.cc src/core/lib/debug/stats_data.cc src/core/lib/debug/trace.cc + src/core/lib/event_engine/ares_resolver.cc src/core/lib/event_engine/cf_engine/cf_engine.cc src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc + src/core/lib/event_engine/cf_engine/dns_service_resolver.cc src/core/lib/event_engine/channel_args_endpoint_config.cc src/core/lib/event_engine/default_event_engine.cc src/core/lib/event_engine/default_event_engine_factory.cc @@ -2530,6 +2537,7 @@ foreach(_hdr include/grpc/grpc_posix.h include/grpc/grpc_security.h include/grpc/grpc_security_constants.h + include/grpc/impl/channel_arg_names.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -2808,6 +2816,8 @@ add_library(grpc_unsecure src/core/ext/transport/chttp2/transport/http_trace.cc src/core/ext/transport/chttp2/transport/huffsyms.cc src/core/ext/transport/chttp2/transport/parsing.cc + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc src/core/ext/transport/chttp2/transport/stream_lists.cc src/core/ext/transport/chttp2/transport/varint.cc src/core/ext/transport/chttp2/transport/writing.cc @@ -2858,8 +2868,10 @@ add_library(grpc_unsecure src/core/lib/debug/stats.cc src/core/lib/debug/stats_data.cc src/core/lib/debug/trace.cc + src/core/lib/event_engine/ares_resolver.cc src/core/lib/event_engine/cf_engine/cf_engine.cc src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc + src/core/lib/event_engine/cf_engine/dns_service_resolver.cc src/core/lib/event_engine/channel_args_endpoint_config.cc src/core/lib/event_engine/default_event_engine.cc src/core/lib/event_engine/default_event_engine_factory.cc @@ -3175,6 +3187,7 @@ foreach(_hdr include/grpc/grpc_posix.h include/grpc/grpc_security.h include/grpc/grpc_security_constants.h + include/grpc/impl/channel_arg_names.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -3273,8 +3286,6 @@ add_library(benchmark_helpers test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/cpp/microbenchmarks/helpers.cc ) @@ -3992,6 +4003,8 @@ endif() if(gRPC_BUILD_TESTS) add_library(grpc++_test_util + src/core/lib/gpr/subprocess_posix.cc + src/core/lib/gpr/subprocess_windows.cc test/core/end2end/data/client_certs.cc test/core/end2end/data/server1_cert.cc test/core/end2end/data/server1_key.cc @@ -4005,8 +4018,6 @@ add_library(grpc++_test_util test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/cpp/util/byte_buffer_proto_helper.cc test/cpp/util/create_test_channel.cc @@ -4394,8 +4405,10 @@ add_library(grpc_authorization_provider src/core/lib/debug/stats.cc src/core/lib/debug/stats_data.cc src/core/lib/debug/trace.cc + src/core/lib/event_engine/ares_resolver.cc src/core/lib/event_engine/cf_engine/cf_engine.cc src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc + src/core/lib/event_engine/cf_engine/dns_service_resolver.cc src/core/lib/event_engine/channel_args_endpoint_config.cc src/core/lib/event_engine/default_event_engine.cc src/core/lib/event_engine/default_event_engine_factory.cc @@ -4657,6 +4670,7 @@ target_link_libraries(grpc_authorization_provider ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_CARES_LIBRARIES} ${_gRPC_RE2_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} absl::cleanup @@ -4692,6 +4706,7 @@ foreach(_hdr include/grpc/grpc_posix.h include/grpc/grpc_security.h include/grpc/grpc_security_constants.h + include/grpc/impl/channel_arg_names.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -5024,8 +5039,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc ) target_compile_features(fd_conservation_posix_test PUBLIC cxx_std_14) @@ -5161,8 +5174,6 @@ add_executable(test_core_iomgr_timer_list_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc ) target_compile_features(test_core_iomgr_timer_list_test PUBLIC cxx_std_14) @@ -5276,6 +5287,8 @@ if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(address_sorting_test_unsecure + src/core/lib/gpr/subprocess_posix.cc + src/core/lib/gpr/subprocess_windows.cc test/core/util/cmdline.cc test/core/util/fuzzer_util.cc test/core/util/grpc_profiler.cc @@ -5285,8 +5298,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/cpp/naming/address_sorting_test.cc test/cpp/util/byte_buffer_proto_helper.cc @@ -5398,8 +5409,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/cpp/common/alarm_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -5842,8 +5851,6 @@ add_executable(alts_security_connector_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -6178,8 +6185,6 @@ add_executable(auth_context_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -6264,8 +6269,6 @@ add_executable(authorization_matchers_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -6372,8 +6375,7 @@ target_link_libraries(avl_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::strings - absl::variant + gpr ) @@ -6391,8 +6393,6 @@ add_executable(aws_request_signer_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -6591,6 +6591,8 @@ if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(bad_ssl_alpn_test + src/core/lib/gpr/subprocess_posix.cc + src/core/lib/gpr/subprocess_windows.cc test/core/bad_ssl/bad_ssl_test.cc test/core/end2end/cq_verifier.cc test/core/util/cmdline.cc @@ -6602,8 +6604,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -6643,6 +6643,8 @@ if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_executable(bad_ssl_cert_test + src/core/lib/gpr/subprocess_posix.cc + src/core/lib/gpr/subprocess_windows.cc test/core/bad_ssl/bad_ssl_test.cc test/core/end2end/cq_verifier.cc test/core/util/cmdline.cc @@ -6654,8 +6656,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -7211,8 +7211,6 @@ add_executable(buffer_list_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -7453,6 +7451,43 @@ target_link_libraries(call_host_override_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(call_tracer_test + test/core/channel/call_tracer_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) +target_compile_features(call_tracer_test PUBLIC cxx_std_14) +target_include_directories(call_tracer_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(call_tracer_test + ${_gRPC_BASELIB_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) @@ -7651,6 +7686,7 @@ if(gRPC_BUILD_TESTS) add_executable(cancel_ares_query_test test/core/end2end/cq_verifier.cc test/core/util/fake_udp_and_tcp_server.cc + test/core/util/socket_use_after_close_detector.cc test/cpp/naming/cancel_ares_query_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -7970,8 +8006,6 @@ add_executable(cel_authorization_engine_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -8306,8 +8340,6 @@ add_executable(channel_creds_registry_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -8603,8 +8635,6 @@ add_executable(check_gcp_environment_linux_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -8652,8 +8682,6 @@ add_executable(check_gcp_environment_windows_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -8750,7 +8778,6 @@ target_link_libraries(chunked_vector_test absl::hash absl::type_traits absl::statusor - absl::utility gpr upb ) @@ -8997,70 +9024,6 @@ target_link_libraries(client_channel_service_config_test ) -endif() -if(gRPC_BUILD_TESTS) -if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) - - add_executable(client_channel_stress_test - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/lb/v1/load_balancer.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/duplicate/echo_duplicate.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/echo_messages.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/simple_messages.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/simple_messages.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/simple_messages.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/simple_messages.grpc.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.cc - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.pb.h - ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/orca_load_report.grpc.pb.h - test/cpp/client/client_channel_stress_test.cc - test/cpp/end2end/test_service_impl.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc - ) - target_compile_features(client_channel_stress_test PUBLIC cxx_std_14) - target_include_directories(client_channel_stress_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_RE2_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_XXHASH_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - third_party/googletest/googletest/include - third_party/googletest/googletest - third_party/googletest/googlemock/include - third_party/googletest/googlemock - ${_gRPC_PROTO_GENS_DIR} - ) - - target_link_libraries(client_channel_stress_test - ${_gRPC_BASELIB_LIBRARIES} - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ZLIB_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc++_test_util - ) - - -endif() endif() if(gRPC_BUILD_TESTS) @@ -9359,8 +9322,6 @@ add_executable(cmdline_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -9485,8 +9446,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -9809,8 +9768,6 @@ add_executable(connectivity_state_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -10872,8 +10829,6 @@ add_executable(endpoint_pair_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -11009,8 +10964,6 @@ add_executable(error_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -11058,8 +11011,6 @@ add_executable(error_utils_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -11107,8 +11058,6 @@ add_executable(evaluate_args_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -11368,10 +11317,53 @@ target_link_libraries(exec_ctx_wakeup_scheduler_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(experiments_tag_test + src/core/lib/experiments/config.cc + src/core/lib/experiments/experiments.cc + test/core/experiments/experiments_tag_test.cc + test/core/experiments/fixtures/experiments.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) +target_compile_features(experiments_tag_test PUBLIC cxx_std_14) +target_include_directories(experiments_tag_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(experiments_tag_test + ${_gRPC_BASELIB_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + absl::statusor + gpr +) + + endif() if(gRPC_BUILD_TESTS) add_executable(experiments_test + src/core/lib/experiments/config.cc + src/core/lib/experiments/experiments.cc test/core/experiments/experiments_test.cc test/core/experiments/fixtures/experiments.cc third_party/googletest/googletest/src/gtest-all.cc @@ -11402,7 +11394,7 @@ target_link_libraries(experiments_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util + gpr ) @@ -11634,8 +11626,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -12120,7 +12110,6 @@ target_link_libraries(flow_control_test absl::hash absl::type_traits absl::statusor - absl::utility gpr upb ) @@ -12239,6 +12228,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(forkable_test + src/core/lib/debug/trace.cc src/core/lib/event_engine/forkable.cc test/core/event_engine/forkable_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -12269,6 +12259,7 @@ target_link_libraries(forkable_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} + absl::statusor gpr ) @@ -12291,8 +12282,6 @@ add_executable(format_request_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -12452,8 +12441,10 @@ add_executable(frame_test src/core/lib/debug/stats.cc src/core/lib/debug/stats_data.cc src/core/lib/debug/trace.cc + src/core/lib/event_engine/ares_resolver.cc src/core/lib/event_engine/cf_engine/cf_engine.cc src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc + src/core/lib/event_engine/cf_engine/dns_service_resolver.cc src/core/lib/event_engine/channel_args_endpoint_config.cc src/core/lib/event_engine/default_event_engine.cc src/core/lib/event_engine/default_event_engine_factory.cc @@ -12675,6 +12666,7 @@ target_link_libraries(frame_test ${_gRPC_BASELIB_LIBRARIES} ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_CARES_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} absl::cleanup absl::flat_hash_map @@ -12974,8 +12966,6 @@ add_executable(grpc_alts_credentials_options_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -13061,8 +13051,6 @@ add_executable(grpc_authorization_engine_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -13110,8 +13098,6 @@ add_executable(grpc_authorization_policy_provider_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -13471,8 +13457,6 @@ add_executable(grpc_ipv6_loopback_available_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -13730,8 +13714,6 @@ add_executable(grpc_tls_certificate_distributor_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -13779,8 +13761,6 @@ add_executable(grpc_tls_certificate_provider_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -13828,8 +13808,6 @@ add_executable(grpc_tls_certificate_verifier_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -13877,8 +13855,6 @@ add_executable(grpc_tls_credentials_options_comparator_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -13926,8 +13902,6 @@ add_executable(grpc_tls_credentials_options_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -14532,8 +14506,6 @@ add_executable(histogram_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -14618,8 +14590,6 @@ add_executable(hpack_encoder_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -14667,8 +14637,6 @@ add_executable(hpack_parser_table_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -14716,8 +14684,6 @@ add_executable(hpack_parser_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -15228,8 +15194,6 @@ add_executable(insecure_security_connector_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -15327,7 +15291,6 @@ target_link_libraries(interceptor_list_test absl::hash absl::type_traits absl::statusor - absl::utility gpr upb ) @@ -15737,8 +15700,6 @@ add_executable(json_token_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -15786,8 +15747,6 @@ add_executable(jwt_verifier_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -16266,7 +16225,6 @@ target_link_libraries(loop_test ${_gRPC_ALLTARGETS_LIBRARIES} absl::type_traits absl::statusor - absl::utility gpr ) @@ -16392,8 +16350,6 @@ add_executable(matchers_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -16763,8 +16719,6 @@ add_executable(message_compress_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -16849,8 +16803,6 @@ add_executable(metadata_map_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -17941,8 +17893,6 @@ add_executable(parser_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -18206,8 +18156,6 @@ add_executable(pid_controller_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -18241,6 +18189,53 @@ target_link_libraries(pid_controller_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(ping_abuse_policy_test + test/core/transport/chttp2/ping_abuse_policy_test.cc + test/core/util/cmdline.cc + test/core/util/fuzzer_util.cc + test/core/util/grpc_profiler.cc + test/core/util/histogram.cc + test/core/util/mock_endpoint.cc + test/core/util/parse_hexstring.cc + test/core/util/passthru_endpoint.cc + test/core/util/resolve_localhost_ip46.cc + test/core/util/slice_splitter.cc + test/core/util/tracer_util.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) +target_compile_features(ping_abuse_policy_test PUBLIC cxx_std_14) +target_include_directories(ping_abuse_policy_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(ping_abuse_policy_test + ${_gRPC_BASELIB_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) @@ -18255,8 +18250,6 @@ add_executable(ping_configuration_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -18338,6 +18331,53 @@ target_link_libraries(ping_pong_streaming_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(ping_rate_policy_test + test/core/transport/chttp2/ping_rate_policy_test.cc + test/core/util/cmdline.cc + test/core/util/fuzzer_util.cc + test/core/util/grpc_profiler.cc + test/core/util/histogram.cc + test/core/util/mock_endpoint.cc + test/core/util/parse_hexstring.cc + test/core/util/passthru_endpoint.cc + test/core/util/resolve_localhost_ip46.cc + test/core/util/slice_splitter.cc + test/core/util/tracer_util.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) +target_compile_features(ping_rate_policy_test PUBLIC cxx_std_14) +target_include_directories(ping_rate_policy_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(ping_rate_policy_test + ${_gRPC_BASELIB_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) @@ -18650,8 +18690,11 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/core/event_engine/test_suite/posix/oracle_event_engine_posix.cc test/core/event_engine/test_suite/posix_event_engine_test.cc test/core/event_engine/test_suite/tests/client_test.cc + test/core/event_engine/test_suite/tests/dns_test.cc test/core/event_engine/test_suite/tests/server_test.cc test/core/event_engine/test_suite/tests/timer_test.cc + test/core/util/fake_udp_and_tcp_server.cc + test/cpp/util/get_grpc_test_runfile_dir.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) @@ -18681,7 +18724,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} grpc_unsecure - grpc_test_util + grpc++_test_util ) @@ -19430,8 +19473,6 @@ add_executable(rbac_translator_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -19738,8 +19779,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -19790,8 +19829,6 @@ add_executable(resolve_address_using_ares_resolver_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -19841,8 +19878,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -19893,8 +19928,6 @@ add_executable(resolve_address_using_native_resolver_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -22001,8 +22034,6 @@ add_executable(secure_endpoint_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -22050,8 +22081,6 @@ add_executable(security_connector_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -22119,7 +22148,6 @@ target_link_libraries(seq_test ${_gRPC_ZLIB_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} absl::type_traits - absl::utility gpr ) @@ -22249,8 +22277,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/cpp/server/server_builder_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -22317,8 +22343,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/cpp/server/server_builder_with_socket_mutator_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -22729,8 +22753,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/cpp/server/server_request_call_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -23001,8 +23023,6 @@ add_executable(settings_timeout_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -23615,8 +23635,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -23738,8 +23756,6 @@ add_executable(ssl_credentials_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -24018,8 +24034,6 @@ add_executable(status_conversion_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -24143,8 +24157,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -24338,8 +24350,6 @@ add_executable(streams_not_seen_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -24499,8 +24509,6 @@ add_executable(system_roots_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -24590,8 +24598,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -24681,8 +24687,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -24732,8 +24736,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -25157,8 +25159,6 @@ add_executable(test_core_iomgr_load_file_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -25206,8 +25206,6 @@ add_executable(test_core_iomgr_timer_heap_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -25255,8 +25253,6 @@ add_executable(test_core_security_credentials_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -25864,8 +25860,6 @@ add_executable(timeout_encoding_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -26080,8 +26074,6 @@ add_executable(tls_security_connector_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -26527,7 +26519,6 @@ target_link_libraries(try_seq_test ${_gRPC_ALLTARGETS_LIBRARIES} absl::type_traits absl::statusor - absl::utility gpr ) @@ -27396,8 +27387,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc test/cpp/performance/writes_per_rpc_test.cc third_party/googletest/googletest/src/gtest-all.cc @@ -28418,8 +28407,6 @@ add_executable(xds_credentials_test test/core/util/passthru_endpoint.cc test/core/util/resolve_localhost_ip46.cc test/core/util/slice_splitter.cc - test/core/util/subprocess_posix.cc - test/core/util/subprocess_windows.cc test/core/util/tracer_util.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -29214,6 +29201,7 @@ add_executable(xds_interop_client src/cpp/server/csds/csds.cc test/cpp/interop/rpc_behavior_lb_policy.cc test/cpp/interop/xds_interop_client.cc + test/cpp/interop/xds_stats_watcher.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc ) @@ -30897,6 +30885,78 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) endif() +endif() +if(gRPC_BUILD_TESTS) + +add_executable(xds_stats_watcher_test + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/empty.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/messages.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/test.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/base.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/config_dump.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/csds.grpc.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.cc + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.pb.h + ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/xds/v3/percent.grpc.pb.h + src/cpp/server/admin/admin_services.cc + src/cpp/server/csds/csds.cc + test/cpp/interop/rpc_behavior_lb_policy.cc + test/cpp/interop/xds_stats_watcher.cc + test/cpp/interop/xds_stats_watcher_test.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) +target_compile_features(xds_stats_watcher_test PUBLIC cxx_std_14) +target_include_directories(xds_stats_watcher_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(xds_stats_watcher_test + ${_gRPC_BASELIB_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc++_reflection + grpcpp_channelz + grpc_test_util + grpc++_test_config +) + + endif() if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) diff --git a/Makefile b/Makefile index 2d51656900209..b0aad729c8fd2 100644 --- a/Makefile +++ b/Makefile @@ -410,9 +410,9 @@ E = @echo Q = @ endif -CORE_VERSION = 33.0.0 -CPP_VERSION = 1.57.0-dev -CSHARP_VERSION = 2.57.0-dev +CORE_VERSION = 34.0.0 +CPP_VERSION = 1.58.0-dev +CSHARP_VERSION = 2.58.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) @@ -448,7 +448,7 @@ SHARED_EXT_CORE = dll SHARED_EXT_CPP = dll SHARED_EXT_CSHARP = dll SHARED_PREFIX = -SHARED_VERSION_CORE = -33 +SHARED_VERSION_CORE = -34 SHARED_VERSION_CPP = -1 SHARED_VERSION_CSHARP = -2 else ifeq ($(SYSTEM),Darwin) @@ -826,8 +826,8 @@ $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.33 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.33 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.34 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.34 $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so endif endif @@ -948,8 +948,8 @@ $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.33 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.33 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.34 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.34 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so endif endif @@ -1065,6 +1065,8 @@ LIBGRPC_SRC = \ src/core/ext/transport/chttp2/transport/http_trace.cc \ src/core/ext/transport/chttp2/transport/huffsyms.cc \ src/core/ext/transport/chttp2/transport/parsing.cc \ + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc \ + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ @@ -1435,8 +1437,10 @@ LIBGRPC_SRC = \ src/core/lib/debug/stats.cc \ src/core/lib/debug/stats_data.cc \ src/core/lib/debug/trace.cc \ + src/core/lib/event_engine/ares_resolver.cc \ src/core/lib/event_engine/cf_engine/cf_engine.cc \ src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc \ + src/core/lib/event_engine/cf_engine/dns_service_resolver.cc \ src/core/lib/event_engine/channel_args_endpoint_config.cc \ src/core/lib/event_engine/default_event_engine.cc \ src/core/lib/event_engine/default_event_engine_factory.cc \ @@ -1751,6 +1755,7 @@ PUBLIC_HEADERS_C += \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ + include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ @@ -1838,8 +1843,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.33 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.33 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.34 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.34 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif endif @@ -1943,6 +1948,8 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/transport/chttp2/transport/http_trace.cc \ src/core/ext/transport/chttp2/transport/huffsyms.cc \ src/core/ext/transport/chttp2/transport/parsing.cc \ + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc \ + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ @@ -1993,8 +2000,10 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/debug/stats.cc \ src/core/lib/debug/stats_data.cc \ src/core/lib/debug/trace.cc \ + src/core/lib/event_engine/ares_resolver.cc \ src/core/lib/event_engine/cf_engine/cf_engine.cc \ src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc \ + src/core/lib/event_engine/cf_engine/dns_service_resolver.cc \ src/core/lib/event_engine/channel_args_endpoint_config.cc \ src/core/lib/event_engine/default_event_engine.cc \ src/core/lib/event_engine/default_event_engine_factory.cc \ @@ -2250,6 +2259,7 @@ PUBLIC_HEADERS_C += \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ + include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ @@ -2327,8 +2337,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.33 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.33 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.34 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.34 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so endif endif @@ -2756,8 +2766,8 @@ $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBUPB_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libupb.so.33 -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so.33 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libupb.so.34 -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so.34 $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so endif endif @@ -2998,9 +3008,15 @@ LIBGRPC_ABSEIL_SRC = \ third_party/abseil-cpp/absl/synchronization/barrier.cc \ third_party/abseil-cpp/absl/synchronization/blocking_counter.cc \ third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc \ + third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc \ third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc \ + third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc \ third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc \ - third_party/abseil-cpp/absl/synchronization/internal/waiter.cc \ + third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc \ + third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc \ + third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc \ + third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc \ + third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc \ third_party/abseil-cpp/absl/synchronization/mutex.cc \ third_party/abseil-cpp/absl/synchronization/notification.cc \ third_party/abseil-cpp/absl/time/civil_time.cc \ diff --git a/Package.swift b/Package.swift index 9c40122a6737d..afeb98b7f1cc2 100644 --- a/Package.swift +++ b/Package.swift @@ -60,6 +60,7 @@ let package = Package( "include/grpc/grpc_posix.h", "include/grpc/grpc_security.h", "include/grpc/grpc_security_constants.h", + "include/grpc/impl/channel_arg_names.h", "include/grpc/impl/codegen/atm.h", "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", @@ -309,6 +310,10 @@ let package = Package( "src/core/ext/transport/chttp2/transport/huffsyms.h", "src/core/ext/transport/chttp2/transport/internal.h", "src/core/ext/transport/chttp2/transport/parsing.cc", + "src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc", + "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h", + "src/core/ext/transport/chttp2/transport/ping_rate_policy.cc", + "src/core/ext/transport/chttp2/transport/ping_rate_policy.h", "src/core/ext/transport/chttp2/transport/stream_lists.cc", "src/core/ext/transport/chttp2/transport/varint.cc", "src/core/ext/transport/chttp2/transport/varint.h", @@ -1057,11 +1062,15 @@ let package = Package( "src/core/lib/debug/stats_data.h", "src/core/lib/debug/trace.cc", "src/core/lib/debug/trace.h", + "src/core/lib/event_engine/ares_resolver.cc", + "src/core/lib/event_engine/ares_resolver.h", "src/core/lib/event_engine/cf_engine/cf_engine.cc", "src/core/lib/event_engine/cf_engine/cf_engine.h", "src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc", "src/core/lib/event_engine/cf_engine/cfstream_endpoint.h", "src/core/lib/event_engine/cf_engine/cftype_unique_ref.h", + "src/core/lib/event_engine/cf_engine/dns_service_resolver.cc", + "src/core/lib/event_engine/cf_engine/dns_service_resolver.h", "src/core/lib/event_engine/channel_args_endpoint_config.cc", "src/core/lib/event_engine/channel_args_endpoint_config.h", "src/core/lib/event_engine/common_closures.h", @@ -1072,6 +1081,7 @@ let package = Package( "src/core/lib/event_engine/event_engine.cc", "src/core/lib/event_engine/forkable.cc", "src/core/lib/event_engine/forkable.h", + "src/core/lib/event_engine/grpc_polled_fd.h", "src/core/lib/event_engine/handle_containers.h", "src/core/lib/event_engine/memory_allocator.cc", "src/core/lib/event_engine/memory_allocator_factory.h", @@ -1084,6 +1094,7 @@ let package = Package( "src/core/lib/event_engine/posix_engine/event_poller.h", "src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc", "src/core/lib/event_engine/posix_engine/event_poller_posix_default.h", + "src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h", "src/core/lib/event_engine/posix_engine/internal_errqueue.cc", "src/core/lib/event_engine/posix_engine/internal_errqueue.h", "src/core/lib/event_engine/posix_engine/lockfree_event.cc", @@ -1433,12 +1444,11 @@ let package = Package( "src/core/lib/promise/arena_promise.h", "src/core/lib/promise/cancel_callback.h", "src/core/lib/promise/context.h", - "src/core/lib/promise/detail/basic_join.h", "src/core/lib/promise/detail/basic_seq.h", "src/core/lib/promise/detail/promise_factory.h", "src/core/lib/promise/detail/promise_like.h", + "src/core/lib/promise/detail/seq_state.h", "src/core/lib/promise/detail/status.h", - "src/core/lib/promise/detail/switch.h", "src/core/lib/promise/exec_ctx_wakeup_scheduler.h", "src/core/lib/promise/for_each.h", "src/core/lib/promise/if.h", @@ -1458,7 +1468,6 @@ let package = Package( "src/core/lib/promise/sleep.h", "src/core/lib/promise/trace.cc", "src/core/lib/promise/trace.h", - "src/core/lib/promise/try_join.h", "src/core/lib/promise/try_seq.h", "src/core/lib/resolver/resolver.cc", "src/core/lib/resolver/resolver.h", diff --git a/_metadata.py b/_metadata.py index 49cc3f9ffb1ee..e54817b24d1b9 100644 --- a/_metadata.py +++ b/_metadata.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/_metadata.py.template`!!! -__version__ = """1.57.0.dev0""" +__version__ = """1.58.0.dev0""" diff --git a/bazel/experiments.bzl b/bazel/experiments.bzl index 244ac830a4941..878d0fb6906c7 100644 --- a/bazel/experiments.bzl +++ b/bazel/experiments.bzl @@ -17,50 +17,158 @@ """Dictionary of tags to experiments so we know when to test different experiments.""" EXPERIMENTS = { - "dbg": { + "windows": { + "dbg": { + }, + "off": { + "census_test": [ + "transport_supplies_client_latency", + ], + "core_end2end_test": [ + "event_engine_listener", + "promise_based_client_call", + "promise_based_server_call", + ], + "cpp_end2end_test": [ + "promise_based_server_call", + ], + "endpoint_test": [ + "tcp_frame_size_tuning", + "tcp_rcv_lowat", + ], + "event_engine_listener_test": [ + "event_engine_listener", + ], + "flow_control_test": [ + "peer_state_based_framing", + "tcp_frame_size_tuning", + "tcp_rcv_lowat", + ], + "lame_client_test": [ + "promise_based_client_call", + ], + "logging_test": [ + "promise_based_server_call", + ], + "resource_quota_test": [ + "free_large_allocator", + "memory_pressure_controller", + "unconstrained_max_quota_buffer_size", + ], + "xds_end2end_test": [ + "promise_based_server_call", + ], + }, + "on": { + "core_end2end_test": [ + "work_stealing", + ], + }, }, - "off": { - "census_test": [ - "transport_supplies_client_latency", - ], - "core_end2end_test": [ - "event_engine_client", - "event_engine_listener", - "promise_based_client_call", - "promise_based_server_call", - "unique_metadata_strings", - "work_stealing", - ], - "cpp_end2end_test": [ - "promise_based_server_call", - ], - "endpoint_test": [ - "tcp_frame_size_tuning", - "tcp_rcv_lowat", - ], - "event_engine_client_test": [ - "event_engine_client", - ], - "event_engine_listener_test": [ - "event_engine_listener", - ], - "flow_control_test": [ - "peer_state_based_framing", - "tcp_frame_size_tuning", - "tcp_rcv_lowat", - ], - "lame_client_test": [ - "promise_based_client_call", - ], - "resource_quota_test": [ - "free_large_allocator", - "memory_pressure_controller", - "unconstrained_max_quota_buffer_size", - ], - "xds_end2end_test": [ - "promise_based_server_call", - ], + "ios": { + "dbg": { + }, + "off": { + "census_test": [ + "transport_supplies_client_latency", + ], + "core_end2end_test": [ + "event_engine_listener", + "promise_based_client_call", + "promise_based_server_call", + ], + "cpp_end2end_test": [ + "promise_based_server_call", + ], + "endpoint_test": [ + "tcp_frame_size_tuning", + "tcp_rcv_lowat", + ], + "event_engine_listener_test": [ + "event_engine_listener", + ], + "flow_control_test": [ + "peer_state_based_framing", + "tcp_frame_size_tuning", + "tcp_rcv_lowat", + ], + "lame_client_test": [ + "promise_based_client_call", + ], + "logging_test": [ + "promise_based_server_call", + ], + "resource_quota_test": [ + "free_large_allocator", + "memory_pressure_controller", + "unconstrained_max_quota_buffer_size", + ], + "xds_end2end_test": [ + "promise_based_server_call", + ], + }, + "on": { + "core_end2end_test": [ + "work_stealing", + ], + }, }, - "on": { + "posix": { + "dbg": { + }, + "off": { + "cancel_ares_query_test": [ + "event_engine_dns", + ], + "census_test": [ + "transport_supplies_client_latency", + ], + "core_end2end_test": [ + "event_engine_client", + "event_engine_listener", + "promise_based_client_call", + "promise_based_server_call", + ], + "cpp_end2end_test": [ + "promise_based_server_call", + ], + "endpoint_test": [ + "tcp_frame_size_tuning", + "tcp_rcv_lowat", + ], + "event_engine_client_test": [ + "event_engine_client", + ], + "event_engine_listener_test": [ + "event_engine_listener", + ], + "flow_control_test": [ + "peer_state_based_framing", + "tcp_frame_size_tuning", + "tcp_rcv_lowat", + ], + "lame_client_test": [ + "promise_based_client_call", + ], + "logging_test": [ + "promise_based_server_call", + ], + "resolver_component_tests_runner_invoker": [ + "event_engine_dns", + ], + "resource_quota_test": [ + "free_large_allocator", + "memory_pressure_controller", + "unconstrained_max_quota_buffer_size", + ], + "xds_end2end_test": [ + "promise_based_server_call", + ], + }, + "on": { + "core_end2end_test": [ + "work_stealing", + ], + }, }, } diff --git a/tools/internal_ci/linux/grpc_xds_v3_php.sh b/bazel/googleapis.BUILD old mode 100755 new mode 100644 similarity index 58% rename from tools/internal_ci/linux/grpc_xds_v3_php.sh rename to bazel/googleapis.BUILD index 0a92be4f7a310..dc7e05f742428 --- a/tools/internal_ci/linux/grpc_xds_v3_php.sh +++ b/bazel/googleapis.BUILD @@ -1,5 +1,4 @@ -#!/usr/bin/env bash -# Copyright 2021 gRPC authors. +# Copyright 2023 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,13 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -ex +licenses(["notice"]) -# change to grpc repo root -cd $(dirname $0)/../../.. +package( + default_visibility = ["//visibility:public"] +) -source tools/internal_ci/helper_scripts/prepare_build_linux_rc - -export DOCKERFILE_DIR=tools/dockerfile/test/php73_zts_debian11_x64 -export DOCKER_RUN_SCRIPT=tools/internal_ci/linux/grpc_xds_v3_php_test_in_docker.sh -exec tools/run_tests/dockerize/build_and_run_docker.sh +# This is needed for the dependency on google_cloud_cpp to work. +# Taken from https://github.com/googleapis/google-cloud-cpp/blob/2839e9dba793ca023e11ea67f201f66f74fa7d3e/bazel/googleapis.BUILD +cc_library( + name = "googleapis_system_includes", + includes = [ + ".", + ], +) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 107a655e8341d..7d3a9e256003e 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -30,6 +30,7 @@ Contains macros used throughout the repo. load("//bazel:cc_grpc_library.bzl", "cc_grpc_library") load("//bazel:copts.bzl", "GRPC_DEFAULT_COPTS") load("//bazel:experiments.bzl", "EXPERIMENTS") +load("//bazel:test_experiments.bzl", "TEST_EXPERIMENTS") load("@upb//bazel:upb_proto_library.bzl", "upb_proto_library", "upb_proto_reflection_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") load("@build_bazel_rules_apple//apple/testing/default_runner:ios_test_runner.bzl", "ios_test_runner") @@ -74,6 +75,8 @@ def _get_external_deps(external_deps): ret.append("@com_google_googleapis//" + dep) elif dep.startswith("otel/"): ret.append(dep.replace("otel/", "@io_opentelemetry_cpp//")) + elif dep.startswith("google_cloud_cpp"): + ret.append(dep.replace("google_cloud_cpp", "@google_cloud_cpp//")) else: ret.append("//external:" + dep) return ret @@ -98,6 +101,7 @@ def _update_visibility(visibility): "endpoint_tests": PRIVATE, "exec_ctx": PRIVATE, "grpclb": PRIVATE, + "grpc_experiments": PRIVATE, "grpc_opencensus_plugin": PUBLIC, "grpcpp_gcp_observability": PUBLIC, "grpc_resolver_fake": PRIVATE, @@ -365,18 +369,26 @@ def expand_tests(name, srcs, deps, tags, args, exclude_pollers, uses_polling, us }) experiments = {} - for mode, tag_to_experiments in EXPERIMENTS.items(): - experiments[mode] = {} - for tag in tags: - if tag not in tag_to_experiments: - continue - for experiment in tag_to_experiments[tag]: - experiments[mode][experiment] = 1 - experiments[mode] = list(experiments[mode].keys()) + + # buildifier: disable=uninitialized + def _populate_experiments_platform_config(config, platform_experiments_map): + for platform, experiments_on_platform in platform_experiments_map.items(): + for mode, tag_to_experiments in experiments_on_platform.items(): + if mode not in config: + config[mode] = {} + for tag in tags: + if tag not in tag_to_experiments: + continue + for experiment in tag_to_experiments[tag]: + if experiment not in config[mode]: + config[mode][experiment] = [] + config[mode][experiment].append(platform) + + _populate_experiments_platform_config(experiments, EXPERIMENTS) + _populate_experiments_platform_config(experiments, TEST_EXPERIMENTS) mode_config = { # format: : (enabled_target_tags, disabled_target_tags) - "dbg": (["noopt"], ["nodbg"]), "on": (None, []), "off": ([], None), } @@ -384,18 +396,31 @@ def expand_tests(name, srcs, deps, tags, args, exclude_pollers, uses_polling, us must_have_tags = [ # We don't run experiments on cmake builds "bazel_only", - # Nor on windows - "no_windows", # Nor on mac "no_mac", # Nor on arm64 "no_arm64", ] + + def _update_experiments_platform_test_tags(tags, platforms): + if "posix" not in platforms: + if "no_linux" not in tags: + tags.append("no_linux") + if "no_mac" not in tags: + tags.append("no_mac") + if "windows" not in platforms: + if "no_windows" not in tags: + tags.append("no_windows") + if "ios" not in platforms: + if "no_test_ios" not in tags: + tags.append("no_test_ios") + return tags + experiment_config = list(poller_config) for mode, config in mode_config.items(): enabled_tags, disabled_tags = config if enabled_tags != None: - for experiment in experiments[mode]: + for experiment in experiments[mode].keys(): for config in poller_config: config = dict(config) config["name"] = config["name"] + "@experiment=" + experiment @@ -406,11 +431,11 @@ def expand_tests(name, srcs, deps, tags, args, exclude_pollers, uses_polling, us for tag in must_have_tags + enabled_tags: if tag not in tags: tags = tags + [tag] - config["tags"] = tags + config["tags"] = _update_experiments_platform_test_tags(tags, experiments[mode][experiment]) config["flaky"] = True experiment_config.append(config) if disabled_tags != None: - for experiment in experiments[mode]: + for experiment in experiments[mode].keys(): for config in poller_config: config = dict(config) config["name"] = config["name"] + "@experiment=no_" + experiment @@ -421,7 +446,7 @@ def expand_tests(name, srcs, deps, tags, args, exclude_pollers, uses_polling, us for tag in must_have_tags + disabled_tags: if tag not in tags: tags = tags + [tag] - config["tags"] = tags + config["tags"] = _update_experiments_platform_test_tags(tags, experiments[mode][experiment]) experiment_config.append(config) return experiment_config diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 7b124cc170bf8..042ab61204181 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -195,16 +195,6 @@ def grpc_deps(): actual = "@io_opencensus_cpp//opencensus/exporters/stats/stackdriver:stackdriver_exporter", ) - native.bind( - name = "libuv", - actual = "@com_github_libuv_libuv//:libuv", - ) - - native.bind( - name = "libuv_test", - actual = "@com_github_libuv_libuv//:libuv_test", - ) - native.bind( name = "googleapis_trace_grpc_service", actual = "@com_google_googleapis//google/devtools/cloudtrace/v2:cloudtrace_cc_grpc", @@ -338,11 +328,11 @@ def grpc_deps(): if "com_google_absl" not in native.existing_rules(): http_archive( name = "com_google_absl", - sha256 = "5366d7e7fa7ba0d915014d387b66d0d002c03236448e1ba9ef98122c13b35c36", - strip_prefix = "abseil-cpp-20230125.3", + sha256 = "59d2976af9d6ecf001a81a35749a6e551a335b949d34918cfade07737b9d93c5", + strip_prefix = "abseil-cpp-20230802.0", urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz", - "https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz", + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/abseil/abseil-cpp/archive/20230802.0.tar.gz", + "https://github.com/abseil/abseil-cpp/archive/20230802.0.tar.gz", ], ) @@ -443,23 +433,12 @@ def grpc_deps(): ], ) - if "com_github_libuv_libuv" not in native.existing_rules(): - http_archive( - name = "com_github_libuv_libuv", - build_file = "@com_github_grpc_grpc//third_party:libuv.BUILD", - sha256 = "5ca4e9091f3231d8ad8801862dc4e851c23af89c69141d27723157776f7291e7", - strip_prefix = "libuv-02a9e1be252b623ee032a3137c0b0c94afbe6809", - urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/libuv/libuv/archive/02a9e1be252b623ee032a3137c0b0c94afbe6809.tar.gz", - "https://github.com/libuv/libuv/archive/02a9e1be252b623ee032a3137c0b0c94afbe6809.tar.gz", - ], - ) - if "com_google_googleapis" not in native.existing_rules(): http_archive( name = "com_google_googleapis", sha256 = "5bb6b0253ccf64b53d6c7249625a7e3f6c3bc6402abd52d3778bfa48258703a0", strip_prefix = "googleapis-2f9af297c84c55c8b871ba4495e01ade42476c92", + build_file = "//bazel:googleapis.BUILD", urls = [ "https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz", "https://github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz", @@ -521,6 +500,17 @@ def grpc_deps(): ], ) + if "google_cloud_cpp" not in native.existing_rules(): + http_archive( + name = "google_cloud_cpp", + sha256 = "371d01b03c7e2604d671b8fa1c86710abe3b524a78bc2705a6bb4de715696755", + strip_prefix = "google-cloud-cpp-2.14.0", + urls = [ + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.14.0.tar.gz", + "https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.14.0.tar.gz", + ], + ) + grpc_python_deps() # TODO: move some dependencies from "grpc_deps" here? @@ -555,11 +545,11 @@ def grpc_test_only_deps(): if "com_github_yaml_pyyaml" not in native.existing_rules(): http_archive( name = "com_github_yaml_pyyaml", - sha256 = "6b4314b1b2051ddb9d4fcd1634e1fa9c1bb4012954273c9ff3ef689f6ec6c93e", - strip_prefix = "pyyaml-3.12", + sha256 = "e34d97db6d846f5e2ad51417fd646e7ce6a3a70726ccea2a857e0580a7155f39", + strip_prefix = "pyyaml-6.0.1", urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/yaml/pyyaml/archive/3.12.zip", - "https://github.com/yaml/pyyaml/archive/3.12.zip", + "https://storage.googleapis.com/grpc-bazel-mirror/github.com/yaml/pyyaml/archive/6.0.1.zip", + "https://github.com/yaml/pyyaml/archive/6.0.1.zip", ], build_file = "@com_github_grpc_grpc//third_party:yaml.BUILD", ) diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl index 4d8afa3131a65..e57aa968eaffc 100644 --- a/bazel/grpc_extra_deps.bzl +++ b/bazel/grpc_extra_deps.bzl @@ -20,6 +20,7 @@ load("@com_envoyproxy_protoc_gen_validate//:dependencies.bzl", "go_third_party") load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@envoy_api//bazel:repositories.bzl", "api_dependencies") +load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps") load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") load("@upb//bazel:workspace_deps.bzl", "upb_deps") @@ -71,3 +72,5 @@ def grpc_extra_deps(ignore_version_differences = False): grpc = True, python = True, ) + + google_cloud_cpp_deps() diff --git a/bazel/test_experiments.bzl b/bazel/test_experiments.bzl new file mode 100644 index 0000000000000..21c52e747ad60 --- /dev/null +++ b/bazel/test_experiments.bzl @@ -0,0 +1,50 @@ +# Copyright 2023 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. + +# Auto generated by tools/codegen/core/gen_experiments.py + +"""Dictionary of tags to experiments so we know when to test different experiments.""" + +TEST_EXPERIMENTS = { + "windows": { + "dbg": { + }, + "off": { + "experiments_tag_test": [ + "test_experiment_1", + ], + }, + "on": { + }, + }, + "ios": { + "dbg": { + }, + "off": { + }, + "on": { + }, + }, + "posix": { + "dbg": { + }, + "off": { + }, + "on": { + "experiments_tag_test": [ + "test_experiment_1", + ], + }, + }, +} diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index f8a523b124c13..e780ca50f6d77 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -161,6 +161,7 @@ libs: - include/grpc/grpc_posix.h - include/grpc/grpc_security.h - include/grpc/grpc_security_constants.h + - include/grpc/impl/channel_arg_names.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h @@ -307,6 +308,8 @@ libs: - src/core/ext/transport/chttp2/transport/http_trace.h - src/core/ext/transport/chttp2/transport/huffsyms.h - src/core/ext/transport/chttp2/transport/internal.h + - src/core/ext/transport/chttp2/transport/ping_abuse_policy.h + - src/core/ext/transport/chttp2/transport/ping_rate_policy.h - src/core/ext/transport/chttp2/transport/varint.h - src/core/ext/transport/inproc/inproc_transport.h - src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h @@ -680,14 +683,17 @@ libs: - src/core/lib/debug/stats.h - src/core/lib/debug/stats_data.h - src/core/lib/debug/trace.h + - src/core/lib/event_engine/ares_resolver.h - src/core/lib/event_engine/cf_engine/cf_engine.h - src/core/lib/event_engine/cf_engine/cfstream_endpoint.h - src/core/lib/event_engine/cf_engine/cftype_unique_ref.h + - src/core/lib/event_engine/cf_engine/dns_service_resolver.h - src/core/lib/event_engine/channel_args_endpoint_config.h - src/core/lib/event_engine/common_closures.h - src/core/lib/event_engine/default_event_engine.h - src/core/lib/event_engine/default_event_engine_factory.h - src/core/lib/event_engine/forkable.h + - src/core/lib/event_engine/grpc_polled_fd.h - src/core/lib/event_engine/handle_containers.h - src/core/lib/event_engine/memory_allocator_factory.h - src/core/lib/event_engine/poller.h @@ -696,6 +702,7 @@ libs: - src/core/lib/event_engine/posix_engine/ev_poll_posix.h - src/core/lib/event_engine/posix_engine/event_poller.h - src/core/lib/event_engine/posix_engine/event_poller_posix_default.h + - src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h - src/core/lib/event_engine/posix_engine/internal_errqueue.h - src/core/lib/event_engine/posix_engine/lockfree_event.h - src/core/lib/event_engine/posix_engine/posix_endpoint.h @@ -847,12 +854,11 @@ libs: - src/core/lib/promise/arena_promise.h - src/core/lib/promise/cancel_callback.h - src/core/lib/promise/context.h - - src/core/lib/promise/detail/basic_join.h - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/for_each.h - src/core/lib/promise/if.h @@ -869,7 +875,6 @@ libs: - src/core/lib/promise/seq.h - src/core/lib/promise/sleep.h - src/core/lib/promise/trace.h - - src/core/lib/promise/try_join.h - src/core/lib/promise/try_seq.h - src/core/lib/resolver/resolver.h - src/core/lib/resolver/resolver_factory.h @@ -1122,6 +1127,8 @@ libs: - src/core/ext/transport/chttp2/transport/http_trace.cc - src/core/ext/transport/chttp2/transport/huffsyms.cc - src/core/ext/transport/chttp2/transport/parsing.cc + - src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc + - src/core/ext/transport/chttp2/transport/ping_rate_policy.cc - src/core/ext/transport/chttp2/transport/stream_lists.cc - src/core/ext/transport/chttp2/transport/varint.cc - src/core/ext/transport/chttp2/transport/writing.cc @@ -1492,8 +1499,10 @@ libs: - src/core/lib/debug/stats.cc - src/core/lib/debug/stats_data.cc - src/core/lib/debug/trace.cc + - src/core/lib/event_engine/ares_resolver.cc - src/core/lib/event_engine/cf_engine/cf_engine.cc - src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc + - src/core/lib/event_engine/cf_engine/dns_service_resolver.cc - src/core/lib/event_engine/channel_args_endpoint_config.cc - src/core/lib/event_engine/default_event_engine.cc - src/core/lib/event_engine/default_event_engine_factory.cc @@ -1887,6 +1896,7 @@ libs: - include/grpc/grpc_posix.h - include/grpc/grpc_security.h - include/grpc/grpc_security_constants.h + - include/grpc/impl/channel_arg_names.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h @@ -2021,6 +2031,8 @@ libs: - src/core/ext/transport/chttp2/transport/http_trace.h - src/core/ext/transport/chttp2/transport/huffsyms.h - src/core/ext/transport/chttp2/transport/internal.h + - src/core/ext/transport/chttp2/transport/ping_abuse_policy.h + - src/core/ext/transport/chttp2/transport/ping_rate_policy.h - src/core/ext/transport/chttp2/transport/varint.h - src/core/ext/transport/inproc/inproc_transport.h - src/core/ext/upb-generated/google/api/annotations.upb.h @@ -2070,14 +2082,17 @@ libs: - src/core/lib/debug/stats.h - src/core/lib/debug/stats_data.h - src/core/lib/debug/trace.h + - src/core/lib/event_engine/ares_resolver.h - src/core/lib/event_engine/cf_engine/cf_engine.h - src/core/lib/event_engine/cf_engine/cfstream_endpoint.h - src/core/lib/event_engine/cf_engine/cftype_unique_ref.h + - src/core/lib/event_engine/cf_engine/dns_service_resolver.h - src/core/lib/event_engine/channel_args_endpoint_config.h - src/core/lib/event_engine/common_closures.h - src/core/lib/event_engine/default_event_engine.h - src/core/lib/event_engine/default_event_engine_factory.h - src/core/lib/event_engine/forkable.h + - src/core/lib/event_engine/grpc_polled_fd.h - src/core/lib/event_engine/handle_containers.h - src/core/lib/event_engine/memory_allocator_factory.h - src/core/lib/event_engine/poller.h @@ -2086,6 +2101,7 @@ libs: - src/core/lib/event_engine/posix_engine/ev_poll_posix.h - src/core/lib/event_engine/posix_engine/event_poller.h - src/core/lib/event_engine/posix_engine/event_poller_posix_default.h + - src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h - src/core/lib/event_engine/posix_engine/internal_errqueue.h - src/core/lib/event_engine/posix_engine/lockfree_event.h - src/core/lib/event_engine/posix_engine/posix_endpoint.h @@ -2234,12 +2250,11 @@ libs: - src/core/lib/promise/arena_promise.h - src/core/lib/promise/cancel_callback.h - src/core/lib/promise/context.h - - src/core/lib/promise/detail/basic_join.h - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/for_each.h - src/core/lib/promise/if.h @@ -2256,7 +2271,6 @@ libs: - src/core/lib/promise/seq.h - src/core/lib/promise/sleep.h - src/core/lib/promise/trace.h - - src/core/lib/promise/try_join.h - src/core/lib/promise/try_seq.h - src/core/lib/resolver/resolver.h - src/core/lib/resolver/resolver_factory.h @@ -2439,6 +2453,8 @@ libs: - src/core/ext/transport/chttp2/transport/http_trace.cc - src/core/ext/transport/chttp2/transport/huffsyms.cc - src/core/ext/transport/chttp2/transport/parsing.cc + - src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc + - src/core/ext/transport/chttp2/transport/ping_rate_policy.cc - src/core/ext/transport/chttp2/transport/stream_lists.cc - src/core/ext/transport/chttp2/transport/varint.cc - src/core/ext/transport/chttp2/transport/writing.cc @@ -2489,8 +2505,10 @@ libs: - src/core/lib/debug/stats.cc - src/core/lib/debug/stats_data.cc - src/core/lib/debug/trace.cc + - src/core/lib/event_engine/ares_resolver.cc - src/core/lib/event_engine/cf_engine/cf_engine.cc - src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc + - src/core/lib/event_engine/cf_engine/dns_service_resolver.cc - src/core/lib/event_engine/channel_args_endpoint_config.cc - src/core/lib/event_engine/default_event_engine.cc - src/core/lib/event_engine/default_event_engine_factory.cc @@ -2759,7 +2777,6 @@ libs: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h - test/cpp/microbenchmarks/fullstack_context_mutators.h - test/cpp/microbenchmarks/fullstack_fixtures.h @@ -2778,8 +2795,6 @@ libs: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/cpp/microbenchmarks/helpers.cc deps: @@ -3168,6 +3183,7 @@ libs: language: c++ public_headers: [] headers: + - src/core/lib/gpr/subprocess.h - test/core/end2end/data/ssl_test_data.h - test/core/util/cmdline.h - test/core/util/evaluate_args_test_util.h @@ -3180,7 +3196,6 @@ libs: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h - test/cpp/util/byte_buffer_proto_helper.h - test/cpp/util/create_test_channel.h @@ -3188,6 +3203,8 @@ libs: - test/cpp/util/subprocess.h - test/cpp/util/test_credentials_provider.h src: + - src/core/lib/gpr/subprocess_posix.cc + - src/core/lib/gpr/subprocess_windows.cc - test/core/end2end/data/client_certs.cc - test/core/end2end/data/server1_cert.cc - test/core/end2end/data/server1_key.cc @@ -3201,8 +3218,6 @@ libs: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/cpp/util/byte_buffer_proto_helper.cc - test/cpp/util/create_test_channel.cc @@ -3489,6 +3504,7 @@ libs: - include/grpc/grpc_posix.h - include/grpc/grpc_security.h - include/grpc/grpc_security_constants.h + - include/grpc/impl/channel_arg_names.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h @@ -3573,14 +3589,17 @@ libs: - src/core/lib/debug/stats.h - src/core/lib/debug/stats_data.h - src/core/lib/debug/trace.h + - src/core/lib/event_engine/ares_resolver.h - src/core/lib/event_engine/cf_engine/cf_engine.h - src/core/lib/event_engine/cf_engine/cfstream_endpoint.h - src/core/lib/event_engine/cf_engine/cftype_unique_ref.h + - src/core/lib/event_engine/cf_engine/dns_service_resolver.h - src/core/lib/event_engine/channel_args_endpoint_config.h - src/core/lib/event_engine/common_closures.h - src/core/lib/event_engine/default_event_engine.h - src/core/lib/event_engine/default_event_engine_factory.h - src/core/lib/event_engine/forkable.h + - src/core/lib/event_engine/grpc_polled_fd.h - src/core/lib/event_engine/handle_containers.h - src/core/lib/event_engine/memory_allocator_factory.h - src/core/lib/event_engine/poller.h @@ -3589,6 +3608,7 @@ libs: - src/core/lib/event_engine/posix_engine/ev_poll_posix.h - src/core/lib/event_engine/posix_engine/event_poller.h - src/core/lib/event_engine/posix_engine/event_poller_posix_default.h + - src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h - src/core/lib/event_engine/posix_engine/internal_errqueue.h - src/core/lib/event_engine/posix_engine/lockfree_event.h - src/core/lib/event_engine/posix_engine/posix_endpoint.h @@ -3731,12 +3751,11 @@ libs: - src/core/lib/promise/arena_promise.h - src/core/lib/promise/cancel_callback.h - src/core/lib/promise/context.h - - src/core/lib/promise/detail/basic_join.h - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/for_each.h - src/core/lib/promise/if.h @@ -3751,7 +3770,6 @@ libs: - src/core/lib/promise/race.h - src/core/lib/promise/seq.h - src/core/lib/promise/trace.h - - src/core/lib/promise/try_join.h - src/core/lib/promise/try_seq.h - src/core/lib/resolver/resolver.h - src/core/lib/resolver/resolver_factory.h @@ -3873,8 +3891,10 @@ libs: - src/core/lib/debug/stats.cc - src/core/lib/debug/stats_data.cc - src/core/lib/debug/trace.cc + - src/core/lib/event_engine/ares_resolver.cc - src/core/lib/event_engine/cf_engine/cf_engine.cc - src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc + - src/core/lib/event_engine/cf_engine/dns_service_resolver.cc - src/core/lib/event_engine/channel_args_endpoint_config.cc - src/core/lib/event_engine/default_event_engine.cc - src/core/lib/event_engine/default_event_engine_factory.cc @@ -4181,7 +4201,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/fd_conservation_posix_test.cc @@ -4194,8 +4213,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -4257,7 +4274,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/timer_list_test.cc @@ -4270,8 +4286,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -4293,8 +4307,8 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/join.h - src/core/lib/promise/poll.h - src/core/lib/promise/promise.h @@ -4331,6 +4345,7 @@ targets: build: test language: c++ headers: + - src/core/lib/gpr/subprocess.h - test/core/util/cmdline.h - test/core/util/evaluate_args_test_util.h - test/core/util/fuzzer_util.h @@ -4342,12 +4357,13 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h - test/cpp/util/byte_buffer_proto_helper.h - test/cpp/util/string_ref_helper.h - test/cpp/util/subprocess.h src: + - src/core/lib/gpr/subprocess_posix.cc + - src/core/lib/gpr/subprocess_windows.cc - test/core/util/cmdline.cc - test/core/util/fuzzer_util.cc - test/core/util/grpc_profiler.cc @@ -4357,8 +4373,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/cpp/naming/address_sorting_test.cc - test/cpp/util/byte_buffer_proto_helper.cc @@ -4406,7 +4420,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/util/cmdline.cc @@ -4418,8 +4431,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/cpp/common/alarm_test.cc deps: @@ -4565,7 +4576,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/alts_security_connector_test.cc @@ -4578,8 +4588,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -4678,7 +4686,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/auth_context_test.cc @@ -4691,8 +4698,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -4723,7 +4728,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/authorization_matchers_test.cc @@ -4736,8 +4740,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -4759,12 +4761,13 @@ targets: language: c++ headers: - src/core/lib/avl/avl.h - - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/atomic_utils.h + - src/core/lib/gprpp/ref_counted.h + - src/core/lib/gprpp/ref_counted_ptr.h src: - test/core/avl/avl_test.cc deps: - - absl/strings:strings - - absl/types:variant + - gpr uses_polling: false - name: aws_request_signer_test gtest: true @@ -4782,7 +4785,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/aws_request_signer_test.cc @@ -4795,8 +4797,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -4871,6 +4871,7 @@ targets: build: test language: c++ headers: + - src/core/lib/gpr/subprocess.h - test/core/end2end/cq_verifier.h - test/core/util/cmdline.h - test/core/util/evaluate_args_test_util.h @@ -4883,9 +4884,10 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: + - src/core/lib/gpr/subprocess_posix.cc + - src/core/lib/gpr/subprocess_windows.cc - test/core/bad_ssl/bad_ssl_test.cc - test/core/end2end/cq_verifier.cc - test/core/util/cmdline.cc @@ -4897,8 +4899,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -4911,6 +4911,7 @@ targets: build: test language: c++ headers: + - src/core/lib/gpr/subprocess.h - test/core/end2end/cq_verifier.h - test/core/util/cmdline.h - test/core/util/evaluate_args_test_util.h @@ -4923,9 +4924,10 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: + - src/core/lib/gpr/subprocess_posix.cc + - src/core/lib/gpr/subprocess_windows.cc - test/core/bad_ssl/bad_ssl_test.cc - test/core/end2end/cq_verifier.cc - test/core/util/cmdline.cc @@ -4937,8 +4939,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -5212,7 +5212,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/buffer_list_test.cc @@ -5225,8 +5224,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -5330,6 +5327,16 @@ targets: - grpc_authorization_provider - grpc_unsecure - grpc_test_util +- name: call_tracer_test + gtest: true + build: test + language: c++ + headers: [] + src: + - test/core/channel/call_tracer_test.cc + deps: + - grpc_test_util + uses_polling: false - name: cancel_after_accept_test gtest: true build: test @@ -5477,9 +5484,11 @@ targets: headers: - test/core/end2end/cq_verifier.h - test/core/util/fake_udp_and_tcp_server.h + - test/core/util/socket_use_after_close_detector.h src: - test/core/end2end/cq_verifier.cc - test/core/util/fake_udp_and_tcp_server.cc + - test/core/util/socket_use_after_close_detector.cc - test/cpp/naming/cancel_ares_query_test.cc deps: - grpc++_test_config @@ -5714,7 +5723,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c @@ -5816,8 +5824,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -5930,7 +5936,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/channel_creds_registry_test.cc @@ -5943,8 +5948,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -6034,7 +6037,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/check_gcp_environment_linux_test.cc @@ -6047,8 +6049,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -6068,7 +6068,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/check_gcp_environment_windows_test.cc @@ -6081,8 +6080,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -6118,8 +6115,8 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/loop.h - src/core/lib/promise/map.h @@ -6170,7 +6167,6 @@ targets: - absl/hash:hash - absl/meta:type_traits - absl/status:statusor - - absl/utility:utility - gpr - upb uses_polling: false @@ -6258,28 +6254,6 @@ targets: deps: - grpc_test_util uses_polling: false -- name: client_channel_stress_test - gtest: true - build: test - run: false - language: c++ - headers: - - test/cpp/end2end/test_service_impl.h - src: - - src/proto/grpc/lb/v1/load_balancer.proto - - src/proto/grpc/testing/duplicate/echo_duplicate.proto - - src/proto/grpc/testing/echo.proto - - src/proto/grpc/testing/echo_messages.proto - - src/proto/grpc/testing/simple_messages.proto - - src/proto/grpc/testing/xds/v3/orca_load_report.proto - - test/cpp/client/client_channel_stress_test.cc - - test/cpp/end2end/test_service_impl.cc - deps: - - grpc++_test_util - platforms: - - linux - - posix - - mac - name: client_channel_test gtest: true build: test @@ -6408,7 +6382,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/util/cmdline.cc @@ -6421,8 +6394,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -6466,7 +6437,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/combiner_test.cc @@ -6479,8 +6449,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -6603,7 +6571,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/connectivity_state_test.cc @@ -6616,8 +6583,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -7080,9 +7045,7 @@ targets: - src/core/lib/event_engine/channel_args_endpoint_config.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/dual_ref_counted.h - - src/core/lib/gprpp/match.h - src/core/lib/gprpp/orphanable.h - - src/core/lib/gprpp/overload.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h - src/core/lib/gprpp/time.h @@ -7115,7 +7078,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/endpoint_pair_test.cc @@ -7129,8 +7091,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -7174,7 +7134,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/endpoint_tests.cc @@ -7188,8 +7147,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -7210,7 +7167,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/error_utils_test.cc @@ -7223,8 +7179,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -7244,7 +7198,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/evaluate_args_test.cc @@ -7257,8 +7210,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -7375,17 +7326,38 @@ targets: - gpr - upb uses_polling: false +- name: experiments_tag_test + gtest: true + build: test + language: c++ + headers: + - src/core/lib/experiments/config.h + - src/core/lib/experiments/experiments.h + - test/core/experiments/fixtures/experiments.h + src: + - src/core/lib/experiments/config.cc + - src/core/lib/experiments/experiments.cc + - test/core/experiments/experiments_tag_test.cc + - test/core/experiments/fixtures/experiments.cc + deps: + - absl/status:statusor + - gpr + uses_polling: false - name: experiments_test gtest: true build: test language: c++ headers: + - src/core/lib/experiments/config.h + - src/core/lib/experiments/experiments.h - test/core/experiments/fixtures/experiments.h src: + - src/core/lib/experiments/config.cc + - src/core/lib/experiments/experiments.cc - test/core/experiments/experiments_test.cc - test/core/experiments/fixtures/experiments.cc deps: - - grpc_test_util + - gpr uses_polling: false - name: factory_test gtest: true @@ -7540,7 +7512,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/fd_posix_test.cc @@ -7553,8 +7524,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -7791,8 +7760,8 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/loop.h - src/core/lib/promise/map.h @@ -7848,7 +7817,6 @@ targets: - absl/hash:hash - absl/meta:type_traits - absl/status:statusor - - absl/utility:utility - gpr - upb uses_polling: false @@ -7884,8 +7852,8 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/for_each.h - src/core/lib/promise/if.h @@ -7968,11 +7936,14 @@ targets: build: test language: c++ headers: + - src/core/lib/debug/trace.h - src/core/lib/event_engine/forkable.h src: + - src/core/lib/debug/trace.cc - src/core/lib/event_engine/forkable.cc - test/core/event_engine/forkable_test.cc deps: + - absl/status:statusor - gpr - name: format_request_test gtest: true @@ -7991,7 +7962,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/end2end/data/client_certs.cc @@ -8008,8 +7978,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -8093,14 +8061,17 @@ targets: - src/core/lib/debug/stats.h - src/core/lib/debug/stats_data.h - src/core/lib/debug/trace.h + - src/core/lib/event_engine/ares_resolver.h - src/core/lib/event_engine/cf_engine/cf_engine.h - src/core/lib/event_engine/cf_engine/cfstream_endpoint.h - src/core/lib/event_engine/cf_engine/cftype_unique_ref.h + - src/core/lib/event_engine/cf_engine/dns_service_resolver.h - src/core/lib/event_engine/channel_args_endpoint_config.h - src/core/lib/event_engine/common_closures.h - src/core/lib/event_engine/default_event_engine.h - src/core/lib/event_engine/default_event_engine_factory.h - src/core/lib/event_engine/forkable.h + - src/core/lib/event_engine/grpc_polled_fd.h - src/core/lib/event_engine/handle_containers.h - src/core/lib/event_engine/memory_allocator_factory.h - src/core/lib/event_engine/poller.h @@ -8109,6 +8080,7 @@ targets: - src/core/lib/event_engine/posix_engine/ev_poll_posix.h - src/core/lib/event_engine/posix_engine/event_poller.h - src/core/lib/event_engine/posix_engine/event_poller_posix_default.h + - src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h - src/core/lib/event_engine/posix_engine/internal_errqueue.h - src/core/lib/event_engine/posix_engine/lockfree_event.h - src/core/lib/event_engine/posix_engine/posix_endpoint.h @@ -8249,12 +8221,11 @@ targets: - src/core/lib/promise/arena_promise.h - src/core/lib/promise/cancel_callback.h - src/core/lib/promise/context.h - - src/core/lib/promise/detail/basic_join.h - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/for_each.h - src/core/lib/promise/if.h @@ -8269,7 +8240,6 @@ targets: - src/core/lib/promise/race.h - src/core/lib/promise/seq.h - src/core/lib/promise/trace.h - - src/core/lib/promise/try_join.h - src/core/lib/promise/try_seq.h - src/core/lib/resolver/resolver.h - src/core/lib/resolver/resolver_factory.h @@ -8375,8 +8345,10 @@ targets: - src/core/lib/debug/stats.cc - src/core/lib/debug/stats_data.cc - src/core/lib/debug/trace.cc + - src/core/lib/event_engine/ares_resolver.cc - src/core/lib/event_engine/cf_engine/cf_engine.cc - src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc + - src/core/lib/event_engine/cf_engine/dns_service_resolver.cc - src/core/lib/event_engine/channel_args_endpoint_config.cc - src/core/lib/event_engine/default_event_engine.cc - src/core/lib/event_engine/default_event_engine_factory.cc @@ -8709,7 +8681,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/grpc_alts_credentials_options_test.cc @@ -8722,8 +8693,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -8753,7 +8722,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/grpc_authorization_engine_test.cc @@ -8767,8 +8735,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -8788,7 +8754,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/grpc_authorization_policy_provider_test.cc @@ -8801,8 +8766,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_authorization_provider @@ -8936,7 +8899,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/grpc_ipv6_loopback_available_test.cc @@ -8949,8 +8911,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9010,7 +8970,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/grpc_tls_certificate_distributor_test.cc @@ -9023,8 +8982,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9044,7 +9001,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/grpc_tls_certificate_provider_test.cc @@ -9057,8 +9013,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9078,7 +9032,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/grpc_tls_certificate_verifier_test.cc @@ -9091,8 +9044,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9112,7 +9063,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/grpc_tls_credentials_options_comparator_test.cc @@ -9125,8 +9075,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9146,7 +9094,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/grpc_tls_credentials_options_test.cc @@ -9159,8 +9106,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9403,7 +9348,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/util/cmdline.cc @@ -9416,8 +9360,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9448,7 +9390,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/chttp2/hpack_encoder_test.cc @@ -9461,8 +9402,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9483,7 +9422,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/chttp2/hpack_parser_table_test.cc @@ -9496,8 +9434,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9518,7 +9454,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/chttp2/hpack_parser_test.cc @@ -9531,8 +9466,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9721,7 +9654,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/insecure_security_connector_test.cc @@ -9734,8 +9666,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -9770,8 +9700,8 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/interceptor_list.h - src/core/lib/promise/loop.h @@ -9826,7 +9756,6 @@ targets: - absl/hash:hash - absl/meta:type_traits - absl/status:statusor - - absl/utility:utility - gpr - upb uses_polling: false @@ -9997,7 +9926,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/json_token_test.cc @@ -10010,8 +9938,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -10032,7 +9958,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/jwt_verifier_test.cc @@ -10045,8 +9970,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -10149,8 +10072,8 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/join.h - src/core/lib/promise/latch.h - src/core/lib/promise/poll.h @@ -10253,7 +10176,7 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h - - src/core/lib/promise/detail/switch.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/loop.h - src/core/lib/promise/poll.h - src/core/lib/promise/seq.h @@ -10262,7 +10185,6 @@ targets: deps: - absl/meta:type_traits - absl/status:statusor - - absl/utility:utility - gpr uses_polling: false - name: map_pipe_test @@ -10297,8 +10219,8 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - src/core/lib/promise/for_each.h - src/core/lib/promise/if.h @@ -10391,7 +10313,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/matchers/matchers_test.cc @@ -10404,8 +10325,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -10604,7 +10523,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/compression/message_compress_test.cc @@ -10617,8 +10535,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -10648,7 +10564,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/metadata_map_test.cc @@ -10661,8 +10576,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -11067,7 +10980,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/end2end/data/client_certs.cc @@ -11084,8 +10996,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -11225,7 +11135,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/pid_controller_test.cc @@ -11238,11 +11147,41 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util +- name: ping_abuse_policy_test + gtest: true + build: test + language: c++ + headers: + - test/core/util/cmdline.h + - test/core/util/evaluate_args_test_util.h + - test/core/util/fuzzer_util.h + - test/core/util/grpc_profiler.h + - test/core/util/histogram.h + - test/core/util/mock_authorization_endpoint.h + - test/core/util/mock_endpoint.h + - test/core/util/parse_hexstring.h + - test/core/util/passthru_endpoint.h + - test/core/util/resolve_localhost_ip46.h + - test/core/util/slice_splitter.h + - test/core/util/tracer_util.h + src: + - test/core/transport/chttp2/ping_abuse_policy_test.cc + - test/core/util/cmdline.cc + - test/core/util/fuzzer_util.cc + - test/core/util/grpc_profiler.cc + - test/core/util/histogram.cc + - test/core/util/mock_endpoint.cc + - test/core/util/parse_hexstring.cc + - test/core/util/passthru_endpoint.cc + - test/core/util/resolve_localhost_ip46.cc + - test/core/util/slice_splitter.cc + - test/core/util/tracer_util.cc + deps: + - grpc_test_util + uses_polling: false - name: ping_configuration_test gtest: true build: test @@ -11259,7 +11198,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/chttp2/ping_configuration_test.cc @@ -11272,8 +11210,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -11313,6 +11249,38 @@ targets: - grpc_authorization_provider - grpc_unsecure - grpc_test_util +- name: ping_rate_policy_test + gtest: true + build: test + language: c++ + headers: + - test/core/util/cmdline.h + - test/core/util/evaluate_args_test_util.h + - test/core/util/fuzzer_util.h + - test/core/util/grpc_profiler.h + - test/core/util/histogram.h + - test/core/util/mock_authorization_endpoint.h + - test/core/util/mock_endpoint.h + - test/core/util/parse_hexstring.h + - test/core/util/passthru_endpoint.h + - test/core/util/resolve_localhost_ip46.h + - test/core/util/slice_splitter.h + - test/core/util/tracer_util.h + src: + - test/core/transport/chttp2/ping_rate_policy_test.cc + - test/core/util/cmdline.cc + - test/core/util/fuzzer_util.cc + - test/core/util/grpc_profiler.cc + - test/core/util/histogram.cc + - test/core/util/mock_endpoint.cc + - test/core/util/parse_hexstring.cc + - test/core/util/passthru_endpoint.cc + - test/core/util/resolve_localhost_ip46.cc + - test/core/util/slice_splitter.cc + - test/core/util/tracer_util.cc + deps: + - grpc_test_util + uses_polling: false - name: ping_test gtest: true build: test @@ -11353,6 +11321,7 @@ targets: build: test language: c++ headers: + - src/core/lib/promise/detail/basic_join.h - src/core/lib/promise/join.h - test/core/promise/test_wakeup_schedulers.h src: @@ -11449,19 +11418,25 @@ targets: - test/core/event_engine/test_suite/event_engine_test_framework.h - test/core/event_engine/test_suite/posix/oracle_event_engine_posix.h - test/core/event_engine/test_suite/tests/client_test.h + - test/core/event_engine/test_suite/tests/dns_test.h - test/core/event_engine/test_suite/tests/server_test.h - test/core/event_engine/test_suite/tests/timer_test.h + - test/core/util/fake_udp_and_tcp_server.h + - test/cpp/util/get_grpc_test_runfile_dir.h src: - test/core/event_engine/event_engine_test_utils.cc - test/core/event_engine/test_suite/event_engine_test_framework.cc - test/core/event_engine/test_suite/posix/oracle_event_engine_posix.cc - test/core/event_engine/test_suite/posix_event_engine_test.cc - test/core/event_engine/test_suite/tests/client_test.cc + - test/core/event_engine/test_suite/tests/dns_test.cc - test/core/event_engine/test_suite/tests/server_test.cc - test/core/event_engine/test_suite/tests/timer_test.cc + - test/core/util/fake_udp_and_tcp_server.cc + - test/cpp/util/get_grpc_test_runfile_dir.cc deps: - grpc_unsecure - - grpc_test_util + - grpc++_test_util platforms: - linux - posix @@ -11482,6 +11457,7 @@ targets: build: test language: c++ headers: + - src/core/lib/promise/detail/basic_join.h - src/core/lib/promise/join.h - src/core/lib/transport/promise_endpoint.h - test/core/promise/test_wakeup_schedulers.h @@ -11760,7 +11736,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/rbac_translator_test.cc @@ -11773,8 +11748,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_authorization_provider @@ -11931,7 +11904,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/resolve_address_posix_test.cc @@ -11944,8 +11916,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - absl/flags:parse @@ -11973,7 +11943,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/resolve_address_test.cc @@ -11987,8 +11956,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -12009,7 +11976,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/resolve_address_posix_test.cc @@ -12022,8 +11988,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - absl/flags:parse @@ -12051,7 +12015,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/resolve_address_test.cc @@ -12065,8 +12028,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -13421,7 +13382,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/endpoint_tests.cc @@ -13435,8 +13395,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -13456,7 +13414,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/security_connector_test.cc @@ -13469,8 +13426,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -13482,14 +13437,13 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h - - src/core/lib/promise/detail/switch.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/poll.h - src/core/lib/promise/seq.h src: - test/core/promise/seq_test.cc deps: - absl/meta:type_traits - - absl/utility:utility - gpr uses_polling: false - name: sequential_connectivity_test @@ -13533,7 +13487,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - src/proto/grpc/testing/echo.proto @@ -13549,8 +13502,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/cpp/server/server_builder_test.cc deps: @@ -13576,7 +13527,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - src/proto/grpc/testing/echo.proto @@ -13592,8 +13542,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/cpp/server/server_builder_with_socket_mutator_test.cc deps: @@ -13736,7 +13684,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - src/proto/grpc/testing/echo.proto @@ -13752,8 +13699,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/cpp/server/server_request_call_test.cc deps: @@ -13863,7 +13808,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/chttp2/settings_timeout_test.cc @@ -13876,8 +13820,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14170,7 +14112,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/socket_utils_test.cc @@ -14183,8 +14124,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14229,7 +14168,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/ssl_credentials_test.cc @@ -14242,8 +14180,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14338,7 +14274,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/status_conversion_test.cc @@ -14351,8 +14286,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14394,7 +14327,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/end2end/cq_verifier.cc @@ -14408,8 +14340,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14496,7 +14426,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/end2end/cq_verifier.cc @@ -14510,8 +14439,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14562,7 +14489,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/system_roots_test.cc @@ -14575,8 +14501,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14613,7 +14537,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/tcp_client_posix_test.cc @@ -14626,8 +14549,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14666,7 +14587,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/endpoint_tests.cc @@ -14680,8 +14600,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14704,7 +14622,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/tcp_server_posix_test.cc @@ -14717,8 +14634,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14904,7 +14819,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/load_file_test.cc @@ -14917,8 +14831,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14939,7 +14851,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/iomgr/timer_heap_test.cc @@ -14952,8 +14863,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -14974,7 +14883,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/credentials_test.cc @@ -14987,8 +14895,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -15188,7 +15094,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/transport/timeout_encoding_test.cc @@ -15201,8 +15106,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -15269,7 +15172,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/tls_security_connector_test.cc @@ -15282,8 +15184,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -15509,8 +15409,8 @@ targets: - src/core/lib/promise/detail/basic_seq.h - src/core/lib/promise/detail/promise_factory.h - src/core/lib/promise/detail/promise_like.h + - src/core/lib/promise/detail/seq_state.h - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - src/core/lib/promise/poll.h - src/core/lib/promise/try_seq.h src: @@ -15518,7 +15418,6 @@ targets: deps: - absl/meta:type_traits - absl/status:statusor - - absl/utility:utility - gpr uses_polling: false - name: unique_type_name_test @@ -15994,7 +15893,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - src/proto/grpc/testing/echo.proto @@ -16010,8 +15908,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc - test/cpp/performance/writes_per_rpc_test.cc deps: @@ -16353,7 +16249,6 @@ targets: - test/core/util/passthru_endpoint.h - test/core/util/resolve_localhost_ip46.h - test/core/util/slice_splitter.h - - test/core/util/subprocess.h - test/core/util/tracer_util.h src: - test/core/security/xds_credentials_test.cc @@ -16366,8 +16261,6 @@ targets: - test/core/util/passthru_endpoint.cc - test/core/util/resolve_localhost_ip46.cc - test/core/util/slice_splitter.cc - - test/core/util/subprocess_posix.cc - - test/core/util/subprocess_windows.cc - test/core/util/tracer_util.cc deps: - grpc_test_util @@ -16615,6 +16508,7 @@ targets: headers: - src/cpp/server/csds/csds.h - test/cpp/interop/rpc_behavior_lb_policy.h + - test/cpp/interop/xds_stats_watcher.h src: - src/proto/grpc/testing/empty.proto - src/proto/grpc/testing/messages.proto @@ -16627,6 +16521,7 @@ targets: - src/cpp/server/csds/csds.cc - test/cpp/interop/rpc_behavior_lb_policy.cc - test/cpp/interop/xds_interop_client.cc + - test/cpp/interop/xds_stats_watcher.cc deps: - grpc++_reflection - grpcpp_channelz @@ -17178,6 +17073,32 @@ targets: - linux - posix - mac +- name: xds_stats_watcher_test + gtest: true + build: test + language: c++ + headers: + - src/cpp/server/csds/csds.h + - test/cpp/interop/rpc_behavior_lb_policy.h + - test/cpp/interop/xds_stats_watcher.h + src: + - src/proto/grpc/testing/empty.proto + - src/proto/grpc/testing/messages.proto + - src/proto/grpc/testing/test.proto + - src/proto/grpc/testing/xds/v3/base.proto + - src/proto/grpc/testing/xds/v3/config_dump.proto + - src/proto/grpc/testing/xds/v3/csds.proto + - src/proto/grpc/testing/xds/v3/percent.proto + - src/cpp/server/admin/admin_services.cc + - src/cpp/server/csds/csds.cc + - test/cpp/interop/rpc_behavior_lb_policy.cc + - test/cpp/interop/xds_stats_watcher.cc + - test/cpp/interop/xds_stats_watcher_test.cc + deps: + - grpc++_reflection + - grpcpp_channelz + - grpc_test_util + - grpc++_test_config - name: xds_wrr_end2end_test gtest: true build: test diff --git a/build_config.rb b/build_config.rb index b05432e364fe4..2c1092220d8f7 100644 --- a/build_config.rb +++ b/build_config.rb @@ -13,5 +13,5 @@ # limitations under the License. module GrpcBuildConfig - CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-33.dll' + CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-34.dll' end diff --git a/build_handwritten.yaml b/build_handwritten.yaml index 603f55c9ed04b..4cc459650fc1e 100644 --- a/build_handwritten.yaml +++ b/build_handwritten.yaml @@ -12,11 +12,11 @@ settings: '#08': Use "-preN" suffixes to identify pre-release versions '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here - core_version: 33.0.0 + core_version: 34.0.0 csharp_major_version: 2 - g_stands_for: grounded + g_stands_for: goku protobuf_version: 3.23.4 - version: 1.57.0-dev + version: 1.58.0-dev configs: asan: CC: clang diff --git a/config.m4 b/config.m4 index e7ddb42f6c361..0d2298b7afaa3 100644 --- a/config.m4 +++ b/config.m4 @@ -144,6 +144,8 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/transport/chttp2/transport/http_trace.cc \ src/core/ext/transport/chttp2/transport/huffsyms.cc \ src/core/ext/transport/chttp2/transport/parsing.cc \ + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc \ + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ @@ -517,8 +519,10 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/debug/stats.cc \ src/core/lib/debug/stats_data.cc \ src/core/lib/debug/trace.cc \ + src/core/lib/event_engine/ares_resolver.cc \ src/core/lib/event_engine/cf_engine/cf_engine.cc \ src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc \ + src/core/lib/event_engine/cf_engine/dns_service_resolver.cc \ src/core/lib/event_engine/channel_args_endpoint_config.cc \ src/core/lib/event_engine/default_event_engine.cc \ src/core/lib/event_engine/default_event_engine_factory.cc \ @@ -961,9 +965,15 @@ if test "$PHP_GRPC" != "no"; then third_party/abseil-cpp/absl/synchronization/barrier.cc \ third_party/abseil-cpp/absl/synchronization/blocking_counter.cc \ third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc \ + third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc \ third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc \ + third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc \ third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc \ - third_party/abseil-cpp/absl/synchronization/internal/waiter.cc \ + third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc \ + third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc \ + third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc \ + third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc \ + third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc \ third_party/abseil-cpp/absl/synchronization/mutex.cc \ third_party/abseil-cpp/absl/synchronization/notification.cc \ third_party/abseil-cpp/absl/time/civil_time.cc \ @@ -1323,7 +1333,7 @@ if test "$PHP_GRPC" != "no"; then -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DGRPC_ARES=0 \ -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 \ -DGRPC_XDS_USER_AGENT_NAME_SUFFIX='"\"PHP\""' \ - -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX='"\"1.57.0dev\""') + -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX='"\"1.58.0dev\""') PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/backend_metrics) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/census) diff --git a/config.w32 b/config.w32 index 64851c79e4370..3003fd2529d1a 100644 --- a/config.w32 +++ b/config.w32 @@ -109,6 +109,8 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\transport\\chttp2\\transport\\http_trace.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\huffsyms.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\parsing.cc " + + "src\\core\\ext\\transport\\chttp2\\transport\\ping_abuse_policy.cc " + + "src\\core\\ext\\transport\\chttp2\\transport\\ping_rate_policy.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\stream_lists.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\varint.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\writing.cc " + @@ -482,8 +484,10 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\debug\\stats.cc " + "src\\core\\lib\\debug\\stats_data.cc " + "src\\core\\lib\\debug\\trace.cc " + + "src\\core\\lib\\event_engine\\ares_resolver.cc " + "src\\core\\lib\\event_engine\\cf_engine\\cf_engine.cc " + "src\\core\\lib\\event_engine\\cf_engine\\cfstream_endpoint.cc " + + "src\\core\\lib\\event_engine\\cf_engine\\dns_service_resolver.cc " + "src\\core\\lib\\event_engine\\channel_args_endpoint_config.cc " + "src\\core\\lib\\event_engine\\default_event_engine.cc " + "src\\core\\lib\\event_engine\\default_event_engine_factory.cc " + @@ -926,9 +930,15 @@ if (PHP_GRPC != "no") { "third_party\\abseil-cpp\\absl\\synchronization\\barrier.cc " + "third_party\\abseil-cpp\\absl\\synchronization\\blocking_counter.cc " + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\create_thread_identity.cc " + + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\futex_waiter.cc " + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\graphcycles.cc " + + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\kernel_timeout.cc " + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\per_thread_sem.cc " + - "third_party\\abseil-cpp\\absl\\synchronization\\internal\\waiter.cc " + + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\pthread_waiter.cc " + + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\sem_waiter.cc " + + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\stdcpp_waiter.cc " + + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\waiter_base.cc " + + "third_party\\abseil-cpp\\absl\\synchronization\\internal\\win32_waiter.cc " + "third_party\\abseil-cpp\\absl\\synchronization\\mutex.cc " + "third_party\\abseil-cpp\\absl\\synchronization\\notification.cc " + "third_party\\abseil-cpp\\absl\\time\\civil_time.cc " + diff --git a/doc/core/grpc-polling-engines.md b/doc/core/grpc-polling-engines.md index 0a15e3312bb22..64d1aeae46f80 100644 --- a/doc/core/grpc-polling-engines.md +++ b/doc/core/grpc-polling-engines.md @@ -24,8 +24,6 @@ There are multiple polling engine implementations depending on the OS and the OS - `poll` (If kernel does not have epoll support) - Mac: **`poll`** (default) - Windows: (no name) -- One-off polling engines: - - NodeJS : `libuv` polling engine implementation (requires different compile `#define`s) ## Polling Engine Interface diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md index 7ce834458dc24..667a0003c03cc 100644 --- a/doc/g_stands_for.md +++ b/doc/g_stands_for.md @@ -56,4 +56,5 @@ - 1.54 'g' stands for ['gracious'](https://github.com/grpc/grpc/tree/v1.54.x) - 1.55 'g' stands for ['grandslam'](https://github.com/grpc/grpc/tree/v1.55.x) - 1.56 'g' stands for ['galvanized'](https://github.com/grpc/grpc/tree/v1.56.x) -- 1.57 'g' stands for ['grounded'](https://github.com/grpc/grpc/tree/master) +- 1.57 'g' stands for ['grounded'](https://github.com/grpc/grpc/tree/v1.57.x) +- 1.58 'g' stands for ['goku'](https://github.com/grpc/grpc/tree/master) diff --git a/doc/python/sphinx/_static/custom.css b/doc/python/sphinx/_static/custom.css index d961c389b9e39..34a31a9926fb5 100644 --- a/doc/python/sphinx/_static/custom.css +++ b/doc/python/sphinx/_static/custom.css @@ -1,3 +1,8 @@ dl.field-list > dt { word-break: keep-all !important; } +.sphinxsidebar { + overflow-y: scroll; + top: 0; + bottom: 0; +} diff --git a/examples/cpp/gcp_observability/helloworld/README.md b/examples/cpp/gcp_observability/helloworld/README.md index 333b86f2eb477..1bc60dec18016 100644 --- a/examples/cpp/gcp_observability/helloworld/README.md +++ b/examples/cpp/gcp_observability/helloworld/README.md @@ -4,10 +4,11 @@ This example consists of a hello world client and a hello world server instrumented with GCP Observability for logs, metrics and tracing. Note that familiarity with the [basic hello world][] example is assumed. -Please refer to GCP's Microservices Observability user guide for setup +Please refer to GCP's [Microservices Observability user guide][] for setup instructions. [basic hello world]: https://grpc.io/docs/languages/cpp/quickstart +[Microservices Observability user guide]: https://cloud.google.com/stackdriver/docs/solutions/grpc ### Run the example with configuration diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index ffc0b13517902..e967f69630df3 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - version = '1.57.0-dev' + version = '1.58.0-dev' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' @@ -215,7 +215,7 @@ Pod::Spec.new do |s| ss.header_mappings_dir = '.' ss.dependency "#{s.name}/Interface", version ss.dependency 'gRPC-Core', version - abseil_version = '1.20230125.3' + abseil_version = '1.20230802.0' ss.dependency 'abseil/algorithm/container', abseil_version ss.dependency 'abseil/base/base', abseil_version ss.dependency 'abseil/base/core_headers', abseil_version @@ -377,6 +377,8 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/http_trace.h', 'src/core/ext/transport/chttp2/transport/huffsyms.h', 'src/core/ext/transport/chttp2/transport/internal.h', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.h', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.h', 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/inproc/inproc_transport.h', 'src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h', @@ -752,14 +754,17 @@ Pod::Spec.new do |s| 'src/core/lib/debug/stats.h', 'src/core/lib/debug/stats_data.h', 'src/core/lib/debug/trace.h', + 'src/core/lib/event_engine/ares_resolver.h', 'src/core/lib/event_engine/cf_engine/cf_engine.h', 'src/core/lib/event_engine/cf_engine/cfstream_endpoint.h', 'src/core/lib/event_engine/cf_engine/cftype_unique_ref.h', + 'src/core/lib/event_engine/cf_engine/dns_service_resolver.h', 'src/core/lib/event_engine/channel_args_endpoint_config.h', 'src/core/lib/event_engine/common_closures.h', 'src/core/lib/event_engine/default_event_engine.h', 'src/core/lib/event_engine/default_event_engine_factory.h', 'src/core/lib/event_engine/forkable.h', + 'src/core/lib/event_engine/grpc_polled_fd.h', 'src/core/lib/event_engine/handle_containers.h', 'src/core/lib/event_engine/memory_allocator_factory.h', 'src/core/lib/event_engine/poller.h', @@ -768,6 +773,7 @@ Pod::Spec.new do |s| 'src/core/lib/event_engine/posix_engine/ev_poll_posix.h', 'src/core/lib/event_engine/posix_engine/event_poller.h', 'src/core/lib/event_engine/posix_engine/event_poller_posix_default.h', + 'src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h', 'src/core/lib/event_engine/posix_engine/internal_errqueue.h', 'src/core/lib/event_engine/posix_engine/lockfree_event.h', 'src/core/lib/event_engine/posix_engine/posix_endpoint.h', @@ -942,12 +948,11 @@ Pod::Spec.new do |s| 'src/core/lib/promise/arena_promise.h', 'src/core/lib/promise/cancel_callback.h', 'src/core/lib/promise/context.h', - 'src/core/lib/promise/detail/basic_join.h', 'src/core/lib/promise/detail/basic_seq.h', 'src/core/lib/promise/detail/promise_factory.h', 'src/core/lib/promise/detail/promise_like.h', + 'src/core/lib/promise/detail/seq_state.h', 'src/core/lib/promise/detail/status.h', - 'src/core/lib/promise/detail/switch.h', 'src/core/lib/promise/exec_ctx_wakeup_scheduler.h', 'src/core/lib/promise/for_each.h', 'src/core/lib/promise/if.h', @@ -964,7 +969,6 @@ Pod::Spec.new do |s| 'src/core/lib/promise/seq.h', 'src/core/lib/promise/sleep.h', 'src/core/lib/promise/trace.h', - 'src/core/lib/promise/try_join.h', 'src/core/lib/promise/try_seq.h', 'src/core/lib/resolver/resolver.h', 'src/core/lib/resolver/resolver_factory.h', @@ -1423,6 +1427,8 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/http_trace.h', 'src/core/ext/transport/chttp2/transport/huffsyms.h', 'src/core/ext/transport/chttp2/transport/internal.h', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.h', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.h', 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/inproc/inproc_transport.h', 'src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h', @@ -1798,14 +1804,17 @@ Pod::Spec.new do |s| 'src/core/lib/debug/stats.h', 'src/core/lib/debug/stats_data.h', 'src/core/lib/debug/trace.h', + 'src/core/lib/event_engine/ares_resolver.h', 'src/core/lib/event_engine/cf_engine/cf_engine.h', 'src/core/lib/event_engine/cf_engine/cfstream_endpoint.h', 'src/core/lib/event_engine/cf_engine/cftype_unique_ref.h', + 'src/core/lib/event_engine/cf_engine/dns_service_resolver.h', 'src/core/lib/event_engine/channel_args_endpoint_config.h', 'src/core/lib/event_engine/common_closures.h', 'src/core/lib/event_engine/default_event_engine.h', 'src/core/lib/event_engine/default_event_engine_factory.h', 'src/core/lib/event_engine/forkable.h', + 'src/core/lib/event_engine/grpc_polled_fd.h', 'src/core/lib/event_engine/handle_containers.h', 'src/core/lib/event_engine/memory_allocator_factory.h', 'src/core/lib/event_engine/poller.h', @@ -1814,6 +1823,7 @@ Pod::Spec.new do |s| 'src/core/lib/event_engine/posix_engine/ev_poll_posix.h', 'src/core/lib/event_engine/posix_engine/event_poller.h', 'src/core/lib/event_engine/posix_engine/event_poller_posix_default.h', + 'src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h', 'src/core/lib/event_engine/posix_engine/internal_errqueue.h', 'src/core/lib/event_engine/posix_engine/lockfree_event.h', 'src/core/lib/event_engine/posix_engine/posix_endpoint.h', @@ -1988,12 +1998,11 @@ Pod::Spec.new do |s| 'src/core/lib/promise/arena_promise.h', 'src/core/lib/promise/cancel_callback.h', 'src/core/lib/promise/context.h', - 'src/core/lib/promise/detail/basic_join.h', 'src/core/lib/promise/detail/basic_seq.h', 'src/core/lib/promise/detail/promise_factory.h', 'src/core/lib/promise/detail/promise_like.h', + 'src/core/lib/promise/detail/seq_state.h', 'src/core/lib/promise/detail/status.h', - 'src/core/lib/promise/detail/switch.h', 'src/core/lib/promise/exec_ctx_wakeup_scheduler.h', 'src/core/lib/promise/for_each.h', 'src/core/lib/promise/if.h', @@ -2010,7 +2019,6 @@ Pod::Spec.new do |s| 'src/core/lib/promise/seq.h', 'src/core/lib/promise/sleep.h', 'src/core/lib/promise/trace.h', - 'src/core/lib/promise/try_join.h', 'src/core/lib/promise/try_seq.h', 'src/core/lib/resolver/resolver.h', 'src/core/lib/resolver/resolver_factory.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 36f40caf3864b..bb75892edf69d 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.57.0-dev' + version = '1.58.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' @@ -46,7 +46,7 @@ Pod::Spec.new do |s| s.requires_arc = false name = 'grpc' - abseil_version = '1.20230125.3' + abseil_version = '1.20230802.0' # When creating a dynamic framework, name it grpc.framework instead of gRPC-Core.framework. # This lets users write their includes like `#include ` as opposed to `#include @@ -126,6 +126,7 @@ Pod::Spec.new do |s| 'include/grpc/grpc_posix.h', 'include/grpc/grpc_security.h', 'include/grpc/grpc_security_constants.h', + 'include/grpc/impl/channel_arg_names.h', 'include/grpc/impl/codegen/atm.h', 'include/grpc/impl/codegen/atm_gcc_atomic.h', 'include/grpc/impl/codegen/atm_gcc_sync.h', @@ -410,6 +411,10 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/huffsyms.h', 'src/core/ext/transport/chttp2/transport/internal.h', 'src/core/ext/transport/chttp2/transport/parsing.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.h', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.h', 'src/core/ext/transport/chttp2/transport/stream_lists.cc', 'src/core/ext/transport/chttp2/transport/varint.cc', 'src/core/ext/transport/chttp2/transport/varint.h', @@ -1158,11 +1163,15 @@ Pod::Spec.new do |s| 'src/core/lib/debug/stats_data.h', 'src/core/lib/debug/trace.cc', 'src/core/lib/debug/trace.h', + 'src/core/lib/event_engine/ares_resolver.cc', + 'src/core/lib/event_engine/ares_resolver.h', 'src/core/lib/event_engine/cf_engine/cf_engine.cc', 'src/core/lib/event_engine/cf_engine/cf_engine.h', 'src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc', 'src/core/lib/event_engine/cf_engine/cfstream_endpoint.h', 'src/core/lib/event_engine/cf_engine/cftype_unique_ref.h', + 'src/core/lib/event_engine/cf_engine/dns_service_resolver.cc', + 'src/core/lib/event_engine/cf_engine/dns_service_resolver.h', 'src/core/lib/event_engine/channel_args_endpoint_config.cc', 'src/core/lib/event_engine/channel_args_endpoint_config.h', 'src/core/lib/event_engine/common_closures.h', @@ -1173,6 +1182,7 @@ Pod::Spec.new do |s| 'src/core/lib/event_engine/event_engine.cc', 'src/core/lib/event_engine/forkable.cc', 'src/core/lib/event_engine/forkable.h', + 'src/core/lib/event_engine/grpc_polled_fd.h', 'src/core/lib/event_engine/handle_containers.h', 'src/core/lib/event_engine/memory_allocator.cc', 'src/core/lib/event_engine/memory_allocator_factory.h', @@ -1185,6 +1195,7 @@ Pod::Spec.new do |s| 'src/core/lib/event_engine/posix_engine/event_poller.h', 'src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc', 'src/core/lib/event_engine/posix_engine/event_poller_posix_default.h', + 'src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h', 'src/core/lib/event_engine/posix_engine/internal_errqueue.cc', 'src/core/lib/event_engine/posix_engine/internal_errqueue.h', 'src/core/lib/event_engine/posix_engine/lockfree_event.cc', @@ -1534,12 +1545,11 @@ Pod::Spec.new do |s| 'src/core/lib/promise/arena_promise.h', 'src/core/lib/promise/cancel_callback.h', 'src/core/lib/promise/context.h', - 'src/core/lib/promise/detail/basic_join.h', 'src/core/lib/promise/detail/basic_seq.h', 'src/core/lib/promise/detail/promise_factory.h', 'src/core/lib/promise/detail/promise_like.h', + 'src/core/lib/promise/detail/seq_state.h', 'src/core/lib/promise/detail/status.h', - 'src/core/lib/promise/detail/switch.h', 'src/core/lib/promise/exec_ctx_wakeup_scheduler.h', 'src/core/lib/promise/for_each.h', 'src/core/lib/promise/if.h', @@ -1559,7 +1569,6 @@ Pod::Spec.new do |s| 'src/core/lib/promise/sleep.h', 'src/core/lib/promise/trace.cc', 'src/core/lib/promise/trace.h', - 'src/core/lib/promise/try_join.h', 'src/core/lib/promise/try_seq.h', 'src/core/lib/resolver/resolver.cc', 'src/core/lib/resolver/resolver.h', @@ -2154,6 +2163,8 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/http_trace.h', 'src/core/ext/transport/chttp2/transport/huffsyms.h', 'src/core/ext/transport/chttp2/transport/internal.h', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.h', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.h', 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/inproc/inproc_transport.h', 'src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h', @@ -2529,14 +2540,17 @@ Pod::Spec.new do |s| 'src/core/lib/debug/stats.h', 'src/core/lib/debug/stats_data.h', 'src/core/lib/debug/trace.h', + 'src/core/lib/event_engine/ares_resolver.h', 'src/core/lib/event_engine/cf_engine/cf_engine.h', 'src/core/lib/event_engine/cf_engine/cfstream_endpoint.h', 'src/core/lib/event_engine/cf_engine/cftype_unique_ref.h', + 'src/core/lib/event_engine/cf_engine/dns_service_resolver.h', 'src/core/lib/event_engine/channel_args_endpoint_config.h', 'src/core/lib/event_engine/common_closures.h', 'src/core/lib/event_engine/default_event_engine.h', 'src/core/lib/event_engine/default_event_engine_factory.h', 'src/core/lib/event_engine/forkable.h', + 'src/core/lib/event_engine/grpc_polled_fd.h', 'src/core/lib/event_engine/handle_containers.h', 'src/core/lib/event_engine/memory_allocator_factory.h', 'src/core/lib/event_engine/poller.h', @@ -2545,6 +2559,7 @@ Pod::Spec.new do |s| 'src/core/lib/event_engine/posix_engine/ev_poll_posix.h', 'src/core/lib/event_engine/posix_engine/event_poller.h', 'src/core/lib/event_engine/posix_engine/event_poller_posix_default.h', + 'src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h', 'src/core/lib/event_engine/posix_engine/internal_errqueue.h', 'src/core/lib/event_engine/posix_engine/lockfree_event.h', 'src/core/lib/event_engine/posix_engine/posix_endpoint.h', @@ -2719,12 +2734,11 @@ Pod::Spec.new do |s| 'src/core/lib/promise/arena_promise.h', 'src/core/lib/promise/cancel_callback.h', 'src/core/lib/promise/context.h', - 'src/core/lib/promise/detail/basic_join.h', 'src/core/lib/promise/detail/basic_seq.h', 'src/core/lib/promise/detail/promise_factory.h', 'src/core/lib/promise/detail/promise_like.h', + 'src/core/lib/promise/detail/seq_state.h', 'src/core/lib/promise/detail/status.h', - 'src/core/lib/promise/detail/switch.h', 'src/core/lib/promise/exec_ctx_wakeup_scheduler.h', 'src/core/lib/promise/for_each.h', 'src/core/lib/promise/if.h', @@ -2741,7 +2755,6 @@ Pod::Spec.new do |s| 'src/core/lib/promise/seq.h', 'src/core/lib/promise/sleep.h', 'src/core/lib/promise/trace.h', - 'src/core/lib/promise/try_join.h', 'src/core/lib/promise/try_seq.h', 'src/core/lib/resolver/resolver.h', 'src/core/lib/resolver/resolver_factory.h', diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index fd4cbad2ddfbf..1ff7b41f65511 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.57.0-dev' + version = '1.58.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index affa95ede182e..ae878deace15a 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.57.0-dev' + version = '1.58.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index ad24fc65a4f32..c12df35b83c58 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.57.0-dev' + version = '1.58.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/grpc.gemspec b/grpc.gemspec index f3dccb93dc2b7..751e2dca64ea1 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -66,6 +66,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/grpc_posix.h ) s.files += %w( include/grpc/grpc_security.h ) s.files += %w( include/grpc/grpc_security_constants.h ) + s.files += %w( include/grpc/impl/channel_arg_names.h ) s.files += %w( include/grpc/impl/codegen/atm.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_sync.h ) @@ -315,6 +316,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/transport/chttp2/transport/huffsyms.h ) s.files += %w( src/core/ext/transport/chttp2/transport/internal.h ) s.files += %w( src/core/ext/transport/chttp2/transport/parsing.cc ) + s.files += %w( src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc ) + s.files += %w( src/core/ext/transport/chttp2/transport/ping_abuse_policy.h ) + s.files += %w( src/core/ext/transport/chttp2/transport/ping_rate_policy.cc ) + s.files += %w( src/core/ext/transport/chttp2/transport/ping_rate_policy.h ) s.files += %w( src/core/ext/transport/chttp2/transport/stream_lists.cc ) s.files += %w( src/core/ext/transport/chttp2/transport/varint.cc ) s.files += %w( src/core/ext/transport/chttp2/transport/varint.h ) @@ -1063,11 +1068,15 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/debug/stats_data.h ) s.files += %w( src/core/lib/debug/trace.cc ) s.files += %w( src/core/lib/debug/trace.h ) + s.files += %w( src/core/lib/event_engine/ares_resolver.cc ) + s.files += %w( src/core/lib/event_engine/ares_resolver.h ) s.files += %w( src/core/lib/event_engine/cf_engine/cf_engine.cc ) s.files += %w( src/core/lib/event_engine/cf_engine/cf_engine.h ) s.files += %w( src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc ) s.files += %w( src/core/lib/event_engine/cf_engine/cfstream_endpoint.h ) s.files += %w( src/core/lib/event_engine/cf_engine/cftype_unique_ref.h ) + s.files += %w( src/core/lib/event_engine/cf_engine/dns_service_resolver.cc ) + s.files += %w( src/core/lib/event_engine/cf_engine/dns_service_resolver.h ) s.files += %w( src/core/lib/event_engine/channel_args_endpoint_config.cc ) s.files += %w( src/core/lib/event_engine/channel_args_endpoint_config.h ) s.files += %w( src/core/lib/event_engine/common_closures.h ) @@ -1078,6 +1087,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/event_engine/event_engine.cc ) s.files += %w( src/core/lib/event_engine/forkable.cc ) s.files += %w( src/core/lib/event_engine/forkable.h ) + s.files += %w( src/core/lib/event_engine/grpc_polled_fd.h ) s.files += %w( src/core/lib/event_engine/handle_containers.h ) s.files += %w( src/core/lib/event_engine/memory_allocator.cc ) s.files += %w( src/core/lib/event_engine/memory_allocator_factory.h ) @@ -1090,6 +1100,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/event_engine/posix_engine/event_poller.h ) s.files += %w( src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc ) s.files += %w( src/core/lib/event_engine/posix_engine/event_poller_posix_default.h ) + s.files += %w( src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h ) s.files += %w( src/core/lib/event_engine/posix_engine/internal_errqueue.cc ) s.files += %w( src/core/lib/event_engine/posix_engine/internal_errqueue.h ) s.files += %w( src/core/lib/event_engine/posix_engine/lockfree_event.cc ) @@ -1439,12 +1450,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/promise/arena_promise.h ) s.files += %w( src/core/lib/promise/cancel_callback.h ) s.files += %w( src/core/lib/promise/context.h ) - s.files += %w( src/core/lib/promise/detail/basic_join.h ) s.files += %w( src/core/lib/promise/detail/basic_seq.h ) s.files += %w( src/core/lib/promise/detail/promise_factory.h ) s.files += %w( src/core/lib/promise/detail/promise_like.h ) + s.files += %w( src/core/lib/promise/detail/seq_state.h ) s.files += %w( src/core/lib/promise/detail/status.h ) - s.files += %w( src/core/lib/promise/detail/switch.h ) s.files += %w( src/core/lib/promise/exec_ctx_wakeup_scheduler.h ) s.files += %w( src/core/lib/promise/for_each.h ) s.files += %w( src/core/lib/promise/if.h ) @@ -1464,7 +1474,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/promise/sleep.h ) s.files += %w( src/core/lib/promise/trace.cc ) s.files += %w( src/core/lib/promise/trace.h ) - s.files += %w( src/core/lib/promise/try_join.h ) s.files += %w( src/core/lib/promise/try_seq.h ) s.files += %w( src/core/lib/resolver/resolver.cc ) s.files += %w( src/core/lib/resolver/resolver.h ) @@ -1819,6 +1828,7 @@ Gem::Specification.new do |s| s.files += %w( third_party/abseil-cpp/absl/base/options.h ) s.files += %w( third_party/abseil-cpp/absl/base/policy_checks.h ) s.files += %w( third_party/abseil-cpp/absl/base/port.h ) + s.files += %w( third_party/abseil-cpp/absl/base/prefetch.h ) s.files += %w( third_party/abseil-cpp/absl/base/thread_annotations.h ) s.files += %w( third_party/abseil-cpp/absl/cleanup/cleanup.h ) s.files += %w( third_party/abseil-cpp/absl/cleanup/internal/cleanup.h ) @@ -2089,13 +2099,25 @@ Gem::Specification.new do |s| s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc ) s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h ) s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/futex.h ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.h ) s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc ) s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc ) s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h ) s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc ) s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h ) - s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/waiter.cc ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.h ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.h ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.h ) s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/waiter.h ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/waiter_base.h ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc ) + s.files += %w( third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.h ) s.files += %w( third_party/abseil-cpp/absl/synchronization/mutex.cc ) s.files += %w( third_party/abseil-cpp/absl/synchronization/mutex.h ) s.files += %w( third_party/abseil-cpp/absl/synchronization/notification.cc ) diff --git a/grpc.gyp b/grpc.gyp index 57482cc048e09..05ca749063ce7 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -369,6 +369,8 @@ 'src/core/ext/transport/chttp2/transport/http_trace.cc', 'src/core/ext/transport/chttp2/transport/huffsyms.cc', 'src/core/ext/transport/chttp2/transport/parsing.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.cc', 'src/core/ext/transport/chttp2/transport/stream_lists.cc', 'src/core/ext/transport/chttp2/transport/varint.cc', 'src/core/ext/transport/chttp2/transport/writing.cc', @@ -739,8 +741,10 @@ 'src/core/lib/debug/stats.cc', 'src/core/lib/debug/stats_data.cc', 'src/core/lib/debug/trace.cc', + 'src/core/lib/event_engine/ares_resolver.cc', 'src/core/lib/event_engine/cf_engine/cf_engine.cc', 'src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc', + 'src/core/lib/event_engine/cf_engine/dns_service_resolver.cc', 'src/core/lib/event_engine/channel_args_endpoint_config.cc', 'src/core/lib/event_engine/default_event_engine.cc', 'src/core/lib/event_engine/default_event_engine_factory.cc', @@ -1187,6 +1191,8 @@ 'src/core/ext/transport/chttp2/transport/http_trace.cc', 'src/core/ext/transport/chttp2/transport/huffsyms.cc', 'src/core/ext/transport/chttp2/transport/parsing.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.cc', 'src/core/ext/transport/chttp2/transport/stream_lists.cc', 'src/core/ext/transport/chttp2/transport/varint.cc', 'src/core/ext/transport/chttp2/transport/writing.cc', @@ -1237,8 +1243,10 @@ 'src/core/lib/debug/stats.cc', 'src/core/lib/debug/stats_data.cc', 'src/core/lib/debug/trace.cc', + 'src/core/lib/event_engine/ares_resolver.cc', 'src/core/lib/event_engine/cf_engine/cf_engine.cc', 'src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc', + 'src/core/lib/event_engine/cf_engine/dns_service_resolver.cc', 'src/core/lib/event_engine/channel_args_endpoint_config.cc', 'src/core/lib/event_engine/default_event_engine.cc', 'src/core/lib/event_engine/default_event_engine_factory.cc', @@ -1498,8 +1506,6 @@ 'test/core/util/passthru_endpoint.cc', 'test/core/util/resolve_localhost_ip46.cc', 'test/core/util/slice_splitter.cc', - 'test/core/util/subprocess_posix.cc', - 'test/core/util/subprocess_windows.cc', 'test/core/util/tracer_util.cc', 'test/cpp/microbenchmarks/helpers.cc', ], @@ -1640,6 +1646,8 @@ 'grpc_test_util', ], 'sources': [ + 'src/core/lib/gpr/subprocess_posix.cc', + 'src/core/lib/gpr/subprocess_windows.cc', 'test/core/end2end/data/client_certs.cc', 'test/core/end2end/data/server1_cert.cc', 'test/core/end2end/data/server1_key.cc', @@ -1653,8 +1661,6 @@ 'test/core/util/passthru_endpoint.cc', 'test/core/util/resolve_localhost_ip46.cc', 'test/core/util/slice_splitter.cc', - 'test/core/util/subprocess_posix.cc', - 'test/core/util/subprocess_windows.cc', 'test/core/util/tracer_util.cc', 'test/cpp/util/byte_buffer_proto_helper.cc', 'test/cpp/util/create_test_channel.cc', @@ -1757,8 +1763,10 @@ 'src/core/lib/debug/stats.cc', 'src/core/lib/debug/stats_data.cc', 'src/core/lib/debug/trace.cc', + 'src/core/lib/event_engine/ares_resolver.cc', 'src/core/lib/event_engine/cf_engine/cf_engine.cc', 'src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc', + 'src/core/lib/event_engine/cf_engine/dns_service_resolver.cc', 'src/core/lib/event_engine/channel_args_endpoint_config.cc', 'src/core/lib/event_engine/default_event_engine.cc', 'src/core/lib/event_engine/default_event_engine_factory.cc', diff --git a/include/grpc/event_engine/event_engine.h b/include/grpc/event_engine/event_engine.h index 4e0df0ef56a09..4b671d2d3f750 100644 --- a/include/grpc/event_engine/event_engine.h +++ b/include/grpc/event_engine/event_engine.h @@ -365,7 +365,6 @@ class EventEngine : public std::enable_shared_from_this { /// lookup. Implementations should pass the appropriate statuses to the /// callback. For example, callbacks might expect to receive CANCELLED or /// NOT_FOUND. - /// virtual void LookupHostname(LookupHostnameCallback on_resolve, absl::string_view name, absl::string_view default_port) = 0; @@ -397,8 +396,11 @@ class EventEngine : public std::enable_shared_from_this { virtual bool IsWorkerThread() = 0; /// Creates and returns an instance of a DNSResolver, optionally configured by - /// the \a options struct. - virtual std::unique_ptr GetDNSResolver( + /// the \a options struct. This method may return a non-OK status if an error + /// occurred when creating the DNSResolver. If the caller requests a custom + /// DNS server, and the EventEngine implementation does not support it, this + /// must return an error. + virtual absl::StatusOr> GetDNSResolver( const DNSResolver::ResolverOptions& options) = 0; /// Asynchronously executes a task as soon as possible. diff --git a/include/grpc/event_engine/memory_allocator.h b/include/grpc/event_engine/memory_allocator.h index b31bed0ed216d..b3143d8dd6a79 100644 --- a/include/grpc/event_engine/memory_allocator.h +++ b/include/grpc/event_engine/memory_allocator.h @@ -56,8 +56,8 @@ class MemoryAllocator { /// The object will not be usable after this call unless it's a valid /// allocator is moved into it. void Reset() { - if (allocator_ != nullptr) allocator_->Shutdown(); - allocator_.reset(); + auto a = std::move(allocator_); + if (a != nullptr) a->Shutdown(); } /// Reserve bytes from the quota. diff --git a/include/grpc/impl/channel_arg_names.h b/include/grpc/impl/channel_arg_names.h new file mode 100644 index 0000000000000..cf1f616c176a9 --- /dev/null +++ b/include/grpc/impl/channel_arg_names.h @@ -0,0 +1,371 @@ +// Copyright 2023 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_IMPL_CHANNEL_ARG_NAMES_H +#define GRPC_IMPL_CHANNEL_ARG_NAMES_H + +/** \defgroup grpc_arg_keys + * Channel argument keys. + * \{ + */ +/** If non-zero, enable census for tracing and stats collection. */ +#define GRPC_ARG_ENABLE_CENSUS "grpc.census" +/** If non-zero, enable load reporting. */ +#define GRPC_ARG_ENABLE_LOAD_REPORTING "grpc.loadreporting" +/** If non-zero, call metric recording is enabled. */ +#define GRPC_ARG_SERVER_CALL_METRIC_RECORDING \ + "grpc.server_call_metric_recording" +/** Request that optional features default to off (regardless of what they + usually default to) - to enable tight control over what gets enabled */ +#define GRPC_ARG_MINIMAL_STACK "grpc.minimal_stack" +/** Maximum number of concurrent incoming streams to allow on a http2 + connection. Int valued. */ +#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams" +/** Maximum message length that the channel can receive. Int valued, bytes. + -1 means unlimited. */ +#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH "grpc.max_receive_message_length" +/** \deprecated For backward compatibility. + * Use GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH instead. */ +#define GRPC_ARG_MAX_MESSAGE_LENGTH GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH +/** Maximum message length that the channel can send. Int valued, bytes. + -1 means unlimited. */ +#define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length" +/** Maximum time that a channel may have no outstanding rpcs, after which the + * server will close the connection. Int valued, milliseconds. INT_MAX means + * unlimited. */ +#define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms" +/** Maximum time that a channel may exist. Int valued, milliseconds. + * INT_MAX means unlimited. */ +#define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms" +/** Grace period after the channel reaches its max age. Int valued, + milliseconds. INT_MAX means unlimited. */ +#define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms" +/** Timeout after the last RPC finishes on the client channel at which the + * channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means + * unlimited. The default value is 30 minutes and the min value is 1 second. */ +#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms" +/** Enable/disable support for per-message compression. Defaults to 1, unless + GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ +#define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression" +/** Experimental Arg. Enable/disable support for per-message decompression. + Defaults to 1. If disabled, decompression will not be performed and the + application will see the compressed message in the byte buffer. */ +#define GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION \ + "grpc.per_message_decompression" +/** Enable/disable support for deadline checking. Defaults to 1, unless + GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0 */ +#define GRPC_ARG_ENABLE_DEADLINE_CHECKS "grpc.enable_deadline_checking" +/** Initial stream ID for http2 transports. Int valued. */ +#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \ + "grpc.http2.initial_sequence_number" +/** Amount to read ahead on individual streams. Defaults to 64kb, larger + values can help throughput on high-latency connections. + NOTE: at some point we'd like to auto-tune this, and this parameter + will become a no-op. Int valued, bytes. */ +#define GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES "grpc.http2.lookahead_bytes" +/** How much memory to use for hpack decoding. Int valued, bytes. */ +#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \ + "grpc.http2.hpack_table_size.decoder" +/** How much memory to use for hpack encoding. Int valued, bytes. */ +#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \ + "grpc.http2.hpack_table_size.encoder" +/** How big a frame are we willing to receive via HTTP2. + Min 16384, max 16777215. Larger values give lower CPU usage for large + messages, but more head of line blocking for small messages. */ +#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size" +/** Should BDP probing be performed? */ +#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe" +/** (DEPRECATED) Does not have any effect. + Earlier, this arg configured the minimum time between successive ping frames + without receiving any data/header frame, Int valued, milliseconds. This put + unnecessary constraints on the configuration of keepalive pings, + requiring users to set this channel arg along with + GRPC_ARG_KEEPALIVE_TIME_MS. This arg also limited the activity of the other + source of pings in gRPC Core - BDP pings, but BDP pings are only sent when + there is receive-side data activity, making this arg unuseful for BDP pings + too. */ +#define GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS \ + "grpc.http2.min_time_between_pings_ms" +/** Minimum allowed time between a server receiving successive ping frames + without sending any data/header frame. Int valued, milliseconds + */ +#define GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS \ + "grpc.http2.min_ping_interval_without_data_ms" +/** Channel arg to override the http2 :scheme header */ +#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" +/** How many pings can the client send before needing to send a + data/header frame? (0 indicates that an infinite number of + pings can be sent without sending a data frame or header frame) */ +#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \ + "grpc.http2.max_pings_without_data" +/** How many misbehaving pings the server can bear before sending goaway and + closing the transport? (0 indicates that the server can bear an infinite + number of misbehaving pings) */ +#define GRPC_ARG_HTTP2_MAX_PING_STRIKES "grpc.http2.max_ping_strikes" +/** How much data are we willing to queue up per stream if + GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */ +#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size" +/** Should we allow receipt of true-binary data on http2 connections? + Defaults to on (1) */ +#define GRPC_ARG_HTTP2_ENABLE_TRUE_BINARY "grpc.http2.true_binary" +/** An experimental channel arg which determines whether the preferred crypto + * frame size http2 setting sent to the peer at startup. If set to 0 (false + * - default), the preferred frame size is not sent to the peer. Otherwise it + * sends a default preferred crypto frame size value of 4GB to the peer at + * the startup of each connection. */ +#define GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE \ + "grpc.experimental.http2.enable_preferred_frame_size" +/** After a duration of this time the client/server pings its peer to see if the + transport is still alive. Int valued, milliseconds. */ +#define GRPC_ARG_KEEPALIVE_TIME_MS "grpc.keepalive_time_ms" +/** After waiting for a duration of this time, if the keepalive ping sender does + not receive the ping ack, it will close the transport. Int valued, + milliseconds. */ +#define GRPC_ARG_KEEPALIVE_TIMEOUT_MS "grpc.keepalive_timeout_ms" +/** Is it permissible to send keepalive pings from the client without any + outstanding streams. Int valued, 0(false)/1(true). */ +#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \ + "grpc.keepalive_permit_without_calls" +/** Default authority to pass if none specified on call construction. A string. + * */ +#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority" +/** Primary user agent: goes at the start of the user-agent metadata + sent on each request. A string. */ +#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent" +/** Secondary user agent: goes at the end of the user-agent metadata + sent on each request. A string. */ +#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent" +/** The minimum time between subsequent connection attempts, in ms */ +#define GRPC_ARG_MIN_RECONNECT_BACKOFF_MS "grpc.min_reconnect_backoff_ms" +/** The maximum time between subsequent connection attempts, in ms */ +#define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms" +/** The time between the first and second connection attempts, in ms */ +#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \ + "grpc.initial_reconnect_backoff_ms" +/** Minimum amount of time between DNS resolutions, in ms */ +#define GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS \ + "grpc.dns_min_time_between_resolutions_ms" +/** The timeout used on servers for finishing handshaking on an incoming + connection. Defaults to 120 seconds. */ +#define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms" +/** This *should* be used for testing only. + The caller of the secure_channel_create functions may override the target + name used for SSL host name checking using this channel argument which is of + type \a GRPC_ARG_STRING. If this argument is not specified, the name used + for SSL host name checking will be the target parameter (assuming that the + secure channel is an SSL channel). If this parameter is specified and the + underlying is not an SSL channel, it will just be ignored. */ +#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override" +/** If non-zero, a pointer to a session cache (a pointer of type + grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch + an appropriate pointer arg vtable) */ +#define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache" +/** If non-zero, it will determine the maximum frame size used by TSI's frame + * protector. + */ +#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size" +/** Maximum metadata size (soft limit), in bytes. Note this limit applies to the + max sum of all metadata key-value entries in a batch of headers. Some random + sample of requests between this limit and + `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` will be rejected. Defaults to maximum + of 8 KB and `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` * 0.8 (if set). + */ +#define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size" +/** Maximum metadata size (hard limit), in bytes. Note this limit applies to the + max sum of all metadata key-value entries in a batch of headers. All requests + exceeding this limit will be rejected. Defaults to maximum of 16 KB and + `GRPC_ARG_MAX_METADATA_SIZE` * 1.25 (if set). */ +#define GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE "grpc.absolute_max_metadata_size" +/** If non-zero, allow the use of SO_REUSEPORT if it's available (default 1) */ +#define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport" +/** If non-zero, a pointer to a buffer pool (a pointer of type + * grpc_resource_quota*). (use grpc_resource_quota_arg_vtable() to fetch an + * appropriate pointer arg vtable) */ +#define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota" +/** If non-zero, expand wildcard addresses to a list of local addresses. */ +#define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs" +/** Service config data in JSON form. + This value will be ignored if the name resolver returns a service config. */ +#define GRPC_ARG_SERVICE_CONFIG "grpc.service_config" +/** Disable looking up the service config via the name resolver. */ +#define GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION \ + "grpc.service_config_disable_resolution" +/** LB policy name. */ +#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name" +/** Cap for ring size in the ring_hash LB policy. The min and max ring size + values set in the LB policy config will be capped to this value. + Default is 4096. */ +#define GRPC_ARG_RING_HASH_LB_RING_SIZE_CAP "grpc.lb.ring_hash.ring_size_cap" +/** The grpc_socket_mutator instance that set the socket options. A pointer. */ +#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" +/** The grpc_socket_factory instance to create and bind sockets. A pointer. */ +#define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" +/** The maximum amount of memory used by trace events per channel trace node. + * Once the maximum is reached, subsequent events will evict the oldest events + * from the buffer. The unit for this knob is bytes. Setting it to zero causes + * channel tracing to be disabled. */ +#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \ + "grpc.max_channel_trace_event_memory_per_node" +/** If non-zero, gRPC library will track stats and information at at per channel + * level. Disabling channelz naturally disables channel tracing. The default + * is for channelz to be enabled. */ +#define GRPC_ARG_ENABLE_CHANNELZ "grpc.enable_channelz" +/** If non-zero, Cronet transport will coalesce packets to fewer frames + * when possible. */ +#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ + "grpc.use_cronet_packet_coalescing" +/** Channel arg (integer) setting how large a slice to try and read from the + wire each time recvmsg (or equivalent) is called **/ +#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size" +/** Note this is not a "channel arg" key. This is the default slice size to use + * when trying to read from the wire if the GRPC_ARG_TCP_READ_CHUNK_SIZE + * channel arg is unspecified. */ +#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192 +#define GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE \ + "grpc.experimental.tcp_min_read_chunk_size" +#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \ + "grpc.experimental.tcp_max_read_chunk_size" +/* TCP TX Zerocopy enable state: zero is disabled, non-zero is enabled. By + default, it is disabled. */ +#define GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED \ + "grpc.experimental.tcp_tx_zerocopy_enabled" +/* TCP TX Zerocopy send threshold: only zerocopy if >= this many bytes sent. By + default, this is set to 16KB. */ +#define GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD \ + "grpc.experimental.tcp_tx_zerocopy_send_bytes_threshold" +/* TCP TX Zerocopy max simultaneous sends: limit for maximum number of pending + calls to tcp_write() using zerocopy. A tcp_write() is considered pending + until the kernel performs the zerocopy-done callback for all sendmsg() calls + issued by the tcp_write(). By default, this is set to 4. */ +#define GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS \ + "grpc.experimental.tcp_tx_zerocopy_max_simultaneous_sends" +/* Overrides the TCP socket recieve buffer size, SO_RCVBUF. */ +#define GRPC_ARG_TCP_RECEIVE_BUFFER_SIZE "grpc.tcp_receive_buffer_size" +/* Timeout in milliseconds to use for calls to the grpclb load balancer. + If 0 or unset, the balancer calls will have no deadline. */ +#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms" +/* Specifies the xDS bootstrap config as a JSON string. + FOR TESTING PURPOSES ONLY -- DO NOT USE IN PRODUCTION. + This option allows controlling the bootstrap configuration on a + per-channel basis, which is useful in tests. However, this results + in having a separate xDS client instance per channel rather than + using the global instance, which is not the intended way to use xDS. + Currently, this will (a) add unnecessary load on the xDS server and + (b) break use of CSDS, and there may be additional side effects in + the future. */ +#define GRPC_ARG_TEST_ONLY_DO_NOT_USE_IN_PROD_XDS_BOOTSTRAP_CONFIG \ + "grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_config" +/* Timeout in milliseconds to wait for the serverlist from the grpclb load + balancer before using fallback backend addresses from the resolver. + If 0, enter fallback mode immediately. Default value is 10000. */ +#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms" +/* Experimental Arg. Channel args to be used for the control-plane channel + * created to the grpclb load balancers. This is a pointer arg whose value is a + * grpc_channel_args object. If unset, most channel args from the parent channel + * will be propagated to the grpclb channel. */ +#define GRPC_ARG_EXPERIMENTAL_GRPCLB_CHANNEL_ARGS \ + "grpc.experimental.grpclb_channel_args" +/* Timeout in milliseconds to wait for the child of a specific priority to + complete its initial connection attempt before the priority LB policy fails + over to the next priority. Default value is 10 seconds. */ +#define GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS \ + "grpc.priority_failover_timeout_ms" +/** If non-zero, grpc server's cronet compression workaround will be enabled */ +#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \ + "grpc.workaround.cronet_compression" +/** String defining the optimization target for a channel. + Can be: "latency" - attempt to minimize latency at the cost of throughput + "blend" - try to balance latency and throughput + "throughput" - attempt to maximize throughput at the expense of + latency + Defaults to "blend". In the current implementation "blend" is equivalent to + "latency". */ +#define GRPC_ARG_OPTIMIZATION_TARGET "grpc.optimization_target" +/** Enables retry functionality. Defaults to true. When enabled, + transparent retries will be performed as appropriate, and configurable + retries are enabled when they are configured via the service config. + For details, see: + https://github.com/grpc/proposal/blob/master/A6-client-retries.md + NOTE: Hedging functionality is not yet implemented, so those + fields in the service config will currently be ignored. See + also the GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING arg below. + */ +#define GRPC_ARG_ENABLE_RETRIES "grpc.enable_retries" +/** Enables hedging functionality, as described in: + https://github.com/grpc/proposal/blob/master/A6-client-retries.md + Default is currently false, since this functionality is not yet + fully implemented. + NOTE: This channel arg is experimental and will eventually be removed. + Once hedging functionality has been implemented and proves stable, + this arg will be removed, and the hedging functionality will + be enabled via the GRPC_ARG_ENABLE_RETRIES arg above. */ +#define GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING "grpc.experimental.enable_hedging" +/** Per-RPC retry buffer size, in bytes. Default is 256 KiB. */ +#define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size" +/** Channel arg that carries the bridged objective c object for custom metrics + * logging filter. */ +#define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context" +/** If non-zero, client authority filter is disabled for the channel */ +#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \ + "grpc.disable_client_authority_filter" +/** If set to zero, disables use of http proxies. Enabled by default. */ +#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy" +/** Channel arg to set http proxy per channel. If set, the channel arg + * value will be preferred over the environment variable settings. */ +#define GRPC_ARG_HTTP_PROXY "grpc.http_proxy" +/** If set to non zero, surfaces the user agent string to the server. User + agent is surfaced by default. */ +#define GRPC_ARG_SURFACE_USER_AGENT "grpc.surface_user_agent" +/** If set, inhibits health checking (which may be enabled via the + * service config.) */ +#define GRPC_ARG_INHIBIT_HEALTH_CHECKING "grpc.inhibit_health_checking" +/** If enabled, the channel's DNS resolver queries for SRV records. + * This is useful only when using the "grpclb" load balancing policy, + * as described in the following documents: + * https://github.com/grpc/proposal/blob/master/A5-grpclb-in-dns.md + * https://github.com/grpc/proposal/blob/master/A24-lb-policy-config.md + * https://github.com/grpc/proposal/blob/master/A26-grpclb-selection.md + * Note that this works only with the "ares" DNS resolver; it isn't supported + * by the "native" DNS resolver. */ +#define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries" +/** If set, determines an upper bound on the number of milliseconds that the + * c-ares based DNS resolver will wait on queries before cancelling them. + * The default value is 120,000. Setting this to "0" will disable the + * overall timeout entirely. Note that this doesn't include internal c-ares + * timeouts/backoff/retry logic, and so the actual DNS resolution may time out + * sooner than the value specified here. */ +#define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout" +/** If set, uses a local subchannel pool within the channel. Otherwise, uses the + * global subchannel pool. */ +#define GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL "grpc.use_local_subchannel_pool" +/** gRPC Objective-C channel pooling domain string. */ +#define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain" +/** gRPC Objective-C channel pooling id. */ +#define GRPC_ARG_CHANNEL_ID "grpc.channel_id" +/** Channel argument for grpc_authorization_policy_provider. If present, enables + gRPC authorization check. */ +#define GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER \ + "grpc.authorization_policy_provider" +/** EXPERIMENTAL. Updates to a server's configuration from a config fetcher (for + * example, listener updates from xDS) cause all older connections to be + * gracefully shut down (i.e., "drained") with a grace period configured by this + * channel arg. Int valued, milliseconds. Defaults to 10 minutes.*/ +#define GRPC_ARG_SERVER_CONFIG_CHANGE_DRAIN_GRACE_TIME_MS \ + "grpc.experimental.server_config_change_drain_grace_time_ms" +/** Configure the Differentiated Services Code Point used on outgoing packets. + * Integer value ranging from 0 to 63. */ +#define GRPC_ARG_DSCP "grpc.dscp" +/** \} */ + +#endif /* GRPC_IMPL_CHANNEL_ARG_NAMES_H */ diff --git a/include/grpc/impl/grpc_types.h b/include/grpc/impl/grpc_types.h index 425fe0b630b6a..9250ce8f6b6ec 100644 --- a/include/grpc/impl/grpc_types.h +++ b/include/grpc/impl/grpc_types.h @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -133,359 +134,6 @@ typedef struct { grpc_arg* args; } grpc_channel_args; -/** \defgroup grpc_arg_keys - * Channel argument keys. - * \{ - */ -/** If non-zero, enable census for tracing and stats collection. */ -#define GRPC_ARG_ENABLE_CENSUS "grpc.census" -/** If non-zero, enable load reporting. */ -#define GRPC_ARG_ENABLE_LOAD_REPORTING "grpc.loadreporting" -/** If non-zero, call metric recording is enabled. */ -#define GRPC_ARG_SERVER_CALL_METRIC_RECORDING \ - "grpc.server_call_metric_recording" -/** Request that optional features default to off (regardless of what they - usually default to) - to enable tight control over what gets enabled */ -#define GRPC_ARG_MINIMAL_STACK "grpc.minimal_stack" -/** Maximum number of concurrent incoming streams to allow on a http2 - connection. Int valued. */ -#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams" -/** Maximum message length that the channel can receive. Int valued, bytes. - -1 means unlimited. */ -#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH "grpc.max_receive_message_length" -/** \deprecated For backward compatibility. - * Use GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH instead. */ -#define GRPC_ARG_MAX_MESSAGE_LENGTH GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH -/** Maximum message length that the channel can send. Int valued, bytes. - -1 means unlimited. */ -#define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length" -/** Maximum time that a channel may have no outstanding rpcs, after which the - * server will close the connection. Int valued, milliseconds. INT_MAX means - * unlimited. */ -#define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms" -/** Maximum time that a channel may exist. Int valued, milliseconds. - * INT_MAX means unlimited. */ -#define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms" -/** Grace period after the channel reaches its max age. Int valued, - milliseconds. INT_MAX means unlimited. */ -#define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms" -/** Timeout after the last RPC finishes on the client channel at which the - * channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means - * unlimited. The default value is 30 minutes and the min value is 1 second. */ -#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms" -/** Enable/disable support for per-message compression. Defaults to 1, unless - GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ -#define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression" -/** Experimental Arg. Enable/disable support for per-message decompression. - Defaults to 1. If disabled, decompression will not be performed and the - application will see the compressed message in the byte buffer. */ -#define GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION \ - "grpc.per_message_decompression" -/** Enable/disable support for deadline checking. Defaults to 1, unless - GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0 */ -#define GRPC_ARG_ENABLE_DEADLINE_CHECKS "grpc.enable_deadline_checking" -/** Initial stream ID for http2 transports. Int valued. */ -#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \ - "grpc.http2.initial_sequence_number" -/** Amount to read ahead on individual streams. Defaults to 64kb, larger - values can help throughput on high-latency connections. - NOTE: at some point we'd like to auto-tune this, and this parameter - will become a no-op. Int valued, bytes. */ -#define GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES "grpc.http2.lookahead_bytes" -/** How much memory to use for hpack decoding. Int valued, bytes. */ -#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \ - "grpc.http2.hpack_table_size.decoder" -/** How much memory to use for hpack encoding. Int valued, bytes. */ -#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \ - "grpc.http2.hpack_table_size.encoder" -/** How big a frame are we willing to receive via HTTP2. - Min 16384, max 16777215. Larger values give lower CPU usage for large - messages, but more head of line blocking for small messages. */ -#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size" -/** Should BDP probing be performed? */ -#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe" -/** (DEPRECATED) Does not have any effect. - Earlier, this arg configured the minimum time between successive ping frames - without receiving any data/header frame, Int valued, milliseconds. This put - unnecessary constraints on the configuration of keepalive pings, - requiring users to set this channel arg along with - GRPC_ARG_KEEPALIVE_TIME_MS. This arg also limited the activity of the other - source of pings in gRPC Core - BDP pings, but BDP pings are only sent when - there is receive-side data activity, making this arg unuseful for BDP pings - too. */ -#define GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS \ - "grpc.http2.min_time_between_pings_ms" -/** Minimum allowed time between a server receiving successive ping frames - without sending any data/header frame. Int valued, milliseconds - */ -#define GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS \ - "grpc.http2.min_ping_interval_without_data_ms" -/** Channel arg to override the http2 :scheme header */ -#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" -/** How many pings can the client send before needing to send a - data/header frame? (0 indicates that an infinite number of - pings can be sent without sending a data frame or header frame) */ -#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \ - "grpc.http2.max_pings_without_data" -/** How many misbehaving pings the server can bear before sending goaway and - closing the transport? (0 indicates that the server can bear an infinite - number of misbehaving pings) */ -#define GRPC_ARG_HTTP2_MAX_PING_STRIKES "grpc.http2.max_ping_strikes" -/** How much data are we willing to queue up per stream if - GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */ -#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size" -/** Should we allow receipt of true-binary data on http2 connections? - Defaults to on (1) */ -#define GRPC_ARG_HTTP2_ENABLE_TRUE_BINARY "grpc.http2.true_binary" -/** An experimental channel arg which determines whether the preferred crypto - * frame size http2 setting sent to the peer at startup. If set to 0 (false - * - default), the preferred frame size is not sent to the peer. Otherwise it - * sends a default preferred crypto frame size value of 4GB to the peer at - * the startup of each connection. */ -#define GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE \ - "grpc.experimental.http2.enable_preferred_frame_size" -/** After a duration of this time the client/server pings its peer to see if the - transport is still alive. Int valued, milliseconds. */ -#define GRPC_ARG_KEEPALIVE_TIME_MS "grpc.keepalive_time_ms" -/** After waiting for a duration of this time, if the keepalive ping sender does - not receive the ping ack, it will close the transport. Int valued, - milliseconds. */ -#define GRPC_ARG_KEEPALIVE_TIMEOUT_MS "grpc.keepalive_timeout_ms" -/** Is it permissible to send keepalive pings from the client without any - outstanding streams. Int valued, 0(false)/1(true). */ -#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \ - "grpc.keepalive_permit_without_calls" -/** Default authority to pass if none specified on call construction. A string. - * */ -#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority" -/** Primary user agent: goes at the start of the user-agent metadata - sent on each request. A string. */ -#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent" -/** Secondary user agent: goes at the end of the user-agent metadata - sent on each request. A string. */ -#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent" -/** The minimum time between subsequent connection attempts, in ms */ -#define GRPC_ARG_MIN_RECONNECT_BACKOFF_MS "grpc.min_reconnect_backoff_ms" -/** The maximum time between subsequent connection attempts, in ms */ -#define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms" -/** The time between the first and second connection attempts, in ms */ -#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \ - "grpc.initial_reconnect_backoff_ms" -/** Minimum amount of time between DNS resolutions, in ms */ -#define GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS \ - "grpc.dns_min_time_between_resolutions_ms" -/** The timeout used on servers for finishing handshaking on an incoming - connection. Defaults to 120 seconds. */ -#define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms" -/** This *should* be used for testing only. - The caller of the secure_channel_create functions may override the target - name used for SSL host name checking using this channel argument which is of - type \a GRPC_ARG_STRING. If this argument is not specified, the name used - for SSL host name checking will be the target parameter (assuming that the - secure channel is an SSL channel). If this parameter is specified and the - underlying is not an SSL channel, it will just be ignored. */ -#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override" -/** If non-zero, a pointer to a session cache (a pointer of type - grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch - an appropriate pointer arg vtable) */ -#define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache" -/** If non-zero, it will determine the maximum frame size used by TSI's frame - * protector. - */ -#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size" -/** Maximum metadata size (soft limit), in bytes. Note this limit applies to the - max sum of all metadata key-value entries in a batch of headers. Some random - sample of requests between this limit and - `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` will be rejected. Defaults to maximum - of 8 KB and `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` * 0.8 (if set). - */ -#define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size" -/** Maximum metadata size (hard limit), in bytes. Note this limit applies to the - max sum of all metadata key-value entries in a batch of headers. All requests - exceeding this limit will be rejected. Defaults to maximum of 16 KB and - `GRPC_ARG_MAX_METADATA_SIZE` * 1.25 (if set). */ -#define GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE "grpc.absolute_max_metadata_size" -/** If non-zero, allow the use of SO_REUSEPORT if it's available (default 1) */ -#define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport" -/** If non-zero, a pointer to a buffer pool (a pointer of type - * grpc_resource_quota*). (use grpc_resource_quota_arg_vtable() to fetch an - * appropriate pointer arg vtable) */ -#define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota" -/** If non-zero, expand wildcard addresses to a list of local addresses. */ -#define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs" -/** Service config data in JSON form. - This value will be ignored if the name resolver returns a service config. */ -#define GRPC_ARG_SERVICE_CONFIG "grpc.service_config" -/** Disable looking up the service config via the name resolver. */ -#define GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION \ - "grpc.service_config_disable_resolution" -/** LB policy name. */ -#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name" -/** Cap for ring size in the ring_hash LB policy. The min and max ring size - values set in the LB policy config will be capped to this value. - Default is 4096. */ -#define GRPC_ARG_RING_HASH_LB_RING_SIZE_CAP "grpc.lb.ring_hash.ring_size_cap" -/** The grpc_socket_mutator instance that set the socket options. A pointer. */ -#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" -/** The grpc_socket_factory instance to create and bind sockets. A pointer. */ -#define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" -/** The maximum amount of memory used by trace events per channel trace node. - * Once the maximum is reached, subsequent events will evict the oldest events - * from the buffer. The unit for this knob is bytes. Setting it to zero causes - * channel tracing to be disabled. */ -#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \ - "grpc.max_channel_trace_event_memory_per_node" -/** If non-zero, gRPC library will track stats and information at at per channel - * level. Disabling channelz naturally disables channel tracing. The default - * is for channelz to be enabled. */ -#define GRPC_ARG_ENABLE_CHANNELZ "grpc.enable_channelz" -/** If non-zero, Cronet transport will coalesce packets to fewer frames - * when possible. */ -#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ - "grpc.use_cronet_packet_coalescing" -/** Channel arg (integer) setting how large a slice to try and read from the - wire each time recvmsg (or equivalent) is called **/ -#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size" -/** Note this is not a "channel arg" key. This is the default slice size to use - * when trying to read from the wire if the GRPC_ARG_TCP_READ_CHUNK_SIZE - * channel arg is unspecified. */ -#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192 -#define GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE \ - "grpc.experimental.tcp_min_read_chunk_size" -#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \ - "grpc.experimental.tcp_max_read_chunk_size" -/* TCP TX Zerocopy enable state: zero is disabled, non-zero is enabled. By - default, it is disabled. */ -#define GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED \ - "grpc.experimental.tcp_tx_zerocopy_enabled" -/* TCP TX Zerocopy send threshold: only zerocopy if >= this many bytes sent. By - default, this is set to 16KB. */ -#define GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD \ - "grpc.experimental.tcp_tx_zerocopy_send_bytes_threshold" -/* TCP TX Zerocopy max simultaneous sends: limit for maximum number of pending - calls to tcp_write() using zerocopy. A tcp_write() is considered pending - until the kernel performs the zerocopy-done callback for all sendmsg() calls - issued by the tcp_write(). By default, this is set to 4. */ -#define GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS \ - "grpc.experimental.tcp_tx_zerocopy_max_simultaneous_sends" -/* Overrides the TCP socket recieve buffer size, SO_RCVBUF. */ -#define GRPC_ARG_TCP_RECEIVE_BUFFER_SIZE "grpc.tcp_receive_buffer_size" -/* Timeout in milliseconds to use for calls to the grpclb load balancer. - If 0 or unset, the balancer calls will have no deadline. */ -#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms" -/* Specifies the xDS bootstrap config as a JSON string. - FOR TESTING PURPOSES ONLY -- DO NOT USE IN PRODUCTION. - This option allows controlling the bootstrap configuration on a - per-channel basis, which is useful in tests. However, this results - in having a separate xDS client instance per channel rather than - using the global instance, which is not the intended way to use xDS. - Currently, this will (a) add unnecessary load on the xDS server and - (b) break use of CSDS, and there may be additional side effects in - the future. */ -#define GRPC_ARG_TEST_ONLY_DO_NOT_USE_IN_PROD_XDS_BOOTSTRAP_CONFIG \ - "grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_config" -/* Timeout in milliseconds to wait for the serverlist from the grpclb load - balancer before using fallback backend addresses from the resolver. - If 0, enter fallback mode immediately. Default value is 10000. */ -#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms" -/* Experimental Arg. Channel args to be used for the control-plane channel - * created to the grpclb load balancers. This is a pointer arg whose value is a - * grpc_channel_args object. If unset, most channel args from the parent channel - * will be propagated to the grpclb channel. */ -#define GRPC_ARG_EXPERIMENTAL_GRPCLB_CHANNEL_ARGS \ - "grpc.experimental.grpclb_channel_args" -/* Timeout in milliseconds to wait for the child of a specific priority to - complete its initial connection attempt before the priority LB policy fails - over to the next priority. Default value is 10 seconds. */ -#define GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS \ - "grpc.priority_failover_timeout_ms" -/** If non-zero, grpc server's cronet compression workaround will be enabled */ -#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \ - "grpc.workaround.cronet_compression" -/** String defining the optimization target for a channel. - Can be: "latency" - attempt to minimize latency at the cost of throughput - "blend" - try to balance latency and throughput - "throughput" - attempt to maximize throughput at the expense of - latency - Defaults to "blend". In the current implementation "blend" is equivalent to - "latency". */ -#define GRPC_ARG_OPTIMIZATION_TARGET "grpc.optimization_target" -/** Enables retry functionality. Defaults to true. When enabled, - transparent retries will be performed as appropriate, and configurable - retries are enabled when they are configured via the service config. - For details, see: - https://github.com/grpc/proposal/blob/master/A6-client-retries.md - NOTE: Hedging functionality is not yet implemented, so those - fields in the service config will currently be ignored. See - also the GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING arg below. - */ -#define GRPC_ARG_ENABLE_RETRIES "grpc.enable_retries" -/** Enables hedging functionality, as described in: - https://github.com/grpc/proposal/blob/master/A6-client-retries.md - Default is currently false, since this functionality is not yet - fully implemented. - NOTE: This channel arg is experimental and will eventually be removed. - Once hedging functionality has been implemented and proves stable, - this arg will be removed, and the hedging functionality will - be enabled via the GRPC_ARG_ENABLE_RETRIES arg above. */ -#define GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING "grpc.experimental.enable_hedging" -/** Per-RPC retry buffer size, in bytes. Default is 256 KiB. */ -#define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size" -/** Channel arg that carries the bridged objective c object for custom metrics - * logging filter. */ -#define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context" -/** If non-zero, client authority filter is disabled for the channel */ -#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \ - "grpc.disable_client_authority_filter" -/** If set to zero, disables use of http proxies. Enabled by default. */ -#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy" -/** Channel arg to set http proxy per channel. If set, the channel arg - * value will be preferred over the environment variable settings. */ -#define GRPC_ARG_HTTP_PROXY "grpc.http_proxy" -/** If set to non zero, surfaces the user agent string to the server. User - agent is surfaced by default. */ -#define GRPC_ARG_SURFACE_USER_AGENT "grpc.surface_user_agent" -/** If set, inhibits health checking (which may be enabled via the - * service config.) */ -#define GRPC_ARG_INHIBIT_HEALTH_CHECKING "grpc.inhibit_health_checking" -/** If enabled, the channel's DNS resolver queries for SRV records. - * This is useful only when using the "grpclb" load balancing policy, - * as described in the following documents: - * https://github.com/grpc/proposal/blob/master/A5-grpclb-in-dns.md - * https://github.com/grpc/proposal/blob/master/A24-lb-policy-config.md - * https://github.com/grpc/proposal/blob/master/A26-grpclb-selection.md - * Note that this works only with the "ares" DNS resolver; it isn't supported - * by the "native" DNS resolver. */ -#define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries" -/** If set, determines an upper bound on the number of milliseconds that the - * c-ares based DNS resolver will wait on queries before cancelling them. - * The default value is 120,000. Setting this to "0" will disable the - * overall timeout entirely. Note that this doesn't include internal c-ares - * timeouts/backoff/retry logic, and so the actual DNS resolution may time out - * sooner than the value specified here. */ -#define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout" -/** If set, uses a local subchannel pool within the channel. Otherwise, uses the - * global subchannel pool. */ -#define GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL "grpc.use_local_subchannel_pool" -/** gRPC Objective-C channel pooling domain string. */ -#define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain" -/** gRPC Objective-C channel pooling id. */ -#define GRPC_ARG_CHANNEL_ID "grpc.channel_id" -/** Channel argument for grpc_authorization_policy_provider. If present, enables - gRPC authorization check. */ -#define GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER \ - "grpc.authorization_policy_provider" -/** EXPERIMENTAL. Updates to a server's configuration from a config fetcher (for - * example, listener updates from xDS) cause all older connections to be - * gracefully shut down (i.e., "drained") with a grace period configured by this - * channel arg. Int valued, milliseconds. Defaults to 10 minutes.*/ -#define GRPC_ARG_SERVER_CONFIG_CHANGE_DRAIN_GRACE_TIME_MS \ - "grpc.experimental.server_config_change_drain_grace_time_ms" -/** Configure the Differentiated Services Code Point used on outgoing packets. - * Integer value ranging from 0 to 63. */ -#define GRPC_ARG_DSCP "grpc.dscp" -/** \} */ - /** Result of a grpc call. If the caller satisfies the prerequisites of a particular operation, the grpc_call_error returned will be GRPC_CALL_OK. Receiving any other value listed here is an indication of a bug in the diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 3f8840ccaff7f..a37f5dcaafc82 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -12,6 +12,7 @@ header "byte_buffer.h" header "grpc_posix.h" header "grpc_security.h" header "grpc_security_constants.h" + header "impl/channel_arg_names.h" header "impl/codegen/atm.h" header "impl/codegen/byte_buffer.h" header "impl/codegen/byte_buffer_reader.h" diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 1e99dc628e51d..bb055465e5f27 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -563,29 +563,6 @@ typedef unsigned __int64 uint64_t; #define GRPC_IF_NAMETOINDEX 1 #endif -#ifndef GRPC_MUST_USE_RESULT -#if defined(__GNUC__) && !defined(__MINGW32__) -#define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result)) -#define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n))) -#else -#define GRPC_MUST_USE_RESULT -#define GPR_ALIGN_STRUCT(n) -#endif -#ifdef USE_STRICT_WARNING -/* When building with USE_STRICT_WARNING (which -Werror), types with this - attribute will be treated as annotated with warn_unused_result, enforcing - returned values of this type should be used. - This is added in grpc::Status in mind to address the issue where it always - has this annotation internally but OSS doesn't, sometimes causing internal - build failure. To prevent this, this is added while not introducing - a breaking change to existing user code which may not use returned values - of grpc::Status. */ -#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING GRPC_MUST_USE_RESULT -#else -#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING -#endif -#endif - #ifndef GRPC_UNUSED #if defined(__GNUC__) && !defined(__MINGW32__) #define GRPC_UNUSED __attribute__((unused)) @@ -611,6 +588,35 @@ typedef unsigned __int64 uint64_t; #endif #endif /* GPR_HAS_CPP_ATTRIBUTE */ +#if defined(__GNUC__) && !defined(__MINGW32__) +#define GPR_ALIGN_STRUCT(n) __attribute__((aligned(n))) +#else +#define GPR_ALIGN_STRUCT(n) +#endif + +#ifndef GRPC_MUST_USE_RESULT +#if GPR_HAS_CPP_ATTRIBUTE(nodiscard) +#define GRPC_MUST_USE_RESULT [[nodiscard]] +#elif defined(__GNUC__) && !defined(__MINGW32__) +#define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result)) +#else +#define GRPC_MUST_USE_RESULT +#endif +#ifdef USE_STRICT_WARNING +/* When building with USE_STRICT_WARNING (which -Werror), types with this + attribute will be treated as annotated with warn_unused_result, enforcing + returned values of this type should be used. + This is added in grpc::Status in mind to address the issue where it always + has this annotation internally but OSS doesn't, sometimes causing internal + build failure. To prevent this, this is added while not introducing + a breaking change to existing user code which may not use returned values + of grpc::Status. */ +#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING GRPC_MUST_USE_RESULT +#else +#define GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING +#endif +#endif + #ifndef GPR_HAS_ATTRIBUTE #ifdef __has_attribute #define GPR_HAS_ATTRIBUTE(a) __has_attribute(a) diff --git a/include/grpcpp/ext/gcp_observability.h b/include/grpcpp/ext/gcp_observability.h index 871b51dce66af..b215312c68a1a 100644 --- a/include/grpcpp/ext/gcp_observability.h +++ b/include/grpcpp/ext/gcp_observability.h @@ -67,7 +67,7 @@ class GcpObservability { // As an implementation detail, this properly initializes the OpenCensus stats // and tracing plugin, so applications do not need to perform any additional // gRPC C++ OpenCensus setup/registration to get GCP Observability for gRPC. - static absl::StatusOr Init() GRPC_MUST_USE_RESULT; + static absl::StatusOr Init(); GcpObservability() = default; // Move constructor and Move-assignment operator. diff --git a/include/grpcpp/impl/call_op_set.h b/include/grpcpp/impl/call_op_set.h index 40d8f5d01c575..48c958a96f6c5 100644 --- a/include/grpcpp/impl/call_op_set.h +++ b/include/grpcpp/impl/call_op_set.h @@ -290,23 +290,23 @@ class CallOpSendMessage { /// Send \a message using \a options for the write. The \a options are cleared /// after use. template - Status SendMessage(const M& message, - WriteOptions options) GRPC_MUST_USE_RESULT; + GRPC_MUST_USE_RESULT Status SendMessage(const M& message, + WriteOptions options); template - Status SendMessage(const M& message) GRPC_MUST_USE_RESULT; + GRPC_MUST_USE_RESULT Status SendMessage(const M& message); /// Send \a message using \a options for the write. The \a options are cleared /// after use. This form of SendMessage allows gRPC to reference \a message /// beyond the lifetime of SendMessage. template - Status SendMessagePtr(const M* message, - WriteOptions options) GRPC_MUST_USE_RESULT; + GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message, + WriteOptions options); /// This form of SendMessage allows gRPC to reference \a message beyond the /// lifetime of SendMessage. template - Status SendMessagePtr(const M* message) GRPC_MUST_USE_RESULT; + GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message); protected: void AddOp(grpc_op* ops, size_t* nops) { diff --git a/include/grpcpp/version_info.h b/include/grpcpp/version_info.h index d84dee3fd9fdf..10f5dc207bb1a 100644 --- a/include/grpcpp/version_info.h +++ b/include/grpcpp/version_info.h @@ -19,9 +19,9 @@ #define GRPCPP_VERSION_INFO_H #define GRPC_CPP_VERSION_MAJOR 1 -#define GRPC_CPP_VERSION_MINOR 57 +#define GRPC_CPP_VERSION_MINOR 58 #define GRPC_CPP_VERSION_PATCH 0 #define GRPC_CPP_VERSION_TAG "dev" -#define GRPC_CPP_VERSION_STRING "1.57.0-dev" +#define GRPC_CPP_VERSION_STRING "1.58.0-dev" #endif // GRPCPP_VERSION_INFO_H diff --git a/package.xml b/package.xml index db3a373a32727..b4fd075885e2f 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2019-09-24 - 1.57.0dev - 1.57.0dev + 1.58.0dev + 1.58.0dev beta @@ -22,7 +22,7 @@ Apache 2.0 -- gRPC Core 1.57.0 update +- gRPC Core 1.58.0 update @@ -48,6 +48,7 @@ + @@ -297,6 +298,10 @@ + + + + @@ -1045,11 +1050,15 @@ + + + + @@ -1060,6 +1069,7 @@ + @@ -1072,6 +1082,7 @@ + @@ -1421,12 +1432,11 @@ - + - @@ -1446,7 +1456,6 @@ - @@ -1823,6 +1832,7 @@ + @@ -2093,13 +2103,25 @@ + + + - + + + + + + + + + + diff --git a/requirements.bazel.txt b/requirements.bazel.txt index 0a26df5ac2746..851dbd15a38da 100644 --- a/requirements.bazel.txt +++ b/requirements.bazel.txt @@ -7,7 +7,7 @@ oauth2client==4.1.0 requests==2.25.1 urllib3==1.26.5 chardet==3.0.4 -certifi==2017.4.17 +certifi==2023.7.22 idna==2.7 gevent==22.08.0 zope.event==4.5.0 @@ -15,3 +15,4 @@ setuptools==44.1.1 xds-protos==0.0.11 opencensus==0.10.0 opencensus-ext-stackdriver==0.8.0 +absl-py==1.4.0 diff --git a/requirements.txt b/requirements.txt index 603db125747ae..05390850559f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # GRPC Python setup requirements coverage>=4.0 -cython>=0.29.8 +cython>=0.29.8,<3.0.0rc1 protobuf>=4.21.3,<5.0dev wheel>=0.29 diff --git a/setup.py b/setup.py index 57364bfb04495..4e4d9cfe4d692 100644 --- a/setup.py +++ b/setup.py @@ -413,19 +413,12 @@ def _quote_build_define(argument): if BUILD_OVERRIDE_BORING_SSL_ASM_PLATFORM else util.get_platform() ) - LINUX_X86_64 = "linux-x86_64" - LINUX_ARM = "linux-arm" - LINUX_AARCH64 = "linux-aarch64" - if LINUX_X86_64 == boringssl_asm_platform: - asm_key = "crypto_linux_x86_64" - elif LINUX_ARM == boringssl_asm_platform: - asm_key = "crypto_linux_arm" - elif LINUX_AARCH64 == boringssl_asm_platform: - asm_key = "crypto_linux_aarch64" - elif "mac" in boringssl_asm_platform and "x86_64" in boringssl_asm_platform: - asm_key = "crypto_apple_x86_64" - elif "mac" in boringssl_asm_platform and "arm64" in boringssl_asm_platform: - asm_key = "crypto_apple_aarch64" + # BoringSSL's gas-compatible assembly files are all internally conditioned + # by the preprocessor. Provided the platform has a gas-compatible assembler + # (i.e. not Windows), we can include the assembly files and let BoringSSL + # decide which ones should and shouldn't be used for the build. + if not boringssl_asm_platform.startswith("win"): + asm_key = "crypto_asm" else: print( "ASM Builds for BoringSSL currently not supported on:", @@ -586,7 +579,7 @@ def cython_extensions_and_necessity(): sys.stderr.write( "We could not find Cython. Setup may take 10-20 minutes.\n" ) - SETUP_REQUIRES += ("cython>=0.23",) + SETUP_REQUIRES += ("cython>=0.23,<3.0.0rc1",) COMMAND_CLASS = { "doc": commands.SphinxDocumentation, diff --git a/src/abseil-cpp/preprocessed_builds.yaml b/src/abseil-cpp/preprocessed_builds.yaml index f5575e79fb109..d9354f889d5fe 100644 --- a/src/abseil-cpp/preprocessed_builds.yaml +++ b/src/abseil-cpp/preprocessed_builds.yaml @@ -150,11 +150,22 @@ name: absl/base:malloc_internal src: - third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +- cmake_target: absl::nullability + deps: + - absl/base:core_headers + - absl/meta:type_traits + headers: + - third_party/abseil-cpp/absl/base/internal/nullability_impl.h + - third_party/abseil-cpp/absl/base/nullability.h + name: absl/base:nullability + src: [] - cmake_target: absl::prefetch deps: - absl/base:config + - absl/base:core_headers headers: - third_party/abseil-cpp/absl/base/internal/prefetch.h + - third_party/abseil-cpp/absl/base/prefetch.h name: absl/base:prefetch src: [] - cmake_target: absl::pretty_function @@ -355,11 +366,13 @@ - absl/base:base - absl/base:config - absl/base:core_headers + - absl/base:raw_logging_internal - absl/debugging:stacktrace - absl/memory:memory - absl/profiling:exponential_biased - absl/profiling:sample_recorder - absl/synchronization:synchronization + - absl/time:time - absl/utility:utility headers: - third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h @@ -447,6 +460,7 @@ deps: - absl/base:config - absl/base:core_headers + - absl/base:dynamic_annotations - absl/base:endian - absl/base:prefetch - absl/base:raw_logging_internal @@ -456,6 +470,7 @@ - absl/container:hash_policy_traits - absl/container:hashtable_debug_hooks - absl/container:hashtablez_sampler + - absl/hash:hash - absl/memory:memory - absl/meta:type_traits - absl/numeric:bits @@ -484,6 +499,7 @@ - absl/crc:cpu_detect - absl/crc:crc_internal - absl/crc:non_temporal_memcpy + - absl/strings:str_format - absl/strings:strings headers: - third_party/abseil-cpp/absl/crc/crc32c.h @@ -607,6 +623,7 @@ deps: - absl/base:config - absl/base:core_headers + - absl/base:dynamic_annotations - absl/base:raw_logging_internal - absl/debugging:debugging_internal headers: @@ -724,6 +741,7 @@ - absl/base:config - absl/base:core_headers - absl/base:log_severity + - absl/numeric:int128 - absl/strings:str_format - absl/strings:strings - absl/types:optional @@ -807,6 +825,7 @@ deps: - absl/base:config - absl/base:core_headers + - absl/base:raw_logging_internal - absl/flags:usage_internal - absl/strings:strings - absl/synchronization:synchronization @@ -861,6 +880,7 @@ deps: - absl/base:base_internal - absl/base:core_headers + - absl/functional:any_invocable - absl/meta:type_traits headers: - third_party/abseil-cpp/absl/functional/function_ref.h @@ -903,6 +923,7 @@ deps: - absl/base:config - absl/base:endian + - absl/base:prefetch - absl/numeric:int128 headers: - third_party/abseil-cpp/absl/hash/internal/low_level_hash.h @@ -1172,6 +1193,7 @@ - absl/base:config - absl/base:core_headers - absl/base:log_severity + - absl/base:raw_logging_internal - absl/hash:hash - absl/strings:strings headers: @@ -1262,6 +1284,7 @@ - cmake_target: absl::type_traits deps: - absl/base:config + - absl/base:core_headers headers: - third_party/abseil-cpp/absl/meta/type_traits.h name: absl/meta:type_traits @@ -1680,7 +1703,6 @@ - absl/strings:cordz_update_scope - absl/strings:cordz_update_tracker - absl/strings:internal - - absl/strings:str_format - absl/strings:strings - absl/types:optional - absl/types:span @@ -1766,6 +1788,7 @@ - absl/strings:cordz_statistics - absl/strings:cordz_update_tracker - absl/synchronization:synchronization + - absl/time:time - absl/types:span headers: - third_party/abseil-cpp/absl/strings/internal/cordz_info.h @@ -1837,6 +1860,7 @@ deps: - absl/base:config - absl/base:core_headers + - absl/container:inlined_vector - absl/functional:function_ref - absl/meta:type_traits - absl/numeric:bits @@ -1863,6 +1887,17 @@ - third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc - third_party/abseil-cpp/absl/strings/internal/str_format/output.cc - third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +- cmake_target: absl::string_view + deps: + - absl/base:base + - absl/base:config + - absl/base:core_headers + - absl/base:throw_delegate + headers: + - third_party/abseil-cpp/absl/strings/string_view.h + name: absl/strings:string_view + src: + - third_party/abseil-cpp/absl/strings/string_view.cc - cmake_target: absl::strings deps: - absl/base:base @@ -1876,6 +1911,7 @@ - absl/numeric:bits - absl/numeric:int128 - absl/strings:internal + - absl/strings:string_view headers: - third_party/abseil-cpp/absl/strings/ascii.h - third_party/abseil-cpp/absl/strings/charconv.h @@ -1897,6 +1933,7 @@ - third_party/abseil-cpp/absl/strings/str_replace.h - third_party/abseil-cpp/absl/strings/str_split.h - third_party/abseil-cpp/absl/strings/string_view.h + - third_party/abseil-cpp/absl/strings/string_view.h - third_party/abseil-cpp/absl/strings/strip.h - third_party/abseil-cpp/absl/strings/substitute.h name: absl/strings:strings @@ -1914,7 +1951,6 @@ - third_party/abseil-cpp/absl/strings/str_cat.cc - third_party/abseil-cpp/absl/strings/str_replace.cc - third_party/abseil-cpp/absl/strings/str_split.cc - - third_party/abseil-cpp/absl/strings/string_view.cc - third_party/abseil-cpp/absl/strings/substitute.cc - cmake_target: absl::graphcycles_internal deps: @@ -1931,13 +1967,16 @@ - third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc - cmake_target: absl::kernel_timeout_internal deps: + - absl/base:base + - absl/base:config - absl/base:core_headers - absl/base:raw_logging_internal - absl/time:time headers: - third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h name: absl/synchronization:kernel_timeout_internal - src: [] + src: + - third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc - cmake_target: absl::synchronization deps: - absl/base:atomic_hook @@ -1958,8 +1997,14 @@ - third_party/abseil-cpp/absl/synchronization/blocking_counter.h - third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h - third_party/abseil-cpp/absl/synchronization/internal/futex.h + - third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.h - third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h + - third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.h + - third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.h + - third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.h - third_party/abseil-cpp/absl/synchronization/internal/waiter.h + - third_party/abseil-cpp/absl/synchronization/internal/waiter_base.h + - third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.h - third_party/abseil-cpp/absl/synchronization/mutex.h - third_party/abseil-cpp/absl/synchronization/notification.h name: absl/synchronization:synchronization @@ -1967,8 +2012,13 @@ - third_party/abseil-cpp/absl/synchronization/barrier.cc - third_party/abseil-cpp/absl/synchronization/blocking_counter.cc - third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc + - third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc - third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc - - third_party/abseil-cpp/absl/synchronization/internal/waiter.cc + - third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc + - third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc + - third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc + - third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc + - third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc - third_party/abseil-cpp/absl/synchronization/mutex.cc - third_party/abseil-cpp/absl/synchronization/notification.cc - cmake_target: absl::civil_time @@ -2122,6 +2172,13 @@ - third_party/abseil-cpp/absl/types/variant.h name: absl/types:variant src: [] +- cmake_target: absl::if_constexpr + deps: + - absl/base:config + headers: + - third_party/abseil-cpp/absl/utility/internal/if_constexpr.h + name: absl/utility:if_constexpr + src: [] - cmake_target: absl::utility deps: - absl/base:base_internal diff --git a/src/core/BUILD b/src/core/BUILD index 24e0e676570ad..b6c7590a4fd47 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -127,6 +127,7 @@ grpc_cc_library( ], language = "c++", tags = ["nofixdeps"], + visibility = ["@grpc:grpc_experiments"], deps = [ "no_destruct", "//:config_vars", @@ -664,21 +665,30 @@ grpc_cc_library( grpc_cc_library( name = "basic_seq", - external_deps = [ - "absl/meta:type_traits", - "absl/utility", - ], language = "c++", public_hdrs = [ "lib/promise/detail/basic_seq.h", ], + deps = [ + "construct_destruct", + "poll", + "//:gpr_platform", + ], +) + +grpc_cc_library( + name = "seq_state", + external_deps = ["absl/base:core_headers"], + language = "c++", + public_hdrs = [ + "lib/promise/detail/seq_state.h", + ], deps = [ "construct_destruct", "poll", "promise_factory", "promise_like", - "switch", - "//:gpr_platform", + "//:gpr", ], ) @@ -692,6 +702,7 @@ grpc_cc_library( "basic_seq", "poll", "promise_like", + "seq_state", "//:gpr_platform", ], ) @@ -712,6 +723,7 @@ grpc_cc_library( "poll", "promise_like", "promise_status", + "seq_state", "//:gpr_platform", ], ) @@ -1079,7 +1091,6 @@ grpc_cc_library( ], deps = [ "activity", - "basic_seq", "event_engine_memory_allocator", "exec_ctx_wakeup_scheduler", "experiments", @@ -1123,9 +1134,8 @@ grpc_cc_library( hdrs = [ "lib/resource_quota/arena.h", ], - external_deps = [ - "absl/meta:type_traits", - "absl/utility", + visibility = [ + "@grpc:alt_grpc_base_legacy", ], deps = [ "construct_destruct", @@ -1175,11 +1185,15 @@ grpc_cc_library( "lib/resource_quota/resource_quota.h", ], external_deps = ["absl/strings"], + visibility = [ + "@grpc:alt_grpc_base_legacy", + ], deps = [ "memory_quota", "ref_counted", "thread_quota", "useful", + "//:channel_arg_names", "//:cpp_impl_of", "//:event_engine_base_hdrs", "//:gpr_platform", @@ -1352,8 +1366,10 @@ grpc_cc_library( "lib/avl/avl.h", ], deps = [ + "ref_counted", "useful", "//:gpr_platform", + "//:ref_counted_ptr", ], ) @@ -1380,6 +1396,7 @@ grpc_cc_library( "//:config_vars", "//:gpr", "//:gpr_platform", + "//:grpc_trace", ], ) @@ -1503,6 +1520,7 @@ grpc_cc_library( "event_engine_work_queue", "experiments", "forkable", + "notification", "time", "useful", "//:backoff", @@ -1735,6 +1753,7 @@ grpc_cc_library( "common_event_engine_closures", "event_engine_poller", "event_engine_time_util", + "forkable", "iomgr_port", "posix_event_engine_closure", "posix_event_engine_event_poller", @@ -1886,6 +1905,7 @@ grpc_cc_library( "strerror", "time", "useful", + "//:channel_arg_names", "//:event_engine_base_hdrs", "//:gpr", "//:ref_counted_ptr", @@ -1967,6 +1987,7 @@ grpc_cc_library( "absl/strings", ], deps = [ + "ares_resolver", "event_engine_common", "event_engine_poller", "event_engine_tcp_socket_utils", @@ -1988,6 +2009,7 @@ grpc_cc_library( "//:event_engine_base_hdrs", "//:gpr", "//:grpc_trace", + "//:orphanable", ], ) @@ -2111,13 +2133,18 @@ grpc_cc_library( srcs = [ "lib/event_engine/cf_engine/cf_engine.cc", "lib/event_engine/cf_engine/cfstream_endpoint.cc", + "lib/event_engine/cf_engine/dns_service_resolver.cc", ], hdrs = [ "lib/event_engine/cf_engine/cf_engine.h", "lib/event_engine/cf_engine/cfstream_endpoint.h", "lib/event_engine/cf_engine/cftype_unique_ref.h", + "lib/event_engine/cf_engine/dns_service_resolver.h", + ], + external_deps = [ + "absl/container:flat_hash_map", + "absl/strings:str_format", ], - external_deps = ["absl/strings:str_format"], deps = [ "event_engine_common", "event_engine_tcp_socket_utils", @@ -2133,6 +2160,7 @@ grpc_cc_library( "strerror", "//:event_engine_base_hdrs", "//:gpr", + "//:parse_address", "//:ref_counted_ptr", "//:sockaddr_utils", ], @@ -2290,6 +2318,49 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "ares_resolver", + srcs = [ + "lib/event_engine/ares_resolver.cc", + ], + hdrs = [ + "lib/event_engine/ares_resolver.h", + "lib/event_engine/grpc_polled_fd.h", + "lib/event_engine/posix_engine/grpc_polled_fd_posix.h", + ], + external_deps = [ + "absl/base:core_headers", + "absl/container:flat_hash_map", + "absl/functional:any_invocable", + "absl/hash", + "absl/status", + "absl/status:statusor", + "absl/strings", + "absl/strings:str_format", + "absl/types:optional", + "absl/types:variant", + "cares", + ], + deps = [ + "error", + "event_engine_time_util", + "grpc_sockaddr", + "iomgr_port", + "posix_event_engine_closure", + "posix_event_engine_event_poller", + "posix_event_engine_tcp_socket_utils", + "resolved_address", + "//:debug_location", + "//:event_engine_base_hdrs", + "//:gpr", + "//:grpc_trace", + "//:orphanable", + "//:parse_address", + "//:ref_counted_ptr", + "//:sockaddr_utils", + ], +) + grpc_cc_library( name = "channel_args_preconditioning", srcs = [ @@ -2567,7 +2638,6 @@ grpc_cc_library( "absl/strings", "absl/strings:str_format", "absl/types:optional", - "absl/types:variant", ], language = "c++", visibility = [ @@ -2577,10 +2647,10 @@ grpc_cc_library( "avl", "channel_stack_type", "dual_ref_counted", - "match", "ref_counted", "time", "useful", + "//:channel_arg_names", "//:debug_location", "//:event_engine_base_hdrs", "//:gpr", @@ -2900,6 +2970,7 @@ grpc_cc_library( "resolved_address", "slice", "useful", + "//:channel_arg_names", "//:gpr", "//:grpc_base", "//:grpc_credentials_util", @@ -2940,6 +3011,7 @@ grpc_cc_library( "slice", "unique_type_name", "useful", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -3074,6 +3146,7 @@ grpc_cc_library( "iomgr_fwd", "unique_type_name", "useful", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -3125,6 +3198,7 @@ grpc_cc_library( "unique_type_name", "useful", "//:alts_util", + "//:channel_arg_names", "//:exec_ctx", "//:gpr", "//:grpc_alts_credentials", @@ -3194,6 +3268,7 @@ grpc_cc_library( "status_helper", "unique_type_name", "useful", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -3359,6 +3434,7 @@ grpc_cc_library( "error", "iomgr_fwd", "unique_type_name", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -3587,6 +3663,7 @@ grpc_cc_library( "status_helper", "time", "try_seq", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:debug_location", @@ -3625,6 +3702,7 @@ grpc_cc_library( "error", "status_helper", "time", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:debug_location", @@ -3657,6 +3735,7 @@ grpc_cc_library( "channel_fwd", "channel_stack_type", "slice", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr_platform", @@ -3699,6 +3778,7 @@ grpc_cc_library( "slice", "slice_buffer", "validation_errors", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr", @@ -3897,6 +3977,7 @@ grpc_cc_library( "useful", "validation_errors", "//:backoff", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:debug_location", @@ -3917,7 +3998,6 @@ grpc_cc_library( "//:ref_counted_ptr", "//:server_address", "//:sockaddr_utils", - "//:uri_parser", "//:work_serializer", ], ) @@ -3989,6 +4069,7 @@ grpc_cc_library( "time", "validation_errors", "//:backoff", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -4004,7 +4085,6 @@ grpc_cc_library( "//:ref_counted_ptr", "//:rls_upb", "//:server_address", - "//:uri_parser", "//:work_serializer", ], ) @@ -4187,6 +4267,7 @@ grpc_cc_library( "validation_errors", "xds_type_upb", "xds_type_upbdefs", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -4387,6 +4468,7 @@ grpc_cc_library( "lb_policy_registry", "pollset_set", "validation_errors", + "//:channel_arg_names", "//:config", "//:debug_location", "//:gpr", @@ -4572,6 +4654,7 @@ grpc_cc_library( "slice", "subchannel_interface", "unique_type_name", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -4604,6 +4687,7 @@ grpc_cc_library( "iomgr_fwd", "lb_policy", "subchannel_interface", + "//:channel_arg_names", "//:debug_location", "//:gpr", "//:grpc_base", @@ -4643,6 +4727,7 @@ grpc_cc_library( "lb_policy_factory", "subchannel_interface", "validation_errors", + "//:channel_arg_names", "//:config", "//:debug_location", "//:gpr", @@ -4688,6 +4773,7 @@ grpc_cc_library( "subchannel_interface", "unique_type_name", "validation_errors", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -4883,6 +4969,7 @@ grpc_cc_library( "pollset_set", "time", "validation_errors", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -5019,6 +5106,7 @@ grpc_cc_library( "resolved_address", "seq", "slice", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr", @@ -5058,6 +5146,7 @@ grpc_cc_library( "grpc_backend_metric_provider", "map", "slice", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr", @@ -5146,7 +5235,9 @@ grpc_cc_library( "time", "validation_errors", "//:backoff", + "//:channel_arg_names", "//:debug_location", + "//:exec_ctx", "//:gpr", "//:gpr_platform", "//:grpc_base", @@ -5205,6 +5296,7 @@ grpc_cc_library( "resolved_address", "time", "//:backoff", + "//:channel_arg_names", "//:config", "//:debug_location", "//:gpr", @@ -5317,6 +5409,7 @@ grpc_cc_library( "ref_counted", "slice", "time", + "//:channel_arg_names", "//:config", "//:debug_location", "//:gpr", @@ -5423,6 +5516,45 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "ping_abuse_policy", + srcs = [ + "ext/transport/chttp2/transport/ping_abuse_policy.cc", + ], + hdrs = [ + "ext/transport/chttp2/transport/ping_abuse_policy.h", + ], + external_deps = ["absl/types:optional"], + deps = [ + "channel_args", + "time", + "//:channel_arg_names", + "//:gpr_platform", + ], +) + +grpc_cc_library( + name = "ping_rate_policy", + srcs = [ + "ext/transport/chttp2/transport/ping_rate_policy.cc", + ], + hdrs = [ + "ext/transport/chttp2/transport/ping_rate_policy.h", + ], + external_deps = [ + "absl/strings", + "absl/types:optional", + "absl/types:variant", + ], + deps = [ + "channel_args", + "match", + "time", + "//:channel_arg_names", + "//:gpr_platform", + ], +) + grpc_cc_library( name = "huffsyms", srcs = [ @@ -5506,6 +5638,7 @@ grpc_cc_library( "time", "transport_fwd", "unique_type_name", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -5557,6 +5690,7 @@ grpc_cc_library( "time", "transport_fwd", "unique_type_name", + "//:channel_arg_names", "//:chttp2_frame", "//:config", "//:debug_location", @@ -5603,6 +5737,7 @@ grpc_cc_library( "status_helper", "time", "transport_fwd", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -5749,6 +5884,7 @@ grpc_cc_library( "slice", "slice_buffer", "time", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr", diff --git a/src/core/ext/filters/backend_metrics/backend_metric_filter.cc b/src/core/ext/filters/backend_metrics/backend_metric_filter.cc index e1eae2a62b32c..61cd59b393280 100644 --- a/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +++ b/src/core/ext/filters/backend_metrics/backend_metric_filter.cc @@ -30,7 +30,7 @@ #include "upb/upb.hpp" #include "xds/data/orca/v3/orca_load_report.upb.h" -#include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h" diff --git a/src/core/ext/filters/channel_idle/channel_idle_filter.cc b/src/core/ext/filters/channel_idle/channel_idle_filter.cc index e2a6c36bb2ba0..5a7d98efc4774 100644 --- a/src/core/ext/filters/channel_idle/channel_idle_filter.cc +++ b/src/core/ext/filters/channel_idle/channel_idle_filter.cc @@ -19,6 +19,7 @@ #include "src/core/ext/filters/channel_idle/channel_idle_filter.h" +#include #include #include @@ -26,7 +27,7 @@ #include "absl/types/optional.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index d250c32102b46..1bab8f8003432 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -41,6 +41,7 @@ #include "absl/types/variant.h" #include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/dynamic_filters.h b/src/core/ext/filters/client_channel/dynamic_filters.h index 50eafa75aabf6..87712aa6c5c2b 100644 --- a/src/core/ext/filters/client_channel/dynamic_filters.h +++ b/src/core/ext/filters/client_channel/dynamic_filters.h @@ -68,9 +68,9 @@ class DynamicFilters : public RefCounted { void SetAfterCallStackDestroy(grpc_closure* closure); // Interface of RefCounted<>. - RefCountedPtr Ref() GRPC_MUST_USE_RESULT; - RefCountedPtr Ref(const DebugLocation& location, - const char* reason) GRPC_MUST_USE_RESULT; + GRPC_MUST_USE_RESULT RefCountedPtr Ref(); + GRPC_MUST_USE_RESULT RefCountedPtr Ref(const DebugLocation& location, + const char* reason); // When refcount drops to 0, destroys itself and the associated call stack, // but does NOT free the memory because it's in the call arena. void Unref(); diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 6eb61fce4fa6d..54dac2dbf4393 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -39,7 +39,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 182bb9f1187cf..2d079ed2b7d50 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -54,6 +54,7 @@ #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" #include +#include #include // IWYU pragma: no_include @@ -78,7 +79,6 @@ #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "absl/types/optional.h" #include "absl/types/variant.h" #include "upb/upb.hpp" @@ -144,7 +144,6 @@ #include "src/core/lib/surface/channel_stack_type.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/metadata_batch.h" -#include "src/core/lib/uri/uri_parser.h" #define GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER 1.6 @@ -523,8 +522,6 @@ class GrpcLb : public LoadBalancingPolicy { void StartSubchannelCacheTimerLocked(); void OnSubchannelCacheTimerLocked(); - // Who the client is trying to communicate with. - std::string server_name_; // Configurations for the policy. RefCountedPtr config_; @@ -854,8 +851,6 @@ GrpcLb::BalancerCallState::BalancerCallState( // Init the LB call. Note that the LB call will progress every time there's // activity in grpclb_policy_->interested_parties(), which is comprised of // the polling entities from client_channel. - GPR_ASSERT(!grpclb_policy()->server_name_.empty()); - // Closure Initialization GRPC_CLOSURE_INIT(&lb_on_initial_request_sent_, OnInitialRequestSent, this, grpc_schedule_on_exec_ctx); GRPC_CLOSURE_INIT(&lb_on_balancer_message_received_, @@ -877,8 +872,8 @@ GrpcLb::BalancerCallState::BalancerCallState( upb::Arena arena; grpc_slice request_payload_slice = GrpcLbRequestCreate( grpclb_policy()->config_->service_name().empty() - ? grpclb_policy()->server_name_.c_str() - : grpclb_policy()->config_->service_name().c_str(), + ? grpclb_policy()->channel_control_helper()->GetAuthority() + : grpclb_policy()->config_->service_name(), arena.ptr()); send_message_payload_ = grpc_raw_byte_buffer_create(&request_payload_slice, 1); @@ -1372,10 +1367,6 @@ ChannelArgs BuildBalancerChannelArgs( // Strip out the service config, since we don't want the LB policy // config specified for the parent channel to affect the LB channel. .Remove(GRPC_ARG_SERVICE_CONFIG) - // The channel arg for the server URI, since that will be different - // for the LB channel than for the parent channel. The client - // channel factory will re-add this arg with the right value. - .Remove(GRPC_ARG_SERVER_URI) // The fake resolver response generator, because we are replacing it // with the one from the grpclb policy, used to propagate updates to // the LB channel. @@ -1411,16 +1402,8 @@ ChannelArgs BuildBalancerChannelArgs( // ctor and dtor // -std::string GetServerNameFromChannelArgs(const ChannelArgs& args) { - absl::StatusOr uri = - URI::Parse(args.GetString(GRPC_ARG_SERVER_URI).value()); - GPR_ASSERT(uri.ok() && !uri->path().empty()); - return std::string(absl::StripPrefix(uri->path(), "/")); -} - GrpcLb::GrpcLb(Args args) : LoadBalancingPolicy(std::move(args)), - server_name_(GetServerNameFromChannelArgs(channel_args())), response_generator_(MakeRefCounted()), lb_call_timeout_(std::max( Duration::Zero(), @@ -1451,7 +1434,8 @@ GrpcLb::GrpcLb(Args args) if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) { gpr_log(GPR_INFO, "[grpclb %p] Will use '%s' as the server name for LB request.", - this, server_name_.c_str()); + this, + std::string(channel_control_helper()->GetAuthority()).c_str()); } } @@ -1581,7 +1565,8 @@ absl::Status GrpcLb::UpdateBalancerChannelLocked() { BuildBalancerChannelArgs(response_generator_.get(), args_); // Create balancer channel if needed. if (lb_channel_ == nullptr) { - std::string uri_str = absl::StrCat("fake:///", server_name_); + std::string uri_str = + absl::StrCat("fake:///", channel_control_helper()->GetAuthority()); lb_channel_ = grpc_channel_create(uri_str.c_str(), channel_credentials.get(), lb_channel_args.ToC().get()); diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc index b1b792a98bda3..457cd5a00ce70 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc @@ -59,15 +59,16 @@ grpc_slice grpc_grpclb_request_encode( } // namespace -grpc_slice GrpcLbRequestCreate(const char* lb_service_name, upb_Arena* arena) { +grpc_slice GrpcLbRequestCreate(absl::string_view lb_service_name, + upb_Arena* arena) { grpc_lb_v1_LoadBalanceRequest* req = grpc_lb_v1_LoadBalanceRequest_new(arena); grpc_lb_v1_InitialLoadBalanceRequest* initial_request = grpc_lb_v1_LoadBalanceRequest_mutable_initial_request(req, arena); - size_t name_len = std::min(strlen(lb_service_name), + size_t name_len = std::min(lb_service_name.size(), size_t{GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH}); grpc_lb_v1_InitialLoadBalanceRequest_set_name( initial_request, - upb_StringView_FromDataAndSize(lb_service_name, name_len)); + upb_StringView_FromDataAndSize(lb_service_name.data(), name_len)); return grpc_grpclb_request_encode(req, arena); } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h index b74868ce3347b..9b7177d059728 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h @@ -24,6 +24,7 @@ #include +#include "absl/strings/string_view.h" #include "upb/mem/arena.h" #include @@ -56,7 +57,8 @@ struct GrpcLbResponse { }; // Creates a serialized grpclb request. -grpc_slice GrpcLbRequestCreate(const char* lb_service_name, upb_Arena* arena); +grpc_slice GrpcLbRequestCreate(absl::string_view lb_service_name, + upb_Arena* arena); // Creates a serialized grpclb load report request. grpc_slice GrpcLbLoadReportRequestCreate( diff --git a/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc b/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc index f9b02cdfe5339..859fc4b78bd1c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +++ b/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc @@ -33,7 +33,7 @@ #include "upb/base/string_view.h" #include "upb/upb.hpp" -#include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 3e4788e279004..ecb6aaeaa61e7 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -33,7 +33,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc b/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc index b1b39dae5e7f6..fe22f3b926368 100644 --- a/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +++ b/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc @@ -35,7 +35,7 @@ #include "absl/types/optional.h" #include -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc b/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc index f5767e4679fdf..6cc1a948b3447 100644 --- a/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +++ b/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc @@ -37,10 +37,11 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include + #define XXH_INLINE_ALL #include "xxhash.h" -#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc b/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc index 3b1927d6d0cea..7a23aa8308440 100644 --- a/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +++ b/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc @@ -48,7 +48,6 @@ #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" -#include "absl/strings/strip.h" #include "absl/types/optional.h" #include "upb/base/string_view.h" #include "upb/upb.hpp" @@ -57,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -103,7 +103,6 @@ #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/error_utils.h" -#include "src/core/lib/uri/uri_parser.h" #include "src/proto/grpc/lookup/v1/rls.upb.h" namespace grpc_core { @@ -693,9 +692,6 @@ class RlsLb : public LoadBalancingPolicy { // Updates the picker in the work serializer. void UpdatePickerLocked() ABSL_LOCKS_EXCLUDED(&mu_); - // The name of the server for the channel. - std::string server_name_; - // Mutex to guard LB policy state that is accessed by the picker. Mutex mu_; bool is_shutdown_ ABSL_GUARDED_BY(mu_) = false; @@ -899,7 +895,7 @@ void RlsLb::ChildPolicyWrapper::ChildPolicyHelper::UpdateState( // Builds the key to be used for a request based on path and initial_metadata. std::map BuildKeyMap( const RlsLbConfig::KeyBuilderMap& key_builder_map, absl::string_view path, - const std::string& host, + absl::string_view host, const LoadBalancingPolicy::MetadataInterface* initial_metadata) { size_t last_slash_pos = path.npos; // May need this a few times, so cache it. // Find key builder for this path. @@ -935,7 +931,7 @@ std::map BuildKeyMap( key_builder->constant_keys.end()); // Add host key. if (!key_builder->host_key.empty()) { - key_map[key_builder->host_key] = host; + key_map[key_builder->host_key] = std::string(host); } // Add service key. if (!key_builder->service_key.empty()) { @@ -970,9 +966,10 @@ RlsLb::Picker::Picker(RefCountedPtr lb_policy) LoadBalancingPolicy::PickResult RlsLb::Picker::Pick(PickArgs args) { // Construct key for request. - RequestKey key = {BuildKeyMap(config_->key_builder_map(), args.path, - lb_policy_->server_name_, - args.initial_metadata)}; + RequestKey key = { + BuildKeyMap(config_->key_builder_map(), args.path, + lb_policy_->channel_control_helper()->GetAuthority(), + args.initial_metadata)}; if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) { gpr_log(GPR_INFO, "[rlslb %p] picker=%p: request keys: %s", lb_policy_.get(), this, key.ToString().c_str()); @@ -1857,18 +1854,7 @@ RlsLb::ResponseInfo RlsLb::RlsRequest::ParseResponseProto() { // RlsLb // -std::string GetServerUri(const ChannelArgs& args) { - auto server_uri_str = args.GetString(GRPC_ARG_SERVER_URI); - GPR_ASSERT(server_uri_str.has_value()); - absl::StatusOr uri = URI::Parse(*server_uri_str); - GPR_ASSERT(uri.ok()); - return std::string(absl::StripPrefix(uri->path(), "/")); -} - -RlsLb::RlsLb(Args args) - : LoadBalancingPolicy(std::move(args)), - server_name_(GetServerUri(channel_args())), - cache_(this) { +RlsLb::RlsLb(Args args) : LoadBalancingPolicy(std::move(args)), cache_(this) { if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) { gpr_log(GPR_INFO, "[rlslb %p] policy created", this); } diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 87072c7381c6d..4acd432d7eb59 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -30,7 +30,7 @@ #include "absl/status/status.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc index b4db0dbec1428..ca487ad5dc576 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc @@ -35,7 +35,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 1f609a8e2f04b..47706e2cbb84f 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -33,7 +33,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc index 4f0813edccab3..79deb800fb89a 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc @@ -17,28 +17,37 @@ // #include -#include -#include - -#include "absl/base/thread_annotations.h" - -#include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/iomgr/port.h" + #if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) -#include +// IWYU pragma: no_include + #include +#include +#include +#include + +#include +#include +#include +#include #include +#include "absl/base/thread_annotations.h" #include "absl/strings/str_cat.h" +#include + #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/lib/gprpp/sync.h" +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/ev_posix.h" +#include "src/core/lib/iomgr/iomgr_fwd.h" +#include "src/core/lib/iomgr/socket_utils_posix.h" namespace grpc_core { @@ -98,12 +107,94 @@ class GrpcPolledFdPosix : public GrpcPolledFd { class GrpcPolledFdFactoryPosix : public GrpcPolledFdFactory { public: + ~GrpcPolledFdFactoryPosix() override { + for (auto& fd : owned_fds_) { + close(fd); + } + } + GrpcPolledFd* NewGrpcPolledFdLocked( ares_socket_t as, grpc_pollset_set* driver_pollset_set) override { + auto insert_result = owned_fds_.insert(as); + GPR_ASSERT(insert_result.second); return new GrpcPolledFdPosix(as, driver_pollset_set); } - void ConfigureAresChannelLocked(ares_channel /*channel*/) override {} + void ConfigureAresChannelLocked(ares_channel channel) override { + ares_set_socket_functions(channel, &kSockFuncs, this); + ares_set_socket_configure_callback( + channel, &GrpcPolledFdFactoryPosix::ConfigureSocket, nullptr); + } + + private: + /// Overridden socket API for c-ares + static ares_socket_t Socket(int af, int type, int protocol, + void* /*user_data*/) { + return socket(af, type, protocol); + } + + /// Overridden connect API for c-ares + static int Connect(ares_socket_t as, const struct sockaddr* target, + ares_socklen_t target_len, void* /*user_data*/) { + return connect(as, target, target_len); + } + + /// Overridden writev API for c-ares + static ares_ssize_t WriteV(ares_socket_t as, const struct iovec* iov, + int iovec_count, void* /*user_data*/) { + return writev(as, iov, iovec_count); + } + + /// Overridden recvfrom API for c-ares + static ares_ssize_t RecvFrom(ares_socket_t as, void* data, size_t data_len, + int flags, struct sockaddr* from, + ares_socklen_t* from_len, void* /*user_data*/) { + return recvfrom(as, data, data_len, flags, from, from_len); + } + + /// Overridden close API for c-ares + static int Close(ares_socket_t as, void* user_data) { + GrpcPolledFdFactoryPosix* self = + static_cast(user_data); + if (self->owned_fds_.find(as) == self->owned_fds_.end()) { + // c-ares owns this fd, grpc has never seen it + return close(as); + } + return 0; + } + + /// Because we're using socket API overrides, c-ares won't + /// perform its typical configuration on the socket. See + /// https://github.com/c-ares/c-ares/blob/bad62225b7f6b278b92e8e85a255600b629ef517/src/lib/ares_process.c#L1018. + /// So we use the configure socket callback override and copy default + /// settings that c-ares would normally apply on posix platforms: + /// - non-blocking + /// - cloexec flag + /// - disable nagle */ + static int ConfigureSocket(ares_socket_t fd, int type, void* /*user_data*/) { + grpc_error_handle err; + err = grpc_set_socket_nonblocking(fd, true); + if (!err.ok()) return -1; + err = grpc_set_socket_cloexec(fd, true); + if (!err.ok()) return -1; + if (type == SOCK_STREAM) { + err = grpc_set_socket_low_latency(fd, true); + if (!err.ok()) return -1; + } + return 0; + } + + const struct ares_socket_functions kSockFuncs = { + &GrpcPolledFdFactoryPosix::Socket /* socket */, + &GrpcPolledFdFactoryPosix::Close /* close */, + &GrpcPolledFdFactoryPosix::Connect /* connect */, + &GrpcPolledFdFactoryPosix::RecvFrom /* recvfrom */, + &GrpcPolledFdFactoryPosix::WriteV /* writev */, + }; + + // fds that are used/owned by grpc - we (grpc) will close them rather than + // c-ares + std::unordered_set owned_fds_; }; std::unique_ptr NewGrpcPolledFdFactory(Mutex* /* mu */) { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index cee19837b4843..3032bfda7970a 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -24,7 +24,7 @@ #include "absl/strings/string_view.h" -#include +#include #include "src/core/lib/gprpp/status_helper.h" #include "src/core/lib/iomgr/sockaddr.h" @@ -510,11 +510,13 @@ void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver) &ev_driver->on_ares_backup_poll_alarm_locked); } -static void noop_inject_channel_config(ares_channel /*channel*/) {} +static void noop_inject_channel_config(ares_channel* /*channel*/) {} -void (*grpc_ares_test_only_inject_config)(ares_channel channel) = +void (*grpc_ares_test_only_inject_config)(ares_channel* channel) = noop_inject_channel_config; +bool g_grpc_ares_test_only_force_tcp = false; + grpc_error_handle grpc_ares_ev_driver_create_locked( grpc_ares_ev_driver** ev_driver, grpc_pollset_set* pollset_set, int query_timeout_ms, grpc_ares_request* request) @@ -523,8 +525,11 @@ grpc_error_handle grpc_ares_ev_driver_create_locked( ares_options opts; memset(&opts, 0, sizeof(opts)); opts.flags |= ARES_FLAG_STAYOPEN; + if (g_grpc_ares_test_only_force_tcp) { + opts.flags |= ARES_FLAG_USEVC; + } int status = ares_init_options(&(*ev_driver)->channel, &opts, ARES_OPT_FLAGS); - grpc_ares_test_only_inject_config((*ev_driver)->channel); + grpc_ares_test_only_inject_config(&(*ev_driver)->channel); GRPC_CARES_TRACE_LOG("request:%p grpc_ares_ev_driver_create_locked", request); if (status != ARES_SUCCESS) { grpc_error_handle err = GRPC_ERROR_CREATE(absl::StrCat( diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h index ffe7cf9e01aa5..5970e131cccfc 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h @@ -131,6 +131,9 @@ void grpc_cares_wrapper_address_sorting_sort( const grpc_ares_request* request, grpc_core::ServerAddressList* addresses); // Exposed in this header for C-core tests only -extern void (*grpc_ares_test_only_inject_config)(ares_channel channel); +extern void (*grpc_ares_test_only_inject_config)(ares_channel* channel); + +// Exposed in this header for C-core tests only +extern bool g_grpc_ares_test_only_force_tcp; #endif // GRPC_SRC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H diff --git a/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc index a7061cfe9231c..8d5566677ae0a 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -36,7 +35,7 @@ #include "absl/types/optional.h" #include -#include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h" @@ -51,6 +50,7 @@ #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/time.h" #include "src/core/lib/gprpp/validation_errors.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/resolver/resolver.h" #include "src/core/lib/resolver/resolver_factory.h" @@ -200,9 +200,17 @@ EventEngineClientChannelDNSResolver::EventEngineClientChannelDNSResolver( event_engine_(channel_args().GetObjectRef()) {} OrphanablePtr EventEngineClientChannelDNSResolver::StartRequest() { + auto dns_resolver = + event_engine_->GetDNSResolver({/*dns_server=*/authority()}); + if (!dns_resolver.ok()) { + Result result; + result.addresses = dns_resolver.status(); + result.service_config = dns_resolver.status(); + OnRequestComplete(std::move(result)); + return nullptr; + } return MakeOrphanable( - Ref(DEBUG_LOCATION, "dns-resolving"), - event_engine_->GetDNSResolver({/*dns_server=*/authority()})); + Ref(DEBUG_LOCATION, "dns-resolving"), std::move(*dns_resolver)); } // ---------------------------------------------------------------------------- @@ -223,8 +231,12 @@ EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: is_hostname_inflight_ = true; event_engine_resolver_->LookupHostname( [self = Ref(DEBUG_LOCATION, "OnHostnameResolved")]( - absl::StatusOr> addresses) { + absl::StatusOr> + addresses) mutable { + ApplicationCallbackExecCtx callback_exec_ctx; + ExecCtx exec_ctx; self->OnHostnameResolved(std::move(addresses)); + self.reset(); }, resolver_->name_to_resolve(), kDefaultSecurePort); if (resolver_->enable_srv_queries_) { @@ -235,8 +247,13 @@ EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: event_engine_resolver_->LookupSRV( [self = Ref(DEBUG_LOCATION, "OnSRVResolved")]( absl::StatusOr> - srv_records) { self->OnSRVResolved(std::move(srv_records)); }, - resolver_->name_to_resolve()); + srv_records) mutable { + ApplicationCallbackExecCtx callback_exec_ctx; + ExecCtx exec_ctx; + self->OnSRVResolved(std::move(srv_records)); + self.reset(); + }, + absl::StrCat("_grpclb._tcp.", resolver_->name_to_resolve())); } if (resolver_->request_service_config_) { GRPC_EVENT_ENGINE_RESOLVER_TRACE( @@ -245,8 +262,11 @@ EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: is_txt_inflight_ = true; event_engine_resolver_->LookupTXT( [self = Ref(DEBUG_LOCATION, "OnTXTResolved")]( - absl::StatusOr> service_config) { + absl::StatusOr> service_config) mutable { + ApplicationCallbackExecCtx callback_exec_ctx; + ExecCtx exec_ctx; self->OnTXTResolved(std::move(service_config)); + self.reset(); }, absl::StrCat("_grpc_config.", resolver_->name_to_resolve())); } @@ -255,8 +275,12 @@ EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: ? EventEngine::Duration::max() : resolver_->query_timeout_ms_; timeout_handle_ = resolver_->event_engine_->RunAfter( - timeout, - [self = Ref(DEBUG_LOCATION, "OnTimeout")]() { self->OnTimeout(); }); + timeout, [self = Ref(DEBUG_LOCATION, "OnTimeout")]() mutable { + ApplicationCallbackExecCtx callback_exec_ctx; + ExecCtx exec_ctx; + self->OnTimeout(); + self.reset(); + }); } EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: @@ -292,10 +316,11 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: OnHostnameResolved(absl::StatusOr> new_addresses) { - ValidationErrors::ScopedField field(&errors_, "hostname lookup"); absl::optional result; { MutexLock lock(&on_resolved_mu_); + // Make sure field destroys before cleanup. + ValidationErrors::ScopedField field(&errors_, "hostname lookup"); if (orphaned_) return; is_hostname_inflight_ = false; if (!new_addresses.ok()) { @@ -317,7 +342,6 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: OnSRVResolved( absl::StatusOr> srv_records) { - ValidationErrors::ScopedField field(&errors_, "srv lookup"); absl::optional result; auto cleanup = absl::MakeCleanup([&]() { if (result.has_value()) { @@ -325,6 +349,8 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: } }); MutexLock lock(&on_resolved_mu_); + // Make sure field destroys before cleanup. + ValidationErrors::ScopedField field(&errors_, "srv lookup"); if (orphaned_) return; is_srv_inflight_ = false; if (!srv_records.ok()) { @@ -351,12 +377,15 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: resolver_.get(), srv_record.host.c_str(), srv_record.port); ++number_of_balancer_hostnames_initiated_; event_engine_resolver_->LookupHostname( - [host = std::move(srv_record.host), + [host = srv_record.host, self = Ref(DEBUG_LOCATION, "OnBalancerHostnamesResolved")]( absl::StatusOr> new_balancer_addresses) mutable { + ApplicationCallbackExecCtx callback_exec_ctx; + ExecCtx exec_ctx; self->OnBalancerHostnamesResolved(std::move(host), std::move(new_balancer_addresses)); + self.reset(); }, srv_record.host, std::to_string(srv_record.port)); } @@ -367,8 +396,6 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: std::string authority, absl::StatusOr> new_balancer_addresses) { - ValidationErrors::ScopedField field( - &errors_, absl::StrCat("balancer lookup for ", authority)); absl::optional result; auto cleanup = absl::MakeCleanup([&]() { if (result.has_value()) { @@ -376,6 +403,9 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: } }); MutexLock lock(&on_resolved_mu_); + // Make sure field destroys before cleanup. + ValidationErrors::ScopedField field( + &errors_, absl::StrCat("balancer lookup for ", authority)); if (orphaned_) return; ++number_of_balancer_hostnames_resolved_; if (!new_balancer_addresses.ok()) { @@ -397,10 +427,11 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: OnTXTResolved(absl::StatusOr> service_config) { - ValidationErrors::ScopedField field(&errors_, "txt lookup"); absl::optional result; { MutexLock lock(&on_resolved_mu_); + // Make sure field destroys before cleanup. + ValidationErrors::ScopedField field(&errors_, "txt lookup"); if (orphaned_) return; GPR_ASSERT(is_txt_inflight_); is_txt_inflight_ = false; @@ -416,8 +447,12 @@ void EventEngineClientChannelDNSResolver::EventEngineDNSRequestWrapper:: s, kServiceConfigAttributePrefix); }); if (result != service_config->end()) { + // Found a service config record. service_config_json_ = result->substr(kServiceConfigAttributePrefix.size()); + GRPC_EVENT_ENGINE_RESOLVER_TRACE( + "DNSResolver::%p found service config: %s", + event_engine_resolver_.get(), service_config_json_->c_str()); } else { service_config_json_ = absl::UnavailableError(absl::StrCat( "failed to find attribute prefix: ", kServiceConfigAttributePrefix, diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 019ce8706a883..4de874fccc108 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -30,7 +30,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" -#include +#include #include #include "src/core/ext/filters/client_channel/resolver/polling_resolver.h" diff --git a/src/core/ext/filters/client_channel/resolver/polling_resolver.cc b/src/core/ext/filters/client_channel/resolver/polling_resolver.cc index 46f63e68e7a68..bd99aebae537e 100644 --- a/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/polling_resolver.cc @@ -159,7 +159,7 @@ void PollingResolver::OnRequestCompleteLocked(Result result) { if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) { gpr_log(GPR_INFO, "[polling resolver %p] returning result: " - "addresses=%s, service_config=%s", + "addresses=%s, service_config=%s, resolution_note=%s", this, result.addresses.ok() ? absl::StrCat("<", result.addresses->size(), " addresses>") @@ -170,7 +170,8 @@ void PollingResolver::OnRequestCompleteLocked(Result result) { ? "" : std::string((*result.service_config)->json_string()) .c_str()) - : result.service_config.status().ToString().c_str()); + : result.service_config.status().ToString().c_str(), + result.resolution_note.c_str()); } GPR_ASSERT(result.result_health_callback == nullptr); RefCountedPtr self = @@ -260,8 +261,13 @@ void PollingResolver::StartResolvingLocked() { request_ = StartRequest(); last_resolution_timestamp_ = Timestamp::Now(); if (GPR_UNLIKELY(tracer_ != nullptr && tracer_->enabled())) { - gpr_log(GPR_INFO, "[polling resolver %p] starting resolution, request_=%p", - this, request_.get()); + if (request_ != nullptr) { + gpr_log(GPR_INFO, + "[polling resolver %p] starting resolution, request_=%p", this, + request_.get()); + } else { + gpr_log(GPR_INFO, "[polling resolver %p] StartRequest failed", this); + } } } diff --git a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc index 43af7b0adec40..04b76b7f73153 100644 --- a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc @@ -44,7 +44,7 @@ #include "absl/types/variant.h" #include "re2/re2.h" -#include +#include #include "src/core/lib/slice/slice.h" diff --git a/src/core/ext/filters/client_channel/retry_filter.h b/src/core/ext/filters/client_channel/retry_filter.h index fbaf6ce336f65..c5d713f5fa95b 100644 --- a/src/core/ext/filters/client_channel/retry_filter.h +++ b/src/core/ext/filters/client_channel/retry_filter.h @@ -28,6 +28,7 @@ #include #include +#include #include #include "src/core/ext/filters/client_channel/client_channel.h" diff --git a/src/core/ext/filters/client_channel/retry_service_config.cc b/src/core/ext/filters/client_channel/retry_service_config.cc index 9743d00014229..db8ee91579162 100644 --- a/src/core/ext/filters/client_channel/retry_service_config.cc +++ b/src/core/ext/filters/client_channel/retry_service_config.cc @@ -27,7 +27,7 @@ #include "absl/strings/str_cat.h" #include "absl/types/optional.h" -#include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc b/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc index 81ef16ee58f31..077e69f857964 100644 --- a/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +++ b/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc @@ -28,7 +28,7 @@ #include "absl/status/statusor.h" #include "absl/types/optional.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 3f7599e9a3657..85da64014fa7e 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -33,7 +33,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 033c711bb6cba..e66d80fd13965 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -119,9 +119,9 @@ class SubchannelCall { void SetAfterCallStackDestroy(grpc_closure* closure); // Interface of RefCounted<>. - RefCountedPtr Ref() GRPC_MUST_USE_RESULT; - RefCountedPtr Ref(const DebugLocation& location, - const char* reason) GRPC_MUST_USE_RESULT; + GRPC_MUST_USE_RESULT RefCountedPtr Ref(); + GRPC_MUST_USE_RESULT RefCountedPtr Ref( + const DebugLocation& location, const char* reason); // When refcount drops to 0, destroys itself and the associated call stack, // but does NOT free the memory because it's in the call arena. void Unref(); diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index bd2f290ca7339..4562e45c61282 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -26,7 +26,7 @@ #include "absl/status/status.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index 89ff0356ccebf..6ed05d9518651 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -35,6 +35,7 @@ #include "absl/types/optional.h" #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 9e15fa18da609..6350788b40325 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -29,7 +29,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include +#include #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channel_stack_builder.h" diff --git a/src/core/ext/filters/http/message_compress/compression_filter.cc b/src/core/ext/filters/http/message_compress/compression_filter.cc index 26868c51ef1f7..2fefd04bb66cb 100644 --- a/src/core/ext/filters/http/message_compress/compression_filter.cc +++ b/src/core/ext/filters/http/message_compress/compression_filter.cc @@ -32,6 +32,7 @@ #include #include +#include #include #include diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc index 8ec0e54df0b0b..6b7648ddb881c 100644 --- a/src/core/ext/filters/http/server/http_server_filter.cc +++ b/src/core/ext/filters/http/server/http_server_filter.cc @@ -30,7 +30,7 @@ #include "absl/status/status.h" #include "absl/types/optional.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc index 29d2a2cf6a491..77575cddf1f63 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc @@ -40,8 +40,8 @@ #include "opencensus/stats/stats.h" #include "opencensus/tags/tag_key.h" -#include #include +#include #include #include #include diff --git a/src/core/ext/filters/logging/logging_filter.cc b/src/core/ext/filters/logging/logging_filter.cc index 37e5450bb0841..561e4718ab352 100644 --- a/src/core/ext/filters/logging/logging_filter.cc +++ b/src/core/ext/filters/logging/logging_filter.cc @@ -43,7 +43,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" -#include +#include #include #include #include diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index 6143239c0c0ca..be5505cf05ab9 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -28,6 +28,7 @@ #include "absl/strings/str_format.h" #include +#include #include #include diff --git a/src/core/ext/filters/rbac/rbac_service_config_parser.cc b/src/core/ext/filters/rbac/rbac_service_config_parser.cc index 91f0ed7e4f813..f7264b3fe0a38 100644 --- a/src/core/ext/filters/rbac/rbac_service_config_parser.cc +++ b/src/core/ext/filters/rbac/rbac_service_config_parser.cc @@ -215,12 +215,11 @@ struct RbacConfig { Rules(Rules&&) = default; Rules& operator=(Rules&&) = default; - Rbac TakeAsRbac(std::string name); + Rbac TakeAsRbac(); static const JsonLoaderInterface* JsonLoader(const JsonArgs&); void JsonPostLoad(const Json&, const JsonArgs&, ValidationErrors* errors); }; - std::string name; absl::optional rules; Rbac TakeAsRbac(); @@ -773,9 +772,8 @@ void RbacConfig::RbacPolicy::Rules::AuditLogger::JsonPostLoad( // RbacConfig::RbacPolicy::Rules // -Rbac RbacConfig::RbacPolicy::Rules::TakeAsRbac(std::string name) { +Rbac RbacConfig::RbacPolicy::Rules::TakeAsRbac() { Rbac rbac; - rbac.name = std::move(name); rbac.action = static_cast(action); rbac.audit_condition = audit_condition; for (auto& p : policies) { @@ -849,15 +847,14 @@ Rbac RbacConfig::RbacPolicy::TakeAsRbac() { if (!rules.has_value()) { // No enforcing to be applied. An empty deny policy with an empty map // is equivalent to no enforcing. - return Rbac(std::move(name), Rbac::Action::kDeny, {}); + return Rbac("", Rbac::Action::kDeny, {}); } - return rules->TakeAsRbac(std::move(name)); + return rules->TakeAsRbac(); } const JsonLoaderInterface* RbacConfig::RbacPolicy::JsonLoader(const JsonArgs&) { static const auto* loader = JsonObjectLoader() .OptionalField("rules", &RbacPolicy::rules) - .Field("filter_name", &RbacPolicy::name) .Finish(); return loader; } diff --git a/src/core/ext/transport/binder/transport/binder_transport.cc b/src/core/ext/transport/binder/transport/binder_transport.cc index 0420e96b18445..ce27943d24844 100644 --- a/src/core/ext/transport/binder/transport/binder_transport.cc +++ b/src/core/ext/transport/binder/transport/binder_transport.cc @@ -505,6 +505,9 @@ static void perform_stream_op_locked(void* stream_op, gbs->recv_message = op->payload->recv_message.recv_message; gbs->call_failed_before_recv_message = op->payload->recv_message.call_failed_before_recv_message; + if (op->payload->recv_message.flags != nullptr) { + *op->payload->recv_message.flags = 0; + } GRPC_BINDER_STREAM_REF(gbs, "recv_message"); gbt->transport_stream_receiver->RegisterRecvMessage( tx_code, [tx_code, gbs, gbt](absl::StatusOr message) { diff --git a/src/core/ext/transport/chaotic_good/frame.cc b/src/core/ext/transport/chaotic_good/frame.cc index 1989c278a2063..34b8a493e8c35 100644 --- a/src/core/ext/transport/chaotic_good/frame.cc +++ b/src/core/ext/transport/chaotic_good/frame.cc @@ -127,8 +127,9 @@ absl::StatusOr> ReadMetadata( : HPackParser::LogInfo::Type::kTrailers, is_client}); for (size_t i = 0; i < slices.Count(); i++) { - GRPC_RETURN_IF_ERROR( - parser->Parse(slices.c_slice_at(i), i == slices.Count() - 1)); + GRPC_RETURN_IF_ERROR(parser->Parse(slices.c_slice_at(i), + i == slices.Count() - 1, + /*call_tracer=*/nullptr)); } parser->FinishFrame(); return std::move(metadata); diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc index f4e716c9265e7..e720ce52ddbbe 100644 --- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc +++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 40c1727b9c99f..7ba070e479e7a 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -209,7 +210,8 @@ class Chttp2ServerListener : public Server::ListenerInterface { OrphanablePtr handshaking_state_ ABSL_GUARDED_BY(&mu_); // Set by HandshakingState when handshaking is done and a valid transport // is created. - grpc_chttp2_transport* transport_ ABSL_GUARDED_BY(&mu_) = nullptr; + RefCountedPtr transport_ ABSL_GUARDED_BY(&mu_) = + nullptr; grpc_closure on_close_; absl::optional drain_grace_timer_handle_ ABSL_GUARDED_BY(&mu_); @@ -246,13 +248,12 @@ class Chttp2ServerListener : public Server::ListenerInterface { IncrementRefCount(); } - RefCountedPtr Ref() GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr Ref() { IncrementRefCount(); return RefCountedPtr(this); } - RefCountedPtr Ref(const DebugLocation& /* location */, - const char* /* reason */) - GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr Ref( + const DebugLocation& /* location */, const char* /* reason */) { return Ref(); } @@ -419,7 +420,7 @@ void Chttp2ServerListener::ActiveConnection::HandshakingState::OnTimeout() { { MutexLock lock(&connection_->mu_); if (timer_handle_.has_value()) { - transport = connection_->transport_; + transport = connection_->transport_.get(); timer_handle_.reset(); } } @@ -490,9 +491,7 @@ void Chttp2ServerListener::ActiveConnection::HandshakingState::OnHandshakeDone( // TODO(roth): Change to static_cast<> when we C++-ify the // transport API. self->connection_->transport_ = - reinterpret_cast(transport); - GRPC_CHTTP2_REF_TRANSPORT(self->connection_->transport_, - "ActiveConnection"); // Held by connection_ + reinterpret_cast(transport)->Ref(); self->Ref().release(); // Held by OnReceiveSettings(). GRPC_CLOSURE_INIT(&self->on_receive_settings_, OnReceiveSettings, self, grpc_schedule_on_exec_ctx); @@ -572,11 +571,7 @@ Chttp2ServerListener::ActiveConnection::ActiveConnection( grpc_schedule_on_exec_ctx); } -Chttp2ServerListener::ActiveConnection::~ActiveConnection() { - if (transport_ != nullptr) { - GRPC_CHTTP2_UNREF_TRANSPORT(transport_, "ActiveConnection"); - } -} +Chttp2ServerListener::ActiveConnection::~ActiveConnection() {} void Chttp2ServerListener::ActiveConnection::Orphan() { OrphanablePtr handshaking_state; @@ -595,7 +590,7 @@ void Chttp2ServerListener::ActiveConnection::SendGoAway() { { MutexLock lock(&mu_); if (transport_ != nullptr && !shutdown_) { - transport = transport_; + transport = transport_.get(); drain_grace_timer_handle_ = event_engine_->RunAfter( std::max(Duration::Zero(), listener_->args_ @@ -667,7 +662,7 @@ void Chttp2ServerListener::ActiveConnection::OnDrainGraceTimeExpiry() { { MutexLock lock(&mu_); if (drain_grace_timer_handle_.has_value()) { - transport = transport_; + transport = transport_.get(); drain_grace_timer_handle_.reset(); } } diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index fb1903a256cf3..c205ba5ab7ff4 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,7 @@ #include #include +#include #include #include #include @@ -61,6 +63,8 @@ #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http_trace.h" #include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/ext/transport/chttp2/transport/varint.h" #include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/channel/channel_args.h" @@ -123,25 +127,26 @@ static grpc_core::Duration g_default_server_keepalive_timeout = static bool g_default_client_keepalive_permit_without_calls = false; static bool g_default_server_keepalive_permit_without_calls = false; -static grpc_core::Duration g_default_min_recv_ping_interval_without_data = - grpc_core::Duration::Minutes(5); -static int g_default_max_pings_without_data = 2; -static int g_default_max_ping_strikes = 2; - #define MAX_CLIENT_STREAM_ID 0x7fffffffu grpc_core::TraceFlag grpc_keepalive_trace(false, "http_keepalive"); grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false, "chttp2_refcount"); // forward declarations of various callbacks that we'll build closures around -static void write_action_begin_locked(void* t, grpc_error_handle error); -static void write_action(void* t, grpc_error_handle error); -static void write_action_end(void* t, grpc_error_handle error); -static void write_action_end_locked(void* t, grpc_error_handle error); - -static void read_action(void* t, grpc_error_handle error); -static void read_action_locked(void* t, grpc_error_handle error); -static void continue_read_action_locked(grpc_chttp2_transport* t); +static void write_action_begin_locked( + grpc_core::RefCountedPtr, grpc_error_handle error); +static void write_action(grpc_chttp2_transport* t); +static void write_action_end(grpc_core::RefCountedPtr, + grpc_error_handle error); +static void write_action_end_locked( + grpc_core::RefCountedPtr, grpc_error_handle error); + +static void read_action(grpc_core::RefCountedPtr, + grpc_error_handle error); +static void read_action_locked(grpc_core::RefCountedPtr, + grpc_error_handle error); +static void continue_read_action_locked( + grpc_core::RefCountedPtr t); // Set a transport level setting, and push it to our peer static void queue_setting_update(grpc_chttp2_transport* t, @@ -158,8 +163,10 @@ static void connectivity_state_set(grpc_chttp2_transport* t, const absl::Status& status, const char* reason); -static void benign_reclaimer_locked(void* arg, grpc_error_handle error); -static void destructive_reclaimer_locked(void* arg, grpc_error_handle error); +static void benign_reclaimer_locked( + grpc_core::RefCountedPtr, grpc_error_handle error); +static void destructive_reclaimer_locked( + grpc_core::RefCountedPtr, grpc_error_handle error); static void post_benign_reclaimer(grpc_chttp2_transport* t); static void post_destructive_reclaimer(grpc_chttp2_transport* t); @@ -169,31 +176,45 @@ static void close_transport_locked(grpc_chttp2_transport* t, static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error_handle error); -static void start_bdp_ping(void* tp, grpc_error_handle error); -static void finish_bdp_ping(void* tp, grpc_error_handle error); -static void start_bdp_ping_locked(void* tp, grpc_error_handle error); -static void finish_bdp_ping_locked(void* tp, grpc_error_handle error); +static void start_bdp_ping(grpc_core::RefCountedPtr, + grpc_error_handle error); +static void finish_bdp_ping(grpc_core::RefCountedPtr, + grpc_error_handle error); +static void start_bdp_ping_locked( + grpc_core::RefCountedPtr, grpc_error_handle error); +static void finish_bdp_ping_locked( + grpc_core::RefCountedPtr, grpc_error_handle error); static void next_bdp_ping_timer_expired(grpc_chttp2_transport* t); static void next_bdp_ping_timer_expired_locked( - void* tp, GRPC_UNUSED grpc_error_handle error); + grpc_core::RefCountedPtr tp, + GRPC_UNUSED grpc_error_handle error); static void cancel_pings(grpc_chttp2_transport* t, grpc_error_handle error); static void send_ping_locked(grpc_chttp2_transport* t, grpc_closure* on_initiate, grpc_closure* on_ack); -static void retry_initiate_ping_locked(void* tp, - GRPC_UNUSED grpc_error_handle error); +static void retry_initiate_ping_locked( + grpc_core::RefCountedPtr t, + GRPC_UNUSED grpc_error_handle error); // keepalive-relevant functions -static void init_keepalive_ping(grpc_chttp2_transport* t); -static void init_keepalive_ping_locked(void* arg, - GRPC_UNUSED grpc_error_handle error); -static void start_keepalive_ping(void* arg, grpc_error_handle error); -static void finish_keepalive_ping(void* arg, grpc_error_handle error); -static void start_keepalive_ping_locked(void* arg, grpc_error_handle error); -static void finish_keepalive_ping_locked(void* arg, grpc_error_handle error); -static void keepalive_watchdog_fired(grpc_chttp2_transport* t); +static void init_keepalive_ping( + grpc_core::RefCountedPtr t); +static void init_keepalive_ping_locked( + grpc_core::RefCountedPtr t, + GRPC_UNUSED grpc_error_handle error); +static void start_keepalive_ping( + grpc_core::RefCountedPtr t, grpc_error_handle error); +static void finish_keepalive_ping( + grpc_core::RefCountedPtr t, grpc_error_handle error); +static void start_keepalive_ping_locked( + grpc_core::RefCountedPtr t, grpc_error_handle error); +static void finish_keepalive_ping_locked( + grpc_core::RefCountedPtr t, grpc_error_handle error); +static void keepalive_watchdog_fired( + grpc_core::RefCountedPtr t); static void keepalive_watchdog_fired_locked( - void* arg, GRPC_UNUSED grpc_error_handle error); + grpc_core::RefCountedPtr t, + GRPC_UNUSED grpc_error_handle error); static void maybe_reset_keepalive_ping_timer_locked(grpc_chttp2_transport* t); namespace { @@ -213,6 +234,24 @@ grpc_core::CopyContextFn g_get_copied_context_fn = nullptr; namespace grpc_core { +namespace { +// Initialize a grpc_closure \a c to call \a Fn with \a t and \a error. Holds +// the passed in reference to \a t until it's moved into Fn. +template , grpc_error_handle)> +grpc_closure* InitTransportClosure(RefCountedPtr t, + grpc_closure* c) { + GRPC_CLOSURE_INIT( + c, + [](void* tp, grpc_error_handle error) { + Fn(RefCountedPtr( + static_cast(tp)), + std::move(error)); + }, + t.release(), nullptr); + return c; +} +} // namespace + namespace { TestOnlyGlobalHttp2TransportInitCallback test_only_init_callback = nullptr; TestOnlyGlobalHttp2TransportDestructCallback test_only_destruct_callback = @@ -346,18 +385,6 @@ static void read_channel_args(grpc_chttp2_transport* t, t->hpack_compressor.SetMaxUsableSize(max_hpack_table_size); } - t->ping_policy.max_pings_without_data = - std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA) - .value_or(g_default_max_pings_without_data)); - t->ping_policy.max_ping_strikes = - std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES) - .value_or(g_default_max_ping_strikes)); - t->ping_policy.min_recv_ping_interval_without_data = - std::max(grpc_core::Duration::Zero(), - channel_args - .GetDurationFromIntMillis( - GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS) - .value_or(g_default_min_recv_ping_interval_without_data)); t->write_buffer_size = std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE) .value_or(grpc_core::chttp2::kDefaultWindow)); @@ -371,16 +398,18 @@ static void read_channel_args(grpc_chttp2_transport* t, channel_args.GetDurationFromIntMillis(GRPC_ARG_KEEPALIVE_TIMEOUT_MS) .value_or(t->is_client ? g_default_client_keepalive_timeout : g_default_server_keepalive_timeout)); - if (grpc_core::IsKeepaliveFixEnabled()) { + if (t->is_client) { t->keepalive_permit_without_calls = channel_args.GetBool(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS) - .value_or(t->is_client + .value_or(grpc_core::IsKeepaliveFixEnabled() ? g_default_client_keepalive_permit_without_calls - : g_default_server_keepalive_permit_without_calls); + : false); } else { t->keepalive_permit_without_calls = channel_args.GetBool(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS) - .value_or(false); + .value_or(grpc_core::IsKeepaliveServerFixEnabled() + ? g_default_server_keepalive_permit_without_calls + : false); } // Only send the prefered rx frame size http2 setting if we are instructed @@ -507,17 +536,16 @@ static void read_channel_args(grpc_chttp2_transport* t, } static void init_keepalive_pings_if_enabled_locked( - void* arg, GRPC_UNUSED grpc_error_handle error) { + grpc_core::RefCountedPtr t, + GRPC_UNUSED grpc_error_handle error) { GPR_DEBUG_ASSERT(error.ok()); - grpc_chttp2_transport* t = static_cast(arg); if (t->keepalive_time != grpc_core::Duration::Infinity()) { t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING; - GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); t->keepalive_ping_timer_handle = - t->event_engine->RunAfter(t->keepalive_time, [t] { + t->event_engine->RunAfter(t->keepalive_time, [t = t->Ref()]() mutable { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; - init_keepalive_ping(t); + init_keepalive_ping(std::move(t)); }); } else { // Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no @@ -546,6 +574,8 @@ grpc_chttp2_transport::grpc_chttp2_transport( GRPC_CHANNEL_READY), is_client(is_client), next_stream_id(is_client ? 1 : 2), + ping_abuse_policy(channel_args), + ping_rate_policy(channel_args, is_client), flow_control( peer_string.as_string_view(), channel_args.GetBool(GRPC_ARG_HTTP2_BDP_PROBE).value_or(true), @@ -588,17 +618,10 @@ grpc_chttp2_transport::grpc_chttp2_transport( read_channel_args(this, channel_args, is_client); - // No pings allowed before receiving a header or data frame. - ping_state.pings_before_data_required = 0; - ping_state.last_ping_sent_time = grpc_core::Timestamp::InfPast(); - - ping_recv_state.last_ping_recv_time = grpc_core::Timestamp::InfPast(); - ping_recv_state.ping_strikes = 0; - grpc_core::ExecCtx exec_ctx; combiner->Run( - GRPC_CLOSURE_INIT(&init_keepalive_ping_locked, - init_keepalive_pings_if_enabled_locked, this, nullptr), + grpc_core::InitTransportClosure( + Ref(), &init_keepalive_ping_locked), absl::OkStatus()); if (flow_control.bdp_probe()) { @@ -623,15 +646,15 @@ grpc_chttp2_transport::grpc_chttp2_transport( } static void destroy_transport_locked(void* tp, grpc_error_handle /*error*/) { - grpc_chttp2_transport* t = static_cast(tp); + grpc_core::RefCountedPtr t( + static_cast(tp)); t->destroying = 1; close_transport_locked( - t, grpc_error_set_int(GRPC_ERROR_CREATE("Transport destroyed"), - grpc_core::StatusIntProperty::kOccurredDuringWrite, - t->write_state)); + t.get(), + grpc_error_set_int(GRPC_ERROR_CREATE("Transport destroyed"), + grpc_core::StatusIntProperty::kOccurredDuringWrite, + t->write_state)); t->memory_owner.Reset(); - // Must be the last line. - GRPC_CHTTP2_UNREF_TRANSPORT(t, "destroy"); } static void destroy_transport(grpc_transport* gt) { @@ -663,15 +686,13 @@ static void close_transport_locked(grpc_chttp2_transport* t, t->closed_with_error = error; connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, absl::Status(), "close_transport"); - if (t->ping_state.delayed_ping_timer_handle.has_value()) { - if (t->event_engine->Cancel(*t->ping_state.delayed_ping_timer_handle)) { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "retry_initiate_ping_locked"); - t->ping_state.delayed_ping_timer_handle.reset(); + if (t->delayed_ping_timer_handle.has_value()) { + if (t->event_engine->Cancel(*t->delayed_ping_timer_handle)) { + t->delayed_ping_timer_handle.reset(); } } if (t->next_bdp_ping_timer_handle.has_value()) { if (t->event_engine->Cancel(*t->next_bdp_ping_timer_handle)) { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping"); t->next_bdp_ping_timer_handle.reset(); } } @@ -679,7 +700,6 @@ static void close_transport_locked(grpc_chttp2_transport* t, case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING: if (t->keepalive_ping_timer_handle.has_value()) { if (t->event_engine->Cancel(*t->keepalive_ping_timer_handle)) { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "init keepalive ping"); t->keepalive_ping_timer_handle.reset(); } } @@ -687,13 +707,11 @@ static void close_transport_locked(grpc_chttp2_transport* t, case GRPC_CHTTP2_KEEPALIVE_STATE_PINGING: if (t->keepalive_ping_timer_handle.has_value()) { if (t->event_engine->Cancel(*t->keepalive_ping_timer_handle)) { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "init keepalive ping"); t->keepalive_ping_timer_handle.reset(); } } if (t->keepalive_watchdog_timer_handle.has_value()) { if (t->event_engine->Cancel(*t->keepalive_watchdog_timer_handle)) { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive watchdog"); t->keepalive_watchdog_timer_handle.reset(); } } @@ -739,21 +757,23 @@ void grpc_chttp2_stream_unref(grpc_chttp2_stream* s) { } #endif -grpc_chttp2_stream::Reffer::Reffer(grpc_chttp2_stream* s) { - // We reserve one 'active stream' that's dropped when the stream is - // read-closed. The others are for Chttp2IncomingByteStreams that are - // actively reading - GRPC_CHTTP2_STREAM_REF(s, "chttp2"); - GRPC_CHTTP2_REF_TRANSPORT(s->t, "stream"); -} - grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t, grpc_stream_refcount* refcount, const void* server_data, grpc_core::Arena* arena) - : t(t), - refcount(refcount), - reffer(this), + : t(t->Ref()), + refcount([refcount]() { +// We reserve one 'active stream' that's dropped when the stream is +// read-closed. The others are for Chttp2IncomingByteStreams that are +// actively reading +// We do this here to avoid cache misses. +#ifndef NDEBUG + grpc_stream_ref(refcount, "chttp2"); +#else + grpc_stream_ref(refcount); +#endif + return refcount; + }()), initial_metadata_buffer(arena), trailing_metadata_buffer(arena), flow_control(&t->flow_control) { @@ -773,8 +793,8 @@ grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t, } grpc_chttp2_stream::~grpc_chttp2_stream() { - grpc_chttp2_list_remove_stalled_by_stream(t, this); - grpc_chttp2_list_remove_stalled_by_transport(t, this); + grpc_chttp2_list_remove_stalled_by_stream(t.get(), this); + grpc_chttp2_list_remove_stalled_by_transport(t.get(), this); if (t->channelz_socket != nullptr) { if ((t->is_client && eos_received) || (!t->is_client && eos_sent)) { @@ -805,7 +825,6 @@ grpc_chttp2_stream::~grpc_chttp2_stream() { GPR_ASSERT(recv_message_ready == nullptr); GPR_ASSERT(recv_trailing_metadata_finished == nullptr); grpc_slice_buffer_destroy(&flow_controlled_buffer); - GRPC_CHTTP2_UNREF_TRANSPORT(t, "stream"); grpc_core::ExecCtx::Run(DEBUG_LOCATION, destroy_stream_arg, absl::OkStatus()); } @@ -893,7 +912,6 @@ void grpc_chttp2_initiate_write(grpc_chttp2_transport* t, case GRPC_CHTTP2_WRITE_STATE_IDLE: set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING, grpc_chttp2_initiate_write_reason_string(reason)); - GRPC_CHTTP2_REF_TRANSPORT(t, "writing"); // Note that the 'write_action_begin_locked' closure is being scheduled // on the 'finally_scheduler' of t->combiner. This means that // 'write_action_begin_locked' is called only *after* all the other @@ -911,8 +929,8 @@ void grpc_chttp2_initiate_write(grpc_chttp2_transport* t, // It does not call the endpoint to write the bytes. That is done by the // 'write_action' (which is scheduled by 'write_action_begin_locked') t->combiner->FinallyRun( - GRPC_CLOSURE_INIT(&t->write_action_begin_locked, - write_action_begin_locked, t, nullptr), + grpc_core::InitTransportClosure( + t->Ref(), &t->write_action_begin_locked), absl::OkStatus()); break; case GRPC_CHTTP2_WRITE_STATE_WRITING: @@ -939,22 +957,22 @@ static const char* begin_writing_desc(bool partial) { } } -static void write_action_begin_locked(void* gt, - grpc_error_handle /*error_ignored*/) { - grpc_chttp2_transport* t = static_cast(gt); +static void write_action_begin_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle /*error_ignored*/) { GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE); grpc_chttp2_begin_write_result r; if (!t->closed_with_error.ok()) { r.writing = false; } else { - r = grpc_chttp2_begin_write(t); + r = grpc_chttp2_begin_write(t.get()); } if (r.writing) { - set_write_state(t, + set_write_state(t.get(), r.partial ? GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE : GRPC_CHTTP2_WRITE_STATE_WRITING, begin_writing_desc(r.partial)); - write_action(t, absl::OkStatus()); + write_action(t.get()); if (t->reading_paused_on_pending_induced_frames) { GPR_ASSERT(t->num_pending_induced_frames == 0); // We had paused reading, because we had many induced frames (SETTINGS @@ -964,18 +982,17 @@ static void write_action_begin_locked(void* gt, GPR_INFO, "transport %p : Resuming reading after being paused due to too " "many unwritten SETTINGS ACK, PINGS ACK and RST_STREAM frames", - t)); + t.get())); t->reading_paused_on_pending_induced_frames = false; - continue_read_action_locked(t); + continue_read_action_locked(std::move(t)); } } else { - set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "begin writing nothing"); - GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing"); + set_write_state(t.get(), GRPC_CHTTP2_WRITE_STATE_IDLE, + "begin writing nothing"); } } -static void write_action(void* gt, grpc_error_handle /*error*/) { - grpc_chttp2_transport* t = static_cast(gt); +static void write_action(grpc_chttp2_transport* t) { void* cl = t->cl; if (!t->cl->empty()) { // Transfer the ownership of the context list to the endpoint and create and @@ -999,28 +1016,28 @@ static void write_action(void* gt, grpc_error_handle /*error*/) { if (max_frame_size == 0) { max_frame_size = INT_MAX; } - grpc_endpoint_write( - t->ep, &t->outbuf, - GRPC_CLOSURE_INIT(&t->write_action_end_locked, write_action_end, t, - grpc_schedule_on_exec_ctx), - cl, max_frame_size); + grpc_endpoint_write(t->ep, &t->outbuf, + grpc_core::InitTransportClosure( + t->Ref(), &t->write_action_end_locked), + cl, max_frame_size); } -static void write_action_end(void* tp, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(tp); - t->combiner->Run(GRPC_CLOSURE_INIT(&t->write_action_end_locked, - write_action_end_locked, t, nullptr), - error); +static void write_action_end(grpc_core::RefCountedPtr t, + grpc_error_handle error) { + auto* tp = t.get(); + tp->combiner->Run(grpc_core::InitTransportClosure( + std::move(t), &tp->write_action_end_locked), + error); } // Callback from the grpc_endpoint after bytes have been written by calling // sendmsg -static void write_action_end_locked(void* tp, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(tp); - +static void write_action_end_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { bool closed = false; if (!error.ok()) { - close_transport_locked(t, error); + close_transport_locked(t.get(), error); closed = true; } @@ -1028,7 +1045,7 @@ static void write_action_end_locked(void* tp, grpc_error_handle error) { t->sent_goaway_state = GRPC_CHTTP2_FINAL_GOAWAY_SENT; closed = true; if (t->stream_map.empty()) { - close_transport_locked(t, GRPC_ERROR_CREATE("goaway sent")); + close_transport_locked(t.get(), GRPC_ERROR_CREATE("goaway sent")); } } @@ -1036,11 +1053,11 @@ static void write_action_end_locked(void* tp, grpc_error_handle error) { case GRPC_CHTTP2_WRITE_STATE_IDLE: GPR_UNREACHABLE_CODE(break); case GRPC_CHTTP2_WRITE_STATE_WRITING: - set_write_state(t, GRPC_CHTTP2_WRITE_STATE_IDLE, "finish writing"); + set_write_state(t.get(), GRPC_CHTTP2_WRITE_STATE_IDLE, "finish writing"); break; case GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE: - set_write_state(t, GRPC_CHTTP2_WRITE_STATE_WRITING, "continue writing"); - GRPC_CHTTP2_REF_TRANSPORT(t, "writing"); + set_write_state(t.get(), GRPC_CHTTP2_WRITE_STATE_WRITING, + "continue writing"); // If the transport is closed, we will retry writing on the endpoint // and next write may contain part of the currently serialized frames. // So, we should only call the run_after_write callbacks when the next @@ -1050,14 +1067,13 @@ static void write_action_end_locked(void* tp, grpc_error_handle error) { grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &t->run_after_write); } t->combiner->FinallyRun( - GRPC_CLOSURE_INIT(&t->write_action_begin_locked, - write_action_begin_locked, t, nullptr), + grpc_core::InitTransportClosure( + t, &t->write_action_begin_locked), absl::OkStatus()); break; } - grpc_chttp2_end_write(t, error); - GRPC_CHTTP2_UNREF_TRANSPORT(t, "writing"); + grpc_chttp2_end_write(t.get(), error); } // Dirties an HTTP2 setting to be sent out next time a writing path occurs. @@ -1130,7 +1146,7 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, s->trailing_metadata_buffer.Set( grpc_core::GrpcStreamNetworkState(), grpc_core::GrpcStreamNetworkState::kNotSeenByServer); - grpc_chttp2_cancel_stream(s->t, s, s->t->goaway_error); + grpc_chttp2_cancel_stream(s->t.get(), s, s->t->goaway_error); } } absl::Status status = grpc_error_to_absl_status(t->goaway_error); @@ -1319,7 +1335,7 @@ static void perform_stream_op_locked(void* stream_op, grpc_chttp2_stream* s = static_cast(op->handler_private.extra_arg); grpc_transport_stream_op_batch_payload* op_payload = op->payload; - grpc_chttp2_transport* t = s->t; + grpc_chttp2_transport* t = s->t.get(); s->context = op->payload->context; s->traced = op->is_traced; @@ -1627,56 +1643,61 @@ static void send_ping_locked(grpc_chttp2_transport* t, // Specialized form of send_ping_locked for keepalive ping. If there is already // a ping in progress, the keepalive ping would piggyback onto that ping, // instead of waiting for that ping to complete and then starting a new ping. -static void send_keepalive_ping_locked(grpc_chttp2_transport* t) { +static void send_keepalive_ping_locked( + grpc_core::RefCountedPtr t) { if (!t->closed_with_error.ok()) { - t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked, - start_keepalive_ping_locked, t, nullptr), - t->closed_with_error); t->combiner->Run( - GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked, - finish_keepalive_ping_locked, t, nullptr), + grpc_core::InitTransportClosure( + t->Ref(), &t->start_keepalive_ping_locked), + t->closed_with_error); + t->combiner->Run( + grpc_core::InitTransportClosure( + t->Ref(), &t->finish_keepalive_ping_locked), t->closed_with_error); return; } grpc_chttp2_ping_queue* pq = &t->ping_queue; if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) { // There is a ping in flight. Add yourself to the inflight closure list. - t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked, - start_keepalive_ping_locked, t, nullptr), - t->closed_with_error); + t->combiner->Run( + grpc_core::InitTransportClosure( + t->Ref(), &t->start_keepalive_ping_locked), + t->closed_with_error); grpc_closure_list_append( &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT], - GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked, - finish_keepalive_ping, t, grpc_schedule_on_exec_ctx), + grpc_core::InitTransportClosure( + t->Ref(), &t->finish_keepalive_ping_locked), absl::OkStatus()); return; } grpc_closure_list_append( &pq->lists[GRPC_CHTTP2_PCL_INITIATE], - GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked, start_keepalive_ping, - t, grpc_schedule_on_exec_ctx), + grpc_core::InitTransportClosure( + t->Ref(), &t->start_keepalive_ping_locked), absl::OkStatus()); grpc_closure_list_append( &pq->lists[GRPC_CHTTP2_PCL_NEXT], - GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked, finish_keepalive_ping, - t, grpc_schedule_on_exec_ctx), + grpc_core::InitTransportClosure( + t->Ref(), &t->finish_keepalive_ping_locked), absl::OkStatus()); } -void grpc_chttp2_retry_initiate_ping(grpc_chttp2_transport* t) { - t->combiner->Run(GRPC_CLOSURE_INIT(&t->retry_initiate_ping_locked, - retry_initiate_ping_locked, t, nullptr), - absl::OkStatus()); +void grpc_chttp2_retry_initiate_ping( + grpc_core::RefCountedPtr t) { + auto tp = t.get(); + tp->combiner->Run(grpc_core::InitTransportClosure( + std::move(t), &tp->retry_initiate_ping_locked), + absl::OkStatus()); } -static void retry_initiate_ping_locked(void* tp, - GRPC_UNUSED grpc_error_handle error) { +static void retry_initiate_ping_locked( + grpc_core::RefCountedPtr t, + GRPC_UNUSED grpc_error_handle error) { GPR_DEBUG_ASSERT(error.ok()); - grpc_chttp2_transport* t = static_cast(tp); - GPR_ASSERT(t->ping_state.delayed_ping_timer_handle.has_value()); - t->ping_state.delayed_ping_timer_handle.reset(); - grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING); - GRPC_CHTTP2_UNREF_TRANSPORT(t, "retry_initiate_ping_locked"); + GPR_ASSERT(t->delayed_ping_timer_handle.has_value()); + t->delayed_ping_timer_handle.reset(); + grpc_chttp2_initiate_write(t.get(), + GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING); } void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id) { @@ -1706,16 +1727,11 @@ class GracefulGoaway : public grpc_core::RefCounted { public: static void Start(grpc_chttp2_transport* t) { new GracefulGoaway(t); } - ~GracefulGoaway() override { - GRPC_CHTTP2_UNREF_TRANSPORT(t_, "graceful goaway"); - } - private: using TaskHandle = ::grpc_event_engine::experimental::EventEngine::TaskHandle; - explicit GracefulGoaway(grpc_chttp2_transport* t) : t_(t) { + explicit GracefulGoaway(grpc_chttp2_transport* t) : t_(t->Ref()) { t->sent_goaway_state = GRPC_CHTTP2_GRACEFUL_GOAWAY; - GRPC_CHTTP2_REF_TRANSPORT(t_, "graceful goaway"); grpc_chttp2_goaway_append((1u << 31) - 1, 0, grpc_empty_slice(), &t->qbuf); send_ping_locked( t, nullptr, GRPC_CLOSURE_INIT(&on_ping_ack_, OnPingAck, this, nullptr)); @@ -1743,7 +1759,7 @@ class GracefulGoaway : public grpc_core::RefCounted { gpr_log(GPR_INFO, "transport:%p %s peer:%s Transport already shutting down. " "Graceful GOAWAY abandoned.", - t_, t_->is_client ? "CLIENT" : "SERVER", + t_.get(), t_->is_client ? "CLIENT" : "SERVER", std::string(t_->peer_string.as_string_view()).c_str())); return; } @@ -1752,13 +1768,14 @@ class GracefulGoaway : public grpc_core::RefCounted { gpr_log(GPR_INFO, "transport:%p %s peer:%s Graceful shutdown: Ping received. " "Sending final GOAWAY with stream_id:%d", - t_, t_->is_client ? "CLIENT" : "SERVER", + t_.get(), t_->is_client ? "CLIENT" : "SERVER", std::string(t_->peer_string.as_string_view()).c_str(), t_->last_new_stream_id)); t_->sent_goaway_state = GRPC_CHTTP2_FINAL_GOAWAY_SEND_SCHEDULED; grpc_chttp2_goaway_append(t_->last_new_stream_id, 0, grpc_empty_slice(), &t_->qbuf); - grpc_chttp2_initiate_write(t_, GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT); + grpc_chttp2_initiate_write(t_.get(), + GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT); } static void OnPingAck(void* arg, grpc_error_handle /* error */) { @@ -1786,7 +1803,7 @@ class GracefulGoaway : public grpc_core::RefCounted { self->Unref(); } - grpc_chttp2_transport* t_; + const grpc_core::RefCountedPtr t_; grpc_closure on_ping_ack_; TaskHandle timer_handle_ = TaskHandle::kInvalid; grpc_closure on_timer_; @@ -1825,39 +1842,34 @@ static void send_goaway(grpc_chttp2_transport* t, grpc_error_handle error, grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT); } -void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t) { - if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes && - t->ping_policy.max_ping_strikes != 0) { - send_goaway(t, - grpc_error_set_int(GRPC_ERROR_CREATE("too_many_pings"), - grpc_core::StatusIntProperty::kHttp2Error, - GRPC_HTTP2_ENHANCE_YOUR_CALM), - /*immediate_disconnect_hint=*/true); - // The transport will be closed after the write is done - close_transport_locked( - t, grpc_error_set_int(GRPC_ERROR_CREATE("Too many pings"), - grpc_core::StatusIntProperty::kRpcStatus, - GRPC_STATUS_UNAVAILABLE)); - } +void grpc_chttp2_exceeded_ping_strikes(grpc_chttp2_transport* t) { + send_goaway(t, + grpc_error_set_int(GRPC_ERROR_CREATE("too_many_pings"), + grpc_core::StatusIntProperty::kHttp2Error, + GRPC_HTTP2_ENHANCE_YOUR_CALM), + /*immediate_disconnect_hint=*/true); + // The transport will be closed after the write is done + close_transport_locked( + t, grpc_error_set_int(GRPC_ERROR_CREATE("Too many pings"), + grpc_core::StatusIntProperty::kRpcStatus, + GRPC_STATUS_UNAVAILABLE)); } void grpc_chttp2_reset_ping_clock(grpc_chttp2_transport* t) { if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = grpc_core::Timestamp::InfPast(); - t->ping_recv_state.ping_strikes = 0; + t->ping_abuse_policy.ResetPingStrikes(); } - t->ping_state.pings_before_data_required = - t->ping_policy.max_pings_without_data; + t->ping_rate_policy.ResetPingsBeforeDataRequired(); } static void perform_transport_op_locked(void* stream_op, grpc_error_handle /*error_ignored*/) { grpc_transport_op* op = static_cast(stream_op); - grpc_chttp2_transport* t = - static_cast(op->handler_private.extra_arg); + grpc_core::RefCountedPtr t( + static_cast(op->handler_private.extra_arg)); if (!op->goaway_error.ok()) { - send_goaway(t, op->goaway_error, /*immediate_disconnect_hint=*/false); + send_goaway(t.get(), op->goaway_error, /*immediate_disconnect_hint=*/false); } if (op->set_accept_stream) { @@ -1874,8 +1886,9 @@ static void perform_transport_op_locked(void* stream_op, } if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) { - send_ping_locked(t, op->send_ping.on_initiate, op->send_ping.on_ack); - grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING); + send_ping_locked(t.get(), op->send_ping.on_initiate, op->send_ping.on_ack); + grpc_chttp2_initiate_write(t.get(), + GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING); } if (op->start_connectivity_watch != nullptr) { @@ -1887,14 +1900,12 @@ static void perform_transport_op_locked(void* stream_op, } if (!op->disconnect_with_error.ok()) { - send_goaway(t, op->disconnect_with_error, + send_goaway(t.get(), op->disconnect_with_error, /*immediate_disconnect_hint=*/true); - close_transport_locked(t, op->disconnect_with_error); + close_transport_locked(t.get(), op->disconnect_with_error); } grpc_core::ExecCtx::Run(DEBUG_LOCATION, op->on_consumed, absl::OkStatus()); - - GRPC_CHTTP2_UNREF_TRANSPORT(t, "transport_op"); } static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) { @@ -1904,10 +1915,10 @@ static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) { grpc_transport_op_string(op).c_str()); } op->handler_private.extra_arg = gt; - GRPC_CHTTP2_REF_TRANSPORT(t, "transport_op"); - t->combiner->Run(GRPC_CLOSURE_INIT(&op->handler_private.closure, - perform_transport_op_locked, op, nullptr), - absl::OkStatus()); + t->Ref().release()->combiner->Run( + GRPC_CLOSURE_INIT(&op->handler_private.closure, + perform_transport_op_locked, op, nullptr), + absl::OkStatus()); } // @@ -2504,16 +2515,17 @@ static grpc_error_handle try_http_parsing(grpc_chttp2_transport* t) { return error; } -static void read_action(void* tp, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(tp); - t->combiner->Run( - GRPC_CLOSURE_INIT(&t->read_action_locked, read_action_locked, t, nullptr), - error); +static void read_action(grpc_core::RefCountedPtr t, + grpc_error_handle error) { + auto* tp = t.get(); + tp->combiner->Run(grpc_core::InitTransportClosure( + std::move(t), &tp->read_action_locked), + error); } -static void read_action_locked(void* tp, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(tp); - +static void read_action_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { grpc_error_handle err = error; if (!err.ok()) { err = grpc_error_set_int( @@ -2525,10 +2537,10 @@ static void read_action_locked(void* tp, grpc_error_handle error) { size_t i = 0; grpc_error_handle errors[3] = {error, absl::OkStatus(), absl::OkStatus()}; for (; i < t->read_buffer.count && errors[1] == absl::OkStatus(); i++) { - errors[1] = grpc_chttp2_perform_read(t, t->read_buffer.slices[i]); + errors[1] = grpc_chttp2_perform_read(t.get(), t->read_buffer.slices[i]); } if (errors[1] != absl::OkStatus()) { - errors[2] = try_http_parsing(t); + errors[2] = try_http_parsing(t.get()); error = GRPC_ERROR_CREATE_REFERENCING("Failed parsing HTTP/2", errors, GPR_ARRAY_SIZE(errors)); } @@ -2536,10 +2548,11 @@ static void read_action_locked(void* tp, grpc_error_handle error) { if (t->initial_window_update != 0) { if (t->initial_window_update > 0) { grpc_chttp2_stream* s; - while (grpc_chttp2_list_pop_stalled_by_stream(t, &s)) { - grpc_chttp2_mark_stream_writable(t, s); + while (grpc_chttp2_list_pop_stalled_by_stream(t.get(), &s)) { + grpc_chttp2_mark_stream_writable(t.get(), s); grpc_chttp2_initiate_write( - t, GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING); + t.get(), + GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING); } } t->initial_window_update = 0; @@ -2558,13 +2571,13 @@ static void read_action_locked(void* tp, grpc_error_handle error) { error = grpc_error_add_child(error, t->goaway_error); } - close_transport_locked(t, error); + close_transport_locked(t.get(), error); t->endpoint_reading = 0; } else if (t->closed_with_error.ok()) { keep_reading = true; // Since we have read a byte, reset the keepalive timer if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) { - maybe_reset_keepalive_ping_timer_locked(t); + maybe_reset_keepalive_ping_timer_locked(t.get()); } } grpc_slice_buffer_reset_and_unref(&t->read_buffer); @@ -2576,45 +2589,48 @@ static void read_action_locked(void* tp, grpc_error_handle error) { gpr_log(GPR_INFO, "transport %p : Pausing reading due to too " "many unwritten SETTINGS ACK and RST_STREAM frames", - t)); + t.get())); } else { - continue_read_action_locked(t); + continue_read_action_locked(std::move(t)); } - } else { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "reading_action"); } } -static void continue_read_action_locked(grpc_chttp2_transport* t) { +static void continue_read_action_locked( + grpc_core::RefCountedPtr t) { const bool urgent = !t->goaway_error.ok(); - GRPC_CLOSURE_INIT(&t->read_action_locked, read_action, t, - grpc_schedule_on_exec_ctx); - grpc_endpoint_read(t->ep, &t->read_buffer, &t->read_action_locked, urgent, - grpc_chttp2_min_read_progress_size(t)); + auto* tp = t.get(); + grpc_endpoint_read(tp->ep, &tp->read_buffer, + grpc_core::InitTransportClosure( + std::move(t), &tp->read_action_locked), + urgent, grpc_chttp2_min_read_progress_size(tp)); } // t is reffed prior to calling the first time, and once the callback chain // that kicks off finishes, it's unreffed -void schedule_bdp_ping_locked(grpc_chttp2_transport* t) { - t->flow_control.bdp_estimator()->SchedulePing(); - send_ping_locked( - t, - GRPC_CLOSURE_INIT(&t->start_bdp_ping_locked, start_bdp_ping, t, - grpc_schedule_on_exec_ctx), - GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked, finish_bdp_ping, t, - grpc_schedule_on_exec_ctx)); - grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_BDP_PING); -} - -static void start_bdp_ping(void* tp, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(tp); - t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_bdp_ping_locked, - start_bdp_ping_locked, t, nullptr), - error); -} - -static void start_bdp_ping_locked(void* tp, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(tp); +void schedule_bdp_ping_locked( + grpc_core::RefCountedPtr t) { + auto* tp = t.get(); + tp->flow_control.bdp_estimator()->SchedulePing(); + send_ping_locked(tp, + grpc_core::InitTransportClosure( + tp->Ref(), &tp->start_bdp_ping_locked), + grpc_core::InitTransportClosure( + std::move(t), &tp->finish_bdp_ping_locked)); + grpc_chttp2_initiate_write(tp, GRPC_CHTTP2_INITIATE_WRITE_BDP_PING); +} + +static void start_bdp_ping(grpc_core::RefCountedPtr t, + grpc_error_handle error) { + grpc_chttp2_transport* tp = t.get(); + tp->combiner->Run(grpc_core::InitTransportClosure( + std::move(t), &tp->start_bdp_ping_locked), + error); +} + +static void start_bdp_ping_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { gpr_log(GPR_INFO, "%s: Start BDP ping err=%s", std::string(t->peer_string.as_string_view()).c_str(), @@ -2625,71 +2641,69 @@ static void start_bdp_ping_locked(void* tp, grpc_error_handle error) { } // Reset the keepalive ping timer if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) { - maybe_reset_keepalive_ping_timer_locked(t); + maybe_reset_keepalive_ping_timer_locked(t.get()); } t->flow_control.bdp_estimator()->StartPing(); t->bdp_ping_started = true; } -static void finish_bdp_ping(void* tp, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(tp); - t->combiner->Run(GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked, - finish_bdp_ping_locked, t, nullptr), - error); +static void finish_bdp_ping(grpc_core::RefCountedPtr t, + grpc_error_handle error) { + grpc_chttp2_transport* tp = t.get(); + tp->combiner->Run(grpc_core::InitTransportClosure( + std::move(t), &tp->finish_bdp_ping_locked), + error); } -static void finish_bdp_ping_locked(void* tp, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(tp); +static void finish_bdp_ping_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { gpr_log(GPR_INFO, "%s: Complete BDP ping err=%s", std::string(t->peer_string.as_string_view()).c_str(), grpc_core::StatusToString(error).c_str()); } if (!error.ok() || !t->closed_with_error.ok()) { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping"); return; } if (!t->bdp_ping_started) { // start_bdp_ping_locked has not been run yet. Schedule // finish_bdp_ping_locked to be run later. - t->combiner->Run(GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked, - finish_bdp_ping_locked, t, nullptr), - error); + finish_bdp_ping(std::move(t), std::move(error)); return; } t->bdp_ping_started = false; grpc_core::Timestamp next_ping = t->flow_control.bdp_estimator()->CompletePing(); - grpc_chttp2_act_on_flowctl_action(t->flow_control.PeriodicUpdate(), t, + grpc_chttp2_act_on_flowctl_action(t->flow_control.PeriodicUpdate(), t.get(), nullptr); GPR_ASSERT(!t->next_bdp_ping_timer_handle.has_value()); t->next_bdp_ping_timer_handle = t->event_engine->RunAfter(next_ping - grpc_core::Timestamp::Now(), [t] { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; - next_bdp_ping_timer_expired(t); + next_bdp_ping_timer_expired(t.get()); }); } static void next_bdp_ping_timer_expired(grpc_chttp2_transport* t) { t->combiner->Run( - GRPC_CLOSURE_INIT(&t->next_bdp_ping_timer_expired_locked, - next_bdp_ping_timer_expired_locked, t, nullptr), + grpc_core::InitTransportClosure( + t->Ref(), &t->next_bdp_ping_timer_expired_locked), absl::OkStatus()); } static void next_bdp_ping_timer_expired_locked( - void* tp, GRPC_UNUSED grpc_error_handle error) { + grpc_core::RefCountedPtr t, + GRPC_UNUSED grpc_error_handle error) { GPR_DEBUG_ASSERT(error.ok()); - grpc_chttp2_transport* t = static_cast(tp); GPR_ASSERT(t->next_bdp_ping_timer_handle.has_value()); t->next_bdp_ping_timer_handle.reset(); if (t->flow_control.bdp_estimator()->accumulator() == 0) { // Block the bdp ping till we receive more data. t->bdp_ping_blocked = true; - GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping"); } else { - schedule_bdp_ping_locked(t); + schedule_bdp_ping_locked(std::move(t)); } } @@ -2736,32 +2750,22 @@ void grpc_chttp2_config_default_keepalive_args( keepalive_permit_without_calls; } - g_default_max_ping_strikes = - std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES) - .value_or(g_default_max_ping_strikes)); - - g_default_max_pings_without_data = - std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA) - .value_or(g_default_max_pings_without_data)); - - g_default_min_recv_ping_interval_without_data = - std::max(grpc_core::Duration::Zero(), - channel_args - .GetDurationFromIntMillis( - GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS) - .value_or(g_default_min_recv_ping_interval_without_data)); + grpc_core::Chttp2PingAbusePolicy::SetDefaults(channel_args); + grpc_core::Chttp2PingRatePolicy::SetDefaults(channel_args); } -static void init_keepalive_ping(grpc_chttp2_transport* t) { - t->combiner->Run(GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, - init_keepalive_ping_locked, t, nullptr), - absl::OkStatus()); +static void init_keepalive_ping( + grpc_core::RefCountedPtr t) { + auto* tp = t.get(); + tp->combiner->Run(grpc_core::InitTransportClosure( + std::move(t), &tp->init_keepalive_ping_locked), + absl::OkStatus()); } -static void init_keepalive_ping_locked(void* arg, - GRPC_UNUSED grpc_error_handle error) { +static void init_keepalive_ping_locked( + grpc_core::RefCountedPtr t, + GRPC_UNUSED grpc_error_handle error) { GPR_DEBUG_ASSERT(error.ok()); - grpc_chttp2_transport* t = static_cast(arg); GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING); GPR_ASSERT(t->keepalive_ping_timer_handle.has_value()); t->keepalive_ping_timer_handle.reset(); @@ -2770,11 +2774,10 @@ static void init_keepalive_ping_locked(void* arg, } else { if (t->keepalive_permit_without_calls || !t->stream_map.empty()) { t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING; - GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive ping end"); send_keepalive_ping_locked(t); - grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING); + grpc_chttp2_initiate_write(t.get(), + GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING); } else { - GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); t->keepalive_ping_timer_handle = t->event_engine->RunAfter(t->keepalive_time, [t] { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; @@ -2783,18 +2786,21 @@ static void init_keepalive_ping_locked(void* arg, }); } } - GRPC_CHTTP2_UNREF_TRANSPORT(t, "init keepalive ping"); } -static void start_keepalive_ping(void* arg, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(arg); - t->combiner->Run(GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked, - start_keepalive_ping_locked, t, nullptr), - error); +static void start_keepalive_ping( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { + auto* tp = t.get(); + tp->combiner->Run( + grpc_core::InitTransportClosure( + std::move(t), &tp->start_keepalive_ping_locked), + error); } -static void start_keepalive_ping_locked(void* arg, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(arg); +static void start_keepalive_ping_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { if (!error.ok()) { return; } @@ -2806,25 +2812,28 @@ static void start_keepalive_ping_locked(void* arg, grpc_error_handle error) { gpr_log(GPR_INFO, "%s: Start keepalive ping", std::string(t->peer_string.as_string_view()).c_str()); } - GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog"); t->keepalive_watchdog_timer_handle = - t->event_engine->RunAfter(t->keepalive_timeout, [t] { + t->event_engine->RunAfter(t->keepalive_timeout, [t]() mutable { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; - keepalive_watchdog_fired(t); + keepalive_watchdog_fired(std::move(t)); }); t->keepalive_ping_started = true; } -static void finish_keepalive_ping(void* arg, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(arg); - t->combiner->Run(GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked, - finish_keepalive_ping_locked, t, nullptr), - error); +static void finish_keepalive_ping( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { + auto* tp = t.get(); + tp->combiner->Run( + grpc_core::InitTransportClosure( + std::move(t), &tp->finish_keepalive_ping_locked), + error); } -static void finish_keepalive_ping_locked(void* arg, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(arg); +static void finish_keepalive_ping_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) { if (error.ok()) { if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || @@ -2835,22 +2844,17 @@ static void finish_keepalive_ping_locked(void* arg, grpc_error_handle error) { if (!t->keepalive_ping_started) { // start_keepalive_ping_locked has not run yet. Reschedule // finish_keepalive_ping_locked for it to be run later. - t->combiner->Run( - GRPC_CLOSURE_INIT(&t->finish_keepalive_ping_locked, - finish_keepalive_ping_locked, t, nullptr), - error); + finish_keepalive_ping(std::move(t), std::move(error)); return; } t->keepalive_ping_started = false; t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING; if (t->keepalive_watchdog_timer_handle.has_value()) { if (t->event_engine->Cancel(*t->keepalive_watchdog_timer_handle)) { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive watchdog"); t->keepalive_watchdog_timer_handle.reset(); } } GPR_ASSERT(!t->keepalive_ping_timer_handle.has_value()); - GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); t->keepalive_ping_timer_handle = t->event_engine->RunAfter(t->keepalive_time, [t] { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; @@ -2859,20 +2863,21 @@ static void finish_keepalive_ping_locked(void* arg, grpc_error_handle error) { }); } } - GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive ping end"); } -static void keepalive_watchdog_fired(grpc_chttp2_transport* t) { - t->combiner->Run( - GRPC_CLOSURE_INIT(&t->keepalive_watchdog_fired_locked, - keepalive_watchdog_fired_locked, t, nullptr), +static void keepalive_watchdog_fired( + grpc_core::RefCountedPtr t) { + auto* tp = t.get(); + tp->combiner->Run( + grpc_core::InitTransportClosure( + std::move(t), &tp->keepalive_watchdog_fired_locked), absl::OkStatus()); } static void keepalive_watchdog_fired_locked( - void* arg, GRPC_UNUSED grpc_error_handle error) { + grpc_core::RefCountedPtr t, + GRPC_UNUSED grpc_error_handle error) { GPR_DEBUG_ASSERT(error.ok()); - grpc_chttp2_transport* t = static_cast(arg); GPR_ASSERT(t->keepalive_watchdog_timer_handle.has_value()); t->keepalive_watchdog_timer_handle.reset(); if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) { @@ -2880,9 +2885,10 @@ static void keepalive_watchdog_fired_locked( std::string(t->peer_string.as_string_view()).c_str()); t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING; close_transport_locked( - t, grpc_error_set_int(GRPC_ERROR_CREATE("keepalive watchdog timeout"), - grpc_core::StatusIntProperty::kRpcStatus, - GRPC_STATUS_UNAVAILABLE)); + t.get(), + grpc_error_set_int(GRPC_ERROR_CREATE("keepalive watchdog timeout"), + grpc_core::StatusIntProperty::kRpcStatus, + GRPC_STATUS_UNAVAILABLE)); } else { // If keepalive_state is not PINGING, we consider it as an error. Maybe the // cancellation failed in finish_keepalive_ping_locked. Users have seen @@ -2890,7 +2896,6 @@ static void keepalive_watchdog_fired_locked( gpr_log(GPR_ERROR, "keepalive_ping_end state error: %d (expect: %d)", t->keepalive_state, GRPC_CHTTP2_KEEPALIVE_STATE_PINGING); } - GRPC_CHTTP2_UNREF_TRANSPORT(t, "keepalive watchdog"); } static void maybe_reset_keepalive_ping_timer_locked(grpc_chttp2_transport* t) { @@ -2903,11 +2908,11 @@ static void maybe_reset_keepalive_ping_timer_locked(grpc_chttp2_transport* t) { gpr_log(GPR_INFO, "%s: Keepalive ping cancelled. Resetting timer.", std::string(t->peer_string.as_string_view()).c_str()); } - t->keepalive_ping_timer_handle = - t->event_engine->RunAfter(t->keepalive_time, [t] { + t->keepalive_ping_timer_handle = t->event_engine->RunAfter( + t->keepalive_time, [t = t->Ref()]() mutable { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; - init_keepalive_ping(t); + init_keepalive_ping(std::move(t)); }); } } @@ -2950,18 +2955,17 @@ static void set_pollset_set(grpc_transport* gt, grpc_stream* /*gs*/, static void post_benign_reclaimer(grpc_chttp2_transport* t) { if (!t->benign_reclaimer_registered) { t->benign_reclaimer_registered = true; - GRPC_CHTTP2_REF_TRANSPORT(t, "benign_reclaimer"); t->memory_owner.PostReclaimer( grpc_core::ReclamationPass::kBenign, - [t](absl::optional sweep) { + [t = t->Ref()]( + absl::optional sweep) mutable { if (sweep.has_value()) { - GRPC_CLOSURE_INIT(&t->benign_reclaimer_locked, - benign_reclaimer_locked, t, - grpc_schedule_on_exec_ctx); - t->active_reclamation = std::move(*sweep); - t->combiner->Run(&t->benign_reclaimer_locked, absl::OkStatus()); - } else { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "benign_reclaimer"); + auto* tp = t.get(); + tp->active_reclamation = std::move(*sweep); + tp->combiner->Run( + grpc_core::InitTransportClosure( + std::move(t), &tp->benign_reclaimer_locked), + absl::OkStatus()); } }); } @@ -2970,26 +2974,25 @@ static void post_benign_reclaimer(grpc_chttp2_transport* t) { static void post_destructive_reclaimer(grpc_chttp2_transport* t) { if (!t->destructive_reclaimer_registered) { t->destructive_reclaimer_registered = true; - GRPC_CHTTP2_REF_TRANSPORT(t, "destructive_reclaimer"); t->memory_owner.PostReclaimer( grpc_core::ReclamationPass::kDestructive, - [t](absl::optional sweep) { + [t = t->Ref()]( + absl::optional sweep) mutable { if (sweep.has_value()) { - GRPC_CLOSURE_INIT(&t->destructive_reclaimer_locked, - destructive_reclaimer_locked, t, - grpc_schedule_on_exec_ctx); - t->active_reclamation = std::move(*sweep); - t->combiner->Run(&t->destructive_reclaimer_locked, - absl::OkStatus()); - } else { - GRPC_CHTTP2_UNREF_TRANSPORT(t, "destructive_reclaimer"); + auto* tp = t.get(); + tp->active_reclamation = std::move(*sweep); + tp->combiner->Run( + grpc_core::InitTransportClosure( + std::move(t), &tp->destructive_reclaimer_locked), + absl::OkStatus()); } }); } } -static void benign_reclaimer_locked(void* arg, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(arg); +static void benign_reclaimer_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { if (error.ok() && t->stream_map.empty()) { // Channel with no active streams: send a goaway to try and make it // disconnect cleanly @@ -2997,7 +3000,7 @@ static void benign_reclaimer_locked(void* arg, grpc_error_handle error) { gpr_log(GPR_INFO, "HTTP2: %s - send goaway to free memory", std::string(t->peer_string.as_string_view()).c_str()); } - send_goaway(t, + send_goaway(t.get(), grpc_error_set_int(GRPC_ERROR_CREATE("Buffers full"), grpc_core::StatusIntProperty::kHttp2Error, GRPC_HTTP2_ENHANCE_YOUR_CALM), @@ -3013,11 +3016,11 @@ static void benign_reclaimer_locked(void* arg, grpc_error_handle error) { if (error != absl::CancelledError()) { t->active_reclamation.Finish(); } - GRPC_CHTTP2_UNREF_TRANSPORT(t, "benign_reclaimer"); } -static void destructive_reclaimer_locked(void* arg, grpc_error_handle error) { - grpc_chttp2_transport* t = static_cast(arg); +static void destructive_reclaimer_locked( + grpc_core::RefCountedPtr t, + grpc_error_handle error) { t->destructive_reclaimer_registered = false; if (error.ok() && !t->stream_map.empty()) { // As stream_map is a hash map, this selects effectively a random stream. @@ -3027,7 +3030,7 @@ static void destructive_reclaimer_locked(void* arg, grpc_error_handle error) { std::string(t->peer_string.as_string_view()).c_str(), s->id); } grpc_chttp2_cancel_stream( - t, s, + t.get(), s, grpc_error_set_int(GRPC_ERROR_CREATE("Buffers full"), grpc_core::StatusIntProperty::kHttp2Error, GRPC_HTTP2_ENHANCE_YOUR_CALM)); @@ -3036,13 +3039,12 @@ static void destructive_reclaimer_locked(void* arg, grpc_error_handle error) { // there are more streams left, we can immediately post a new // reclaimer in case the resource quota needs to free more // memory - post_destructive_reclaimer(t); + post_destructive_reclaimer(t.get()); } } if (error != absl::CancelledError()) { t->active_reclamation.Finish(); } - GRPC_CHTTP2_UNREF_TRANSPORT(t, "destructive_reclaimer"); } // @@ -3136,17 +3138,15 @@ grpc_transport* grpc_create_chttp2_transport( void grpc_chttp2_transport_start_reading( grpc_transport* transport, grpc_slice_buffer* read_buffer, grpc_closure* notify_on_receive_settings, grpc_closure* notify_on_close) { - grpc_chttp2_transport* t = - reinterpret_cast(transport); - GRPC_CHTTP2_REF_TRANSPORT( - t, "reading_action"); // matches unref inside reading_action + auto t = reinterpret_cast(transport)->Ref(); if (read_buffer != nullptr) { grpc_slice_buffer_move_into(read_buffer, &t->read_buffer); gpr_free(read_buffer); } - t->combiner->Run( - grpc_core::NewClosure([t, notify_on_receive_settings, - notify_on_close](grpc_error_handle) { + auto* tp = t.get(); + tp->combiner->Run( + grpc_core::NewClosure([t = std::move(t), notify_on_receive_settings, + notify_on_close](grpc_error_handle) mutable { if (!t->closed_with_error.ok()) { if (notify_on_receive_settings != nullptr) { grpc_core::ExecCtx::Run(DEBUG_LOCATION, notify_on_receive_settings, @@ -3156,12 +3156,11 @@ void grpc_chttp2_transport_start_reading( grpc_core::ExecCtx::Run(DEBUG_LOCATION, notify_on_close, t->closed_with_error); } - GRPC_CHTTP2_UNREF_TRANSPORT(t, "reading_action"); return; } t->notify_on_receive_settings = notify_on_receive_settings; t->notify_on_close = notify_on_close; - read_action_locked(t, absl::OkStatus()); + read_action_locked(std::move(t), absl::OkStatus()); }), absl::OkStatus()); } diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc index 8cf45a59dcf1a..18a73a3cab27a 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.cc +++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc @@ -33,7 +33,7 @@ #include #include "src/core/ext/transport/chttp2/transport/internal.h" -#include "src/core/lib/gprpp/time.h" +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) { grpc_slice slice = GRPC_SLICE_MALLOC(9 + 8); @@ -94,24 +94,11 @@ grpc_error_handle grpc_chttp2_ping_parser_parse(void* parser, grpc_chttp2_ack_ping(t, p->opaque_8bytes); } else { if (!t->is_client) { - grpc_core::Timestamp now = grpc_core::Timestamp::Now(); - grpc_core::Timestamp next_allowed_ping = - t->ping_recv_state.last_ping_recv_time + - t->ping_policy.min_recv_ping_interval_without_data; - - if (t->keepalive_permit_without_calls == 0 && t->stream_map.empty()) { - // According to RFC1122, the interval of TCP Keep-Alive is default to - // no less than two hours. When there is no outstanding streams, we - // restrict the number of PINGS equivalent to TCP Keep-Alive. - next_allowed_ping = t->ping_recv_state.last_ping_recv_time + - grpc_core::Duration::Hours(2); - } - - if (next_allowed_ping > now) { - grpc_chttp2_add_ping_strike(t); + const bool transport_idle = + t->keepalive_permit_without_calls == 0 && t->stream_map.empty(); + if (t->ping_abuse_policy.ReceivedOnePing(transport_idle)) { + grpc_chttp2_exceeded_ping_strikes(t); } - - t->ping_recv_state.last_ping_recv_time = now; } if (t->ack_pings) { if (t->ping_ack_count == t->ping_ack_capacity) { diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index f8c72dd2bf891..3ca3e5c812135 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -44,6 +44,7 @@ #include "src/core/ext/transport/chttp2/transport/hpack_constants.h" #include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h" +#include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" #include "src/core/lib/debug/trace.h" @@ -1069,6 +1070,55 @@ Slice HPackParser::String::Take() { GPR_UNREACHABLE_CODE(return Slice()); } +class HPackParser::MetadataSizeEncoder { + public: + explicit MetadataSizeEncoder(std::string& summary) : summary_(summary) {} + + void Encode(const Slice& key, const Slice& value) { + AddToSummary(key.as_string_view(), value.size()); + } + + template + void Encode(Key, const Value& value) { + AddToSummary(Key::key(), EncodedSizeOfKey(Key(), value)); + } + + private: + void AddToSummary(absl::string_view key, + size_t value_length) GPR_ATTRIBUTE_NOINLINE { + absl::StrAppend(&summary_, key, ":", + hpack_constants::SizeForEntry(key.size(), value_length), + ","); + } + std::string& summary_; +}; + +class HPackParser::MetadataSizesAnnotation + : public CallTracerAnnotationInterface::Annotation { + public: + MetadataSizesAnnotation(grpc_metadata_batch* metadata_buffer, + uint64_t soft_limit, uint64_t hard_limit) + : CallTracerAnnotationInterface::Annotation( + CallTracerAnnotationInterface::AnnotationType::kMetadataSizes), + metadata_buffer_(metadata_buffer), + soft_limit_(soft_limit), + hard_limit_(hard_limit) {} + + std::string ToString() const override { + std::string metadata_annotation = + absl::StrCat("gRPC metadata soft_limit:", soft_limit_, + ",hard_limit:", hard_limit_, ","); + MetadataSizeEncoder encoder(metadata_annotation); + metadata_buffer_->Encode(&encoder); + return metadata_annotation; + } + + private: + grpc_metadata_batch* metadata_buffer_; + uint64_t soft_limit_; + uint64_t hard_limit_; +}; + // PUBLIC INTERFACE HPackParser::HPackParser() = default; @@ -1093,7 +1143,9 @@ void HPackParser::BeginFrame(grpc_metadata_batch* metadata_buffer, log_info_ = log_info; } -grpc_error_handle HPackParser::Parse(const grpc_slice& slice, bool is_last) { +grpc_error_handle HPackParser::Parse( + const grpc_slice& slice, bool is_last, + CallTracerAnnotationInterface* call_tracer) { if (GPR_UNLIKELY(!unparsed_bytes_.empty())) { unparsed_bytes_.insert(unparsed_bytes_.end(), GRPC_SLICE_START_PTR(slice), GRPC_SLICE_END_PTR(slice)); @@ -1105,20 +1157,27 @@ grpc_error_handle HPackParser::Parse(const grpc_slice& slice, bool is_last) { std::vector buffer = std::move(unparsed_bytes_); return ParseInput(Input(nullptr, buffer.data(), buffer.data() + buffer.size(), state_.frame_error), - is_last); + is_last, call_tracer); } return ParseInput(Input(slice.refcount, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_END_PTR(slice), state_.frame_error), - is_last); + is_last, call_tracer); } -grpc_error_handle HPackParser::ParseInput(Input input, bool is_last) { +grpc_error_handle HPackParser::ParseInput( + Input input, bool is_last, CallTracerAnnotationInterface* call_tracer) { ParseInputInner(&input); if (is_last && is_boundary()) { if (state_.metadata_early_detection.Reject(state_.frame_length)) { HandleMetadataSoftSizeLimitExceeded(&input); } global_stats().IncrementHttp2MetadataSize(state_.frame_length); + if (call_tracer != nullptr && metadata_buffer_ != nullptr) { + MetadataSizesAnnotation metadata_sizes_annotation( + metadata_buffer_, state_.metadata_early_detection.soft_limit(), + state_.metadata_early_detection.hard_limit()); + call_tracer->RecordAnnotation(metadata_sizes_annotation); + } if (!state_.frame_error.connection_error() && (input.eof_error() || state_.parse_state != ParseState::kTop)) { state_.frame_error = HpackParseResult::IncompleteHeaderAtBoundaryError(); diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index 70ba2273def7c..fd1747f345257 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -40,6 +40,7 @@ #include "src/core/ext/transport/chttp2/transport/hpack_parse_result.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h" #include "src/core/lib/backoff/random_early_detection.h" +#include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_refcount.h" @@ -99,7 +100,8 @@ class HPackParser { // Start throwing away any received headers after parsing them. void StopBufferingFrame() { metadata_buffer_ = nullptr; } // Parse one slice worth of data - grpc_error_handle Parse(const grpc_slice& slice, bool is_last); + grpc_error_handle Parse(const grpc_slice& slice, bool is_last, + CallTracerAnnotationInterface* call_tracer); // Reset state ready for the next BeginFrame void FinishFrame(); @@ -117,6 +119,8 @@ class HPackParser { // Helper classes: see implementation class Parser; class Input; + class MetadataSizeEncoder; + class MetadataSizesAnnotation; // Helper to parse a string and turn it into a slice with appropriate memory // management characteristics @@ -249,7 +253,8 @@ class HPackParser { absl::variant key; }; - grpc_error_handle ParseInput(Input input, bool is_last); + grpc_error_handle ParseInput(Input input, bool is_last, + CallTracerAnnotationInterface* call_tracer); void ParseInputInner(Input* input); GPR_ATTRIBUTE_NOINLINE void HandleMetadataSoftSizeLimitExceeded(Input* input); diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser_table.h b/src/core/ext/transport/chttp2/transport/hpack_parser_table.h index 283a3184b0d79..c9839dae77102 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser_table.h @@ -71,7 +71,7 @@ class HPackTable { } // add a table entry to the index - bool Add(Memento md) GRPC_MUST_USE_RESULT; + GRPC_MUST_USE_RESULT bool Add(Memento md); void AddLargerThanCurrentTableSize(); // Current entry count in the table. diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 479c7518e2e46..760051697e2ad 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -48,6 +48,8 @@ #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/trace.h" @@ -146,21 +148,14 @@ struct grpc_chttp2_ping_queue { grpc_closure_list lists[GRPC_CHTTP2_PCL_COUNT] = {}; uint64_t inflight_id = 0; }; -struct grpc_chttp2_repeated_ping_policy { - int max_pings_without_data; - int max_ping_strikes; - grpc_core::Duration min_recv_ping_interval_without_data; -}; + struct grpc_chttp2_repeated_ping_state { grpc_core::Timestamp last_ping_sent_time; int pings_before_data_required; absl::optional delayed_ping_timer_handle; }; -struct grpc_chttp2_server_ping_recv_state { - grpc_core::Timestamp last_ping_recv_time; - int ping_strikes; -}; + // deframer state for the overall http2 stream of bytes typedef enum { // prefix: one entry per http2 connection prefix byte @@ -250,6 +245,19 @@ struct grpc_chttp2_transport : public grpc_core::KeepsGrpcInitialized { grpc_endpoint* ep, bool is_client); ~grpc_chttp2_transport(); + // Make this be able to be contained in RefCountedPtr<> + // Can't yet make this derive from RefCounted because we need to keep + // `grpc_transport base` first. + // TODO(ctiller): Make a transport interface. + void IncrementRefCount() { refs.Ref(); } + void Unref() { + if (refs.Unref()) delete this; + } + grpc_core::RefCountedPtr Ref() { + IncrementRefCount(); + return grpc_core::RefCountedPtr(this); + } + grpc_transport base; // must be first grpc_core::RefCount refs; grpc_endpoint* ep; @@ -343,8 +351,10 @@ struct grpc_chttp2_transport : public grpc_core::KeepsGrpcInitialized { /// ping queues for various ping insertion points grpc_chttp2_ping_queue ping_queue = grpc_chttp2_ping_queue(); - grpc_chttp2_repeated_ping_policy ping_policy; - grpc_chttp2_repeated_ping_state ping_state; + grpc_core::Chttp2PingAbusePolicy ping_abuse_policy; + grpc_core::Chttp2PingRatePolicy ping_rate_policy; + absl::optional + delayed_ping_timer_handle; uint64_t ping_ctr = 0; // unique id for pings grpc_closure retry_initiate_ping_locked; @@ -352,7 +362,6 @@ struct grpc_chttp2_transport : public grpc_core::KeepsGrpcInitialized { size_t ping_ack_count = 0; size_t ping_ack_capacity = 0; uint64_t* ping_acks = nullptr; - grpc_chttp2_server_ping_recv_state ping_recv_state; /// parser for headers grpc_core::HPackParser hpack_parser; @@ -486,15 +495,9 @@ struct grpc_chttp2_stream { const void* server_data, grpc_core::Arena* arena); ~grpc_chttp2_stream(); - void* context; - grpc_chttp2_transport* t; + void* context = nullptr; + const grpc_core::RefCountedPtr t; grpc_stream_refcount* refcount; - // Reffer is a 0-len structure, simply reffing `t` and `refcount` in its ctor - // before initializing the rest of the stream, to avoid cache misses. This - // field MUST be right after `t` and `refcount`. - struct Reffer { - explicit Reffer(grpc_chttp2_stream* s); - } reffer; grpc_closure destroy_stream; grpc_closure* destroy_stream_arg; @@ -740,43 +743,11 @@ void grpc_chttp2_stream_ref(grpc_chttp2_stream* s); void grpc_chttp2_stream_unref(grpc_chttp2_stream* s); #endif -#ifndef NDEBUG -#define GRPC_CHTTP2_REF_TRANSPORT(t, r) \ - grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__) -#define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) \ - grpc_chttp2_unref_transport(t, r, __FILE__, __LINE__) -inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, - const char* reason, const char* file, - int line) { - if (t->refs.Unref(grpc_core::DebugLocation(file, line), reason)) { - delete t; - } -} -inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, - const char* reason, const char* file, - int line) { - t->refs.Ref(grpc_core::DebugLocation(file, line), reason); -} -#else -#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t) -#define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) grpc_chttp2_unref_transport(t) -inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) { - if (t->refs.Unref()) { - delete t; - } -} -inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { - t->refs.Ref(); -} -#endif - void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id); -/// Add a new ping strike to ping_recv_state.ping_strikes. If -/// ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY -/// with error code ENHANCE_YOUR_CALM and additional debug data resembling -/// "too_many_pings" followed by immediately closing the connection. -void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t); +/// Sends GOAWAY with error code ENHANCE_YOUR_CALM and additional debug data +/// resembling "too_many_pings" followed by immediately closing the connection. +void grpc_chttp2_exceeded_ping_strikes(grpc_chttp2_transport* t); /// Resets ping clock. Should be called when flushing window updates, /// initial/trailing metadata or data frames. For a server, it resets the number @@ -810,9 +781,11 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args, void grpc_chttp2_config_default_keepalive_args( const grpc_core::ChannelArgs& channel_args, bool is_client); -void grpc_chttp2_retry_initiate_ping(grpc_chttp2_transport* t); +void grpc_chttp2_retry_initiate_ping( + grpc_core::RefCountedPtr t); -void schedule_bdp_ping_locked(grpc_chttp2_transport* t); +void schedule_bdp_ping_locked( + grpc_core::RefCountedPtr t); uint32_t grpc_chttp2_min_read_progress_size(grpc_chttp2_transport* t); diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 9fd946297216d..b5ac509102326 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -47,11 +47,13 @@ #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http_trace.h" #include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" +#include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/channel/channelz.h" +#include "src/core/lib/channel/context.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/status_helper.h" -#include "src/core/lib/gprpp/time.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/endpoint.h" @@ -510,8 +512,7 @@ static grpc_error_handle init_data_frame_parser(grpc_chttp2_transport* t) { if (bdp_est) { if (t->bdp_ping_blocked) { t->bdp_ping_blocked = false; - GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping"); - schedule_bdp_ping_locked(t); + schedule_bdp_ping_locked(t->Ref()); } bdp_est->AddIncomingBytes(t->incoming_frame_size); } @@ -549,7 +550,7 @@ static grpc_error_handle init_data_frame_parser(grpc_chttp2_transport* t) { t->incoming_stream = s; t->parser = grpc_chttp2_transport::Parser{ "data", grpc_chttp2_data_parser_parse, nullptr}; - t->ping_state.last_ping_sent_time = grpc_core::Timestamp::InfPast(); + t->ping_rate_policy.ReceivedDataFrame(); return absl::OkStatus(); } else if (s != nullptr) { // handle stream errors by closing the stream @@ -588,7 +589,7 @@ static grpc_error_handle init_header_frame_parser(grpc_chttp2_transport* t, ? HPackParser::Priority::Included : HPackParser::Priority::None; - t->ping_state.last_ping_sent_time = grpc_core::Timestamp::InfPast(); + t->ping_rate_policy.ReceivedDataFrame(); // could be a new grpc_chttp2_stream or an existing grpc_chttp2_stream s = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id); @@ -841,7 +842,7 @@ static const maybe_complete_func_type maybe_complete_funcs[] = { static void force_client_rst_stream(void* sp, grpc_error_handle /*error*/) { grpc_chttp2_stream* s = static_cast(sp); - grpc_chttp2_transport* t = s->t; + grpc_chttp2_transport* t = s->t.get(); if (!s->write_closed) { grpc_chttp2_add_rst_stream_to_next_write(t, s->id, GRPC_HTTP2_NO_ERROR, &s->stats.outgoing); @@ -857,10 +858,18 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser, const grpc_slice& slice, int is_last) { auto* parser = static_cast(hpack_parser); + grpc_core::CallTracerAnnotationInterface* call_tracer = nullptr; if (s != nullptr) { s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice); + + if (s->context != nullptr) { + call_tracer = static_cast( + static_cast( + s->context)[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE] + .value); + } } - grpc_error_handle error = parser->Parse(slice, is_last != 0); + grpc_error_handle error = parser->Parse(slice, is_last != 0, call_tracer); if (!error.ok()) { return error; } diff --git a/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc new file mode 100644 index 0000000000000..1ace22dd9a8f0 --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc @@ -0,0 +1,80 @@ +// Copyright 2023 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/ext/transport/chttp2/transport/ping_abuse_policy.h" + +#include + +#include "absl/types/optional.h" + +#include + +namespace grpc_core { + +namespace { +Duration g_default_min_recv_ping_interval_without_data = Duration::Minutes(5); +int g_default_max_ping_strikes = 2; +} // namespace + +Chttp2PingAbusePolicy::Chttp2PingAbusePolicy(const ChannelArgs& args) + : min_recv_ping_interval_without_data_(std::max( + Duration::Zero(), + args.GetDurationFromIntMillis( + GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS) + .value_or(g_default_min_recv_ping_interval_without_data))), + max_ping_strikes_( + std::max(0, args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES) + .value_or(g_default_max_ping_strikes))) {} + +void Chttp2PingAbusePolicy::SetDefaults(const ChannelArgs& args) { + g_default_max_ping_strikes = + std::max(0, args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES) + .value_or(g_default_max_ping_strikes)); + g_default_min_recv_ping_interval_without_data = + std::max(Duration::Zero(), + args.GetDurationFromIntMillis( + GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS) + .value_or(g_default_min_recv_ping_interval_without_data)); +} + +bool Chttp2PingAbusePolicy::ReceivedOnePing(bool transport_idle) { + const Timestamp now = Timestamp::Now(); + const Timestamp next_allowed_ping = + last_ping_recv_time_ + RecvPingIntervalWithoutData(transport_idle); + last_ping_recv_time_ = now; + if (next_allowed_ping <= now) return false; + // Received ping too soon: increment strike count. + ++ping_strikes_; + return ping_strikes_ > max_ping_strikes_ && max_ping_strikes_ != 0; +} + +Duration Chttp2PingAbusePolicy::RecvPingIntervalWithoutData( + bool transport_idle) const { + if (transport_idle) { + // According to RFC1122, the interval of TCP Keep-Alive is default to + // no less than two hours. When there is no outstanding streams, we + // restrict the number of PINGS equivalent to TCP Keep-Alive. + return Duration::Hours(2); + } + return min_recv_ping_interval_without_data_; +} + +void Chttp2PingAbusePolicy::ResetPingStrikes() { + last_ping_recv_time_ = Timestamp::InfPast(); + ping_strikes_ = 0; +} + +} // namespace grpc_core diff --git a/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h new file mode 100644 index 0000000000000..adc5cb7969920 --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h @@ -0,0 +1,55 @@ +// Copyright 2023 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_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H +#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H + +#include + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/time.h" + +namespace grpc_core { + +class Chttp2PingAbusePolicy { + public: + explicit Chttp2PingAbusePolicy(const ChannelArgs& args); + + static void SetDefaults(const ChannelArgs& args); + + // Record one received ping; returns true if the connection should be closed. + // If transport_idle is true, we increase the allowed time between pings up to + // TCP keep-alive check time. + GRPC_MUST_USE_RESULT bool ReceivedOnePing(bool transport_idle); + + // Reset the ping clock, strike count. + void ResetPingStrikes(); + + int TestOnlyMaxPingStrikes() const { return max_ping_strikes_; } + Duration TestOnlyMinPingIntervalWithoutData() const { + return min_recv_ping_interval_without_data_; + } + + private: + Duration RecvPingIntervalWithoutData(bool transport_idle) const; + + Timestamp last_ping_recv_time_ = Timestamp::InfPast(); + const Duration min_recv_ping_interval_without_data_; + int ping_strikes_ = 0; + const int max_ping_strikes_; +}; + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H diff --git a/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc b/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc new file mode 100644 index 0000000000000..51b7b38d578d1 --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc @@ -0,0 +1,98 @@ +// Copyright 2023 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/ext/transport/chttp2/transport/ping_rate_policy.h" + +#include +#include +#include + +#include "absl/strings/str_cat.h" +#include "absl/types/optional.h" + +#include + +#include "src/core/lib/gprpp/match.h" + +namespace grpc_core { + +namespace { +int g_default_max_pings_without_data = 2; +} // namespace + +Chttp2PingRatePolicy::Chttp2PingRatePolicy(const ChannelArgs& args, + bool is_client) + : max_pings_without_data_( + is_client + ? std::max(0, args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA) + .value_or(g_default_max_pings_without_data)) + : 0) {} + +void Chttp2PingRatePolicy::SetDefaults(const ChannelArgs& args) { + g_default_max_pings_without_data = + std::max(0, args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA) + .value_or(g_default_max_pings_without_data)); +} + +Chttp2PingRatePolicy::RequestSendPingResult +Chttp2PingRatePolicy::RequestSendPing(Duration next_allowed_ping_interval) { + if (max_pings_without_data_ != 0 && pings_before_data_required_ == 0) { + return TooManyRecentPings{}; + } + const Timestamp next_allowed_ping = + last_ping_sent_time_ + next_allowed_ping_interval; + const Timestamp now = Timestamp::Now(); + if (next_allowed_ping > now) { + return TooSoon{next_allowed_ping_interval, last_ping_sent_time_, + next_allowed_ping - now}; + } + last_ping_sent_time_ = now; + if (pings_before_data_required_) --pings_before_data_required_; + return SendGranted{}; +} + +void Chttp2PingRatePolicy::ReceivedDataFrame() { + last_ping_sent_time_ = Timestamp::InfPast(); +} + +void Chttp2PingRatePolicy::ResetPingsBeforeDataRequired() { + pings_before_data_required_ = max_pings_without_data_; +} + +std::string Chttp2PingRatePolicy::GetDebugString() const { + return absl::StrCat( + "max_pings_without_data: ", max_pings_without_data_, + ", pings_before_data_required: ", pings_before_data_required_, + ", last_ping_sent_time_: ", last_ping_sent_time_.ToString()); +} + +std::ostream& operator<<(std::ostream& out, + const Chttp2PingRatePolicy::RequestSendPingResult& r) { + Match( + r, [&out](Chttp2PingRatePolicy::SendGranted) { out << "SendGranted"; }, + [&out](Chttp2PingRatePolicy::TooManyRecentPings) { + out << "TooManyRecentPings"; + }, + [&out](Chttp2PingRatePolicy::TooSoon r) { + out << "TooSoon: next_allowed=" + << r.next_allowed_ping_interval.ToString() + << " last_ping_sent_time=" << r.last_ping.ToString() + << " wait=" << r.wait.ToString(); + }); + return out; +} + +} // namespace grpc_core diff --git a/src/core/ext/transport/chttp2/transport/ping_rate_policy.h b/src/core/ext/transport/chttp2/transport/ping_rate_policy.h new file mode 100644 index 0000000000000..7363259fb8b1e --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/ping_rate_policy.h @@ -0,0 +1,73 @@ +// Copyright 2023 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_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_RATE_POLICY_H +#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_RATE_POLICY_H + +#include + +#include +#include + +#include "absl/types/variant.h" + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/time.h" + +namespace grpc_core { + +class Chttp2PingRatePolicy { + public: + explicit Chttp2PingRatePolicy(const ChannelArgs& args, bool is_client); + + static void SetDefaults(const ChannelArgs& args); + + struct SendGranted { + bool operator==(const SendGranted&) const { return true; } + }; + struct TooManyRecentPings { + bool operator==(const TooManyRecentPings&) const { return true; } + }; + struct TooSoon { + Duration next_allowed_ping_interval; + Timestamp last_ping; + Duration wait; + bool operator==(const TooSoon& other) const { + return next_allowed_ping_interval == other.next_allowed_ping_interval && + last_ping == other.last_ping && wait == other.wait; + } + }; + using RequestSendPingResult = + absl::variant; + + RequestSendPingResult RequestSendPing(Duration next_allowed_ping_interval); + void ResetPingsBeforeDataRequired(); + void ReceivedDataFrame(); + std::string GetDebugString() const; + + int TestOnlyMaxPingsWithoutData() const { return max_pings_without_data_; } + + private: + const int max_pings_without_data_; + // No pings allowed before receiving a header or data frame. + int pings_before_data_required_ = 0; + Timestamp last_ping_sent_time_ = Timestamp::InfPast(); +}; + +std::ostream& operator<<(std::ostream& out, + const Chttp2PingRatePolicy::RequestSendPingResult& r); + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_RATE_POLICY_H diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index f24c852d73a6c..89aec5539d9bf 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include "absl/container/flat_hash_map.h" #include "absl/status/status.h" @@ -35,10 +36,6 @@ #include #include -#include "src/core/ext/transport/chttp2/transport/http_trace.h" - -// IWYU pragma: no_include "src/core/lib/gprpp/orphanable.h" - #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/ext/transport/chttp2/transport/context_list_entry.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" @@ -50,12 +47,15 @@ #include "src/core/ext/transport/chttp2/transport/frame_window_update.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" +#include "src/core/ext/transport/chttp2/transport/http_trace.h" #include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/debug_location.h" +#include "src/core/lib/gprpp/match.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/time.h" @@ -69,6 +69,8 @@ #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" +// IWYU pragma: no_include "src/core/lib/gprpp/orphanable.h" + static void add_to_write_list(grpc_chttp2_write_cb** list, grpc_chttp2_write_cb* cb) { cb->next = *list; @@ -83,6 +85,25 @@ static void finish_write_cb(grpc_chttp2_transport* t, grpc_chttp2_stream* s, t->write_cb_pool = cb; } +static grpc_core::Duration NextAllowedPingInterval(grpc_chttp2_transport* t) { + if (t->is_client) { + return (t->keepalive_permit_without_calls == 0 && t->stream_map.empty()) + ? grpc_core::Duration::Hours(2) + : grpc_core::Duration::Seconds( + 1); // A second is added to deal with + // network delays and timing imprecision + } + if (t->sent_goaway_state != GRPC_CHTTP2_GRACEFUL_GOAWAY) { + // The gRPC keepalive spec doesn't call for any throttling on the server + // side, but we are adding some throttling for protection anyway, unless + // we are doing a graceful GOAWAY in which case we don't want to wait. + return t->keepalive_time == grpc_core::Duration::Infinity() + ? grpc_core::Duration::Seconds(20) + : t->keepalive_time / 2; + } + return grpc_core::Duration::Zero(); +} + static void maybe_initiate_ping(grpc_chttp2_transport* t) { grpc_chttp2_ping_queue* pq = &t->ping_queue; if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) { @@ -100,95 +121,66 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) { } return; } - if (t->is_client && t->ping_state.pings_before_data_required == 0 && - t->ping_policy.max_pings_without_data != 0) { - // need to receive something of substance before sending a ping again - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { - gpr_log(GPR_INFO, - "CLIENT: Ping delayed [%s]: too many recent pings: %d/%d", - std::string(t->peer_string.as_string_view()).c_str(), - t->ping_state.pings_before_data_required, - t->ping_policy.max_pings_without_data); - } - return; - } // InvalidateNow to avoid getting stuck re-initializing the ping timer // in a loop while draining the currently-held combiner. Also see // https://github.com/grpc/grpc/issues/26079. grpc_core::ExecCtx::Get()->InvalidateNow(); - grpc_core::Timestamp now = grpc_core::Timestamp::Now(); - - grpc_core::Duration next_allowed_ping_interval = grpc_core::Duration::Zero(); - if (t->is_client) { - next_allowed_ping_interval = - (t->keepalive_permit_without_calls == 0 && t->stream_map.empty()) - ? grpc_core::Duration::Hours(2) - : grpc_core::Duration::Seconds( - 1); // A second is added to deal with - // network delays and timing imprecision - } else if (t->sent_goaway_state != GRPC_CHTTP2_GRACEFUL_GOAWAY) { - // The gRPC keepalive spec doesn't call for any throttling on the server - // side, but we are adding some throttling for protection anyway, unless - // we are doing a graceful GOAWAY in which case we don't want to wait. - next_allowed_ping_interval = - t->keepalive_time == grpc_core::Duration::Infinity() - ? grpc_core::Duration::Seconds(20) - : t->keepalive_time / 2; - } - grpc_core::Timestamp next_allowed_ping = - t->ping_state.last_ping_sent_time + next_allowed_ping_interval; - - if (next_allowed_ping > now) { - // not enough elapsed time between successive pings - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { - gpr_log( - GPR_INFO, - "%s: Ping delayed [%s]: not enough time elapsed since last " - "ping. " - " Last ping %" PRId64 ": Next ping %" PRId64 ": Now %" PRId64, - t->is_client ? "CLIENT" : "SERVER", - std::string(t->peer_string.as_string_view()).c_str(), - t->ping_state.last_ping_sent_time.milliseconds_after_process_epoch(), - next_allowed_ping.milliseconds_after_process_epoch(), - now.milliseconds_after_process_epoch()); - } - if (!t->ping_state.delayed_ping_timer_handle.has_value()) { - GRPC_CHTTP2_REF_TRANSPORT(t, "retry_initiate_ping_locked"); - t->ping_state.delayed_ping_timer_handle = - t->event_engine->RunAfter(next_allowed_ping - now, [t] { - grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; - grpc_core::ExecCtx exec_ctx; - grpc_chttp2_retry_initiate_ping(t); - }); - } - return; - } - t->ping_state.last_ping_sent_time = now; - - pq->inflight_id = t->ping_ctr; - t->ping_ctr++; - grpc_core::ExecCtx::RunList(DEBUG_LOCATION, - &pq->lists[GRPC_CHTTP2_PCL_INITIATE]); - grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT], - &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]); - grpc_slice_buffer_add(&t->outbuf, - grpc_chttp2_ping_create(false, pq->inflight_id)); - grpc_core::global_stats().IncrementHttp2PingsSent(); - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { - gpr_log(GPR_INFO, "%s: Ping sent [%s]: %d/%d", - t->is_client ? "CLIENT" : "SERVER", - std::string(t->peer_string.as_string_view()).c_str(), - t->ping_state.pings_before_data_required, - t->ping_policy.max_pings_without_data); - } - t->ping_state.pings_before_data_required -= - (t->ping_state.pings_before_data_required != 0); + Match( + t->ping_rate_policy.RequestSendPing(NextAllowedPingInterval(t)), + [pq, t](grpc_core::Chttp2PingRatePolicy::SendGranted) { + pq->inflight_id = t->ping_ctr; + t->ping_ctr++; + grpc_core::ExecCtx::RunList(DEBUG_LOCATION, + &pq->lists[GRPC_CHTTP2_PCL_INITIATE]); + grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT], + &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]); + grpc_slice_buffer_add(&t->outbuf, + grpc_chttp2_ping_create(false, pq->inflight_id)); + grpc_core::global_stats().IncrementHttp2PingsSent(); + if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { + gpr_log(GPR_INFO, "%s: Ping sent [%s]: %s", + t->is_client ? "CLIENT" : "SERVER", + std::string(t->peer_string.as_string_view()).c_str(), + t->ping_rate_policy.GetDebugString().c_str()); + } + }, + [t](grpc_core::Chttp2PingRatePolicy::TooManyRecentPings) { + // need to receive something of substance before sending a ping again + if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { + gpr_log(GPR_INFO, + "CLIENT: Ping delayed [%s]: too many recent pings: %s", + std::string(t->peer_string.as_string_view()).c_str(), + t->ping_rate_policy.GetDebugString().c_str()); + } + }, + [t](grpc_core::Chttp2PingRatePolicy::TooSoon too_soon) { + // not enough elapsed time between successive pings + if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { + gpr_log(GPR_INFO, + "%s: Ping delayed [%s]: not enough time elapsed since last " + "ping. " + " Last ping:%s, minimum wait:%s need to wait:%s", + t->is_client ? "CLIENT" : "SERVER", + std::string(t->peer_string.as_string_view()).c_str(), + too_soon.last_ping.ToString().c_str(), + too_soon.next_allowed_ping_interval.ToString().c_str(), + too_soon.wait.ToString().c_str()); + } + if (!t->delayed_ping_timer_handle.has_value()) { + t->delayed_ping_timer_handle = t->event_engine->RunAfter( + too_soon.wait, [t = t->Ref()]() mutable { + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; + grpc_core::ExecCtx exec_ctx; + grpc_chttp2_retry_initiate_ping(std::move(t)); + }); + } + }); } static bool update_list(grpc_chttp2_transport* t, grpc_chttp2_stream* s, 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 f5e602fc89cbe..5cc1d5b554c1c 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 @@ -22,6 +22,7 @@ #include "absl/status/statusor.h" +#include #include #include "src/core/ext/transport/cronet/transport/cronet_transport.h" diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index e1dfbb33b714b..270639362a001 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -37,6 +37,7 @@ #include "absl/types/optional.h" #include "third_party/objective_c/Cronet/bidirectional_stream_c.h" +#include #include #include #include diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index b4185e454c05b..fb9bd9d6fe913 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -35,6 +35,7 @@ #include "absl/types/optional.h" #include +#include #include #include #include diff --git a/src/core/ext/xds/xds_client_grpc.cc b/src/core/ext/xds/xds_client_grpc.cc index ca14f536266f9..7df4c36a5b255 100644 --- a/src/core/ext/xds/xds_client_grpc.cc +++ b/src/core/ext/xds/xds_client_grpc.cc @@ -30,6 +30,7 @@ #include "absl/types/optional.h" #include +#include #include #include #include diff --git a/src/core/ext/xds/xds_http_fault_filter.cc b/src/core/ext/xds/xds_http_fault_filter.cc index 1950ca812ccd0..4c460daef584f 100644 --- a/src/core/ext/xds/xds_http_fault_filter.cc +++ b/src/core/ext/xds/xds_http_fault_filter.cc @@ -227,8 +227,7 @@ ChannelArgs XdsHttpFaultFilter::ModifyChannelArgs( absl::StatusOr XdsHttpFaultFilter::GenerateServiceConfig( const FilterConfig& hcm_filter_config, - const FilterConfig* filter_config_override, - absl::string_view /*filter_name*/) const { + const FilterConfig* filter_config_override) const { Json policy_json = filter_config_override != nullptr ? filter_config_override->config : hcm_filter_config.config; diff --git a/src/core/ext/xds/xds_http_fault_filter.h b/src/core/ext/xds/xds_http_fault_filter.h index f2dd3555dc0a2..690d89eb684d9 100644 --- a/src/core/ext/xds/xds_http_fault_filter.h +++ b/src/core/ext/xds/xds_http_fault_filter.h @@ -48,8 +48,7 @@ class XdsHttpFaultFilter : public XdsHttpFilterImpl { ChannelArgs ModifyChannelArgs(const ChannelArgs& args) const override; absl::StatusOr GenerateServiceConfig( const FilterConfig& hcm_filter_config, - const FilterConfig* filter_config_override, - absl::string_view filter_name) const override; + const FilterConfig* filter_config_override) const override; bool IsSupportedOnClients() const override { return true; } bool IsSupportedOnServers() const override { return false; } }; diff --git a/src/core/ext/xds/xds_http_filters.h b/src/core/ext/xds/xds_http_filters.h index 26d73cd764e37..b99f12bd4f9ca 100644 --- a/src/core/ext/xds/xds_http_filters.h +++ b/src/core/ext/xds/xds_http_filters.h @@ -112,8 +112,7 @@ class XdsHttpFilterImpl { // there is no override in any of those locations. virtual absl::StatusOr GenerateServiceConfig( const FilterConfig& hcm_filter_config, - const FilterConfig* filter_config_override, - absl::string_view filter_name) const = 0; + const FilterConfig* filter_config_override) const = 0; // Returns true if the filter is supported on clients; false otherwise virtual bool IsSupportedOnClients() const = 0; @@ -139,8 +138,7 @@ class XdsHttpRouterFilter : public XdsHttpFilterImpl { const grpc_channel_filter* channel_filter() const override { return nullptr; } absl::StatusOr GenerateServiceConfig( const FilterConfig& /*hcm_filter_config*/, - const FilterConfig* /*filter_config_override*/, - absl::string_view /*filter_name*/) const override { + const FilterConfig* /*filter_config_override*/) const override { // This will never be called, since channel_filter() returns null. return absl::UnimplementedError("router filter should never be called"); } diff --git a/src/core/ext/xds/xds_http_rbac_filter.cc b/src/core/ext/xds/xds_http_rbac_filter.cc index f7bde62b5747d..ed107c37a370d 100644 --- a/src/core/ext/xds/xds_http_rbac_filter.cc +++ b/src/core/ext/xds/xds_http_rbac_filter.cc @@ -575,17 +575,12 @@ ChannelArgs XdsHttpRbacFilter::ModifyChannelArgs( absl::StatusOr XdsHttpRbacFilter::GenerateServiceConfig( const FilterConfig& hcm_filter_config, - const FilterConfig* filter_config_override, - absl::string_view filter_name) const { + const FilterConfig* filter_config_override) const { const Json& policy_json = filter_config_override != nullptr ? filter_config_override->config : hcm_filter_config.config; - auto json_object = policy_json.object(); - json_object.emplace("filter_name", - Json::FromString(std::string(filter_name))); - // The policy JSON may be empty other than the filter name, that's allowed. - return ServiceConfigJsonEntry{"rbacPolicy", - JsonDump(Json::FromObject(json_object))}; + // The policy JSON may be empty and that's allowed. + return ServiceConfigJsonEntry{"rbacPolicy", JsonDump(policy_json)}; } } // namespace grpc_core diff --git a/src/core/ext/xds/xds_http_rbac_filter.h b/src/core/ext/xds/xds_http_rbac_filter.h index 74c71f3cb9367..c066521658ae6 100644 --- a/src/core/ext/xds/xds_http_rbac_filter.h +++ b/src/core/ext/xds/xds_http_rbac_filter.h @@ -48,8 +48,7 @@ class XdsHttpRbacFilter : public XdsHttpFilterImpl { ChannelArgs ModifyChannelArgs(const ChannelArgs& args) const override; absl::StatusOr GenerateServiceConfig( const FilterConfig& hcm_filter_config, - const FilterConfig* filter_config_override, - absl::string_view filter_name) const override; + const FilterConfig* filter_config_override) const override; bool IsSupportedOnClients() const override { return false; } bool IsSupportedOnServers() const override { return true; } }; diff --git a/src/core/ext/xds/xds_http_stateful_session_filter.cc b/src/core/ext/xds/xds_http_stateful_session_filter.cc index 85526a98d7e02..f58152b4e461d 100644 --- a/src/core/ext/xds/xds_http_stateful_session_filter.cc +++ b/src/core/ext/xds/xds_http_stateful_session_filter.cc @@ -211,8 +211,7 @@ ChannelArgs XdsHttpStatefulSessionFilter::ModifyChannelArgs( absl::StatusOr XdsHttpStatefulSessionFilter::GenerateServiceConfig( const FilterConfig& hcm_filter_config, - const FilterConfig* filter_config_override, - absl::string_view /*filter_name*/) const { + const FilterConfig* filter_config_override) const { const Json& config = filter_config_override != nullptr ? filter_config_override->config : hcm_filter_config.config; diff --git a/src/core/ext/xds/xds_http_stateful_session_filter.h b/src/core/ext/xds/xds_http_stateful_session_filter.h index 71a2fab20a2d1..4fe68e57bc8c9 100644 --- a/src/core/ext/xds/xds_http_stateful_session_filter.h +++ b/src/core/ext/xds/xds_http_stateful_session_filter.h @@ -48,8 +48,7 @@ class XdsHttpStatefulSessionFilter : public XdsHttpFilterImpl { ChannelArgs ModifyChannelArgs(const ChannelArgs& args) const override; absl::StatusOr GenerateServiceConfig( const FilterConfig& hcm_filter_config, - const FilterConfig* filter_config_override, - absl::string_view filter_name) const override; + const FilterConfig* filter_config_override) const override; bool IsSupportedOnClients() const override { return true; } bool IsSupportedOnServers() const override { return false; } }; diff --git a/src/core/ext/xds/xds_routing.cc b/src/core/ext/xds/xds_routing.cc index 5d56b2bf93487..e59d6b9d50ebe 100644 --- a/src/core/ext/xds/xds_routing.cc +++ b/src/core/ext/xds/xds_routing.cc @@ -248,8 +248,8 @@ XdsRouting::GeneratePerHTTPFilterConfigs( FindFilterConfigOverride(http_filter.name, vhost, route, cluster_weight); // Generate service config for filter. - auto method_config_field = filter_impl->GenerateServiceConfig( - http_filter.config, config_override, http_filter.name); + auto method_config_field = + filter_impl->GenerateServiceConfig(http_filter.config, config_override); if (!method_config_field.ok()) { return absl::FailedPreconditionError(absl::StrCat( "failed to generate method config for HTTP filter ", http_filter.name, diff --git a/src/core/ext/xds/xds_transport_grpc.cc b/src/core/ext/xds/xds_transport_grpc.cc index 9c0cc48cf138c..1a012416106e8 100644 --- a/src/core/ext/xds/xds_transport_grpc.cc +++ b/src/core/ext/xds/xds_transport_grpc.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/lib/address_utils/sockaddr_utils.h b/src/core/lib/address_utils/sockaddr_utils.h index 871dfedfc64fd..32c72bd525fef 100644 --- a/src/core/lib/address_utils/sockaddr_utils.h +++ b/src/core/lib/address_utils/sockaddr_utils.h @@ -67,8 +67,8 @@ int grpc_sockaddr_set_port(grpc_resolved_address* addr, int port); // Currently, only the AF_INET, AF_INET6, and AF_UNIX families are recognized. // If the normalize flag is enabled, ::ffff:0.0.0.0/96 IPv6 addresses are // displayed as plain IPv4. -absl::StatusOr grpc_sockaddr_to_string( - const grpc_resolved_address* addr, bool normalize) GRPC_MUST_USE_RESULT; +GRPC_MUST_USE_RESULT absl::StatusOr grpc_sockaddr_to_string( + const grpc_resolved_address* addr, bool normalize); // Returns the URI string corresponding to \a addr absl::StatusOr grpc_sockaddr_to_uri( diff --git a/src/core/lib/avl/avl.h b/src/core/lib/avl/avl.h index 9ce529689cb2b..269bdb85c7087 100644 --- a/src/core/lib/avl/avl.h +++ b/src/core/lib/avl/avl.h @@ -20,10 +20,11 @@ #include #include // IWYU pragma: keep -#include #include #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" namespace grpc_core { @@ -42,12 +43,12 @@ class AVL { template const V* Lookup(const SomethingLikeK& key) const { NodePtr n = Get(root_, key); - return n ? &n->kv.second : nullptr; + return n != nullptr ? &n->kv.second : nullptr; } const std::pair* LookupBelow(const K& key) const { NodePtr n = GetBelow(root_, *key); - return n ? &n->kv : nullptr; + return n != nullptr ? &n->kv : nullptr; } bool Empty() const { return root_ == nullptr; } @@ -95,8 +96,8 @@ class AVL { private: struct Node; - typedef std::shared_ptr NodePtr; - struct Node : public std::enable_shared_from_this { + typedef RefCountedPtr NodePtr; + struct Node : public RefCounted { Node(K k, V v, NodePtr l, NodePtr r, long h) : kv(std::move(k), std::move(v)), left(std::move(l)), @@ -167,12 +168,12 @@ class AVL { ForEachImpl(n->right.get(), std::forward(f)); } - static long Height(const NodePtr& n) { return n ? n->height : 0; } + static long Height(const NodePtr& n) { return n != nullptr ? n->height : 0; } static NodePtr MakeNode(K key, V value, const NodePtr& left, const NodePtr& right) { - return std::make_shared(std::move(key), std::move(value), left, right, - 1 + std::max(Height(left), Height(right))); + return MakeRefCounted(std::move(key), std::move(value), left, right, + 1 + std::max(Height(left), Height(right))); } template @@ -259,7 +260,7 @@ class AVL { } static NodePtr AddKey(const NodePtr& node, K key, V value) { - if (!node) { + if (node == nullptr) { return MakeNode(std::move(key), std::move(value), nullptr, nullptr); } if (node->kv.first < key) { @@ -318,170 +319,6 @@ class AVL { } }; -template -class AVL { - public: - AVL() {} - - AVL Add(K key) const { return AVL(AddKey(root_, std::move(key))); } - AVL Remove(const K& key) const { return AVL(RemoveKey(root_, key)); } - bool Lookup(const K& key) const { return Get(root_, key) != nullptr; } - bool Empty() const { return root_ == nullptr; } - - template - void ForEach(F&& f) const { - ForEachImpl(root_.get(), std::forward(f)); - } - - bool SameIdentity(AVL avl) const { return root_ == avl.root_; } - - private: - struct Node; - - typedef std::shared_ptr NodePtr; - struct Node : public std::enable_shared_from_this { - Node(K k, NodePtr l, NodePtr r, long h) - : key(std::move(k)), - left(std::move(l)), - right(std::move(r)), - height(h) {} - const K key; - const NodePtr left; - const NodePtr right; - const long height; - }; - NodePtr root_; - - explicit AVL(NodePtr root) : root_(std::move(root)) {} - - template - static void ForEachImpl(const Node* n, F&& f) { - if (n == nullptr) return; - ForEachImpl(n->left.get(), std::forward(f)); - f(const_cast(n->key)); - ForEachImpl(n->right.get(), std::forward(f)); - } - - static long Height(const NodePtr& n) { return n ? n->height : 0; } - - static NodePtr MakeNode(K key, const NodePtr& left, const NodePtr& right) { - return std::make_shared(std::move(key), left, right, - 1 + std::max(Height(left), Height(right))); - } - - static NodePtr Get(const NodePtr& node, const K& key) { - if (node == nullptr) { - return nullptr; - } - - if (node->key > key) { - return Get(node->left, key); - } else if (node->key < key) { - return Get(node->right, key); - } else { - return node; - } - } - - static NodePtr RotateLeft(K key, const NodePtr& left, const NodePtr& right) { - return MakeNode(right->key, MakeNode(std::move(key), left, right->left), - right->right); - } - - static NodePtr RotateRight(K key, const NodePtr& left, const NodePtr& right) { - return MakeNode(left->key, left->left, - MakeNode(std::move(key), left->right, right)); - } - - static NodePtr RotateLeftRight(K key, const NodePtr& left, - const NodePtr& right) { - // rotate_right(..., rotate_left(left), right) - return MakeNode(left->right->key, - MakeNode(left->key, left->left, left->right->left), - MakeNode(std::move(key), left->right->right, right)); - } - - static NodePtr RotateRightLeft(K key, const NodePtr& left, - const NodePtr& right) { - // rotate_left(..., left, rotate_right(right)) - return MakeNode(right->left->key, - MakeNode(std::move(key), left, right->left->left), - MakeNode(right->key, right->left->right, right->right)); - } - - static NodePtr Rebalance(K key, const NodePtr& left, const NodePtr& right) { - switch (Height(left) - Height(right)) { - case 2: - if (Height(left->left) - Height(left->right) == -1) { - return RotateLeftRight(std::move(key), left, right); - } else { - return RotateRight(std::move(key), left, right); - } - case -2: - if (Height(right->left) - Height(right->right) == 1) { - return RotateRightLeft(std::move(key), left, right); - } else { - return RotateLeft(std::move(key), left, right); - } - default: - return MakeNode(key, left, right); - } - } - - static NodePtr AddKey(const NodePtr& node, K key) { - if (!node) { - return MakeNode(std::move(key), nullptr, nullptr); - } - if (node->key < key) { - return Rebalance(node->key, node->left, - AddKey(node->right, std::move(key))); - } - if (key < node->key) { - return Rebalance(node->key, AddKey(node->left, std::move(key)), - node->right); - } - return MakeNode(std::move(key), node->left, node->right); - } - - static NodePtr InOrderHead(NodePtr node) { - while (node->left != nullptr) { - node = node->left; - } - return node; - } - - static NodePtr InOrderTail(NodePtr node) { - while (node->right != nullptr) { - node = node->right; - } - return node; - } - - static NodePtr RemoveKey(const NodePtr& node, const K& key) { - if (node == nullptr) { - return nullptr; - } - if (key < node->key) { - return Rebalance(node->key, RemoveKey(node->left, key), node->right); - } else if (node->key < key) { - return Rebalance(node->key, node->left, RemoveKey(node->right, key)); - } else { - if (node->left == nullptr) { - return node->right; - } else if (node->right == nullptr) { - return node->left; - } else if (node->left->height < node->right->height) { - NodePtr h = InOrderHead(node->right); - return Rebalance(h->key, node->left, RemoveKey(node->right, h->key)); - } else { - NodePtr h = InOrderTail(node->left); - return Rebalance(h->key, RemoveKey(node->left, h->key), node->right); - } - } - abort(); - } -}; - } // namespace grpc_core #endif // GRPC_SRC_CORE_LIB_AVL_AVL_H diff --git a/src/core/lib/channel/call_tracer.cc b/src/core/lib/channel/call_tracer.cc index e6dd42e57ed03..ae1e477b5f11b 100644 --- a/src/core/lib/channel/call_tracer.cc +++ b/src/core/lib/channel/call_tracer.cc @@ -20,6 +20,14 @@ #include "src/core/lib/channel/call_tracer.h" +#include +#include +#include + +#include + +#include "src/core/lib/promise/context.h" + namespace grpc_core { // @@ -27,6 +35,7 @@ namespace grpc_core { // namespace { + ServerCallTracerFactory* g_server_call_tracer_factory_ = nullptr; const char* kServerCallTracerFactoryChannelArgName = @@ -48,4 +57,284 @@ absl::string_view ServerCallTracerFactory::ChannelArgName() { return kServerCallTracerFactoryChannelArgName; } +class DelegatingClientCallTracer : public ClientCallTracer { + public: + class DelegatingClientCallAttemptTracer + : public ClientCallTracer::CallAttemptTracer { + public: + explicit DelegatingClientCallAttemptTracer( + std::vector tracers) + : tracers_(std::move(tracers)) { + GPR_DEBUG_ASSERT(!tracers_.empty()); + } + ~DelegatingClientCallAttemptTracer() override {} + void RecordSendInitialMetadata( + grpc_metadata_batch* send_initial_metadata) override { + for (auto* tracer : tracers_) { + tracer->RecordSendInitialMetadata(send_initial_metadata); + } + } + void RecordSendTrailingMetadata( + grpc_metadata_batch* send_trailing_metadata) override { + for (auto* tracer : tracers_) { + tracer->RecordSendTrailingMetadata(send_trailing_metadata); + } + } + void RecordSendMessage(const SliceBuffer& send_message) override { + for (auto* tracer : tracers_) { + tracer->RecordSendMessage(send_message); + } + } + void RecordSendCompressedMessage( + const SliceBuffer& send_compressed_message) override { + for (auto* tracer : tracers_) { + tracer->RecordSendCompressedMessage(send_compressed_message); + } + } + void RecordReceivedInitialMetadata( + grpc_metadata_batch* recv_initial_metadata) override { + for (auto* tracer : tracers_) { + tracer->RecordReceivedInitialMetadata(recv_initial_metadata); + } + } + void RecordReceivedMessage(const SliceBuffer& recv_message) override { + for (auto* tracer : tracers_) { + tracer->RecordReceivedMessage(recv_message); + } + } + void RecordReceivedDecompressedMessage( + const SliceBuffer& recv_decompressed_message) override { + for (auto* tracer : tracers_) { + tracer->RecordReceivedDecompressedMessage(recv_decompressed_message); + } + } + void RecordCancel(grpc_error_handle cancel_error) override { + for (auto* tracer : tracers_) { + tracer->RecordCancel(cancel_error); + } + } + void RecordReceivedTrailingMetadata( + absl::Status status, grpc_metadata_batch* recv_trailing_metadata, + const grpc_transport_stream_stats* transport_stream_stats) override { + for (auto* tracer : tracers_) { + tracer->RecordReceivedTrailingMetadata(status, recv_trailing_metadata, + transport_stream_stats); + } + } + void RecordEnd(const gpr_timespec& latency) override { + for (auto* tracer : tracers_) { + tracer->RecordEnd(latency); + } + } + void RecordAnnotation(absl::string_view annotation) override { + for (auto* tracer : tracers_) { + tracer->RecordAnnotation(annotation); + } + } + void RecordAnnotation(const Annotation& annotation) override { + for (auto* tracer : tracers_) { + tracer->RecordAnnotation(annotation); + } + } + std::string TraceId() override { return tracers_[0]->TraceId(); } + std::string SpanId() override { return tracers_[0]->SpanId(); } + bool IsSampled() override { return tracers_[0]->IsSampled(); } + bool IsDelegatingTracer() override { return true; } + + private: + // There is no additional synchronization needed since filters/interceptors + // will be adding call tracers to the context and these are already + // synchronized through promises/call combiners (single promise running per + // call at any moment). + std::vector tracers_; + }; + explicit DelegatingClientCallTracer(ClientCallTracer* tracer) + : tracers_{tracer} {} + ~DelegatingClientCallTracer() override {} + CallAttemptTracer* StartNewAttempt(bool is_transparent_retry) override { + std::vector attempt_tracers; + attempt_tracers.reserve(tracers_.size()); + for (auto* tracer : tracers_) { + auto* attempt_tracer = tracer->StartNewAttempt(is_transparent_retry); + GPR_DEBUG_ASSERT(attempt_tracer != nullptr); + attempt_tracers.push_back(attempt_tracer); + } + return GetContext()->ManagedNew( + std::move(attempt_tracers)); + } + + void RecordAnnotation(absl::string_view annotation) override { + for (auto* tracer : tracers_) { + tracer->RecordAnnotation(annotation); + } + } + void RecordAnnotation(const Annotation& annotation) override { + for (auto* tracer : tracers_) { + tracer->RecordAnnotation(annotation); + } + } + std::string TraceId() override { return tracers_[0]->TraceId(); } + std::string SpanId() override { return tracers_[0]->SpanId(); } + bool IsSampled() override { return tracers_[0]->IsSampled(); } + bool IsDelegatingTracer() override { return true; } + + // There is no additional synchronization needed since filters/interceptors + // will be adding call tracers to the context and these are already + // synchronized through promises/call combiners (single promise running per + // call at any moment). + void AddTracer(ClientCallTracer* tracer) { tracers_.push_back(tracer); } + + private: + std::vector tracers_; +}; + +class DelegatingServerCallTracer : public ServerCallTracer { + public: + explicit DelegatingServerCallTracer(ServerCallTracer* tracer) + : tracers_{tracer} {} + ~DelegatingServerCallTracer() override {} + void RecordSendInitialMetadata( + grpc_metadata_batch* send_initial_metadata) override { + for (auto* tracer : tracers_) { + tracer->RecordSendInitialMetadata(send_initial_metadata); + } + } + void RecordSendTrailingMetadata( + grpc_metadata_batch* send_trailing_metadata) override { + for (auto* tracer : tracers_) { + tracer->RecordSendTrailingMetadata(send_trailing_metadata); + } + } + void RecordSendMessage(const SliceBuffer& send_message) override { + for (auto* tracer : tracers_) { + tracer->RecordSendMessage(send_message); + } + } + void RecordSendCompressedMessage( + const SliceBuffer& send_compressed_message) override { + for (auto* tracer : tracers_) { + tracer->RecordSendCompressedMessage(send_compressed_message); + } + } + void RecordReceivedInitialMetadata( + grpc_metadata_batch* recv_initial_metadata) override { + for (auto* tracer : tracers_) { + tracer->RecordReceivedInitialMetadata(recv_initial_metadata); + } + } + void RecordReceivedMessage(const SliceBuffer& recv_message) override { + for (auto* tracer : tracers_) { + tracer->RecordReceivedMessage(recv_message); + } + } + void RecordReceivedDecompressedMessage( + const SliceBuffer& recv_decompressed_message) override { + for (auto* tracer : tracers_) { + tracer->RecordReceivedDecompressedMessage(recv_decompressed_message); + } + } + void RecordCancel(grpc_error_handle cancel_error) override { + for (auto* tracer : tracers_) { + tracer->RecordCancel(cancel_error); + } + } + void RecordReceivedTrailingMetadata( + grpc_metadata_batch* recv_trailing_metadata) override { + for (auto* tracer : tracers_) { + tracer->RecordReceivedTrailingMetadata(recv_trailing_metadata); + } + } + void RecordEnd(const grpc_call_final_info* final_info) override { + for (auto* tracer : tracers_) { + tracer->RecordEnd(final_info); + } + } + void RecordAnnotation(absl::string_view annotation) override { + for (auto* tracer : tracers_) { + tracer->RecordAnnotation(annotation); + } + } + void RecordAnnotation(const Annotation& annotation) override { + for (auto* tracer : tracers_) { + tracer->RecordAnnotation(annotation); + } + } + std::string TraceId() override { return tracers_[0]->TraceId(); } + std::string SpanId() override { return tracers_[0]->SpanId(); } + bool IsSampled() override { return tracers_[0]->IsSampled(); } + bool IsDelegatingTracer() override { return true; } + + void AddTracer(ServerCallTracer* tracer) { tracers_.push_back(tracer); } + + private: + // The ServerCallTracerFilter will be responsible for making sure that the + // tracers are added in a thread-safe manner. It is imagined that the filter + // will just invoke the factories in the server call tracer factory list + // sequentially, removing the need for any synchronization. + std::vector tracers_; +}; + +void AddClientCallTracerToContext(grpc_call_context_element* call_context, + ClientCallTracer* tracer) { + if (call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value == + nullptr) { + // This is the first call tracer. Set it directly. + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value = tracer; + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].destroy = + nullptr; + } else { + // There was already a call tracer present. + auto* orig_tracer = static_cast( + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value); + if (orig_tracer->IsDelegatingTracer()) { + // We already created a delegating tracer. Just add the new tracer to the + // list. + static_cast(orig_tracer)->AddTracer(tracer); + } else { + // Create a new delegating tracer and add the first tracer and the new + // tracer to the list. + auto* delegating_tracer = + GetContext()->ManagedNew( + orig_tracer); + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value = + delegating_tracer; + delegating_tracer->AddTracer(tracer); + } + } +} + +void AddServerCallTracerToContext(grpc_call_context_element* call_context, + ServerCallTracer* tracer) { + GPR_DEBUG_ASSERT( + call_context[GRPC_CONTEXT_CALL_TRACER].value == + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value); + if (call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value == + nullptr) { + // This is the first call tracer. Set it directly. + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value = tracer; + call_context[GRPC_CONTEXT_CALL_TRACER].value = tracer; + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].destroy = + nullptr; + } else { + // There was already a call tracer present. + auto* orig_tracer = static_cast( + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value); + if (orig_tracer->IsDelegatingTracer()) { + // We already created a delegating tracer. Just add the new tracer to the + // list. + static_cast(orig_tracer)->AddTracer(tracer); + } else { + // Create a new delegating tracer and add the first tracer and the new + // tracer to the list. + auto* delegating_tracer = + GetContext()->ManagedNew( + orig_tracer); + call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value = + delegating_tracer; + call_context[GRPC_CONTEXT_CALL_TRACER].value = delegating_tracer; + delegating_tracer->AddTracer(tracer); + } + } +} + } // namespace grpc_core diff --git a/src/core/lib/channel/call_tracer.h b/src/core/lib/channel/call_tracer.h index 3b2a94faaf449..9fb10e67711de 100644 --- a/src/core/lib/channel/call_tracer.h +++ b/src/core/lib/channel/call_tracer.h @@ -30,6 +30,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/context.h" #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/resource_quota/arena.h" @@ -49,14 +50,37 @@ namespace grpc_core { // The base class for all tracer implementations. class CallTracerAnnotationInterface { public: + // Enum associated with types of Annotations. + enum class AnnotationType { + kMetadataSizes, + kDoNotUse_MustBeLast, + }; + + // Base class to define a new type of annotation. + class Annotation { + public: + explicit Annotation(AnnotationType type) : type_(type) {} + AnnotationType type() const { return type_; } + virtual std::string ToString() const = 0; + virtual ~Annotation() = default; + + private: + const AnnotationType type_; + }; + virtual ~CallTracerAnnotationInterface() {} // Records an annotation on the call attempt. // TODO(yashykt): If needed, extend this to attach attributes with // annotations. virtual void RecordAnnotation(absl::string_view annotation) = 0; + virtual void RecordAnnotation(const Annotation& annotation) = 0; virtual std::string TraceId() = 0; virtual std::string SpanId() = 0; virtual bool IsSampled() = 0; + // Indicates whether this tracer is a delegating tracer or not. + // `DelegatingClientCallTracer`, `DelegatingClientCallAttemptTracer` and + // `DelegatingServerCallTracer` are the only delegating call tracers. + virtual bool IsDelegatingTracer() { return false; } }; // The base class for CallAttemptTracer and ServerCallTracer. @@ -161,6 +185,17 @@ class ServerCallTracerFactory { void RegisterServerCallTracerFilter(CoreConfiguration::Builder* builder); +// Convenience functions to add call tracers to a call context. Allows setting +// multiple call tracers to a single call. It is only valid to add client call +// tracers before the client_channel filter sees the send_initial_metadata op. +void AddClientCallTracerToContext(grpc_call_context_element* call_context, + ClientCallTracer* tracer); + +// TODO(yashykt): We want server call tracers to be registered through the +// ServerCallTracerFactory, which has yet to be made into a list. +void AddServerCallTracerToContext(grpc_call_context_element* call_context, + ServerCallTracer* tracer); + } // namespace grpc_core #endif // GRPC_SRC_CORE_LIB_CHANNEL_CALL_TRACER_H diff --git a/src/core/lib/channel/channel_args.cc b/src/core/lib/channel/channel_args.cc index 52bcb1d087e30..4496abad4b985 100644 --- a/src/core/lib/channel/channel_args.cc +++ b/src/core/lib/channel/channel_args.cc @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include #include #include "absl/strings/match.h" @@ -34,16 +37,53 @@ #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" +#include #include #include #include #include "src/core/lib/gpr/useful.h" -#include "src/core/lib/gprpp/crash.h" -#include "src/core/lib/gprpp/match.h" namespace grpc_core { +RefCountedPtr RcString::Make(absl::string_view src) { + void* p = gpr_malloc(sizeof(Header) + src.length() + 1); + return RefCountedPtr(new (p) RcString(src)); +} + +RcString::RcString(absl::string_view src) : header_{{}, src.length()} { + memcpy(payload_, src.data(), header_.length); + // Null terminate because we frequently need to convert to char* still to go + // back and forth to the old c-style api. + payload_[header_.length] = 0; +} + +void RcString::Destroy() { gpr_free(this); } + +const grpc_arg_pointer_vtable ChannelArgs::Value::int_vtable_{ + // copy + [](void* p) { return p; }, + // destroy + [](void*) {}, + // cmp + [](void* p1, void* p2) -> int { + return QsortCompare(reinterpret_cast(p1), + reinterpret_cast(p2)); + }, +}; + +const grpc_arg_pointer_vtable ChannelArgs::Value::string_vtable_{ + // copy + [](void* p) -> void* { return static_cast(p)->Ref().release(); }, + // destroy + [](void* p) { static_cast(p)->Unref(); }, + // cmp + [](void* p1, void* p2) -> int { + return QsortCompare(static_cast(p1)->as_string_view(), + static_cast(p2)->as_string_view()); + }, +}; + ChannelArgs::Pointer::Pointer(void* p, const grpc_arg_pointer_vtable* vtable) : p_(p), vtable_(vtable == nullptr ? EmptyVTable() : vtable) {} @@ -99,7 +139,7 @@ bool ChannelArgs::WantMinimalStack() const { return GetBool(GRPC_ARG_MINIMAL_STACK).value_or(false); } -ChannelArgs::ChannelArgs(AVL args) +ChannelArgs::ChannelArgs(AVL args) : args_(std::move(args)) {} ChannelArgs ChannelArgs::Set(grpc_arg arg) const { @@ -129,52 +169,22 @@ ChannelArgs ChannelArgs::FromC(const grpc_channel_args* args) { grpc_arg ChannelArgs::Value::MakeCArg(const char* name) const { char* c_name = const_cast(name); - return Match( - rep_, - [c_name](int i) { return grpc_channel_arg_integer_create(c_name, i); }, - [c_name](const std::shared_ptr& s) { - return grpc_channel_arg_string_create(c_name, - const_cast(s->c_str())); - }, - [c_name](const Pointer& p) { - return grpc_channel_arg_pointer_create(c_name, p.c_pointer(), - p.c_vtable()); - }); -} - -bool ChannelArgs::Value::operator<(const Value& rhs) const { - if (rhs.rep_.index() != rep_.index()) return rep_.index() < rhs.rep_.index(); - switch (rep_.index()) { - case 0: - return absl::get(rep_) < absl::get(rhs.rep_); - case 1: - return *absl::get>(rep_) < - *absl::get>(rhs.rep_); - case 2: - return absl::get(rep_) < absl::get(rhs.rep_); - default: - Crash("unreachable"); + if (rep_.c_vtable() == &int_vtable_) { + return grpc_channel_arg_integer_create( + c_name, reinterpret_cast(rep_.c_pointer())); } -} - -bool ChannelArgs::Value::operator==(const Value& rhs) const { - if (rhs.rep_.index() != rep_.index()) return false; - switch (rep_.index()) { - case 0: - return absl::get(rep_) == absl::get(rhs.rep_); - case 1: - return *absl::get>(rep_) == - *absl::get>(rhs.rep_); - case 2: - return absl::get(rep_) == absl::get(rhs.rep_); - default: - Crash("unreachable"); + if (rep_.c_vtable() == &string_vtable_) { + return grpc_channel_arg_string_create( + c_name, + const_cast(static_cast(rep_.c_pointer())->c_str())); } + return grpc_channel_arg_pointer_create(c_name, rep_.c_pointer(), + rep_.c_vtable()); } ChannelArgs::CPtr ChannelArgs::ToC() const { std::vector c_args; - args_.ForEach([&c_args](const std::string& key, const Value& value) { + args_.ForEach([&c_args](const RcStringValue& key, const Value& value) { c_args.push_back(value.MakeCArg(key.c_str())); }); return CPtr(static_cast( @@ -189,44 +199,44 @@ ChannelArgs ChannelArgs::Set(absl::string_view name, int value) const { return Set(name, Value(value)); } -ChannelArgs ChannelArgs::Set(absl::string_view key, Value value) const { - return ChannelArgs(args_.Add(std::string(key), std::move(value))); +ChannelArgs ChannelArgs::Set(absl::string_view name, Value value) const { + if (const auto* p = args_.Lookup(name)) { + if (*p == value) return *this; // already have this value for this key + } + return ChannelArgs(args_.Add(RcStringValue(name), std::move(value))); } -ChannelArgs ChannelArgs::Set(absl::string_view key, +ChannelArgs ChannelArgs::Set(absl::string_view name, absl::string_view value) const { - return Set(key, std::string(value)); + return Set(name, std::string(value)); } -ChannelArgs ChannelArgs::Set(absl::string_view key, const char* value) const { - return Set(key, std::string(value)); +ChannelArgs ChannelArgs::Set(absl::string_view name, const char* value) const { + return Set(name, std::string(value)); } -ChannelArgs ChannelArgs::Set(absl::string_view key, std::string value) const { - return Set(key, Value(std::move(value))); +ChannelArgs ChannelArgs::Set(absl::string_view name, std::string value) const { + return Set(name, Value(std::move(value))); } -ChannelArgs ChannelArgs::Remove(absl::string_view key) const { - return ChannelArgs(args_.Remove(key)); +ChannelArgs ChannelArgs::Remove(absl::string_view name) const { + if (args_.Lookup(name) == nullptr) return *this; + return ChannelArgs(args_.Remove(name)); } ChannelArgs ChannelArgs::RemoveAllKeysWithPrefix( absl::string_view prefix) const { - ChannelArgs result; - args_.ForEach([&](const std::string& key, const Value& value) { - if (!absl::StartsWith(key, prefix)) { - result.args_ = result.args_.Add(key, value); - } + auto args = args_; + args_.ForEach([&](const RcStringValue& key, const Value&) { + if (absl::StartsWith(key.as_string_view(), prefix)) args = args.Remove(key); }); - return result; + return ChannelArgs(std::move(args)); } absl::optional ChannelArgs::GetInt(absl::string_view name) const { auto* v = Get(name); if (v == nullptr) return absl::nullopt; - const auto* i = v->GetIfInt(); - if (i == nullptr) return absl::nullopt; - return *i; + return v->GetIfInt(); } absl::optional ChannelArgs::GetDurationFromIntMillis( @@ -242,9 +252,9 @@ absl::optional ChannelArgs::GetString( absl::string_view name) const { auto* v = Get(name); if (v == nullptr) return absl::nullopt; - const auto* s = v->GetIfString(); + const auto s = v->GetIfString(); if (s == nullptr) return absl::nullopt; - return *s; + return s->as_string_view(); } absl::optional ChannelArgs::GetOwnedString( @@ -265,8 +275,8 @@ void* ChannelArgs::GetVoidPointer(absl::string_view name) const { absl::optional ChannelArgs::GetBool(absl::string_view name) const { auto* v = Get(name); if (v == nullptr) return absl::nullopt; - auto* i = v->GetIfInt(); - if (i == nullptr) { + auto i = v->GetIfInt(); + if (!i.has_value()) { gpr_log(GPR_ERROR, "%s ignored: it must be an integer", std::string(name).c_str()); return absl::nullopt; @@ -283,18 +293,22 @@ absl::optional ChannelArgs::GetBool(absl::string_view name) const { } } +std::string ChannelArgs::Value::ToString() const { + if (rep_.c_vtable() == &int_vtable_) { + return std::to_string(reinterpret_cast(rep_.c_pointer())); + } + if (rep_.c_vtable() == &string_vtable_) { + return std::string( + static_cast(rep_.c_pointer())->as_string_view()); + } + return absl::StrFormat("%p", rep_.c_pointer()); +} + std::string ChannelArgs::ToString() const { std::vector arg_strings; - args_.ForEach([&arg_strings](const std::string& key, const Value& value) { - std::string value_str; - if (auto* i = value.GetIfInt()) { - value_str = std::to_string(*i); - } else if (auto* s = value.GetIfString()) { - value_str = *s; - } else if (auto* p = value.GetIfPointer()) { - value_str = absl::StrFormat("%p", p->c_pointer()); - } - arg_strings.push_back(absl::StrCat(key, "=", value_str)); + args_.ForEach([&arg_strings](const RcStringValue& key, const Value& value) { + arg_strings.push_back( + absl::StrCat(key.as_string_view(), "=", value.ToString())); }); return absl::StrCat("{", absl::StrJoin(arg_strings, ", "), "}"); } @@ -303,24 +317,25 @@ ChannelArgs ChannelArgs::UnionWith(ChannelArgs other) const { if (args_.Empty()) return other; if (other.args_.Empty()) return *this; if (args_.Height() <= other.args_.Height()) { - args_.ForEach([&other](const std::string& key, const Value& value) { + args_.ForEach([&other](const RcStringValue& key, const Value& value) { other.args_ = other.args_.Add(key, value); }); return other; } else { auto result = *this; - other.args_.ForEach([&result](const std::string& key, const Value& value) { - if (result.args_.Lookup(key) == nullptr) { - result.args_ = result.args_.Add(key, value); - } - }); + other.args_.ForEach( + [&result](const RcStringValue& key, const Value& value) { + if (result.args_.Lookup(key) == nullptr) { + result.args_ = result.args_.Add(key, value); + } + }); return result; } } ChannelArgs ChannelArgs::FuzzingReferenceUnionWith(ChannelArgs other) const { // DO NOT OPTIMIZE THIS!! - args_.ForEach([&other](const std::string& key, const Value& value) { + args_.ForEach([&other](const RcStringValue& key, const Value& value) { other.args_ = other.args_.Add(key, value); }); return other; diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h index 57d6f35e33534..676ca6066f8b0 100644 --- a/src/core/lib/channel/channel_args.h +++ b/src/core/lib/channel/channel_args.h @@ -22,6 +22,7 @@ #include #include +#include #include // IWYU pragma: keep #include @@ -33,7 +34,6 @@ #include "absl/meta/type_traits.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "absl/types/variant.h" #include #include @@ -220,6 +220,91 @@ struct GetObjectImpl::value, void>> { }; }; +// Immutable reference counted string +class RcString { + public: + static RefCountedPtr Make(absl::string_view src); + + RefCountedPtr Ref() { + IncrementRefCount(); + return RefCountedPtr(this); + } + void IncrementRefCount() { header_.rc.Ref(); } + void Unref() { + if (header_.rc.Unref()) Destroy(); + } + + absl::string_view as_string_view() const { + return absl::string_view(payload_, header_.length); + } + + char* c_str() { return payload_; } + + private: + explicit RcString(absl::string_view src); + void Destroy(); + + struct Header { + RefCount rc; + size_t length; + }; + Header header_; + char payload_[]; +}; + +// Wrapper around RefCountedPtr to give value semantics, especially to +// overloaded operators. +class RcStringValue { + public: + RcStringValue() : str_{} {} + explicit RcStringValue(absl::string_view str) : str_(RcString::Make(str)) {} + + absl::string_view as_string_view() const { + return str_ == nullptr ? absl::string_view() : str_->as_string_view(); + } + + const char* c_str() const { return str_ == nullptr ? "" : str_->c_str(); } + + private: + RefCountedPtr str_; +}; + +inline bool operator==(const RcStringValue& lhs, absl::string_view rhs) { + return lhs.as_string_view() == rhs; +} + +inline bool operator==(absl::string_view lhs, const RcStringValue& rhs) { + return lhs == rhs.as_string_view(); +} + +inline bool operator==(const RcStringValue& lhs, const RcStringValue& rhs) { + return lhs.as_string_view() == rhs.as_string_view(); +} + +inline bool operator<(const RcStringValue& lhs, absl::string_view rhs) { + return lhs.as_string_view() < rhs; +} + +inline bool operator<(absl::string_view lhs, const RcStringValue& rhs) { + return lhs < rhs.as_string_view(); +} + +inline bool operator<(const RcStringValue& lhs, const RcStringValue& rhs) { + return lhs.as_string_view() < rhs.as_string_view(); +} + +inline bool operator>(const RcStringValue& lhs, absl::string_view rhs) { + return lhs.as_string_view() > rhs; +} + +inline bool operator>(absl::string_view lhs, const RcStringValue& rhs) { + return lhs > rhs.as_string_view(); +} + +inline bool operator>(const RcStringValue& lhs, const RcStringValue& rhs) { + return lhs.as_string_view() > rhs.as_string_view(); +} + // Provide the canonical name for a type's channel arg key template struct ChannelArgNameTraits { @@ -283,32 +368,43 @@ class ChannelArgs { class Value { public: - explicit Value(int n) : rep_(n) {} + explicit Value(int n) : rep_(reinterpret_cast(n), &int_vtable_) {} explicit Value(std::string s) - : rep_(std::make_shared(std::move(s))) {} + : rep_(RcString::Make(s).release(), &string_vtable_) {} explicit Value(Pointer p) : rep_(std::move(p)) {} - const int* GetIfInt() const { return absl::get_if(&rep_); } - const std::string* GetIfString() const { - auto* p = absl::get_if>(&rep_); - if (p == nullptr) return nullptr; - return p->get(); + absl::optional GetIfInt() const { + if (rep_.c_vtable() != &int_vtable_) return absl::nullopt; + return reinterpret_cast(rep_.c_pointer()); + } + RefCountedPtr GetIfString() const { + if (rep_.c_vtable() != &string_vtable_) return nullptr; + return static_cast(rep_.c_pointer())->Ref(); + } + const Pointer* GetIfPointer() const { + if (rep_.c_vtable() == &int_vtable_) return nullptr; + if (rep_.c_vtable() == &string_vtable_) return nullptr; + return &rep_; } - const Pointer* GetIfPointer() const { return absl::get_if(&rep_); } + + std::string ToString() const; grpc_arg MakeCArg(const char* name) const; - bool operator<(const Value& rhs) const; - bool operator==(const Value& rhs) const; + bool operator<(const Value& rhs) const { return rep_ < rhs.rep_; } + bool operator==(const Value& rhs) const { return rep_ == rhs.rep_; } bool operator!=(const Value& rhs) const { return !this->operator==(rhs); } bool operator==(absl::string_view rhs) const { - auto* p = absl::get_if>(&rep_); - if (p == nullptr) return false; - return **p == rhs; + auto str = GetIfString(); + if (str == nullptr) return false; + return str->as_string_view() == rhs; } private: - absl::variant, Pointer> rep_; + static const grpc_arg_pointer_vtable int_vtable_; + static const grpc_arg_pointer_vtable string_vtable_; + + Pointer rep_; }; struct ChannelArgsDeleter { @@ -462,12 +558,12 @@ class ChannelArgs { std::string ToString() const; private: - explicit ChannelArgs(AVL args); + explicit ChannelArgs(AVL args); GRPC_MUST_USE_RESULT ChannelArgs Set(absl::string_view name, Value value) const; - AVL args_; + AVL args_; }; std::ostream& operator<<(std::ostream& out, const ChannelArgs& args); diff --git a/src/core/lib/channel/connected_channel.cc b/src/core/lib/channel/connected_channel.cc index 44b1fdb97baf6..29f0924b665ef 100644 --- a/src/core/lib/channel/connected_channel.cc +++ b/src/core/lib/channel/connected_channel.cc @@ -39,6 +39,7 @@ #include #include +#include "src/core/lib/channel/call_finalization.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack.h" @@ -56,7 +57,6 @@ #include "src/core/lib/promise/activity.h" #include "src/core/lib/promise/arena_promise.h" #include "src/core/lib/promise/context.h" -#include "src/core/lib/promise/detail/basic_seq.h" #include "src/core/lib/promise/detail/status.h" #include "src/core/lib/promise/for_each.h" #include "src/core/lib/promise/if.h" @@ -597,7 +597,9 @@ ArenaPromise MakeServerCallPromise( bool sent_initial_metadata = false; bool sent_trailing_metadata = false; }; - auto* call_data = GetContext()->ManagedNew(); + auto* call_data = GetContext()->New(); + GetContext()->Add( + [call_data](const grpc_call_final_info*) { call_data->~CallData(); }); party->Spawn( "set_polling_entity", call_data->polling_entity_latch.Wait(), diff --git a/src/core/lib/channel/promise_based_filter.cc b/src/core/lib/channel/promise_based_filter.cc index 84c8f3da28c8f..f81bcc08ca218 100644 --- a/src/core/lib/channel/promise_based_filter.cc +++ b/src/core/lib/channel/promise_based_filter.cc @@ -38,7 +38,7 @@ #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/status_helper.h" #include "src/core/lib/iomgr/error.h" -#include "src/core/lib/promise/detail/basic_seq.h" +#include "src/core/lib/promise/seq.h" #include "src/core/lib/slice/slice.h" extern grpc_core::TraceFlag grpc_trace_channel; @@ -302,6 +302,9 @@ BaseCallData::Flusher::~Flusher() { gpr_log(GPR_INFO, "FLUSHER:forward batch: %s", grpc_transport_stream_op_batch_string(release_[0], false).c_str()); } + if (call_->call_context_ != nullptr && call_->call_context_->traced()) { + release_[0]->is_traced = true; + } grpc_call_next_op(call_->elem(), release_[0]); GRPC_CALL_STACK_UNREF(call_->call_stack(), "flusher"); } diff --git a/src/core/lib/channel/promise_based_filter.h b/src/core/lib/channel/promise_based_filter.h index fdacc6be0cce6..23181395da7b8 100644 --- a/src/core/lib/channel/promise_based_filter.h +++ b/src/core/lib/channel/promise_based_filter.h @@ -188,6 +188,7 @@ class BaseCallData : public Activity, private Wakeable { std::string ActivityDebugTag(WakeupMask) const override { return DebugTag(); } void Finalize(const grpc_call_final_info* final_info) { + ScopedContext ctx(this); finalization_.Run(final_info); } diff --git a/src/core/lib/compression/compression_internal.cc b/src/core/lib/compression/compression_internal.cc index 4871e46f70552..793e8969d872f 100644 --- a/src/core/lib/compression/compression_internal.cc +++ b/src/core/lib/compression/compression_internal.cc @@ -32,6 +32,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/crash.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/surface/api_trace.h" namespace grpc_core { @@ -227,11 +228,13 @@ absl::optional DefaultCompressionAlgorithmFromChannelArgs(const ChannelArgs& args) { auto* value = args.Get(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM); if (value == nullptr) return absl::nullopt; - if (auto* p = value->GetIfInt()) { - return static_cast(*p); + auto ival = value->GetIfInt(); + if (ival.has_value()) { + return static_cast(*ival); } - if (auto* p = value->GetIfString()) { - return ParseCompressionAlgorithm(*p); + auto sval = value->GetIfString(); + if (sval != nullptr) { + return ParseCompressionAlgorithm(sval->as_string_view()); } return absl::nullopt; } diff --git a/src/core/lib/event_engine/ares_resolver.cc b/src/core/lib/event_engine/ares_resolver.cc new file mode 100644 index 0000000000000..2f26a9fcf1cc0 --- /dev/null +++ b/src/core/lib/event_engine/ares_resolver.cc @@ -0,0 +1,712 @@ +// Copyright 2023 The 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/event_engine/ares_resolver.h" + +#include + +#include +#include + +#include "src/core/lib/iomgr/port.h" + +// IWYU pragma: no_include +// IWYU pragma: no_include +// IWYU pragma: no_include +// IWYU pragma: no_include +// IWYU pragma: no_include +// IWYU pragma: no_include +// IWYU pragma: no_include +// IWYU pragma: no_include + +#if GRPC_ARES == 1 + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "absl/functional/any_invocable.h" +#include "absl/hash/hash.h" +#include "absl/strings/match.h" +#include "absl/strings/numbers.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/types/optional.h" + +#include +#include + +#include "src/core/lib/address_utils/parse_address.h" +#include "src/core/lib/address_utils/sockaddr_utils.h" +#include "src/core/lib/event_engine/grpc_polled_fd.h" +#include "src/core/lib/event_engine/time_util.h" +#include "src/core/lib/gprpp/debug_location.h" +#include "src/core/lib/gprpp/host_port.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/iomgr/resolved_address.h" +#include "src/core/lib/iomgr/sockaddr.h" +#ifdef GRPC_POSIX_SOCKET_ARES_EV_DRIVER +#include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" +#endif + +namespace grpc_event_engine { +namespace experimental { + +grpc_core::TraceFlag grpc_trace_ares_resolver(false, "cares_resolver"); + +namespace { + +absl::Status AresStatusToAbslStatus(int status, absl::string_view error_msg) { + switch (status) { + case ARES_ECANCELLED: + return absl::CancelledError(error_msg); + case ARES_ENOTIMP: + return absl::UnimplementedError(error_msg); + case ARES_ENOTFOUND: + return absl::NotFoundError(error_msg); + default: + return absl::UnknownError(error_msg); + } +} + +// An alternative here could be to use ares_timeout to try to be more +// accurate, but that would require using "struct timeval"'s, which just +// makes things a bit more complicated. So just poll every second, as +// suggested by the c-ares code comments. +constexpr EventEngine::Duration kAresBackupPollAlarmDuration = + std::chrono::seconds(1); + +bool IsIpv6LoopbackAvailable() { +#ifdef GRPC_POSIX_SOCKET_ARES_EV_DRIVER + return PosixSocketWrapper::IsIpv6LoopbackAvailable(); +#elif defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER) + // TODO(yijiem): implement this for Windows + return true; +#else +#error "Unsupported platform" +#endif +} + +absl::Status SetRequestDNSServer(absl::string_view dns_server, + ares_channel* channel) { + GRPC_ARES_RESOLVER_TRACE_LOG("Using DNS server %s", dns_server.data()); + grpc_resolved_address addr; + struct ares_addr_port_node dns_server_addr = {}; + if (grpc_parse_ipv4_hostport(dns_server, &addr, /*log_errors=*/false)) { + dns_server_addr.family = AF_INET; + struct sockaddr_in* in = reinterpret_cast(addr.addr); + memcpy(&dns_server_addr.addr.addr4, &in->sin_addr, sizeof(struct in_addr)); + dns_server_addr.tcp_port = grpc_sockaddr_get_port(&addr); + dns_server_addr.udp_port = grpc_sockaddr_get_port(&addr); + } else if (grpc_parse_ipv6_hostport(dns_server, &addr, + /*log_errors=*/false)) { + dns_server_addr.family = AF_INET6; + struct sockaddr_in6* in6 = + reinterpret_cast(addr.addr); + memcpy(&dns_server_addr.addr.addr6, &in6->sin6_addr, + sizeof(struct in6_addr)); + dns_server_addr.tcp_port = grpc_sockaddr_get_port(&addr); + dns_server_addr.udp_port = grpc_sockaddr_get_port(&addr); + } else { + return absl::InvalidArgumentError( + absl::StrCat("Cannot parse authority: ", dns_server)); + } + int status = ares_set_servers_ports(*channel, &dns_server_addr); + if (status != ARES_SUCCESS) { + return AresStatusToAbslStatus(status, ares_strerror(status)); + } + return absl::OkStatus(); +} + +struct QueryArg { + QueryArg(AresResolver* ar, int id, absl::string_view name) + : ares_resolver(ar), callback_map_id(id), query_name(name) {} + AresResolver* ares_resolver; + int callback_map_id; + std::string query_name; +}; + +struct HostnameQueryArg : public QueryArg { + HostnameQueryArg(AresResolver* ar, int id, absl::string_view name, int p) + : QueryArg(ar, id, name), port(p) {} + int port; +}; + +} // namespace + +absl::StatusOr> +AresResolver::CreateAresResolver( + absl::string_view dns_server, + std::unique_ptr polled_fd_factory, + std::shared_ptr event_engine) { + ares_options opts = {}; + opts.flags |= ARES_FLAG_STAYOPEN; + if (g_event_engine_grpc_ares_test_only_force_tcp) { + opts.flags |= ARES_FLAG_USEVC; + } + ares_channel channel; + int status = ares_init_options(&channel, &opts, ARES_OPT_FLAGS); + if (status != ARES_SUCCESS) { + gpr_log(GPR_ERROR, "ares_init_options failed, status: %d", status); + return AresStatusToAbslStatus( + status, + absl::StrCat("Failed to init c-ares channel: ", ares_strerror(status))); + } + event_engine_grpc_ares_test_only_inject_config(&channel); + polled_fd_factory->ConfigureAresChannelLocked(channel); + if (!dns_server.empty()) { + absl::Status status = SetRequestDNSServer(dns_server, &channel); + if (!status.ok()) { + return status; + } + } + return grpc_core::MakeOrphanable( + std::move(polled_fd_factory), std::move(event_engine), channel); +} + +AresResolver::~AresResolver() { + GPR_ASSERT(fd_node_list_.empty()); + GPR_ASSERT(callback_map_.empty()); + ares_destroy(channel_); +} + +void AresResolver::Orphan() { + { + grpc_core::MutexLock lock(&mutex_); + shutting_down_ = true; + if (ares_backup_poll_alarm_handle_.has_value()) { + event_engine_->Cancel(*ares_backup_poll_alarm_handle_); + ares_backup_poll_alarm_handle_.reset(); + } + for (const auto& fd_node : fd_node_list_) { + if (!fd_node->already_shutdown) { + GRPC_ARES_RESOLVER_TRACE_LOG("resolver: %p shutdown fd: %s", this, + fd_node->polled_fd->GetName()); + fd_node->polled_fd->ShutdownLocked( + absl::CancelledError("AresResolver::Orphan")); + fd_node->already_shutdown = true; + } + } + } + Unref(DEBUG_LOCATION, "Orphan"); +} + +void AresResolver::LookupHostname( + absl::string_view name, absl::string_view default_port, + EventEngine::DNSResolver::LookupHostnameCallback callback) { + absl::string_view host; + absl::string_view port_string; + if (!grpc_core::SplitHostPort(name, &host, &port_string)) { + event_engine_->Run( + [callback = std::move(callback), + status = absl::InvalidArgumentError(absl::StrCat( + "Unparseable name: ", name))]() mutable { callback(status); }); + return; + } + GPR_ASSERT(!host.empty()); + if (port_string.empty()) { + if (default_port.empty()) { + event_engine_->Run([callback = std::move(callback), + status = absl::InvalidArgumentError(absl::StrFormat( + "No port in name %s or default_port argument", + name))]() mutable { callback(status); }); + return; + } + port_string = default_port; + } + int port = 0; + if (port_string == "http") { + port = 80; + } else if (port_string == "https") { + port = 443; + } else if (!absl::SimpleAtoi(port_string, &port)) { + event_engine_->Run([callback = std::move(callback), + status = absl::InvalidArgumentError(absl::StrCat( + "Failed to parse port in name: ", + name))]() mutable { callback(status); }); + return; + } + // TODO(yijiem): Change this when refactoring code in + // src/core/lib/address_utils to use EventEngine::ResolvedAddress. + grpc_resolved_address addr; + const std::string hostport = grpc_core::JoinHostPort(host, port); + if (grpc_parse_ipv4_hostport(hostport.c_str(), &addr, + false /* log errors */) || + grpc_parse_ipv6_hostport(hostport.c_str(), &addr, + false /* log errors */)) { + // Early out if the target is an ipv4 or ipv6 literal. + std::vector result; + result.emplace_back(reinterpret_cast(addr.addr), addr.len); + event_engine_->Run( + [callback = std::move(callback), result = std::move(result)]() mutable { + callback(std::move(result)); + }); + return; + } + grpc_core::MutexLock lock(&mutex_); + callback_map_.emplace(++id_, std::move(callback)); + auto* resolver_arg = new HostnameQueryArg(this, id_, name, port); + if (IsIpv6LoopbackAvailable()) { + ares_gethostbyname(channel_, std::string(host).c_str(), AF_UNSPEC, + &AresResolver::OnHostbynameDoneLocked, resolver_arg); + } else { + ares_gethostbyname(channel_, std::string(host).c_str(), AF_INET, + &AresResolver::OnHostbynameDoneLocked, resolver_arg); + } + CheckSocketsLocked(); + MaybeStartTimerLocked(); +} + +void AresResolver::LookupSRV( + absl::string_view name, + EventEngine::DNSResolver::LookupSRVCallback callback) { + absl::string_view host; + absl::string_view port; + if (!grpc_core::SplitHostPort(name, &host, &port)) { + event_engine_->Run( + [callback = std::move(callback), + status = absl::InvalidArgumentError(absl::StrCat( + "Unparseable name: ", name))]() mutable { callback(status); }); + return; + } + GPR_ASSERT(!host.empty()); + // Don't query for SRV records if the target is "localhost" + if (absl::EqualsIgnoreCase(host, "localhost")) { + event_engine_->Run([callback = std::move(callback)]() mutable { + callback(std::vector()); + }); + return; + } + grpc_core::MutexLock lock(&mutex_); + callback_map_.emplace(++id_, std::move(callback)); + auto* resolver_arg = new QueryArg(this, id_, host); + ares_query(channel_, std::string(host).c_str(), ns_c_in, ns_t_srv, + &AresResolver::OnSRVQueryDoneLocked, resolver_arg); + CheckSocketsLocked(); + MaybeStartTimerLocked(); +} + +void AresResolver::LookupTXT( + absl::string_view name, + EventEngine::DNSResolver::LookupTXTCallback callback) { + absl::string_view host; + absl::string_view port; + if (!grpc_core::SplitHostPort(name, &host, &port)) { + event_engine_->Run( + [callback = std::move(callback), + status = absl::InvalidArgumentError(absl::StrCat( + "Unparseable name: ", name))]() mutable { callback(status); }); + return; + } + GPR_ASSERT(!host.empty()); + // Don't query for TXT records if the target is "localhost" + if (absl::EqualsIgnoreCase(host, "localhost")) { + event_engine_->Run([callback = std::move(callback)]() mutable { + callback(std::vector()); + }); + return; + } + grpc_core::MutexLock lock(&mutex_); + callback_map_.emplace(++id_, std::move(callback)); + auto* resolver_arg = new QueryArg(this, id_, host); + ares_search(channel_, std::string(host).c_str(), ns_c_in, ns_t_txt, + &AresResolver::OnTXTDoneLocked, resolver_arg); + CheckSocketsLocked(); + MaybeStartTimerLocked(); +} + +AresResolver::AresResolver( + std::unique_ptr polled_fd_factory, + std::shared_ptr event_engine, ares_channel channel) + : grpc_core::InternallyRefCounted( + GRPC_TRACE_FLAG_ENABLED(grpc_trace_ares_resolver) ? "AresResolver" + : nullptr), + channel_(channel), + polled_fd_factory_(std::move(polled_fd_factory)), + event_engine_(std::move(event_engine)) {} + +void AresResolver::CheckSocketsLocked() { + FdNodeList new_list; + if (!shutting_down_) { + ares_socket_t socks[ARES_GETSOCK_MAXNUM]; + int socks_bitmask = ares_getsock(channel_, socks, ARES_GETSOCK_MAXNUM); + for (size_t i = 0; i < ARES_GETSOCK_MAXNUM; i++) { + if (ARES_GETSOCK_READABLE(socks_bitmask, i) || + ARES_GETSOCK_WRITABLE(socks_bitmask, i)) { + auto iter = std::find_if( + fd_node_list_.begin(), fd_node_list_.end(), + [sock = socks[i]](const auto& node) { return node->as == sock; }); + if (iter == fd_node_list_.end()) { + GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p new fd: %d", this, + socks[i]); + new_list.push_back(std::make_unique( + socks[i], polled_fd_factory_->NewGrpcPolledFdLocked(socks[i]))); + } else { + new_list.splice(new_list.end(), fd_node_list_, iter); + } + FdNode* fd_node = new_list.back().get(); + if (ARES_GETSOCK_READABLE(socks_bitmask, i) && + !fd_node->readable_registered) { + fd_node->readable_registered = true; + if (fd_node->polled_fd->IsFdStillReadableLocked()) { + // If c-ares is interested to read and the socket already has data + // available for read, schedules OnReadable directly here. This is + // to cope with the edge-triggered poller not getting an event if no + // new data arrives and c-ares hasn't read all the data in the + // previous ares_process_fd. + GRPC_ARES_RESOLVER_TRACE_LOG( + "resolver:%p schedule read directly on: %d", this, fd_node->as); + event_engine_->Run( + [self = Ref(DEBUG_LOCATION, "CheckSocketsLocked"), + fd_node]() mutable { + self->OnReadable(fd_node, absl::OkStatus()); + }); + } else { + // Otherwise register with the poller for readable event. + GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p notify read on: %d", this, + fd_node->as); + fd_node->polled_fd->RegisterForOnReadableLocked( + [self = Ref(DEBUG_LOCATION, "CheckSocketsLocked"), + fd_node](absl::Status status) mutable { + self->OnReadable(fd_node, status); + }); + } + } + // Register write_closure if the socket is writable and write_closure + // has not been registered with this socket. + if (ARES_GETSOCK_WRITABLE(socks_bitmask, i) && + !fd_node->writable_registered) { + GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p notify write on: %d", this, + fd_node->as); + fd_node->writable_registered = true; + fd_node->polled_fd->RegisterForOnWriteableLocked( + [self = Ref(DEBUG_LOCATION, "CheckSocketsLocked"), + fd_node](absl::Status status) mutable { + self->OnWritable(fd_node, status); + }); + } + } + } + } + // Any remaining fds in fd_node_list_ were not returned by ares_getsock() + // and are therefore no longer in use, so they can be shut down and removed + // from the list. + while (!fd_node_list_.empty()) { + FdNode* fd_node = fd_node_list_.front().get(); + if (!fd_node->already_shutdown) { + GRPC_ARES_RESOLVER_TRACE_LOG("resolver: %p shutdown fd: %s", this, + fd_node->polled_fd->GetName()); + fd_node->polled_fd->ShutdownLocked(absl::OkStatus()); + fd_node->already_shutdown = true; + } + if (!fd_node->readable_registered && !fd_node->writable_registered) { + GRPC_ARES_RESOLVER_TRACE_LOG("resolver: %p delete fd: %s", this, + fd_node->polled_fd->GetName()); + fd_node_list_.pop_front(); + } else { + new_list.splice(new_list.end(), fd_node_list_, fd_node_list_.begin()); + } + } + fd_node_list_ = std::move(new_list); +} + +void AresResolver::MaybeStartTimerLocked() { + if (ares_backup_poll_alarm_handle_.has_value()) { + return; + } + // Initialize the backup poll alarm + GRPC_ARES_RESOLVER_TRACE_LOG( + "request:%p MaybeStartTimerLocked next ares process poll time in %zu ms", + this, Milliseconds(kAresBackupPollAlarmDuration)); + ares_backup_poll_alarm_handle_ = event_engine_->RunAfter( + kAresBackupPollAlarmDuration, + [self = Ref(DEBUG_LOCATION, "MaybeStartTimerLocked")]() { + self->OnAresBackupPollAlarm(); + }); +} + +void AresResolver::OnReadable(FdNode* fd_node, absl::Status status) { + grpc_core::MutexLock lock(&mutex_); + GPR_ASSERT(fd_node->readable_registered); + fd_node->readable_registered = false; + GRPC_ARES_RESOLVER_TRACE_LOG("OnReadable: fd: %d; request: %p; status: %s", + fd_node->as, this, status.ToString().c_str()); + if (status.ok() && !shutting_down_) { + ares_process_fd(channel_, fd_node->as, ARES_SOCKET_BAD); + } else { + // If error is not absl::OkStatus() or the resolution was cancelled, it + // means the fd has been shutdown or timed out. The pending lookups made + // on this request will be cancelled by the following ares_cancel(). The + // remaining file descriptors in this request will be cleaned up in the + // following Work() method. + ares_cancel(channel_); + } + CheckSocketsLocked(); +} + +void AresResolver::OnWritable(FdNode* fd_node, absl::Status status) { + grpc_core::MutexLock lock(&mutex_); + GPR_ASSERT(fd_node->writable_registered); + fd_node->writable_registered = false; + GRPC_ARES_RESOLVER_TRACE_LOG("OnWritable: fd: %d; request:%p; status: %s", + fd_node->as, this, status.ToString().c_str()); + if (status.ok() && !shutting_down_) { + ares_process_fd(channel_, ARES_SOCKET_BAD, fd_node->as); + } else { + // If error is not absl::OkStatus() or the resolution was cancelled, it + // means the fd has been shutdown or timed out. The pending lookups made + // on this request will be cancelled by the following ares_cancel(). The + // remaining file descriptors in this request will be cleaned up in the + // following Work() method. + ares_cancel(channel_); + } + CheckSocketsLocked(); +} + +// In case of non-responsive DNS servers, dropped packets, etc., c-ares has +// intelligent timeout and retry logic, which we can take advantage of by +// polling ares_process_fd on time intervals. Overall, the c-ares library is +// meant to be called into and given a chance to proceed name resolution: +// a) when fd events happen +// b) when some time has passed without fd events having happened +// For the latter, we use this backup poller. Also see +// https://github.com/grpc/grpc/pull/17688 description for more details. +void AresResolver::OnAresBackupPollAlarm() { + grpc_core::MutexLock lock(&mutex_); + ares_backup_poll_alarm_handle_.reset(); + GRPC_ARES_RESOLVER_TRACE_LOG( + "request:%p OnAresBackupPollAlarm shutting_down=%d.", this, + shutting_down_); + if (!shutting_down_) { + for (const auto& fd_node : fd_node_list_) { + if (!fd_node->already_shutdown) { + GRPC_ARES_RESOLVER_TRACE_LOG( + "request:%p OnAresBackupPollAlarm; ares_process_fd. fd=%s", this, + fd_node->polled_fd->GetName()); + ares_socket_t as = fd_node->polled_fd->GetWrappedAresSocketLocked(); + ares_process_fd(channel_, as, as); + } + } + MaybeStartTimerLocked(); + CheckSocketsLocked(); + } +} + +void AresResolver::OnHostbynameDoneLocked(void* arg, int status, + int /*timeouts*/, + struct hostent* hostent) { + std::unique_ptr hostname_qa( + static_cast(arg)); + auto* ares_resolver = hostname_qa->ares_resolver; + auto nh = ares_resolver->callback_map_.extract(hostname_qa->callback_map_id); + GPR_ASSERT(!nh.empty()); + GPR_ASSERT( + absl::holds_alternative( + nh.mapped())); + auto callback = absl::get( + std::move(nh.mapped())); + if (status != ARES_SUCCESS) { + std::string error_msg = + absl::StrFormat("address lookup failed for %s: %s", + hostname_qa->query_name, ares_strerror(status)); + GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p OnHostbynameDoneLocked: %s", + ares_resolver, error_msg.c_str()); + ares_resolver->event_engine_->Run( + [callback = std::move(callback), + status = AresStatusToAbslStatus(status, error_msg)]() mutable { + callback(status); + }); + return; + } + GRPC_ARES_RESOLVER_TRACE_LOG( + "resolver:%p OnHostbynameDoneLocked name=%s ARES_SUCCESS", ares_resolver, + hostname_qa->query_name.c_str()); + std::vector result; + for (size_t i = 0; hostent->h_addr_list[i] != nullptr; i++) { + switch (hostent->h_addrtype) { + case AF_INET6: { + size_t addr_len = sizeof(struct sockaddr_in6); + struct sockaddr_in6 addr; + memset(&addr, 0, addr_len); + memcpy(&addr.sin6_addr, hostent->h_addr_list[i], + sizeof(struct in6_addr)); + addr.sin6_family = static_cast(hostent->h_addrtype); + addr.sin6_port = htons(hostname_qa->port); + result.emplace_back(reinterpret_cast(&addr), addr_len); + char output[INET6_ADDRSTRLEN]; + ares_inet_ntop(AF_INET6, &addr.sin6_addr, output, INET6_ADDRSTRLEN); + GRPC_ARES_RESOLVER_TRACE_LOG( + "resolver:%p c-ares resolver gets a AF_INET6 result: \n" + " addr: %s\n port: %d\n sin6_scope_id: %d\n", + ares_resolver, output, hostname_qa->port, addr.sin6_scope_id); + break; + } + case AF_INET: { + size_t addr_len = sizeof(struct sockaddr_in); + struct sockaddr_in addr; + memset(&addr, 0, addr_len); + memcpy(&addr.sin_addr, hostent->h_addr_list[i], sizeof(struct in_addr)); + addr.sin_family = static_cast(hostent->h_addrtype); + addr.sin_port = htons(hostname_qa->port); + result.emplace_back(reinterpret_cast(&addr), addr_len); + char output[INET_ADDRSTRLEN]; + ares_inet_ntop(AF_INET, &addr.sin_addr, output, INET_ADDRSTRLEN); + GRPC_ARES_RESOLVER_TRACE_LOG( + "resolver:%p c-ares resolver gets a AF_INET result: \n" + " addr: %s\n port: %d\n", + ares_resolver, output, hostname_qa->port); + break; + } + } + } + ares_resolver->event_engine_->Run( + [callback = std::move(callback), result = std::move(result)]() mutable { + callback(std::move(result)); + }); +} + +void AresResolver::OnSRVQueryDoneLocked(void* arg, int status, int /*timeouts*/, + unsigned char* abuf, int alen) { + std::unique_ptr qa(static_cast(arg)); + auto* ares_resolver = qa->ares_resolver; + auto nh = ares_resolver->callback_map_.extract(qa->callback_map_id); + GPR_ASSERT(!nh.empty()); + GPR_ASSERT( + absl::holds_alternative( + nh.mapped())); + auto callback = absl::get( + std::move(nh.mapped())); + auto fail = [&](absl::string_view prefix) { + std::string error_message = absl::StrFormat( + "%s for %s: %s", prefix, qa->query_name, ares_strerror(status)); + GRPC_ARES_RESOLVER_TRACE_LOG("OnSRVQueryDoneLocked: %s", + error_message.c_str()); + ares_resolver->event_engine_->Run( + [callback = std::move(callback), + status = AresStatusToAbslStatus(status, error_message)]() mutable { + callback(status); + }); + }; + if (status != ARES_SUCCESS) { + fail("SRV lookup failed"); + return; + } + GRPC_ARES_RESOLVER_TRACE_LOG( + "resolver:%p OnSRVQueryDoneLocked name=%s ARES_SUCCESS", ares_resolver, + qa->query_name.c_str()); + struct ares_srv_reply* reply = nullptr; + status = ares_parse_srv_reply(abuf, alen, &reply); + GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p ares_parse_srv_reply: %d", + ares_resolver, status); + if (status != ARES_SUCCESS) { + fail("Failed to parse SRV reply"); + return; + } + std::vector result; + for (struct ares_srv_reply* srv_it = reply; srv_it != nullptr; + srv_it = srv_it->next) { + EventEngine::DNSResolver::SRVRecord record; + record.host = srv_it->host; + record.port = srv_it->port; + record.priority = srv_it->priority; + record.weight = srv_it->weight; + result.push_back(std::move(record)); + } + if (reply != nullptr) { + ares_free_data(reply); + } + ares_resolver->event_engine_->Run( + [callback = std::move(callback), result = std::move(result)]() mutable { + callback(std::move(result)); + }); +} + +void AresResolver::OnTXTDoneLocked(void* arg, int status, int /*timeouts*/, + unsigned char* buf, int len) { + std::unique_ptr qa(static_cast(arg)); + auto* ares_resolver = qa->ares_resolver; + auto nh = ares_resolver->callback_map_.extract(qa->callback_map_id); + GPR_ASSERT(!nh.empty()); + GPR_ASSERT( + absl::holds_alternative( + nh.mapped())); + auto callback = absl::get( + std::move(nh.mapped())); + auto fail = [&](absl::string_view prefix) { + std::string error_message = absl::StrFormat( + "%s for %s: %s", prefix, qa->query_name, ares_strerror(status)); + GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p OnTXTDoneLocked: %s", + ares_resolver, error_message.c_str()); + ares_resolver->event_engine_->Run( + [callback = std::move(callback), + status = AresStatusToAbslStatus(status, error_message)]() mutable { + callback(status); + }); + }; + if (status != ARES_SUCCESS) { + fail("TXT lookup failed"); + return; + } + GRPC_ARES_RESOLVER_TRACE_LOG( + "resolver:%p OnTXTDoneLocked name=%s ARES_SUCCESS", ares_resolver, + qa->query_name.c_str()); + struct ares_txt_ext* reply = nullptr; + status = ares_parse_txt_reply_ext(buf, len, &reply); + if (status != ARES_SUCCESS) { + fail("Failed to parse TXT result"); + return; + } + std::vector result; + for (struct ares_txt_ext* part = reply; part != nullptr; part = part->next) { + if (part->record_start) { + result.emplace_back(reinterpret_cast(part->txt), part->length); + } else { + absl::StrAppend( + &result.back(), + std::string(reinterpret_cast(part->txt), part->length)); + } + } + GRPC_ARES_RESOLVER_TRACE_LOG("resolver:%p Got %zu TXT records", ares_resolver, + result.size()); + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_ares_resolver)) { + for (const auto& record : result) { + gpr_log(GPR_INFO, "%s", record.c_str()); + } + } + // Clean up. + ares_free_data(reply); + ares_resolver->event_engine_->Run( + [callback = std::move(callback), result = std::move(result)]() mutable { + callback(std::move(result)); + }); +} + +} // namespace experimental +} // namespace grpc_event_engine + +void noop_inject_channel_config(ares_channel* /*channel*/) {} + +void (*event_engine_grpc_ares_test_only_inject_config)(ares_channel* channel) = + noop_inject_channel_config; + +bool g_event_engine_grpc_ares_test_only_force_tcp = false; + +#endif // GRPC_ARES == 1 diff --git a/src/core/lib/event_engine/ares_resolver.h b/src/core/lib/event_engine/ares_resolver.h new file mode 100644 index 0000000000000..d90f13d8a8ff5 --- /dev/null +++ b/src/core/lib/event_engine/ares_resolver.h @@ -0,0 +1,150 @@ +// Copyright 2023 The 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_SRC_CORE_LIB_EVENT_ENGINE_ARES_RESOLVER_H +#define GRPC_SRC_CORE_LIB_EVENT_ENGINE_ARES_RESOLVER_H + +#include + +#include "src/core/lib/debug/trace.h" + +#if GRPC_ARES == 1 + +#include +#include + +#include + +#include "absl/base/thread_annotations.h" +#include "absl/container/flat_hash_map.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "absl/types/variant.h" + +#include +#include + +#include "src/core/lib/event_engine/grpc_polled_fd.h" +#include "src/core/lib/gprpp/orphanable.h" +#include "src/core/lib/gprpp/sync.h" + +namespace grpc_event_engine { +namespace experimental { + +extern grpc_core::TraceFlag grpc_trace_ares_resolver; + +#define GRPC_ARES_RESOLVER_TRACE_LOG(format, ...) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_ares_resolver)) { \ + gpr_log(GPR_INFO, "(EventEngine c-ares resolver) " format, __VA_ARGS__); \ + } \ + } while (0) + +class AresResolver : public grpc_core::InternallyRefCounted { + public: + static absl::StatusOr> + CreateAresResolver(absl::string_view dns_server, + std::unique_ptr polled_fd_factory, + std::shared_ptr event_engine); + + // Do not instantiate directly -- use CreateAresResolver() instead. + AresResolver(std::unique_ptr polled_fd_factory, + std::shared_ptr event_engine, ares_channel channel); + ~AresResolver() override; + void Orphan() override ABSL_LOCKS_EXCLUDED(mutex_); + + void LookupHostname(absl::string_view name, absl::string_view default_port, + EventEngine::DNSResolver::LookupHostnameCallback callback) + ABSL_LOCKS_EXCLUDED(mutex_); + void LookupSRV(absl::string_view name, + EventEngine::DNSResolver::LookupSRVCallback callback) + ABSL_LOCKS_EXCLUDED(mutex_); + void LookupTXT(absl::string_view name, + EventEngine::DNSResolver::LookupTXTCallback callback) + ABSL_LOCKS_EXCLUDED(mutex_); + + private: + // A FdNode saves (not owns) a live socket/fd which c-ares creates, and owns a + // GrpcPolledFd object which has a platform-agnostic interface to interact + // with the poller. The liveness of the socket means that c-ares needs us to + // monitor r/w events on this socket and notifies c-ares when such events have + // happened which we achieve through the GrpcPolledFd object. FdNode also + // handles the shutdown (maybe due to socket no longer used, finished request, + // cancel or timeout) and the destruction of the poller handle. Note that + // FdNode does not own the socket and it's the c-ares' responsibility to + // close the socket (possibly through ares_destroy). + struct FdNode { + FdNode() = default; + FdNode(ares_socket_t as, GrpcPolledFd* polled_fd) + : as(as), polled_fd(polled_fd) {} + ares_socket_t as; + std::unique_ptr polled_fd; + // true if the readable closure has been registered + bool readable_registered = false; + // true if the writable closure has been registered + bool writable_registered = false; + bool already_shutdown = false; + }; + using FdNodeList = std::list>; + + using CallbackType = + absl::variant; + + void CheckSocketsLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + void MaybeStartTimerLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + void OnReadable(FdNode* fd_node, absl::Status status) + ABSL_LOCKS_EXCLUDED(mutex_); + void OnWritable(FdNode* fd_node, absl::Status status) + ABSL_LOCKS_EXCLUDED(mutex_); + void OnAresBackupPollAlarm() ABSL_LOCKS_EXCLUDED(mutex_); + + // These callbacks are invoked from the c-ares library, so disable thread + // safety analysis. We are guaranteed to be holding mutex_. + static void OnHostbynameDoneLocked(void* arg, int status, int /*timeouts*/, + struct hostent* hostent) + ABSL_NO_THREAD_SAFETY_ANALYSIS; + static void OnSRVQueryDoneLocked(void* arg, int status, int /*timeouts*/, + unsigned char* abuf, + int alen) ABSL_NO_THREAD_SAFETY_ANALYSIS; + static void OnTXTDoneLocked(void* arg, int status, int /*timeouts*/, + unsigned char* buf, + int len) ABSL_NO_THREAD_SAFETY_ANALYSIS; + + grpc_core::Mutex mutex_; + bool shutting_down_ ABSL_GUARDED_BY(mutex_) = false; + ares_channel channel_ ABSL_GUARDED_BY(mutex_); + FdNodeList fd_node_list_ ABSL_GUARDED_BY(mutex_); + int id_ ABSL_GUARDED_BY(mutex_) = 0; + absl::flat_hash_map callback_map_ ABSL_GUARDED_BY(mutex_); + absl::optional ares_backup_poll_alarm_handle_ + ABSL_GUARDED_BY(mutex_); + std::unique_ptr polled_fd_factory_; + std::shared_ptr event_engine_; +}; + +} // namespace experimental +} // namespace grpc_event_engine + +// Exposed in this header for C-core tests only +extern void (*event_engine_grpc_ares_test_only_inject_config)( + ares_channel* channel); + +// Exposed in this header for C-core tests only +extern bool g_event_engine_grpc_ares_test_only_force_tcp; + +#endif // GRPC_ARES == 1 +#endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_ARES_RESOLVER_H diff --git a/src/core/lib/event_engine/cf_engine/cf_engine.cc b/src/core/lib/event_engine/cf_engine/cf_engine.cc index ecd5e4fe21869..af0b7248d1992 100644 --- a/src/core/lib/event_engine/cf_engine/cf_engine.cc +++ b/src/core/lib/event_engine/cf_engine/cf_engine.cc @@ -22,6 +22,7 @@ #include "src/core/lib/event_engine/cf_engine/cf_engine.h" #include "src/core/lib/event_engine/cf_engine/cfstream_endpoint.h" +#include "src/core/lib/event_engine/cf_engine/dns_service_resolver.h" #include "src/core/lib/event_engine/posix_engine/timer_manager.h" #include "src/core/lib/event_engine/tcp_socket_utils.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" @@ -155,9 +156,15 @@ bool CFEventEngine::CancelConnectInternal(ConnectionHandle handle, bool CFEventEngine::IsWorkerThread() { grpc_core::Crash("unimplemented"); } -std::unique_ptr CFEventEngine::GetDNSResolver( - const DNSResolver::ResolverOptions& /* options */) { - grpc_core::Crash("unimplemented"); +absl::StatusOr> +CFEventEngine::GetDNSResolver(const DNSResolver::ResolverOptions& options) { + if (!options.dns_server.empty()) { + return absl::InvalidArgumentError( + "CFEventEngine does not support custom DNS servers"); + } + + return std::make_unique( + std::static_pointer_cast(shared_from_this())); } void CFEventEngine::Run(EventEngine::Closure* closure) { diff --git a/src/core/lib/event_engine/cf_engine/cf_engine.h b/src/core/lib/event_engine/cf_engine/cf_engine.h index 3e55ce85616a4..e67f9c7533157 100644 --- a/src/core/lib/event_engine/cf_engine/cf_engine.h +++ b/src/core/lib/event_engine/cf_engine/cf_engine.h @@ -51,7 +51,7 @@ class CFEventEngine : public EventEngine, Duration timeout) override; bool CancelConnect(ConnectionHandle handle) override; bool IsWorkerThread() override; - std::unique_ptr GetDNSResolver( + absl::StatusOr> GetDNSResolver( const DNSResolver::ResolverOptions& options) override; void Run(Closure* closure) override; void Run(absl::AnyInvocable closure) override; diff --git a/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc b/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc index f77a626d7f533..1dd3107381f04 100644 --- a/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +++ b/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc @@ -96,8 +96,8 @@ void CFStreamEndpointImpl::Connect( std::string host_string; std::string port_string; grpc_core::SplitHostPort(host_port.value(), &host_string, &port_string); - CFStringRef host = CFStringCreateWithCString(NULL, host_string.c_str(), - kCFStringEncodingUTF8); + CFTypeUniqueRef host = CFStringCreateWithCString( + NULL, host_string.c_str(), kCFStringEncodingUTF8); int port = ResolvedAddressGetPort(peer_address_); CFStreamCreatePairWithSocketToHost(NULL, host, port, &cf_read_stream_, &cf_write_stream_); diff --git a/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc b/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc new file mode 100644 index 0000000000000..6e30f478ffc66 --- /dev/null +++ b/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc @@ -0,0 +1,229 @@ +// Copyright 2023 The 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 + +#ifdef GPR_APPLE + +#include "absl/strings/str_format.h" + +#include "src/core/lib/address_utils/parse_address.h" +#include "src/core/lib/event_engine/cf_engine/dns_service_resolver.h" +#include "src/core/lib/event_engine/posix_engine/lockfree_event.h" +#include "src/core/lib/event_engine/tcp_socket_utils.h" +#include "src/core/lib/event_engine/trace.h" +#include "src/core/lib/gprpp/host_port.h" + +namespace grpc_event_engine { +namespace experimental { + +void DNSServiceResolverImpl::LookupHostname( + EventEngine::DNSResolver::LookupHostnameCallback on_resolve, + absl::string_view name, absl::string_view default_port) { + GRPC_EVENT_ENGINE_DNS_TRACE( + "DNSServiceResolverImpl::LookupHostname: name: %.*s, default_port: %.*s, " + "this: %p", + static_cast(name.length()), name.data(), + static_cast(default_port.length()), default_port.data(), this); + + absl::string_view host; + absl::string_view port_string; + if (!grpc_core::SplitHostPort(name, &host, &port_string)) { + engine_->Run([on_resolve = std::move(on_resolve), + status = absl::InvalidArgumentError( + absl::StrCat("Unparseable name: ", name))]() mutable { + on_resolve(status); + }); + return; + } + GPR_ASSERT(!host.empty()); + if (port_string.empty()) { + if (default_port.empty()) { + engine_->Run([on_resolve = std::move(on_resolve), + status = absl::InvalidArgumentError(absl::StrFormat( + "No port in name %s or default_port argument", + name))]() mutable { on_resolve(std::move(status)); }); + return; + } + port_string = default_port; + } + + int port = 0; + if (port_string == "http") { + port = 80; + } else if (port_string == "https") { + port = 443; + } else if (!absl::SimpleAtoi(port_string, &port)) { + engine_->Run([on_resolve = std::move(on_resolve), + status = absl::InvalidArgumentError(absl::StrCat( + "Failed to parse port in name: ", name))]() mutable { + on_resolve(std::move(status)); + }); + return; + } + + // TODO(yijiem): Change this when refactoring code in + // src/core/lib/address_utils to use EventEngine::ResolvedAddress. + grpc_resolved_address addr; + const std::string hostport = grpc_core::JoinHostPort(host, port); + if (grpc_parse_ipv4_hostport(hostport.c_str(), &addr, + /*log_errors=*/false) || + grpc_parse_ipv6_hostport(hostport.c_str(), &addr, + /*log_errors=*/false)) { + // Early out if the target is an ipv4 or ipv6 literal, otherwise dns service + // responses with kDNSServiceErr_NoSuchRecord + std::vector result; + result.emplace_back(reinterpret_cast(addr.addr), addr.len); + engine_->Run([on_resolve = std::move(on_resolve), + result = std::move(result)]() mutable { + on_resolve(std::move(result)); + }); + return; + } + + DNSServiceRef sdRef; + auto host_string = std::string{host}; + auto error = DNSServiceGetAddrInfo( + &sdRef, kDNSServiceFlagsTimeout | kDNSServiceFlagsReturnIntermediates, 0, + kDNSServiceProtocol_IPv4 | kDNSServiceProtocol_IPv6, host_string.c_str(), + &DNSServiceResolverImpl::ResolveCallback, this /* do not Ref */); + + if (error != kDNSServiceErr_NoError) { + engine_->Run([on_resolve = std::move(on_resolve), + status = absl::UnknownError(absl::StrFormat( + "DNSServiceGetAddrInfo failed with error:%d", + error))]() mutable { on_resolve(std::move(status)); }); + return; + } + + grpc_core::ReleasableMutexLock lock(&request_mu_); + + error = DNSServiceSetDispatchQueue(sdRef, queue_); + if (error != kDNSServiceErr_NoError) { + engine_->Run([on_resolve = std::move(on_resolve), + status = absl::UnknownError(absl::StrFormat( + "DNSServiceSetDispatchQueue failed with error:%d", + error))]() mutable { on_resolve(std::move(status)); }); + return; + } + + requests_.try_emplace( + sdRef, DNSServiceRequest{ + std::move(on_resolve), static_cast(port), {}}); +} + +/* static */ +void DNSServiceResolverImpl::ResolveCallback( + DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, + DNSServiceErrorType errorCode, const char* hostname, + const struct sockaddr* address, uint32_t ttl, void* context) { + GRPC_EVENT_ENGINE_DNS_TRACE( + "DNSServiceResolverImpl::ResolveCallback: sdRef: %p, flags: %x, " + "interface: %d, errorCode: %d, hostname: %s, addressFamily: %d, ttl: " + "%d, " + "this: %p", + sdRef, flags, interfaceIndex, errorCode, hostname, address->sa_family, + ttl, context); + + // no need to increase refcount here, since ResolveCallback and Shutdown is + // called from the serial queue and it is guarenteed that it won't be called + // after the sdRef is deallocated + auto that = static_cast(context); + + grpc_core::ReleasableMutexLock lock(&that->request_mu_); + auto request_it = that->requests_.find(sdRef); + GPR_ASSERT(request_it != that->requests_.end()); + auto& request = request_it->second; + + if (errorCode != kDNSServiceErr_NoError && + errorCode != kDNSServiceErr_NoSuchRecord) { + request.on_resolve(absl::UnknownError(absl::StrFormat( + "address lookup failed for %s: errorCode: %d", hostname, errorCode))); + that->requests_.erase(request_it); + DNSServiceRefDeallocate(sdRef); + return; + } + + // set received ipv4 or ipv6 response, even for kDNSServiceErr_NoSuchRecord to + // mark that the response for the stack is received, it is possible that the + // one stack receives some results and the other stack gets + // kDNSServiceErr_NoSuchRecord error. + if (address->sa_family == AF_INET) { + request.has_ipv4_response = true; + } else if (address->sa_family == AF_INET6) { + request.has_ipv6_response = true; + } + + // collect results if there is no error (not kDNSServiceErr_NoSuchRecord) + if (errorCode == kDNSServiceErr_NoError) { + request.result.emplace_back(address, address->sa_len); + auto& resolved_address = request.result.back(); + if (address->sa_family == AF_INET) { + (const_cast( + reinterpret_cast(resolved_address.address()))) + ->sin_port = htons(request.port); + } else if (address->sa_family == AF_INET6) { + (const_cast( + reinterpret_cast(resolved_address.address()))) + ->sin6_port = htons(request.port); + } + + GRPC_EVENT_ENGINE_DNS_TRACE( + "DNSServiceResolverImpl::ResolveCallback: " + "sdRef: %p, hostname: %s, addressPort: %s, this: %p", + sdRef, hostname, + ResolvedAddressToString(resolved_address).value_or("ERROR").c_str(), + context); + } + + // received both ipv4 and ipv6 responses, and no more responses (e.g. multiple + // IP addresses for a domain name) are coming, finish `LookupHostname` resolve + // with the collected results. + if (!(flags & kDNSServiceFlagsMoreComing) && request.has_ipv4_response && + request.has_ipv6_response) { + if (request.result.empty()) { + request.on_resolve(absl::NotFoundError(absl::StrFormat( + "address lookup failed for %s: Domain name not found", hostname))); + } else { + request.on_resolve(std::move(request.result)); + } + that->requests_.erase(request_it); + DNSServiceRefDeallocate(sdRef); + } +} + +void DNSServiceResolverImpl::Shutdown() { + dispatch_async_f(queue_, Ref().release(), [](void* thatPtr) { + grpc_core::RefCountedPtr that{ + static_cast(thatPtr)}; + grpc_core::MutexLock lock(&that->request_mu_); + for (auto& kv : that->requests_) { + auto& sdRef = kv.first; + auto& request = kv.second; + GRPC_EVENT_ENGINE_DNS_TRACE( + "DNSServiceResolverImpl::Shutdown sdRef: %p, this: %p", sdRef, + thatPtr); + + request.on_resolve( + absl::CancelledError("DNSServiceResolverImpl::Shutdown")); + DNSServiceRefDeallocate(static_cast(sdRef)); + } + that->requests_.clear(); + }); +} + +} // namespace experimental +} // namespace grpc_event_engine + +#endif // GPR_APPLE diff --git a/src/core/lib/event_engine/cf_engine/dns_service_resolver.h b/src/core/lib/event_engine/cf_engine/dns_service_resolver.h new file mode 100644 index 0000000000000..00a55a3050025 --- /dev/null +++ b/src/core/lib/event_engine/cf_engine/dns_service_resolver.h @@ -0,0 +1,117 @@ +// Copyright 2023 The 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_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_DNS_SERVICE_RESOLVER_H +#define GRPC_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_DNS_SERVICE_RESOLVER_H +#include + +#ifdef GPR_APPLE + +#include +#include + +#include "absl/container/flat_hash_map.h" + +#include + +#include "src/core/lib/event_engine/cf_engine/cf_engine.h" +#include "src/core/lib/gprpp/ref_counted.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" + +namespace grpc_event_engine { +namespace experimental { + +class DNSServiceResolverImpl + : public grpc_core::RefCounted { + struct DNSServiceRequest { + EventEngine::DNSResolver::LookupHostnameCallback on_resolve; + uint16_t port; + std::vector result; + bool has_ipv4_response = false; + bool has_ipv6_response = false; + }; + + public: + explicit DNSServiceResolverImpl(std::shared_ptr engine) + : engine_(std::move((engine))) {} + ~DNSServiceResolverImpl() override { + GPR_ASSERT(requests_.empty()); + dispatch_release(queue_); + } + + void Shutdown(); + + void LookupHostname( + EventEngine::DNSResolver::LookupHostnameCallback on_resolve, + absl::string_view name, absl::string_view default_port); + + private: + static void ResolveCallback(DNSServiceRef sdRef, DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char* hostname, + const struct sockaddr* address, uint32_t ttl, + void* context); + + private: + std::shared_ptr engine_; + // DNSServiceSetDispatchQueue requires a serial dispatch queue + dispatch_queue_t queue_ = + dispatch_queue_create("dns_service_resolver", nullptr); + grpc_core::Mutex request_mu_; + absl::flat_hash_map requests_ + ABSL_GUARDED_BY(request_mu_); +}; + +class DNSServiceResolver : public EventEngine::DNSResolver { + public: + explicit DNSServiceResolver(std::shared_ptr engine) + : engine_(std::move(engine)), + impl_(grpc_core::MakeRefCounted( + std::move((engine_)))) {} + + ~DNSServiceResolver() override { impl_->Shutdown(); } + + void LookupHostname( + EventEngine::DNSResolver::LookupHostnameCallback on_resolve, + absl::string_view name, absl::string_view default_port) override { + impl_->LookupHostname(std::move(on_resolve), name, default_port); + }; + + void LookupSRV(EventEngine::DNSResolver::LookupSRVCallback on_resolve, + absl::string_view /* name */) override { + engine_->Run([on_resolve = std::move(on_resolve)]() mutable { + on_resolve(absl::UnimplementedError( + "The DNS Service resolver does not support looking up SRV records")); + }); + } + + void LookupTXT(EventEngine::DNSResolver::LookupTXTCallback on_resolve, + absl::string_view /* name */) override { + engine_->Run([on_resolve = std::move(on_resolve)]() mutable { + on_resolve(absl::UnimplementedError( + "The DNS Service resolver does not support looking up TXT records")); + }); + } + + private: + std::shared_ptr engine_; + grpc_core::RefCountedPtr impl_; +}; + +} // namespace experimental +} // namespace grpc_event_engine + +#endif // GPR_APPLE + +#endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_CF_ENGINE_DNS_SERVICE_RESOLVER_H diff --git a/src/core/lib/event_engine/forkable.cc b/src/core/lib/event_engine/forkable.cc index 4906084d274ec..57f60577d1078 100644 --- a/src/core/lib/event_engine/forkable.cc +++ b/src/core/lib/event_engine/forkable.cc @@ -35,6 +35,8 @@ namespace grpc_event_engine { namespace experimental { +grpc_core::TraceFlag grpc_trace_fork(false, "fork"); + namespace { grpc_core::NoDestruct g_mu; bool g_registered ABSL_GUARDED_BY(g_mu){false}; @@ -58,41 +60,52 @@ void RegisterForkHandlers() { grpc_core::MutexLock lock(g_mu.get()); if (!std::exchange(g_registered, true)) { #ifdef GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK + GRPC_FORK_TRACE_LOG_STRING("RegisterForkHandlers"); pthread_atfork(PrepareFork, PostforkParent, PostforkChild); #endif } } -}; +} void PrepareFork() { if (IsForkEnabled()) { + GRPC_FORK_TRACE_LOG_STRING("PrepareFork"); grpc_core::MutexLock lock(g_mu.get()); for (auto forkable_iter = g_forkables->rbegin(); forkable_iter != g_forkables->rend(); ++forkable_iter) { (*forkable_iter)->PrepareFork(); } + GRPC_FORK_TRACE_LOG_STRING("PrepareFork finished"); } } + void PostforkParent() { if (IsForkEnabled()) { + GRPC_FORK_TRACE_LOG_STRING("PostforkParent"); grpc_core::MutexLock lock(g_mu.get()); for (auto* forkable : *g_forkables) { + GRPC_FORK_TRACE_LOG("Calling PostforkParent for forkable::%p", forkable); forkable->PostforkParent(); } + GRPC_FORK_TRACE_LOG_STRING("PostforkParent finished"); } } void PostforkChild() { if (IsForkEnabled()) { + GRPC_FORK_TRACE_LOG_STRING("PostforkChild"); grpc_core::MutexLock lock(g_mu.get()); for (auto* forkable : *g_forkables) { + GRPC_FORK_TRACE_LOG("Calling PostforkChild for forkable::%p", forkable); forkable->PostforkChild(); } + GRPC_FORK_TRACE_LOG_STRING("PostforkChild finished"); } } void ManageForkable(Forkable* forkable) { if (IsForkEnabled()) { + GRPC_FORK_TRACE_LOG("Manage forkable::%p", forkable); grpc_core::MutexLock lock(g_mu.get()); g_forkables->push_back(forkable); } @@ -100,6 +113,7 @@ void ManageForkable(Forkable* forkable) { void StopManagingForkable(Forkable* forkable) { if (IsForkEnabled()) { + GRPC_FORK_TRACE_LOG("Stop managing forkable::%p", forkable); grpc_core::MutexLock lock(g_mu.get()); auto iter = std::find(g_forkables->begin(), g_forkables->end(), forkable); GPR_ASSERT(iter != g_forkables->end()); diff --git a/src/core/lib/event_engine/forkable.h b/src/core/lib/event_engine/forkable.h index 17fed628e1538..c585a8309881e 100644 --- a/src/core/lib/event_engine/forkable.h +++ b/src/core/lib/event_engine/forkable.h @@ -16,9 +16,24 @@ #include +#include + +#include "src/core/lib/debug/trace.h" + namespace grpc_event_engine { namespace experimental { +extern grpc_core::TraceFlag grpc_trace_fork; + +#define GRPC_FORK_TRACE_LOG(format, ...) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_fork)) { \ + gpr_log(GPR_DEBUG, "[fork] " format, __VA_ARGS__); \ + } \ + } while (0) + +#define GRPC_FORK_TRACE_LOG_STRING(format) GRPC_FORK_TRACE_LOG("%s", format) + // Register fork handlers with the system, enabling fork support. // // This provides pthread-based support for fork events. Any objects that diff --git a/src/core/lib/event_engine/grpc_polled_fd.h b/src/core/lib/event_engine/grpc_polled_fd.h new file mode 100644 index 0000000000000..bb66089d5ada2 --- /dev/null +++ b/src/core/lib/event_engine/grpc_polled_fd.h @@ -0,0 +1,73 @@ +// Copyright 2023 The 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_SRC_CORE_LIB_EVENT_ENGINE_GRPC_POLLED_FD_H +#define GRPC_SRC_CORE_LIB_EVENT_ENGINE_GRPC_POLLED_FD_H + +#include + +#if GRPC_ARES == 1 + +#include + +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" + +#include "src/core/lib/iomgr/error.h" + +namespace grpc_event_engine { +namespace experimental { + +// A wrapped fd that integrates with the EventEngine poller of the current +// platform. A GrpcPolledFd knows how to create grpc platform-specific poller +// handle from "ares_socket_t" sockets, and then sign up for +// readability/writeability with that poller handle, and do shutdown and +// destruction. +class GrpcPolledFd { + public: + virtual ~GrpcPolledFd() {} + // Called when c-ares library is interested and there's no pending callback + virtual void RegisterForOnReadableLocked( + absl::AnyInvocable read_closure) = 0; + // Called when c-ares library is interested and there's no pending callback + virtual void RegisterForOnWriteableLocked( + absl::AnyInvocable write_closure) = 0; + // Indicates if there is data left even after just being read from + virtual bool IsFdStillReadableLocked() = 0; + // Called once and only once. Must cause cancellation of any pending + // read/write callbacks. + virtual void ShutdownLocked(grpc_error_handle error) = 0; + // Get the underlying ares_socket_t that this was created from + virtual ares_socket_t GetWrappedAresSocketLocked() = 0; + // A unique name, for logging + virtual const char* GetName() const = 0; +}; + +// A GrpcPolledFdFactory is 1-to-1 with and owned by a GrpcAresRequest. It knows +// how to create GrpcPolledFd's for the current platform, and the +// GrpcAresRequest uses it for all of its fd's. +class GrpcPolledFdFactory { + public: + virtual ~GrpcPolledFdFactory() {} + // Creates a new wrapped fd for the current platform + virtual GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as) = 0; + // Optionally configures the ares channel after creation + virtual void ConfigureAresChannelLocked(ares_channel channel) = 0; +}; + +} // namespace experimental +} // namespace grpc_event_engine + +#endif // GRPC_ARES == 1 +#endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_GRPC_POLLED_FD_H diff --git a/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc b/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc index fdb4ed09becc3..56fd15c26f0d7 100644 --- a/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +++ b/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc @@ -316,7 +316,7 @@ void ResetEventManagerOnFork() { while (!fork_poller_list.empty()) { PollPoller* poller = fork_poller_list.front(); fork_poller_list.pop_front(); - delete poller; + poller->Close(); } gpr_mu_unlock(&fork_fd_list_mu); InitPollPollerPosix(); @@ -566,6 +566,9 @@ bool PollEventHandle::EndPollLocked(bool got_read, bool got_write) { void PollPoller::KickExternal(bool ext) { grpc_core::MutexLock lock(&mu_); + if (closed_) { + return; + } if (was_kicked_) { if (ext) { was_kicked_ext_ = true; @@ -610,7 +613,8 @@ PollPoller::PollPoller(Scheduler* scheduler) was_kicked_(false), was_kicked_ext_(false), num_poll_handles_(0), - poll_handles_list_head_(nullptr) { + poll_handles_list_head_(nullptr), + closed_(false) { wakeup_fd_ = *CreateWakeupFd(); GPR_ASSERT(wakeup_fd_ != nullptr); ForkPollerListAddPoller(this); @@ -622,7 +626,8 @@ PollPoller::PollPoller(Scheduler* scheduler, bool use_phony_poll) was_kicked_(false), was_kicked_ext_(false), num_poll_handles_(0), - poll_handles_list_head_(nullptr) { + poll_handles_list_head_(nullptr), + closed_(false) { wakeup_fd_ = *CreateWakeupFd(); GPR_ASSERT(wakeup_fd_ != nullptr); ForkPollerListAddPoller(this); @@ -829,6 +834,17 @@ void PollPoller::Shutdown() { Unref(); } +void PollPoller::PrepareFork() { Kick(); } +// TODO(vigneshbabu): implement +void PollPoller::PostforkParent() {} +// TODO(vigneshbabu): implement +void PollPoller::PostforkChild() {} + +void PollPoller::Close() { + grpc_core::MutexLock lock(&mu_); + closed_ = true; +} + PollPoller* MakePollPoller(Scheduler* scheduler, bool use_phony_poll) { static bool kPollPollerSupported = InitPollPollerPosix(); if (kPollPollerSupported) { @@ -875,6 +891,12 @@ PollPoller* MakePollPoller(Scheduler* /*scheduler*/, return nullptr; } +void PollPoller::PrepareFork() { grpc_core::Crash("unimplemented"); } +void PollPoller::PostforkParent() { grpc_core::Crash("unimplemented"); } +void PollPoller::PostforkChild() { grpc_core::Crash("unimplemented"); } + +void PollPoller::Close() { grpc_core::Crash("unimplemented"); } + void PollPoller::KickExternal(bool /*ext*/) { grpc_core::Crash("unimplemented"); } diff --git a/src/core/lib/event_engine/posix_engine/ev_poll_posix.h b/src/core/lib/event_engine/posix_engine/ev_poll_posix.h index dac37ea130de0..582991b7c7afc 100644 --- a/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +++ b/src/core/lib/event_engine/posix_engine/ev_poll_posix.h @@ -27,6 +27,7 @@ #include +#include "src/core/lib/event_engine/forkable.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h" @@ -38,7 +39,7 @@ namespace experimental { class PollEventHandle; // Definition of poll based poller. -class PollPoller : public PosixEventPoller { +class PollPoller : public PosixEventPoller, public Forkable { public: explicit PollPoller(Scheduler* scheduler); PollPoller(Scheduler* scheduler, bool use_phony_poll); @@ -54,6 +55,13 @@ class PollPoller : public PosixEventPoller { bool CanTrackErrors() const override { return false; } ~PollPoller() override; + // Forkable + void PrepareFork() override; + void PostforkParent() override; + void PostforkChild() override; + + void Close(); + private: void Ref() { ref_count_.fetch_add(1, std::memory_order_relaxed); } void Unref() { @@ -83,6 +91,7 @@ class PollPoller : public PosixEventPoller { int num_poll_handles_ ABSL_GUARDED_BY(mu_); PollEventHandle* poll_handles_list_head_ ABSL_GUARDED_BY(mu_) = nullptr; std::unique_ptr wakeup_fd_; + bool closed_ ABSL_GUARDED_BY(mu_); }; // Return an instance of a poll based poller tied to the specified scheduler. diff --git a/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h b/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h new file mode 100644 index 0000000000000..c6eed183233d2 --- /dev/null +++ b/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h @@ -0,0 +1,197 @@ +// Copyright 2023 The 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_SRC_CORE_LIB_EVENT_ENGINE_POSIX_ENGINE_GRPC_POLLED_FD_POSIX_H +#define GRPC_SRC_CORE_LIB_EVENT_ENGINE_POSIX_ENGINE_GRPC_POLLED_FD_POSIX_H + +#include + +#include "src/core/lib/iomgr/port.h" + +#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) + +// IWYU pragma: no_include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/strings/str_cat.h" + +#include "src/core/lib/event_engine/grpc_polled_fd.h" +#include "src/core/lib/event_engine/posix_engine/event_poller.h" +#include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h" +#include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" +#include "src/core/lib/iomgr/error.h" + +namespace grpc_event_engine { +namespace experimental { + +class GrpcPolledFdPosix : public GrpcPolledFd { + public: + GrpcPolledFdPosix(ares_socket_t as, EventHandle* handle) + : name_(absl::StrCat("c-ares fd: ", static_cast(as))), + as_(as), + handle_(handle) {} + + ~GrpcPolledFdPosix() override { + // c-ares library will close the fd. This fd may be picked up immediately by + // another thread and should not be closed by the following OrphanHandle. + int phony_release_fd; + handle_->OrphanHandle(/*on_done=*/nullptr, &phony_release_fd, + "c-ares query finished"); + } + + void RegisterForOnReadableLocked( + absl::AnyInvocable read_closure) override { + handle_->NotifyOnRead(new PosixEngineClosure(std::move(read_closure), + /*is_permanent=*/false)); + } + + void RegisterForOnWriteableLocked( + absl::AnyInvocable write_closure) override { + handle_->NotifyOnWrite(new PosixEngineClosure(std::move(write_closure), + /*is_permanent=*/false)); + } + + bool IsFdStillReadableLocked() override { + size_t bytes_available = 0; + return ioctl(handle_->WrappedFd(), FIONREAD, &bytes_available) == 0 && + bytes_available > 0; + } + + void ShutdownLocked(grpc_error_handle error) override { + handle_->ShutdownHandle(error); + } + + ares_socket_t GetWrappedAresSocketLocked() override { return as_; } + + const char* GetName() const override { return name_.c_str(); } + + private: + const std::string name_; + const ares_socket_t as_; + EventHandle* handle_; +}; + +class GrpcPolledFdFactoryPosix : public GrpcPolledFdFactory { + public: + explicit GrpcPolledFdFactoryPosix(PosixEventPoller* poller) + : poller_(poller) {} + + ~GrpcPolledFdFactoryPosix() override { + for (auto& fd : owned_fds_) { + close(fd); + } + } + + GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as) override { + owned_fds_.insert(as); + return new GrpcPolledFdPosix( + as, + poller_->CreateHandle(as, "c-ares socket", poller_->CanTrackErrors())); + } + + void ConfigureAresChannelLocked(ares_channel channel) override { + ares_set_socket_functions(channel, &kSockFuncs, this); + ares_set_socket_configure_callback( + channel, &GrpcPolledFdFactoryPosix::ConfigureSocket, nullptr); + } + + private: + /// Overridden socket API for c-ares + static ares_socket_t Socket(int af, int type, int protocol, + void* /*user_data*/) { + return socket(af, type, protocol); + } + + /// Overridden connect API for c-ares + static int Connect(ares_socket_t as, const struct sockaddr* target, + ares_socklen_t target_len, void* /*user_data*/) { + return connect(as, target, target_len); + } + + /// Overridden writev API for c-ares + static ares_ssize_t WriteV(ares_socket_t as, const struct iovec* iov, + int iovec_count, void* /*user_data*/) { + return writev(as, iov, iovec_count); + } + + /// Overridden recvfrom API for c-ares + static ares_ssize_t RecvFrom(ares_socket_t as, void* data, size_t data_len, + int flags, struct sockaddr* from, + ares_socklen_t* from_len, void* /*user_data*/) { + return recvfrom(as, data, data_len, flags, from, from_len); + } + + /// Overridden close API for c-ares + static int Close(ares_socket_t as, void* user_data) { + GrpcPolledFdFactoryPosix* self = + static_cast(user_data); + if (self->owned_fds_.find(as) == self->owned_fds_.end()) { + // c-ares owns this fd, grpc has never seen it + return close(as); + } + return 0; + } + + /// Because we're using socket API overrides, c-ares won't + /// perform its typical configuration on the socket. See + /// https://github.com/c-ares/c-ares/blob/bad62225b7f6b278b92e8e85a255600b629ef517/src/lib/ares_process.c#L1018. + /// So we use the configure socket callback override and copy default + /// settings that c-ares would normally apply on posix platforms: + /// - non-blocking + /// - cloexec flag + /// - disable nagle + static int ConfigureSocket(ares_socket_t fd, int type, void* /*user_data*/) { + // clang-format off +#define RETURN_IF_ERROR(expr) if (!(expr).ok()) { return -1; } + // clang-format on + PosixSocketWrapper sock(fd); + RETURN_IF_ERROR(sock.SetSocketNonBlocking(1)); + RETURN_IF_ERROR(sock.SetSocketCloexec(1)); + if (type == SOCK_STREAM) { + RETURN_IF_ERROR(sock.SetSocketLowLatency(1)); + } + return 0; + } + + const struct ares_socket_functions kSockFuncs = { + &GrpcPolledFdFactoryPosix::Socket /* socket */, + &GrpcPolledFdFactoryPosix::Close /* close */, + &GrpcPolledFdFactoryPosix::Connect /* connect */, + &GrpcPolledFdFactoryPosix::RecvFrom /* recvfrom */, + &GrpcPolledFdFactoryPosix::WriteV /* writev */, + }; + + PosixEventPoller* poller_; + // fds that are used/owned by grpc - we (grpc) will close them rather than + // c-ares + std::unordered_set owned_fds_; +}; + +} // namespace experimental +} // namespace grpc_event_engine + +#endif // GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) +#endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_POSIX_ENGINE_GRPC_POLLED_FD_POSIX_H diff --git a/src/core/lib/event_engine/posix_engine/posix_endpoint.cc b/src/core/lib/event_engine/posix_engine/posix_endpoint.cc index 6d90c99c79dcb..0fc192c3e5bdb 100644 --- a/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +++ b/src/core/lib/event_engine/posix_engine/posix_endpoint.cc @@ -521,7 +521,7 @@ void PosixEndpointImpl::UpdateRcvLowat() { void PosixEndpointImpl::MaybeMakeReadSlices() { static const int kBigAlloc = 64 * 1024; static const int kSmallAlloc = 8 * 1024; - if (incoming_buffer_->Length() < static_cast(min_progress_size_)) { + if (incoming_buffer_->Length() < std::max(min_progress_size_, 1)) { size_t allocate_length = min_progress_size_; const size_t target_length = static_cast(target_length_); // If memory pressure is low and we think there will be more than @@ -531,8 +531,8 @@ void PosixEndpointImpl::MaybeMakeReadSlices() { if (low_memory_pressure && target_length > allocate_length) { allocate_length = target_length; } - int extra_wanted = - allocate_length - static_cast(incoming_buffer_->Length()); + int extra_wanted = std::max( + 1, allocate_length - static_cast(incoming_buffer_->Length())); if (extra_wanted >= (low_memory_pressure ? kSmallAlloc * 3 / 2 : kBigAlloc)) { while (extra_wanted > 0) { diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.cc b/src/core/lib/event_engine/posix_engine/posix_engine.cc index 0bb74bbab587d..8e71e435f9499 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.cc +++ b/src/core/lib/event_engine/posix_engine/posix_engine.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -37,8 +38,10 @@ #include #include "src/core/lib/debug/trace.h" +#include "src/core/lib/event_engine/grpc_polled_fd.h" #include "src/core/lib/event_engine/poller.h" #include "src/core/lib/event_engine/posix.h" +#include "src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h" #include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h" #include "src/core/lib/event_engine/posix_engine/timer.h" #include "src/core/lib/event_engine/tcp_socket_utils.h" @@ -487,9 +490,49 @@ EventEngine::TaskHandle PosixEventEngine::RunAfterInternal( return handle; } -std::unique_ptr PosixEventEngine::GetDNSResolver( - EventEngine::DNSResolver::ResolverOptions const& /*options*/) { +#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) + +PosixEventEngine::PosixDNSResolver::PosixDNSResolver( + grpc_core::OrphanablePtr ares_resolver) + : ares_resolver_(std::move(ares_resolver)) {} + +void PosixEventEngine::PosixDNSResolver::LookupHostname( + LookupHostnameCallback on_resolve, absl::string_view name, + absl::string_view default_port) { + ares_resolver_->LookupHostname(name, default_port, std::move(on_resolve)); +} + +void PosixEventEngine::PosixDNSResolver::LookupSRV(LookupSRVCallback on_resolve, + absl::string_view name) { + ares_resolver_->LookupSRV(name, std::move(on_resolve)); +} + +void PosixEventEngine::PosixDNSResolver::LookupTXT(LookupTXTCallback on_resolve, + absl::string_view name) { + ares_resolver_->LookupTXT(name, std::move(on_resolve)); +} + +#endif // GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) + +absl::StatusOr> +PosixEventEngine::GetDNSResolver( + const EventEngine::DNSResolver::ResolverOptions& options) { +#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) + auto ares_resolver = AresResolver::CreateAresResolver( + options.dns_server, + std::make_unique(poller_manager_->Poller()), + shared_from_this()); + if (!ares_resolver.ok()) { + return ares_resolver.status(); + } + return std::make_unique( + std::move(*ares_resolver)); +#else // GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) + // TODO(yijiem): Implement a basic A/AAAA-only native resolver in + // PosixEventEngine. + (void)options; grpc_core::Crash("unimplemented"); +#endif // GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) } bool PosixEventEngine::IsWorkerThread() { grpc_core::Crash("unimplemented"); } diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.h b/src/core/lib/event_engine/posix_engine/posix_engine.h index 815a663d3d0a5..bd28bde9509f5 100644 --- a/src/core/lib/event_engine/posix_engine/posix_engine.h +++ b/src/core/lib/event_engine/posix_engine/posix_engine.h @@ -34,11 +34,13 @@ #include #include +#include "src/core/lib/event_engine/ares_resolver.h" #include "src/core/lib/event_engine/handle_containers.h" #include "src/core/lib/event_engine/posix.h" #include "src/core/lib/event_engine/posix_engine/event_poller.h" #include "src/core/lib/event_engine/posix_engine/timer_manager.h" #include "src/core/lib/event_engine/thread_pool/thread_pool.h" +#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/port.h" #include "src/core/lib/surface/init_internally.h" @@ -138,7 +140,11 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport, public: class PosixDNSResolver : public EventEngine::DNSResolver { public: - ~PosixDNSResolver() override; + PosixDNSResolver() = delete; +#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) + explicit PosixDNSResolver( + grpc_core::OrphanablePtr ares_resolver); +#endif // GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) void LookupHostname(LookupHostnameCallback on_resolve, absl::string_view name, absl::string_view default_port) override; @@ -146,6 +152,11 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport, absl::string_view name) override; void LookupTXT(LookupTXTCallback on_resolve, absl::string_view name) override; + +#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) + private: + grpc_core::OrphanablePtr ares_resolver_; +#endif // GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_TCP) }; #ifdef GRPC_POSIX_SOCKET_TCP @@ -188,7 +199,7 @@ class PosixEventEngine final : public PosixEventEngineWithFdSupport, bool CancelConnect(ConnectionHandle handle) override; bool IsWorkerThread() override; - std::unique_ptr GetDNSResolver( + absl::StatusOr> GetDNSResolver( const DNSResolver::ResolverOptions& options) override; void Run(Closure* closure) override; void Run(absl::AnyInvocable closure) override; diff --git a/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc b/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc index 1841212d58ac1..326248cb84677 100644 --- a/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +++ b/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc @@ -27,6 +27,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/crash.h" // IWYU pragma: keep diff --git a/src/core/lib/event_engine/posix_engine/timer.h b/src/core/lib/event_engine/posix_engine/timer.h index c21a03dce10d2..9c9b220c41199 100644 --- a/src/core/lib/event_engine/posix_engine/timer.h +++ b/src/core/lib/event_engine/posix_engine/timer.h @@ -89,7 +89,7 @@ class TimerList { // timer has already fired, or if its closure is currently running. The // closure is guaranteed to run eventually if this method returns false. // Otherwise, this returns true, and the closure will not be run. - bool TimerCancel(Timer* timer) GRPC_MUST_USE_RESULT; + GRPC_MUST_USE_RESULT bool TimerCancel(Timer* timer); // Check for timers to be run, and return them. // Return nullopt if timers could not be checked due to contention with diff --git a/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc b/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc index be175fcbef9f9..c0aeae596095c 100644 --- a/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +++ b/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc @@ -29,6 +29,13 @@ namespace grpc_event_engine { namespace experimental { std::shared_ptr MakeThreadPool(size_t reserve_threads) { +// TODO(hork): remove when the listener flake is identified +#ifdef GPR_WINDOWS + if (grpc_core::IsEventEngineListenerEnabled()) { + return std::make_shared( + grpc_core::Clamp(gpr_cpu_num_cores(), 2u, 16u)); + } +#endif if (grpc_core::IsWorkStealingEnabled()) { return std::make_shared( grpc_core::Clamp(gpr_cpu_num_cores(), 2u, 16u)); diff --git a/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc b/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc index 89b34d919cd34..29eefb2facfd2 100644 --- a/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +++ b/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -39,10 +38,50 @@ #include "src/core/lib/event_engine/trace.h" #include "src/core/lib/event_engine/work_queue/basic_work_queue.h" #include "src/core/lib/event_engine/work_queue/work_queue.h" -#include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gprpp/thd.h" #include "src/core/lib/gprpp/time.h" +// ## Thread Pool Fork-handling +// +// Thread-safety needs special attention with regard to fork() calls. The +// Forkable system employs a pre- and post- fork callback system that does not +// guarantee any ordering of execution. On fork() events, the thread pool does +// the following: +// +// On pre-fork: +// * the WorkStealingThreadPool triggers all threads to exit, +// * all queued work is saved, and +// * all threads will are down, including the Lifeguard thread. +// +// On post-fork: +// * all threads are restarted, including the Lifeguard thread, and +// * all previously-saved work is enqueued for execution. +// +// However, the queue may may get into trouble if one thread is attempting to +// restart the thread pool while another thread is shutting it down. For that +// reason, Quiesce and Start must be thread-safe, and Quiesce must wait for the +// pool to be in a fully started state before it is allowed to continue. +// Consider this potential ordering of events between Start and Quiesce: +// +// ┌──────────┐ +// │ Thread 1 │ +// └────┬─────┘ ┌──────────┐ +// │ │ Thread 2 │ +// ▼ └────┬─────┘ +// Start() │ +// │ ▼ +// │ Quiesce() +// │ Wait for worker threads to exit +// │ Wait for the lifeguard thread to exit +// ▼ +// Start the Lifeguard thread +// Start the worker threads +// +// Thread 2 will find no worker threads, and it will then want to wait on a +// non-existent Lifeguard thread to finish. Trying a simple +// `lifeguard_thread_.Join()` leads to memory access errors. This implementation +// uses Notifications to coordinate startup and shutdown states. + namespace grpc_event_engine { namespace experimental { @@ -169,16 +208,13 @@ void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Quiesce() { // Note that if this is a threadpool thread then we won't exit this thread // until all other threads have exited, so we need to wait for just one thread // running instead of zero. - gpr_cycle_counter start_time = gpr_get_cycle_counter(); bool is_threadpool_thread = g_local_queue != nullptr; thread_count()->BlockUntilThreadCount(CounterType::kLivingThreadCount, is_threadpool_thread ? 1 : 0, "shutting down", work_signal()); GPR_ASSERT(queue_.Empty()); quiesced_.store(true, std::memory_order_relaxed); - lifeguard_.BlockUntilShutdown(); - GRPC_EVENT_ENGINE_TRACE("%ld cycles spent quiescing the pool", - std::lround(gpr_get_cycle_counter() - start_time)); + lifeguard_.BlockUntilShutdownAndReset(); } bool WorkStealingThreadPool::WorkStealingThreadPoolImpl::SetThrottled( @@ -215,7 +251,7 @@ void WorkStealingThreadPool::WorkStealingThreadPoolImpl::PrepareFork() { SetForking(true); thread_count()->BlockUntilThreadCount(CounterType::kLivingThreadCount, 0, "forking", &work_signal_); - lifeguard_.BlockUntilShutdown(); + lifeguard_.BlockUntilShutdownAndReset(); } void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Postfork() { @@ -231,13 +267,14 @@ WorkStealingThreadPool::WorkStealingThreadPoolImpl::Lifeguard::Lifeguard( backoff_(grpc_core::BackOff::Options() .set_initial_backoff(kLifeguardMinSleepBetweenChecks) .set_max_backoff(kLifeguardMaxSleepBetweenChecks) - .set_multiplier(1.3)) {} + .set_multiplier(1.3)), + lifeguard_should_shut_down_(std::make_unique()), + lifeguard_is_shut_down_(std::make_unique()) {} void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Lifeguard::Start() { // lifeguard_running_ is set early to avoid a quiesce race while the // lifeguard is still starting up. - grpc_core::MutexLock lock(&lifeguard_shutdown_mu_); - lifeguard_running_ = true; + lifeguard_running_.store(true); grpc_core::Thread( "lifeguard", [](void* arg) { @@ -251,7 +288,6 @@ void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Lifeguard::Start() { void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Lifeguard:: LifeguardMain() { - grpc_core::MutexLock lock(&lifeguard_shutdown_mu_); while (true) { if (pool_->IsForking()) break; // If the pool is shut down, loop quickly until quiesced. Otherwise, @@ -259,29 +295,33 @@ void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Lifeguard:: if (pool_->IsShutdown()) { if (pool_->IsQuiesced()) break; } else { - lifeguard_shutdown_cv_.WaitWithTimeout( - &lifeguard_shutdown_mu_, + lifeguard_should_shut_down_->WaitForNotificationWithTimeout( absl::Milliseconds( (backoff_.NextAttemptTime() - grpc_core::Timestamp::Now()) .millis())); } MaybeStartNewThread(); } - lifeguard_running_ = false; - lifeguard_shutdown_cv_.Signal(); + lifeguard_running_.store(false, std::memory_order_relaxed); + lifeguard_is_shut_down_->Notify(); } void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Lifeguard:: - BlockUntilShutdown() { - grpc_core::MutexLock lock(&lifeguard_shutdown_mu_); - while (lifeguard_running_) { - lifeguard_shutdown_cv_.Signal(); - lifeguard_shutdown_cv_.WaitWithTimeout( - &lifeguard_shutdown_mu_, absl::Seconds(kBlockingQuiesceLogRateSeconds)); + BlockUntilShutdownAndReset() { + lifeguard_should_shut_down_->Notify(); + while (lifeguard_running_.load(std::memory_order_relaxed)) { GRPC_LOG_EVERY_N_SEC_DELAYED(kBlockingQuiesceLogRateSeconds, GPR_DEBUG, "%s", "Waiting for lifeguard thread to shut down"); + lifeguard_is_shut_down_->WaitForNotification(); } + // Do an additional wait in case this method races with LifeguardMain's + // shutdown. This should return immediately if the lifeguard is already shut + // down. + lifeguard_is_shut_down_->WaitForNotification(); + backoff_.Reset(); + lifeguard_should_shut_down_ = std::make_unique(); + lifeguard_is_shut_down_ = std::make_unique(); } void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Lifeguard:: @@ -406,6 +446,7 @@ bool WorkStealingThreadPool::ThreadState::Step() { if (pool_->IsShutdown()) break; bool timed_out = pool_->work_signal()->WaitWithTimeout( backoff_.NextAttemptTime() - grpc_core::Timestamp::Now()); + if (pool_->IsForking() || pool_->IsShutdown()) break; // Quit a thread if the pool has more than it requires, and this thread // has been idle long enough. if (timed_out && @@ -472,6 +513,7 @@ void WorkStealingThreadPool::ThreadCount::BlockUntilThreadCount( CounterType counter_type, size_t desired_threads, const char* why, WorkSignal* work_signal) { // Wait for all threads to exit. + work_signal->SignalAll(); while (true) { auto curr_threads = WaitForCountChange( counter_type, desired_threads, @@ -482,7 +524,6 @@ void WorkStealingThreadPool::ThreadCount::BlockUntilThreadCount( "Waiting for thread pool to idle before %s. (%" PRIdPTR " to %" PRIdPTR ")", why, curr_threads, desired_threads); - work_signal->SignalAll(); } } diff --git a/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h b/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h index 9f933eb563bd4..96afc8ab5404c 100644 --- a/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +++ b/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h @@ -36,6 +36,7 @@ #include "src/core/lib/event_engine/thread_pool/thread_pool.h" #include "src/core/lib/event_engine/work_queue/basic_work_queue.h" #include "src/core/lib/event_engine/work_queue/work_queue.h" +#include "src/core/lib/gprpp/notification.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/gprpp/time.h" @@ -202,7 +203,8 @@ class WorkStealingThreadPool final : public ThreadPool { // Start the lifeguard thread. void Start(); // Block until the lifeguard thread is shut down. - void BlockUntilShutdown(); + // Afterwards, reset the lifeguard state so it can start again cleanly. + void BlockUntilShutdownAndReset(); private: // The main body of the lifeguard thread. @@ -213,10 +215,9 @@ class WorkStealingThreadPool final : public ThreadPool { WorkStealingThreadPoolImpl* pool_; grpc_core::BackOff backoff_; // Used for signaling that the lifeguard thread has stopped running. - grpc_core::Mutex lifeguard_shutdown_mu_; - bool lifeguard_running_ ABSL_GUARDED_BY(lifeguard_shutdown_mu_) = false; - grpc_core::CondVar lifeguard_shutdown_cv_ - ABSL_GUARDED_BY(lifeguard_shutdown_mu_); + std::unique_ptr lifeguard_should_shut_down_; + std::unique_ptr lifeguard_is_shut_down_; + std::atomic lifeguard_running_{false}; }; const size_t reserve_threads_; diff --git a/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc b/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc index 81794e02cd075..4beb7b68bcfff 100644 --- a/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +++ b/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc @@ -82,9 +82,10 @@ bool ThreadyEventEngine::IsWorkerThread() { grpc_core::Crash("we should remove this"); } -std::unique_ptr ThreadyEventEngine::GetDNSResolver( +absl::StatusOr> +ThreadyEventEngine::GetDNSResolver( const DNSResolver::ResolverOptions& options) { - return std::make_unique(impl_->GetDNSResolver(options)); + return std::make_unique(*impl_->GetDNSResolver(options)); } void ThreadyEventEngine::Run(Closure* closure) { diff --git a/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h b/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h index bcb972a8d65e9..23b79dc62cfed 100644 --- a/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +++ b/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h @@ -63,7 +63,7 @@ class ThreadyEventEngine final : public EventEngine { bool IsWorkerThread() override; - std::unique_ptr GetDNSResolver( + absl::StatusOr> GetDNSResolver( const DNSResolver::ResolverOptions& options) override; void Run(Closure* closure) override; diff --git a/src/core/lib/event_engine/windows/windows_endpoint.cc b/src/core/lib/event_engine/windows/windows_endpoint.cc index 05971bebdbdab..85cd968e8bce8 100644 --- a/src/core/lib/event_engine/windows/windows_endpoint.cc +++ b/src/core/lib/event_engine/windows/windows_endpoint.cc @@ -284,6 +284,7 @@ void WindowsEndpoint::HandleWriteClosure::Prime( void WindowsEndpoint::HandleReadClosure::Run() { // Deletes the shared_ptr when this closure returns + // Note that the endpoint may have already been destroyed. auto io_state = std::move(io_state_); GRPC_EVENT_ENGINE_ENDPOINT_TRACE("WindowsEndpoint::%p Handling Read Event", io_state->endpoint); @@ -297,10 +298,8 @@ void WindowsEndpoint::HandleReadClosure::Run() { if (result.bytes_transferred == 0) { // Either the endpoint is shut down or we've seen the end of the stream if (grpc_event_engine_endpoint_data_trace.enabled()) { - DumpSliceBuffer( - buffer_, absl::StrFormat("WindowsEndpoint::%p READ (peer=%s)", - io_state->endpoint, - io_state->endpoint->peer_address_string_)); + DumpSliceBuffer(buffer_, absl::StrFormat("WindowsEndpoint::%p READ", + io_state->endpoint)); } status = absl::UnavailableError("End of TCP stream"); grpc_core::StatusSetInt(&status, grpc_core::StatusIntProperty::kRpcStatus, diff --git a/src/core/lib/event_engine/windows/windows_engine.cc b/src/core/lib/event_engine/windows/windows_engine.cc index 435b9c32197ab..552488639f130 100644 --- a/src/core/lib/event_engine/windows/windows_engine.cc +++ b/src/core/lib/event_engine/windows/windows_engine.cc @@ -194,7 +194,8 @@ EventEngine::TaskHandle WindowsEventEngine::RunAfterInternal( return handle; } -std::unique_ptr WindowsEventEngine::GetDNSResolver( +absl::StatusOr> +WindowsEventEngine::GetDNSResolver( EventEngine::DNSResolver::ResolverOptions const& /*options*/) { grpc_core::Crash("unimplemented"); } diff --git a/src/core/lib/event_engine/windows/windows_engine.h b/src/core/lib/event_engine/windows/windows_engine.h index 67de37211892d..5fed3ae95f0ce 100644 --- a/src/core/lib/event_engine/windows/windows_engine.h +++ b/src/core/lib/event_engine/windows/windows_engine.h @@ -75,7 +75,7 @@ class WindowsEventEngine : public EventEngine, bool CancelConnect(ConnectionHandle handle) override; bool IsWorkerThread() override; - std::unique_ptr GetDNSResolver( + absl::StatusOr> GetDNSResolver( const DNSResolver::ResolverOptions& options) override; void Run(Closure* closure) override; void Run(absl::AnyInvocable closure) override; diff --git a/src/core/lib/experiments/config.cc b/src/core/lib/experiments/config.cc index 891229bc151be..e65a623f180fe 100644 --- a/src/core/lib/experiments/config.cc +++ b/src/core/lib/experiments/config.cc @@ -27,6 +27,7 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" +#include "absl/strings/strip.h" #include @@ -66,6 +67,19 @@ class TestExperiments { enabled_[i] = experiment_metadata[i].default_value; } } + // For each comma-separated experiment in the global config: + for (auto experiment : absl::StrSplit(ConfigVars::Get().Experiments(), ',', + absl::SkipWhitespace())) { + // Enable unless prefixed with '-' (=> disable). + bool enable = !absl::ConsumePrefix(&experiment, "-"); + // See if we can find the experiment in the list in this binary. + for (size_t i = 0; i < num_experiments; i++) { + if (experiment == experiment_metadata[i].name) { + enabled_[i] = enable; + break; + } + } + } } // Overloading [] operator to access elements in array style diff --git a/src/core/lib/experiments/experiments.cc b/src/core/lib/experiments/experiments.cc index ca97b7ce0a51f..25fad0ac7026a 100644 --- a/src/core/lib/experiments/experiments.cc +++ b/src/core/lib/experiments/experiments.cc @@ -97,6 +97,15 @@ const char* const description_keepalive_fix = "Allows overriding keepalive_permit_without_calls. Refer " "https://github.com/grpc/grpc/pull/33428 for more information."; const char* const additional_constraints_keepalive_fix = "{}"; +const char* const description_keepalive_server_fix = + "Allows overriding keepalive_permit_without_calls for servers. Refer " + "https://github.com/grpc/grpc/pull/33917 for more information."; +const char* const additional_constraints_keepalive_server_fix = "{}"; +#ifdef NDEBUG +const bool kDefaultForDebugOnly = false; +#else +const bool kDefaultForDebugOnly = true; +#endif } // namespace namespace grpc_core { @@ -136,7 +145,7 @@ const ExperimentMetadata g_experiment_metadata[] = { {"event_engine_dns", description_event_engine_dns, additional_constraints_event_engine_dns, false, false}, {"work_stealing", description_work_stealing, - additional_constraints_work_stealing, false, false}, + additional_constraints_work_stealing, kDefaultForDebugOnly, false}, {"client_privacy", description_client_privacy, additional_constraints_client_privacy, false, false}, {"canary_client_privacy", description_canary_client_privacy, @@ -144,9 +153,11 @@ const ExperimentMetadata g_experiment_metadata[] = { {"server_privacy", description_server_privacy, additional_constraints_server_privacy, false, false}, {"unique_metadata_strings", description_unique_metadata_strings, - additional_constraints_unique_metadata_strings, false, true}, + additional_constraints_unique_metadata_strings, true, true}, {"keepalive_fix", description_keepalive_fix, additional_constraints_keepalive_fix, false, false}, + {"keepalive_server_fix", description_keepalive_server_fix, + additional_constraints_keepalive_server_fix, false, false}, }; } // namespace grpc_core @@ -228,6 +239,15 @@ const char* const description_keepalive_fix = "Allows overriding keepalive_permit_without_calls. Refer " "https://github.com/grpc/grpc/pull/33428 for more information."; const char* const additional_constraints_keepalive_fix = "{}"; +const char* const description_keepalive_server_fix = + "Allows overriding keepalive_permit_without_calls for servers. Refer " + "https://github.com/grpc/grpc/pull/33917 for more information."; +const char* const additional_constraints_keepalive_server_fix = "{}"; +#ifdef NDEBUG +const bool kDefaultForDebugOnly = false; +#else +const bool kDefaultForDebugOnly = true; +#endif } // namespace namespace grpc_core { @@ -267,7 +287,7 @@ const ExperimentMetadata g_experiment_metadata[] = { {"event_engine_dns", description_event_engine_dns, additional_constraints_event_engine_dns, false, false}, {"work_stealing", description_work_stealing, - additional_constraints_work_stealing, false, false}, + additional_constraints_work_stealing, kDefaultForDebugOnly, false}, {"client_privacy", description_client_privacy, additional_constraints_client_privacy, false, false}, {"canary_client_privacy", description_canary_client_privacy, @@ -275,9 +295,11 @@ const ExperimentMetadata g_experiment_metadata[] = { {"server_privacy", description_server_privacy, additional_constraints_server_privacy, false, false}, {"unique_metadata_strings", description_unique_metadata_strings, - additional_constraints_unique_metadata_strings, false, true}, + additional_constraints_unique_metadata_strings, true, true}, {"keepalive_fix", description_keepalive_fix, additional_constraints_keepalive_fix, false, false}, + {"keepalive_server_fix", description_keepalive_server_fix, + additional_constraints_keepalive_server_fix, false, false}, }; } // namespace grpc_core @@ -359,6 +381,15 @@ const char* const description_keepalive_fix = "Allows overriding keepalive_permit_without_calls. Refer " "https://github.com/grpc/grpc/pull/33428 for more information."; const char* const additional_constraints_keepalive_fix = "{}"; +const char* const description_keepalive_server_fix = + "Allows overriding keepalive_permit_without_calls for servers. Refer " + "https://github.com/grpc/grpc/pull/33917 for more information."; +const char* const additional_constraints_keepalive_server_fix = "{}"; +#ifdef NDEBUG +const bool kDefaultForDebugOnly = false; +#else +const bool kDefaultForDebugOnly = true; +#endif } // namespace namespace grpc_core { @@ -398,7 +429,7 @@ const ExperimentMetadata g_experiment_metadata[] = { {"event_engine_dns", description_event_engine_dns, additional_constraints_event_engine_dns, false, false}, {"work_stealing", description_work_stealing, - additional_constraints_work_stealing, false, false}, + additional_constraints_work_stealing, kDefaultForDebugOnly, false}, {"client_privacy", description_client_privacy, additional_constraints_client_privacy, false, false}, {"canary_client_privacy", description_canary_client_privacy, @@ -406,9 +437,11 @@ const ExperimentMetadata g_experiment_metadata[] = { {"server_privacy", description_server_privacy, additional_constraints_server_privacy, false, false}, {"unique_metadata_strings", description_unique_metadata_strings, - additional_constraints_unique_metadata_strings, false, true}, + additional_constraints_unique_metadata_strings, true, true}, {"keepalive_fix", description_keepalive_fix, additional_constraints_keepalive_fix, false, false}, + {"keepalive_server_fix", description_keepalive_server_fix, + additional_constraints_keepalive_server_fix, false, false}, }; } // namespace grpc_core diff --git a/src/core/lib/experiments/experiments.h b/src/core/lib/experiments/experiments.h index f718267df7c11..1200524af8537 100644 --- a/src/core/lib/experiments/experiments.h +++ b/src/core/lib/experiments/experiments.h @@ -75,12 +75,23 @@ inline bool IsEventEngineListenerEnabled() { return false; } inline bool IsScheduleCancellationOverWriteEnabled() { return false; } inline bool IsTraceRecordCallopsEnabled() { return false; } inline bool IsEventEngineDnsEnabled() { return false; } -inline bool IsWorkStealingEnabled() { return false; } +#ifndef NDEBUG +#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_STEALING +#endif +inline bool IsWorkStealingEnabled() { +#ifdef NDEBUG + return false; +#else + return true; +#endif +} inline bool IsClientPrivacyEnabled() { return false; } inline bool IsCanaryClientPrivacyEnabled() { return false; } inline bool IsServerPrivacyEnabled() { return false; } -inline bool IsUniqueMetadataStringsEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_UNIQUE_METADATA_STRINGS +inline bool IsUniqueMetadataStringsEnabled() { return true; } inline bool IsKeepaliveFixEnabled() { return false; } +inline bool IsKeepaliveServerFixEnabled() { return false; } #elif defined(GPR_WINDOWS) inline bool IsTcpFrameSizeTuningEnabled() { return false; } @@ -99,12 +110,23 @@ inline bool IsEventEngineListenerEnabled() { return false; } inline bool IsScheduleCancellationOverWriteEnabled() { return false; } inline bool IsTraceRecordCallopsEnabled() { return false; } inline bool IsEventEngineDnsEnabled() { return false; } -inline bool IsWorkStealingEnabled() { return false; } +#ifndef NDEBUG +#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_STEALING +#endif +inline bool IsWorkStealingEnabled() { +#ifdef NDEBUG + return false; +#else + return true; +#endif +} inline bool IsClientPrivacyEnabled() { return false; } inline bool IsCanaryClientPrivacyEnabled() { return false; } inline bool IsServerPrivacyEnabled() { return false; } -inline bool IsUniqueMetadataStringsEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_UNIQUE_METADATA_STRINGS +inline bool IsUniqueMetadataStringsEnabled() { return true; } inline bool IsKeepaliveFixEnabled() { return false; } +inline bool IsKeepaliveServerFixEnabled() { return false; } #else inline bool IsTcpFrameSizeTuningEnabled() { return false; } @@ -123,12 +145,23 @@ inline bool IsEventEngineListenerEnabled() { return false; } inline bool IsScheduleCancellationOverWriteEnabled() { return false; } inline bool IsTraceRecordCallopsEnabled() { return false; } inline bool IsEventEngineDnsEnabled() { return false; } -inline bool IsWorkStealingEnabled() { return false; } +#ifndef NDEBUG +#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_STEALING +#endif +inline bool IsWorkStealingEnabled() { +#ifdef NDEBUG + return false; +#else + return true; +#endif +} inline bool IsClientPrivacyEnabled() { return false; } inline bool IsCanaryClientPrivacyEnabled() { return false; } inline bool IsServerPrivacyEnabled() { return false; } -inline bool IsUniqueMetadataStringsEnabled() { return false; } +#define GRPC_EXPERIMENT_IS_INCLUDED_UNIQUE_METADATA_STRINGS +inline bool IsUniqueMetadataStringsEnabled() { return true; } inline bool IsKeepaliveFixEnabled() { return false; } +inline bool IsKeepaliveServerFixEnabled() { return false; } #endif #else @@ -182,8 +215,10 @@ inline bool IsServerPrivacyEnabled() { return IsExperimentEnabled(18); } inline bool IsUniqueMetadataStringsEnabled() { return IsExperimentEnabled(19); } #define GRPC_EXPERIMENT_IS_INCLUDED_KEEPALIVE_FIX inline bool IsKeepaliveFixEnabled() { return IsExperimentEnabled(20); } +#define GRPC_EXPERIMENT_IS_INCLUDED_KEEPALIVE_SERVER_FIX +inline bool IsKeepaliveServerFixEnabled() { return IsExperimentEnabled(21); } -constexpr const size_t kNumExperiments = 21; +constexpr const size_t kNumExperiments = 22; extern const ExperimentMetadata g_experiment_metadata[kNumExperiments]; #endif diff --git a/src/core/lib/experiments/experiments.yaml b/src/core/lib/experiments/experiments.yaml index a8051ee067fa4..27cb8f2d9089c 100644 --- a/src/core/lib/experiments/experiments.yaml +++ b/src/core/lib/experiments/experiments.yaml @@ -39,12 +39,12 @@ TCP would not indicate completion of a read operation until a specified number of bytes have been read over the socket. Buffers are also allocated according to estimated RPC sizes. - expiry: 2023/08/01 + expiry: 2024/01/01 owner: vigneshbabu@google.com test_tags: ["endpoint_test", "flow_control_test"] - name: tcp_rcv_lowat description: Use SO_RCVLOWAT to avoid wakeups on the read path. - expiry: 2023/08/01 + expiry: 2024/01/01 owner: vigneshbabu@google.com test_tags: ["endpoint_test", "flow_control_test"] - name: peer_state_based_framing @@ -52,7 +52,7 @@ If set, the max sizes of frames sent to lower layers is controlled based on the peer's memory pressure which is reflected in its max http2 frame size. - expiry: 2023/08/01 + expiry: 2024/01/01 owner: vigneshbabu@google.com test_tags: ["flow_control_test"] - name: memory_pressure_controller @@ -93,7 +93,7 @@ (ie when all filters in a stack are promise based) expiry: 2023/11/01 owner: ctiller@google.com - test_tags: ["core_end2end_test", "cpp_end2end_test", "xds_end2end_test"] + test_tags: ["core_end2end_test", "cpp_end2end_test", "xds_end2end_test", "logging_test"] - name: transport_supplies_client_latency description: If set, use the transport represented value for client latency in opencensus expiry: 2023/09/01 @@ -101,17 +101,17 @@ test_tags: [census_test] - name: event_engine_listener description: Use EventEngine listeners instead of iomgr's grpc_tcp_server - expiry: 2023/10/01 + expiry: 2024/01/01 owner: vigneshbabu@google.com test_tags: ["core_end2end_test", "event_engine_listener_test"] - name: schedule_cancellation_over_write description: Allow cancellation op to be scheduled over a write - expiry: 2023/10/01 + expiry: 2024/01/01 owner: vigneshbabu@google.com test_tags: [] - name: trace_record_callops description: Enables tracing of call batch initiation and completion. - expiry: 2023/10/01 + expiry: 2024/01/01 owner: vigneshbabu@google.com test_tags: [] - name: event_engine_dns @@ -119,12 +119,12 @@ If set, use EventEngine DNSResolver for client channel resolution expiry: 2023/10/01 owner: yijiem@google.com - test_tags: [] + test_tags: ["cancel_ares_query_test", "resolver_component_tests_runner_invoker"] allow_in_fuzzing_config: false - name: work_stealing description: If set, use a work stealing thread pool implementation in EventEngine - expiry: 2023/08/01 + expiry: 2023/10/01 owner: hork@google.com test_tags: ["core_end2end_test"] allow_in_fuzzing_config: false @@ -156,7 +156,7 @@ lifetimes to be extended leading to memory bloat. expiry: 2023/11/01 owner: ctiller@google.com - test_tags: ["core_end2end_test"] + test_tags: [] allow_in_fuzzing_config: true - name: keepalive_fix description: @@ -166,3 +166,11 @@ owner: yashkt@google.com test_tags: [] allow_in_fuzzing_config: false +- name: keepalive_server_fix + description: + Allows overriding keepalive_permit_without_calls for servers. + Refer https://github.com/grpc/grpc/pull/33917 for more information. + expiry: 2023/09/07 + owner: yashkt@google.com + test_tags: [] + allow_in_fuzzing_config: false diff --git a/src/core/lib/experiments/rollouts.yaml b/src/core/lib/experiments/rollouts.yaml index 6a80638b6c90f..9261959e1b544 100644 --- a/src/core/lib/experiments/rollouts.yaml +++ b/src/core/lib/experiments/rollouts.yaml @@ -33,7 +33,7 @@ # ios: broken # windows: false # posix: debug -# +# # Supported platforms: ios, windows, posix - name: tcp_frame_size_tuning @@ -47,7 +47,13 @@ - name: unconstrained_max_quota_buffer_size default: false - name: event_engine_client - default: false + default: + # not tested on iOS at all + ios: broken + posix: false + # TODO(hork): resolve when the client end2end test flake rate reduces to + # a tolerable amount. + windows: broken - name: monitoring_experiment default: true - name: promise_based_client_call @@ -65,9 +71,15 @@ - name: trace_record_callops default: false - name: event_engine_dns - default: false + default: + # not tested on iOS at all + ios: broken + posix: false + # TODO(yijiem): resolve when the WindowsEventEngine DNS Resolver is + # implemented + windows: broken - name: work_stealing - default: false + default: debug - name: client_privacy default: false - name: canary_client_privacy @@ -75,6 +87,8 @@ - name: server_privacy default: false - name: unique_metadata_strings - default: false + default: true - name: keepalive_fix default: false +- name: keepalive_server_fix + default: false diff --git a/test/core/util/subprocess.h b/src/core/lib/gpr/subprocess.h similarity index 68% rename from test/core/util/subprocess.h rename to src/core/lib/gpr/subprocess.h index a46be258516b0..71d4796fde6f2 100644 --- a/test/core/util/subprocess.h +++ b/src/core/lib/gpr/subprocess.h @@ -16,17 +16,26 @@ // // -#ifndef GRPC_TEST_CORE_UTIL_SUBPROCESS_H -#define GRPC_TEST_CORE_UTIL_SUBPROCESS_H +#ifndef GRPC_SRC_CORE_LIB_GPR_SUBPROCESS_H +#define GRPC_SRC_CORE_LIB_GPR_SUBPROCESS_H #include +#include + typedef struct gpr_subprocess gpr_subprocess; /// .exe on windows, empty on unices const char* gpr_subprocess_binary_extension(); gpr_subprocess* gpr_subprocess_create(int argc, const char** argv); + +gpr_subprocess* gpr_subprocess_create_with_envp(int argc, const char** argv, + int envc, const char** envp); + +// communicate to the subprocess via stdin, stdout and stderr +bool gpr_subprocess_communicate(gpr_subprocess* p, std::string& input_data, + std::string* output_data, std::string* error); /// if subprocess has not been joined, kill it void gpr_subprocess_destroy(gpr_subprocess* p); /// returns exit status; can be called at most once @@ -34,4 +43,4 @@ int gpr_subprocess_join(gpr_subprocess* p); void gpr_subprocess_interrupt(gpr_subprocess* p); int gpr_subprocess_get_process_id(gpr_subprocess* p); -#endif // GRPC_TEST_CORE_UTIL_SUBPROCESS_H +#endif // GRPC_SRC_CORE_LIB_GPR_SUBPROCESS_H diff --git a/src/core/lib/gpr/subprocess_posix.cc b/src/core/lib/gpr/subprocess_posix.cc new file mode 100644 index 0000000000000..5444bd822011b --- /dev/null +++ b/src/core/lib/gpr/subprocess_posix.cc @@ -0,0 +1,252 @@ +// +// +// Copyright 2015 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 + +#ifdef GPR_POSIX_SUBPROCESS + +#include +#include +#include +#include +#include + +#include + +#include "absl/strings/substitute.h" + +#include +#include + +#include "src/core/lib/gpr/subprocess.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/gprpp/strerror.h" + +struct gpr_subprocess { + int pid; + bool joined; + int child_stdin_; + int child_stdout_; +}; + +const char* gpr_subprocess_binary_extension() { return ""; } + +gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { + gpr_subprocess* r; + int pid; + char** exec_args; + pid = fork(); + if (pid == -1) { + return nullptr; + } else if (pid == 0) { + exec_args = static_cast( + gpr_malloc((static_cast(argc) + 1) * sizeof(char*))); + memcpy(exec_args, argv, static_cast(argc) * sizeof(char*)); + exec_args[argc] = nullptr; + execv(exec_args[0], exec_args); + // if we reach here, an error has occurred + gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], + grpc_core::StrError(errno).c_str()); + _exit(1); + } else { + r = grpc_core::Zalloc(); + r->pid = pid; + r->child_stdin_ = -1; + r->child_stdout_ = -1; + return r; + } +} + +gpr_subprocess* gpr_subprocess_create_with_envp(int argc, const char** argv, + int envc, const char** envp) { + gpr_subprocess* r; + int pid; + char **exec_args, **envp_args; + int stdin_pipe[2]; + int stdout_pipe[2]; + int p0 = pipe(stdin_pipe); + int p1 = pipe(stdout_pipe); + GPR_ASSERT(p0 != -1); + GPR_ASSERT(p1 != -1); + pid = fork(); + if (pid == -1) { + return nullptr; + } else if (pid == 0) { + dup2(stdin_pipe[0], STDIN_FILENO); + dup2(stdout_pipe[1], STDOUT_FILENO); + close(stdin_pipe[0]); + close(stdin_pipe[1]); + close(stdout_pipe[0]); + close(stdout_pipe[1]); + exec_args = static_cast( + gpr_malloc((static_cast(argc) + 1) * sizeof(char*))); + memcpy(exec_args, argv, static_cast(argc) * sizeof(char*)); + exec_args[argc] = nullptr; + envp_args = static_cast( + gpr_malloc((static_cast(envc) + 1) * sizeof(char*))); + memcpy(envp_args, envp, static_cast(envc) * sizeof(char*)); + envp_args[envc] = nullptr; + execve(exec_args[0], exec_args, envp_args); + // if we reach here, an error has occurred + gpr_log(GPR_ERROR, "execvpe '%s' failed: %s", exec_args[0], + grpc_core::StrError(errno).c_str()); + _exit(1); + } else { + r = grpc_core::Zalloc(); + r->pid = pid; + close(stdin_pipe[0]); + close(stdout_pipe[1]); + r->child_stdin_ = stdin_pipe[1]; + r->child_stdout_ = stdout_pipe[0]; + return r; + } +} + +bool gpr_subprocess_communicate(gpr_subprocess* p, std::string& input_data, + std::string* output_data, std::string* error) { + typedef void SignalHandler(int); + + // Make sure SIGPIPE is disabled so that if the child dies it doesn't kill us. + SignalHandler* old_pipe_handler = signal(SIGPIPE, SIG_IGN); + + int input_pos = 0; + int max_fd = std::max(p->child_stdin_, p->child_stdout_); + + while (p->child_stdout_ != -1) { + fd_set read_fds; + fd_set write_fds; + FD_ZERO(&read_fds); + FD_ZERO(&write_fds); + if (p->child_stdout_ != -1) { + FD_SET(p->child_stdout_, &read_fds); + } + if (p->child_stdin_ != -1) { + FD_SET(p->child_stdin_, &write_fds); + } + + if (select(max_fd + 1, &read_fds, &write_fds, nullptr, nullptr) < 0) { + if (errno == EINTR) { + // Interrupted by signal. Try again. + continue; + } else { + std::cerr << "select: " << strerror(errno) << std::endl; + GPR_ASSERT(0); + } + } + + if (p->child_stdin_ != -1 && FD_ISSET(p->child_stdin_, &write_fds)) { + int n = write(p->child_stdin_, input_data.data() + input_pos, + input_data.size() - input_pos); + if (n < 0) { + // Child closed pipe. Presumably it will report an error later. + // Pretend we're done for now. + input_pos = input_data.size(); + } else { + input_pos += n; + } + + if (input_pos == static_cast(input_data.size())) { + // We're done writing. Close. + close(p->child_stdin_); + p->child_stdin_ = -1; + } + } + + if (p->child_stdout_ != -1 && FD_ISSET(p->child_stdout_, &read_fds)) { + char buffer[4096]; + int n = read(p->child_stdout_, buffer, sizeof(buffer)); + + if (n > 0) { + output_data->append(buffer, static_cast(n)); + } else { + // We're done reading. Close. + close(p->child_stdout_); + p->child_stdout_ = -1; + } + } + } + + if (p->child_stdin_ != -1) { + // Child did not finish reading input before it closed the output. + // Presumably it exited with an error. + close(p->child_stdin_); + p->child_stdin_ = -1; + } + + int status; + while (waitpid(p->pid, &status, 0) == -1) { + if (errno != EINTR) { + std::cerr << "waitpid: " << strerror(errno) << std::endl; + GPR_ASSERT(0); + } + } + + // Restore SIGPIPE handling. + signal(SIGPIPE, old_pipe_handler); + + if (WIFEXITED(status)) { + if (WEXITSTATUS(status) != 0) { + int error_code = WEXITSTATUS(status); + *error = + absl::Substitute("Plugin failed with status code $0.", error_code); + return false; + } + } else if (WIFSIGNALED(status)) { + int signal = WTERMSIG(status); + *error = absl::Substitute("Plugin killed by signal $0.", signal); + return false; + } else { + *error = "Neither WEXITSTATUS nor WTERMSIG is true?"; + return false; + } + + return true; +} + +void gpr_subprocess_destroy(gpr_subprocess* p) { + if (!p->joined) { + kill(p->pid, SIGKILL); + gpr_subprocess_join(p); + } + gpr_free(p); +} + +int gpr_subprocess_join(gpr_subprocess* p) { + int status; +retry: + if (waitpid(p->pid, &status, 0) == -1) { + if (errno == EINTR) { + goto retry; + } + gpr_log(GPR_ERROR, "waitpid failed for pid %d: %s", p->pid, + grpc_core::StrError(errno).c_str()); + return -1; + } + p->joined = true; + return status; +} + +void gpr_subprocess_interrupt(gpr_subprocess* p) { + if (!p->joined) { + kill(p->pid, SIGINT); + } +} + +int gpr_subprocess_get_process_id(gpr_subprocess* p) { return p->pid; } + +#endif // GPR_POSIX_SUBPROCESS diff --git a/test/core/util/subprocess_windows.cc b/src/core/lib/gpr/subprocess_windows.cc similarity index 98% rename from test/core/util/subprocess_windows.cc rename to src/core/lib/gpr/subprocess_windows.cc index b639b3ef737c7..3efadd2a9b082 100644 --- a/test/core/util/subprocess_windows.cc +++ b/src/core/lib/gpr/subprocess_windows.cc @@ -31,9 +31,9 @@ #include #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/subprocess.h" #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/tchar.h" -#include "test/core/util/subprocess.h" struct gpr_subprocess { PROCESS_INFORMATION pi; diff --git a/src/core/lib/gprpp/dual_ref_counted.h b/src/core/lib/gprpp/dual_ref_counted.h index e83b27370ca0b..4fc6ea760dabe 100644 --- a/src/core/lib/gprpp/dual_ref_counted.h +++ b/src/core/lib/gprpp/dual_ref_counted.h @@ -49,13 +49,13 @@ class DualRefCounted : public Orphanable { public: ~DualRefCounted() override = default; - RefCountedPtr Ref() GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr Ref() { IncrementRefCount(); return RefCountedPtr(static_cast(this)); } - RefCountedPtr Ref(const DebugLocation& location, - const char* reason) GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr Ref(const DebugLocation& location, + const char* reason) { IncrementRefCount(location, reason); return RefCountedPtr(static_cast(this)); } @@ -103,7 +103,7 @@ class DualRefCounted : public Orphanable { WeakUnref(location, reason); } - RefCountedPtr RefIfNonZero() GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr RefIfNonZero() { uint64_t prev_ref_pair = refs_.load(std::memory_order_acquire); do { const uint32_t strong_refs = GetStrongRefs(prev_ref_pair); @@ -121,8 +121,8 @@ class DualRefCounted : public Orphanable { return RefCountedPtr(static_cast(this)); } - RefCountedPtr RefIfNonZero(const DebugLocation& location, - const char* reason) GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr RefIfNonZero( + const DebugLocation& location, const char* reason) { uint64_t prev_ref_pair = refs_.load(std::memory_order_acquire); do { const uint32_t strong_refs = GetStrongRefs(prev_ref_pair); @@ -146,13 +146,13 @@ class DualRefCounted : public Orphanable { return RefCountedPtr(static_cast(this)); } - WeakRefCountedPtr WeakRef() GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT WeakRefCountedPtr WeakRef() { IncrementWeakRefCount(); return WeakRefCountedPtr(static_cast(this)); } - WeakRefCountedPtr WeakRef(const DebugLocation& location, - const char* reason) GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT WeakRefCountedPtr WeakRef( + const DebugLocation& location, const char* reason) { IncrementWeakRefCount(location, reason); return WeakRefCountedPtr(static_cast(this)); } diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index a2f24cb54c2ff..86319429e5c2d 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -87,12 +87,12 @@ class InternallyRefCounted : public Orphanable { : refs_(initial_refcount, trace) {} ~InternallyRefCounted() override = default; - RefCountedPtr Ref() GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr Ref() { IncrementRefCount(); return RefCountedPtr(static_cast(this)); } - RefCountedPtr Ref(const DebugLocation& location, - const char* reason) GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr Ref(const DebugLocation& location, + const char* reason) { IncrementRefCount(location, reason); return RefCountedPtr(static_cast(this)); } diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index 96fe288ff6f72..cdf692c5ce7df 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -45,12 +45,14 @@ class RefCount { public: using Value = intptr_t; + RefCount() : RefCount(1) {} + // `init` is the initial refcount stored in this object. // // `trace` is a string to be logged with trace events; if null, no // trace logging will be done. Tracing is a no-op in non-debug builds. explicit RefCount( - Value init = 1, + Value init, const char* #ifndef NDEBUG // Leave unnamed if NDEBUG to avoid unused parameter warning @@ -277,13 +279,13 @@ class RefCounted : public Impl { // Note: Depending on the Impl used, this dtor can be implicitly virtual. ~RefCounted() = default; - RefCountedPtr Ref() GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr Ref() { IncrementRefCount(); return RefCountedPtr(static_cast(this)); } - RefCountedPtr Ref(const DebugLocation& location, - const char* reason) GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr Ref(const DebugLocation& location, + const char* reason) { IncrementRefCount(location, reason); return RefCountedPtr(static_cast(this)); } @@ -303,12 +305,12 @@ class RefCounted : public Impl { } } - RefCountedPtr RefIfNonZero() GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr RefIfNonZero() { return RefCountedPtr(refs_.RefIfNonZero() ? static_cast(this) : nullptr); } - RefCountedPtr RefIfNonZero(const DebugLocation& location, - const char* reason) GRPC_MUST_USE_RESULT { + GRPC_MUST_USE_RESULT RefCountedPtr RefIfNonZero( + const DebugLocation& location, const char* reason) { return RefCountedPtr(refs_.RefIfNonZero(location, reason) ? static_cast(this) : nullptr); diff --git a/src/core/lib/gprpp/status_helper.h b/src/core/lib/gprpp/status_helper.h index 3f61c3e16457c..536ced385c604 100644 --- a/src/core/lib/gprpp/status_helper.h +++ b/src/core/lib/gprpp/status_helper.h @@ -116,57 +116,58 @@ enum class StatusTimeProperty { }; /// Creates a status with given additional information -absl::Status StatusCreate( - absl::StatusCode code, absl::string_view msg, const DebugLocation& location, - std::vector children) GRPC_MUST_USE_RESULT; +absl::Status StatusCreate(absl::StatusCode code, absl::string_view msg, + const DebugLocation& location, + std::vector children); /// Sets the int property to the status void StatusSetInt(absl::Status* status, StatusIntProperty key, intptr_t value); /// Gets the int property from the status -absl::optional StatusGetInt( - const absl::Status& status, StatusIntProperty key) GRPC_MUST_USE_RESULT; +GRPC_MUST_USE_RESULT +absl::optional StatusGetInt(const absl::Status& status, + StatusIntProperty key); /// Sets the str property to the status void StatusSetStr(absl::Status* status, StatusStrProperty key, absl::string_view value); /// Gets the str property from the status -absl::optional StatusGetStr( - const absl::Status& status, StatusStrProperty key) GRPC_MUST_USE_RESULT; +GRPC_MUST_USE_RESULT absl::optional StatusGetStr( + const absl::Status& status, StatusStrProperty key); /// Sets the time property to the status void StatusSetTime(absl::Status* status, StatusTimeProperty key, absl::Time time); /// Gets the time property from the status -absl::optional StatusGetTime( - const absl::Status& status, StatusTimeProperty key) GRPC_MUST_USE_RESULT; +GRPC_MUST_USE_RESULT absl::optional StatusGetTime( + const absl::Status& status, StatusTimeProperty key); /// Adds a child status to status void StatusAddChild(absl::Status* status, absl::Status child); /// Returns all children status from a status -std::vector StatusGetChildren(absl::Status status) - GRPC_MUST_USE_RESULT; +GRPC_MUST_USE_RESULT std::vector StatusGetChildren( + absl::Status status); /// Returns a string representation from status /// Error status will be like /// STATUS[:MESSAGE] [{PAYLOADS[, children:[CHILDREN-STATUS-LISTS]]}] /// e.g. /// CANCELLATION:SampleMessage {errno:'2021', line:'54', children:[ABORTED]} -std::string StatusToString(const absl::Status& status) GRPC_MUST_USE_RESULT; +GRPC_MUST_USE_RESULT std::string StatusToString(const absl::Status& status); namespace internal { /// Builds a upb message, google_rpc_Status from a status /// This is for internal implementation & test only -google_rpc_Status* StatusToProto(const absl::Status& status, - upb_Arena* arena) GRPC_MUST_USE_RESULT; +GRPC_MUST_USE_RESULT google_rpc_Status* StatusToProto( + const absl::Status& status, upb_Arena* arena); /// Builds a status from a upb message, google_rpc_Status /// This is for internal implementation & test only -absl::Status StatusFromProto(google_rpc_Status* msg) GRPC_MUST_USE_RESULT; +absl::Status StatusFromProto(google_rpc_Status* msg); /// Returns ptr that is allocated in the heap memory and the given status is /// copied into. This ptr can be used to get Status later and should be diff --git a/src/core/lib/gprpp/time.h b/src/core/lib/gprpp/time.h index 3c39916c3b072..32b1065e380b5 100644 --- a/src/core/lib/gprpp/time.h +++ b/src/core/lib/gprpp/time.h @@ -37,8 +37,8 @@ uint64_t now = grpc_core::Timestamp::FromTimespecRoundDown( \ gpr_now(GPR_CLOCK_MONOTONIC)) \ .milliseconds_after_process_epoch(); \ - uint64_t prev_tsamp = prev.exchange(now); \ - if (prev_tsamp == 0 || now - prev_tsamp > (n)*1000) { \ + if (prev == 0 || now - prev > (n)*1000) { \ + prev = now; \ gpr_log(severity, format, __VA_ARGS__); \ } \ } while (0) diff --git a/src/core/lib/http/httpcli.h b/src/core/lib/http/httpcli.h index bcbaa315b92a2..bfa98a378f664 100644 --- a/src/core/lib/http/httpcli.h +++ b/src/core/lib/http/httpcli.h @@ -100,12 +100,11 @@ class HttpRequest : public InternallyRefCounted { // nullptr is treated as insecure credentials. // TODO(yihuaz): disallow nullptr as a value after unsecure builds // are removed. - static OrphanablePtr Get( + GRPC_MUST_USE_RESULT static OrphanablePtr Get( URI uri, const grpc_channel_args* args, grpc_polling_entity* pollent, const grpc_http_request* request, Timestamp deadline, grpc_closure* on_done, grpc_http_response* response, - RefCountedPtr channel_creds) - GRPC_MUST_USE_RESULT; + RefCountedPtr channel_creds); // Asynchronously perform a HTTP POST. // 'uri' is the target to make the request to. The scheme field is used to @@ -126,12 +125,11 @@ class HttpRequest : public InternallyRefCounted { // TODO(apolcyn): disallow nullptr as a value after unsecure builds // are removed. // Does not support ?var1=val1&var2=val2 in the path. - static OrphanablePtr Post( + GRPC_MUST_USE_RESULT static OrphanablePtr Post( URI uri, const grpc_channel_args* args, grpc_polling_entity* pollent, const grpc_http_request* request, Timestamp deadline, grpc_closure* on_done, grpc_http_response* response, - RefCountedPtr channel_creds) - GRPC_MUST_USE_RESULT; + RefCountedPtr channel_creds); // Asynchronously perform a HTTP PUT. // 'uri' is the target to make the request to. The scheme field is used to @@ -152,12 +150,11 @@ class HttpRequest : public InternallyRefCounted { // TODO(apolcyn): disallow nullptr as a value after unsecure builds // are removed. // Does not support ?var1=val1&var2=val2 in the path. - static OrphanablePtr Put( + GRPC_MUST_USE_RESULT static OrphanablePtr Put( URI uri, const grpc_channel_args* args, grpc_polling_entity* pollent, const grpc_http_request* request, Timestamp deadline, grpc_closure* on_done, grpc_http_response* response, - RefCountedPtr channel_creds) - GRPC_MUST_USE_RESULT; + RefCountedPtr channel_creds); HttpRequest(URI uri, const grpc_slice& request_text, grpc_http_response* response, Timestamp deadline, diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index d99befef0996d..22efdc30034c7 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index 79ce199b5340d..e1bec1b91dfe5 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -46,8 +46,7 @@ typedef absl::Status grpc_error_handle; absl::Status grpc_status_create(absl::StatusCode code, absl::string_view msg, const grpc_core::DebugLocation& location, - size_t children_count, - absl::Status* children) GRPC_MUST_USE_RESULT; + size_t children_count, absl::Status* children); // Create an error that references some other errors. #define GRPC_ERROR_CREATE_REFERENCING(desc, errs, count) \ @@ -73,7 +72,7 @@ static absl::Status grpc_status_create_from_vector( grpc_status_create_from_vector(DEBUG_LOCATION, desc, error_list) absl::Status grpc_os_error(const grpc_core::DebugLocation& location, int err, - const char* call_name) GRPC_MUST_USE_RESULT; + const char* call_name); inline absl::Status grpc_assert_never_ok(absl::Status error) { GPR_ASSERT(!error.ok()); @@ -85,7 +84,7 @@ inline absl::Status grpc_assert_never_ok(absl::Status error) { grpc_assert_never_ok(grpc_os_error(DEBUG_LOCATION, err, call_name)) absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err, - absl::string_view call_name) GRPC_MUST_USE_RESULT; + absl::string_view call_name); /// windows only: create an error associated with WSAGetLastError()!=0 #define GRPC_WSA_ERROR(err, call_name) \ @@ -93,14 +92,14 @@ absl::Status grpc_wsa_error(const grpc_core::DebugLocation& location, int err, grpc_error_handle grpc_error_set_int(grpc_error_handle src, grpc_core::StatusIntProperty which, - intptr_t value) GRPC_MUST_USE_RESULT; + intptr_t value); /// It is an error to pass nullptr as `p`. Caller should allocate a phony /// intptr_t for `p`, even if the value of `p` is not used. bool grpc_error_get_int(grpc_error_handle error, grpc_core::StatusIntProperty which, intptr_t* p); -grpc_error_handle grpc_error_set_str( - grpc_error_handle src, grpc_core::StatusStrProperty which, - absl::string_view str) GRPC_MUST_USE_RESULT; +grpc_error_handle grpc_error_set_str(grpc_error_handle src, + grpc_core::StatusStrProperty which, + absl::string_view str); /// Returns false if the specified string is not set. bool grpc_error_get_str(grpc_error_handle error, grpc_core::StatusStrProperty which, std::string* str); @@ -116,8 +115,8 @@ bool grpc_error_get_str(grpc_error_handle error, /// returns absl::OkStatus(). 3) If \a src and \a child point to the same error, /// returns a single reference. (Note that, 2 references should have been /// received to the error in this case.) -grpc_error_handle grpc_error_add_child( - grpc_error_handle src, grpc_error_handle child) GRPC_MUST_USE_RESULT; +grpc_error_handle grpc_error_add_child(grpc_error_handle src, + grpc_error_handle child); bool grpc_log_error(const char* what, grpc_error_handle error, const char* file, int line); diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index e72bb404600b9..75acbbe8d1d25 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -235,7 +235,7 @@ static int poll_deadline_to_millis_timeout(grpc_core::Timestamp deadline); // -- mostly for fd_posix's use. static grpc_error_handle pollset_kick_ext(grpc_pollset* p, grpc_pollset_worker* specific_worker, - uint32_t flags) GRPC_MUST_USE_RESULT; + uint32_t flags); // Return 1 if the pollset has active threads in pollset_work (pollset must // be locked) diff --git a/src/core/lib/iomgr/event_engine_shims/endpoint.cc b/src/core/lib/iomgr/event_engine_shims/endpoint.cc index ae9004f11b6ef..20b6a158494bb 100644 --- a/src/core/lib/iomgr/event_engine_shims/endpoint.cc +++ b/src/core/lib/iomgr/event_engine_shims/endpoint.cc @@ -74,15 +74,9 @@ class EventEngineEndpointWrapper { return fd_; } - absl::string_view PeerAddress() { - grpc_core::MutexLock lock(&mu_); - return peer_address_; - } + absl::string_view PeerAddress() { return peer_address_; } - absl::string_view LocalAddress() { - grpc_core::MutexLock lock(&mu_); - return local_address_; - } + absl::string_view LocalAddress() { return local_address_; } void Ref() { refs_.fetch_add(1, std::memory_order_relaxed); } void Unref() { @@ -119,8 +113,7 @@ class EventEngineEndpointWrapper { read_buffer->~SliceBuffer(); if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) { size_t i; - gpr_log(GPR_INFO, "TCP: %p READ (peer=%s) error=%s", eeep_->wrapper, - std::string(eeep_->wrapper->PeerAddress()).c_str(), + gpr_log(GPR_INFO, "TCP: %p READ error=%s", eeep_->wrapper, status.ToString().c_str()); if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) { for (i = 0; i < pending_read_buffer_->count; i++) { @@ -270,8 +263,6 @@ class EventEngineEndpointWrapper { { grpc_core::MutexLock lock(&mu_); fd_ = -1; - local_address_ = ""; - peer_address_ = ""; } endpoint_.reset(); // For the Ref taken in TriggerShutdown @@ -286,8 +277,10 @@ class EventEngineEndpointWrapper { grpc_closure* pending_read_cb_; grpc_closure* pending_write_cb_; grpc_slice_buffer* pending_read_buffer_; - std::string peer_address_; - std::string local_address_; + const std::string peer_address_{ + ResolvedAddressToURI(endpoint_->GetPeerAddress()).value_or("")}; + const std::string local_address_{ + ResolvedAddressToURI(endpoint_->GetLocalAddress()).value_or("")}; int fd_{-1}; }; @@ -413,14 +406,6 @@ EventEngineEndpointWrapper::EventEngineEndpointWrapper( eeep_(std::make_unique()) { eeep_->base.vtable = &grpc_event_engine_endpoint_vtable; eeep_->wrapper = this; - auto local_addr = ResolvedAddressToURI(endpoint_->GetLocalAddress()); - if (local_addr.ok()) { - local_address_ = *local_addr; - } - auto peer_addr = ResolvedAddressToURI(endpoint_->GetPeerAddress()); - if (peer_addr.ok()) { - peer_address_ = *peer_addr; - } if (EventEngineSupportsFd()) { fd_ = reinterpret_cast(endpoint_.get()) ->GetWrappedFd(); diff --git a/src/core/lib/iomgr/pollset.h b/src/core/lib/iomgr/pollset.h index b04f71fa376c1..137a581b91faf 100644 --- a/src/core/lib/iomgr/pollset.h +++ b/src/core/lib/iomgr/pollset.h @@ -86,14 +86,13 @@ void grpc_pollset_destroy(grpc_pollset* pollset); // May call grpc_closure_list_run on grpc_closure_list, without holding the // pollset // lock -grpc_error_handle grpc_pollset_work( - grpc_pollset* pollset, grpc_pollset_worker** worker, - grpc_core::Timestamp deadline) GRPC_MUST_USE_RESULT; +grpc_error_handle grpc_pollset_work(grpc_pollset* pollset, + grpc_pollset_worker** worker, + grpc_core::Timestamp deadline); // Break one polling thread out of polling work for this pollset. // If specific_worker is non-NULL, then kick that worker. grpc_error_handle grpc_pollset_kick(grpc_pollset* pollset, - grpc_pollset_worker* specific_worker) - GRPC_MUST_USE_RESULT; + grpc_pollset_worker* specific_worker); #endif // GRPC_SRC_CORE_LIB_IOMGR_POLLSET_H diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 4664d1a10d257..035f9426f6285 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -1057,7 +1057,7 @@ static void maybe_make_read_slices(grpc_tcp* tcp) static const int kBigAlloc = 64 * 1024; static const int kSmallAlloc = 8 * 1024; if (tcp->incoming_buffer->length < - static_cast(tcp->min_progress_size)) { + std::max(tcp->min_progress_size, 1)) { size_t allocate_length = tcp->min_progress_size; const size_t target_length = static_cast(tcp->target_length); // If memory pressure is low and we think there will be more than @@ -1067,8 +1067,8 @@ static void maybe_make_read_slices(grpc_tcp* tcp) if (low_memory_pressure && target_length > allocate_length) { allocate_length = target_length; } - int extra_wanted = - allocate_length - static_cast(tcp->incoming_buffer->length); + int extra_wanted = std::max( + 1, allocate_length - static_cast(tcp->incoming_buffer->length)); if (extra_wanted >= (low_memory_pressure ? kSmallAlloc * 3 / 2 : kBigAlloc)) { while (extra_wanted > 0) { diff --git a/src/core/lib/iomgr/wakeup_fd_posix.h b/src/core/lib/iomgr/wakeup_fd_posix.h index 3c8ed5278bb12..329e7ddd710c5 100644 --- a/src/core/lib/iomgr/wakeup_fd_posix.h +++ b/src/core/lib/iomgr/wakeup_fd_posix.h @@ -81,12 +81,9 @@ extern int grpc_allow_pipe_wakeup_fd; #define GRPC_WAKEUP_FD_GET_READ_FD(fd_info) ((fd_info)->read_fd) -grpc_error_handle grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info) - GRPC_MUST_USE_RESULT; -grpc_error_handle grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info) - GRPC_MUST_USE_RESULT; -grpc_error_handle grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info) - GRPC_MUST_USE_RESULT; +grpc_error_handle grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info); +grpc_error_handle grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info); +grpc_error_handle grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info); void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info); // Defined in some specialized implementation's .c file, or by diff --git a/src/core/lib/promise/detail/basic_seq.h b/src/core/lib/promise/detail/basic_seq.h index 3ebb251a96125..663609d41928f 100644 --- a/src/core/lib/promise/detail/basic_seq.h +++ b/src/core/lib/promise/detail/basic_seq.h @@ -17,384 +17,13 @@ #include -#include -#include -#include -#include -#include - -#include "absl/meta/type_traits.h" -#include "absl/utility/utility.h" - #include "src/core/lib/gprpp/construct_destruct.h" -#include "src/core/lib/promise/detail/promise_factory.h" -#include "src/core/lib/promise/detail/promise_like.h" -#include "src/core/lib/promise/detail/switch.h" #include "src/core/lib/promise/poll.h" namespace grpc_core { namespace promise_detail { -// Helper for SeqState to evaluate some common types to all partial -// specializations. -template