From 0148b49aea1527c4ac1debd6bbf1c281027f6413 Mon Sep 17 00:00:00 2001 From: Vignesh Babu Date: Thu, 7 Nov 2024 11:28:23 -0800 Subject: [PATCH] Automated rollback of commit 2eaaa9cbf7226054df83b19ddd6d530a2e8edb32. PiperOrigin-RevId: 694190066 --- BUILD | 1 + CMakeLists.txt | 4 +++- Makefile | 1 + Package.swift | 2 ++ build_autogenerated.yaml | 8 ++++++-- config.m4 | 1 + config.w32 | 1 + gRPC-C++.podspec | 2 ++ gRPC-Core.podspec | 3 +++ grpc.gemspec | 2 ++ package.xml | 2 ++ src/core/BUILD | 1 + src/core/lib/security/context/security_context.h | 8 ++++++++ src/core/lib/surface/connection_context.h | 5 +++-- src/python/grpcio/grpc_core_dependencies.py | 1 + tools/doxygen/Doxyfile.c++.internal | 2 ++ tools/doxygen/Doxyfile.core.internal | 2 ++ 17 files changed, 41 insertions(+), 5 deletions(-) diff --git a/BUILD b/BUILD index 5fd5babdb5b..728c7dca944 100644 --- a/BUILD +++ b/BUILD @@ -2179,6 +2179,7 @@ grpc_cc_library( "//src/core:channel_args", "//src/core:channel_fwd", "//src/core:closure", + "//src/core:connection_context", "//src/core:context", "//src/core:error", "//src/core:event_engine_memory_allocator", diff --git a/CMakeLists.txt b/CMakeLists.txt index de8e1f5f8b8..82dadd69c42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2830,6 +2830,7 @@ add_library(grpc src/core/lib/surface/client_call.cc src/core/lib/surface/completion_queue.cc src/core/lib/surface/completion_queue_factory.cc + src/core/lib/surface/connection_context.cc src/core/lib/surface/event_string.cc src/core/lib/surface/filter_stack_call.cc src/core/lib/surface/init.cc @@ -3603,6 +3604,7 @@ add_library(grpc_unsecure src/core/lib/surface/client_call.cc src/core/lib/surface/completion_queue.cc src/core/lib/surface/completion_queue_factory.cc + src/core/lib/surface/connection_context.cc src/core/lib/surface/event_string.cc src/core/lib/surface/filter_stack_call.cc src/core/lib/surface/init.cc @@ -5823,6 +5825,7 @@ add_library(grpc_authorization_provider src/core/lib/surface/client_call.cc src/core/lib/surface/completion_queue.cc src/core/lib/surface/completion_queue_factory.cc + src/core/lib/surface/connection_context.cc src/core/lib/surface/event_string.cc src/core/lib/surface/filter_stack_call.cc src/core/lib/surface/init_internally.cc @@ -12955,7 +12958,6 @@ endif() if(gRPC_BUILD_TESTS) add_executable(connection_context_test - src/core/lib/surface/connection_context.cc test/core/surface/connection_context_test.cc test/core/test_util/cmdline.cc test/core/test_util/fuzzer_util.cc diff --git a/Makefile b/Makefile index 45e2e7e72c0..ba9bd8ba040 100644 --- a/Makefile +++ b/Makefile @@ -1302,6 +1302,7 @@ LIBGRPC_SRC = \ src/core/lib/surface/client_call.cc \ src/core/lib/surface/completion_queue.cc \ src/core/lib/surface/completion_queue_factory.cc \ + src/core/lib/surface/connection_context.cc \ src/core/lib/surface/event_string.cc \ src/core/lib/surface/filter_stack_call.cc \ src/core/lib/surface/init.cc \ diff --git a/Package.swift b/Package.swift index 1ba620eab9a..780fe8ff063 100644 --- a/Package.swift +++ b/Package.swift @@ -1596,6 +1596,8 @@ let package = Package( "src/core/lib/surface/completion_queue.h", "src/core/lib/surface/completion_queue_factory.cc", "src/core/lib/surface/completion_queue_factory.h", + "src/core/lib/surface/connection_context.cc", + "src/core/lib/surface/connection_context.h", "src/core/lib/surface/event_string.cc", "src/core/lib/surface/event_string.h", "src/core/lib/surface/filter_stack_call.cc", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index a5dc5a06bd6..eedb10e5587 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -1055,6 +1055,7 @@ libs: - src/core/lib/surface/client_call.h - src/core/lib/surface/completion_queue.h - src/core/lib/surface/completion_queue_factory.h + - src/core/lib/surface/connection_context.h - src/core/lib/surface/event_string.h - src/core/lib/surface/filter_stack_call.h - src/core/lib/surface/init.h @@ -1911,6 +1912,7 @@ libs: - src/core/lib/surface/client_call.cc - src/core/lib/surface/completion_queue.cc - src/core/lib/surface/completion_queue_factory.cc + - src/core/lib/surface/connection_context.cc - src/core/lib/surface/event_string.cc - src/core/lib/surface/filter_stack_call.cc - src/core/lib/surface/init.cc @@ -2609,6 +2611,7 @@ libs: - src/core/lib/surface/client_call.h - src/core/lib/surface/completion_queue.h - src/core/lib/surface/completion_queue_factory.h + - src/core/lib/surface/connection_context.h - src/core/lib/surface/event_string.h - src/core/lib/surface/filter_stack_call.h - src/core/lib/surface/init.h @@ -3038,6 +3041,7 @@ libs: - src/core/lib/surface/client_call.cc - src/core/lib/surface/completion_queue.cc - src/core/lib/surface/completion_queue_factory.cc + - src/core/lib/surface/connection_context.cc - src/core/lib/surface/event_string.cc - src/core/lib/surface/filter_stack_call.cc - src/core/lib/surface/init.cc @@ -4680,6 +4684,7 @@ libs: - src/core/lib/surface/client_call.h - src/core/lib/surface/completion_queue.h - src/core/lib/surface/completion_queue_factory.h + - src/core/lib/surface/connection_context.h - src/core/lib/surface/event_string.h - src/core/lib/surface/filter_stack_call.h - src/core/lib/surface/init.h @@ -4984,6 +4989,7 @@ libs: - src/core/lib/surface/client_call.cc - src/core/lib/surface/completion_queue.cc - src/core/lib/surface/completion_queue_factory.cc + - src/core/lib/surface/connection_context.cc - src/core/lib/surface/event_string.cc - src/core/lib/surface/filter_stack_call.cc - src/core/lib/surface/init_internally.cc @@ -9301,7 +9307,6 @@ targets: build: test language: c++ headers: - - src/core/lib/surface/connection_context.h - test/core/test_util/cmdline.h - test/core/test_util/evaluate_args_test_util.h - test/core/test_util/fuzzer_util.h @@ -9313,7 +9318,6 @@ targets: - test/core/test_util/slice_splitter.h - test/core/test_util/tracer_util.h src: - - src/core/lib/surface/connection_context.cc - test/core/surface/connection_context_test.cc - test/core/test_util/cmdline.cc - test/core/test_util/fuzzer_util.cc diff --git a/config.m4 b/config.m4 index f8b38adf606..98278457102 100644 --- a/config.m4 +++ b/config.m4 @@ -677,6 +677,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/surface/client_call.cc \ src/core/lib/surface/completion_queue.cc \ src/core/lib/surface/completion_queue_factory.cc \ + src/core/lib/surface/connection_context.cc \ src/core/lib/surface/event_string.cc \ src/core/lib/surface/filter_stack_call.cc \ src/core/lib/surface/init.cc \ diff --git a/config.w32 b/config.w32 index 7a03656de1d..6dac489066e 100644 --- a/config.w32 +++ b/config.w32 @@ -642,6 +642,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\surface\\client_call.cc " + "src\\core\\lib\\surface\\completion_queue.cc " + "src\\core\\lib\\surface\\completion_queue_factory.cc " + + "src\\core\\lib\\surface\\connection_context.cc " + "src\\core\\lib\\surface\\event_string.cc " + "src\\core\\lib\\surface\\filter_stack_call.cc " + "src\\core\\lib\\surface\\init.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 72a7240a5e4..671a9cf30ba 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -1106,6 +1106,7 @@ Pod::Spec.new do |s| 'src/core/lib/surface/client_call.h', 'src/core/lib/surface/completion_queue.h', 'src/core/lib/surface/completion_queue_factory.h', + 'src/core/lib/surface/connection_context.h', 'src/core/lib/surface/event_string.h', 'src/core/lib/surface/filter_stack_call.h', 'src/core/lib/surface/init.h', @@ -2397,6 +2398,7 @@ Pod::Spec.new do |s| 'src/core/lib/surface/client_call.h', 'src/core/lib/surface/completion_queue.h', 'src/core/lib/surface/completion_queue_factory.h', + 'src/core/lib/surface/connection_context.h', 'src/core/lib/surface/event_string.h', 'src/core/lib/surface/filter_stack_call.h', 'src/core/lib/surface/init.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index d8a7b33b9bd..733e089783e 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1712,6 +1712,8 @@ Pod::Spec.new do |s| 'src/core/lib/surface/completion_queue.h', 'src/core/lib/surface/completion_queue_factory.cc', 'src/core/lib/surface/completion_queue_factory.h', + 'src/core/lib/surface/connection_context.cc', + 'src/core/lib/surface/connection_context.h', 'src/core/lib/surface/event_string.cc', 'src/core/lib/surface/event_string.h', 'src/core/lib/surface/filter_stack_call.cc', @@ -3250,6 +3252,7 @@ Pod::Spec.new do |s| 'src/core/lib/surface/client_call.h', 'src/core/lib/surface/completion_queue.h', 'src/core/lib/surface/completion_queue_factory.h', + 'src/core/lib/surface/connection_context.h', 'src/core/lib/surface/event_string.h', 'src/core/lib/surface/filter_stack_call.h', 'src/core/lib/surface/init.h', diff --git a/grpc.gemspec b/grpc.gemspec index 268da42963b..b53df0df1f5 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -1598,6 +1598,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/surface/completion_queue.h ) s.files += %w( src/core/lib/surface/completion_queue_factory.cc ) s.files += %w( src/core/lib/surface/completion_queue_factory.h ) + s.files += %w( src/core/lib/surface/connection_context.cc ) + s.files += %w( src/core/lib/surface/connection_context.h ) s.files += %w( src/core/lib/surface/event_string.cc ) s.files += %w( src/core/lib/surface/event_string.h ) s.files += %w( src/core/lib/surface/filter_stack_call.cc ) diff --git a/package.xml b/package.xml index b19e583a1b9..2f235cfa185 100644 --- a/package.xml +++ b/package.xml @@ -1580,6 +1580,8 @@ + + diff --git a/src/core/BUILD b/src/core/BUILD index d1e3096912e..7e5391432ca 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -3692,6 +3692,7 @@ grpc_cc_library( srcs = ["lib/surface/connection_context.cc"], hdrs = ["lib/surface/connection_context.h"], deps = [ + "no_destruct", "//:gpr", "//:gpr_platform", "//:orphanable", diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h index 1a5b7afa320..105222eefdb 100644 --- a/src/core/lib/security/context/security_context.h +++ b/src/core/lib/security/context/security_context.h @@ -33,7 +33,9 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/security/credentials/credentials.h" // IWYU pragma: keep +#include "src/core/lib/surface/connection_context.h" #include "src/core/util/debug_location.h" +#include "src/core/util/orphanable.h" #include "src/core/util/ref_counted.h" #include "src/core/util/ref_counted_ptr.h" #include "src/core/util/useful.h" @@ -77,6 +79,7 @@ struct grpc_auth_context if (chained_ != nullptr) { peer_identity_property_name_ = chained_->peer_identity_property_name_; } + connection_context_ = grpc_core::ConnectionContext::Create(); } ~grpc_auth_context() { @@ -98,6 +101,10 @@ struct grpc_auth_context const grpc_auth_context* chained() const { return chained_.get(); } const grpc_auth_property_array& properties() const { return properties_; } + grpc_core::ConnectionContext* connection_context() const { + return connection_context_.get(); + } + bool is_authenticated() const { return peer_identity_property_name_ != nullptr; } @@ -120,6 +127,7 @@ struct grpc_auth_context grpc_auth_property_array properties_; const char* peer_identity_property_name_ = nullptr; std::unique_ptr extension_; + grpc_core::OrphanablePtr connection_context_; }; // --- grpc_security_context_extension --- diff --git a/src/core/lib/surface/connection_context.h b/src/core/lib/surface/connection_context.h index 56043991837..2366f213355 100644 --- a/src/core/lib/surface/connection_context.h +++ b/src/core/lib/surface/connection_context.h @@ -25,6 +25,7 @@ #include #include +#include "src/core/util/no_destruct.h" #include "src/core/util/orphanable.h" namespace grpc_core { @@ -68,8 +69,8 @@ class BaseConnectionContextPropertiesTraits { // Allocate a new context id and register the destruction function. static std::vector& RegisteredTraits() { - static std::vector registered_traits; - return registered_traits; + static NoDestruct> registered_traits; + return *registered_traits; } }; diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index b73b62761e7..d2c46a476a1 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -651,6 +651,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/surface/client_call.cc', 'src/core/lib/surface/completion_queue.cc', 'src/core/lib/surface/completion_queue_factory.cc', + 'src/core/lib/surface/connection_context.cc', 'src/core/lib/surface/event_string.cc', 'src/core/lib/surface/filter_stack_call.cc', 'src/core/lib/surface/init.cc', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 5cce618c9f1..b611cc7877a 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -2562,6 +2562,8 @@ src/core/lib/surface/completion_queue.cc \ src/core/lib/surface/completion_queue.h \ src/core/lib/surface/completion_queue_factory.cc \ src/core/lib/surface/completion_queue_factory.h \ +src/core/lib/surface/connection_context.cc \ +src/core/lib/surface/connection_context.h \ src/core/lib/surface/event_string.cc \ src/core/lib/surface/event_string.h \ src/core/lib/surface/filter_stack_call.cc \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 8f03a2b34df..f72d7a221d3 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -2373,6 +2373,8 @@ src/core/lib/surface/completion_queue.cc \ src/core/lib/surface/completion_queue.h \ src/core/lib/surface/completion_queue_factory.cc \ src/core/lib/surface/completion_queue_factory.h \ +src/core/lib/surface/connection_context.cc \ +src/core/lib/surface/connection_context.h \ src/core/lib/surface/event_string.cc \ src/core/lib/surface/event_string.h \ src/core/lib/surface/filter_stack_call.cc \