diff options
author | thegeorg <thegeorg@yandex-team.com> | 2023-03-28 10:11:46 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2023-03-28 10:11:46 +0300 |
commit | 14a9357e8d2d937e22b789d5aea09219a3e92c31 (patch) | |
tree | 9e899edffa271e32ae6272be3034a371b3742c2a /contrib/libs/grpc/src/cpp | |
parent | 1911ec1bf2da9ae39eb5f31511a92b06b9631da1 (diff) | |
download | ydb-14a9357e8d2d937e22b789d5aea09219a3e92c31.tar.gz |
Update contrib/libs/grpc to 1.45.2
Diffstat (limited to 'contrib/libs/grpc/src/cpp')
26 files changed, 133 insertions, 97 deletions
diff --git a/contrib/libs/grpc/src/cpp/README.md b/contrib/libs/grpc/src/cpp/README.md index 5c1c40acf7..6329a8dc2f 100755 --- a/contrib/libs/grpc/src/cpp/README.md +++ b/contrib/libs/grpc/src/cpp/README.md @@ -27,10 +27,10 @@ Therefore, gRPC supports several major build systems, which should satisfy most | Operating System | Architectures | Versions | Support Level | |------------------|---------------|----------|---------------| -| Linux - Debian, Ubuntu, CentOS | x86, x64 | clang 4+, GCC 4.9+ | Officially Supported | +| Linux - Debian, Ubuntu, CentOS | x86, x64 | clang 4+, GCC 5.1+ | Officially Supported | | Windows 10+ | x86, x64 | Visual Studio 2015+ | Officially Supported | | MacOS | x86, x64 | XCode 7.2+ | Officially Supported | -| Linux - Others | x86, x64 | clang 4+, GCC 4.9+ | Best Effort | +| Linux - Others | x86, x64 | clang 4+, GCC 5.1+ | Best Effort | | Linux | ARM | | Best Effort | | iOS | | | Best Effort | | Android | | | Best Effort | diff --git a/contrib/libs/grpc/src/cpp/client/channel_cc.cc b/contrib/libs/grpc/src/cpp/client/channel_cc.cc index 280537bbbd..cf15c808aa 100644 --- a/contrib/libs/grpc/src/cpp/client/channel_cc.cc +++ b/contrib/libs/grpc/src/cpp/client/channel_cc.cc @@ -44,11 +44,12 @@ namespace grpc { -static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer; -Channel::Channel(const TString& host, grpc_channel* channel, - std::vector<std::unique_ptr< - ::grpc::experimental::ClientInterceptorFactoryInterface>> - interceptor_creators) +static grpc::internal::GrpcLibraryInitializer g_gli_initializer; +Channel::Channel( + const TString& host, grpc_channel* channel, + std::vector< + std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> + interceptor_creators) : host_(host), c_channel_(channel) { interceptor_creators_ = std::move(interceptor_creators); g_gli_initializer.summon(); @@ -108,9 +109,9 @@ void ChannelResetConnectionBackoff(Channel* channel) { } // namespace experimental -::grpc::internal::Call Channel::CreateCallInternal( - const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, - ::grpc::CompletionQueue* cq, size_t interceptor_pos) { +grpc::internal::Call Channel::CreateCallInternal( + const grpc::internal::RpcMethod& method, grpc::ClientContext* context, + grpc::CompletionQueue* cq, size_t interceptor_pos) { const bool kRegistered = method.channel_tag() && context->authority().empty(); grpc_call* c_call = nullptr; if (kRegistered) { @@ -129,7 +130,7 @@ void ChannelResetConnectionBackoff(Channel* channel) { SliceFromArray(method.name(), strlen(method.name())); grpc_slice host_slice; if (host_str != nullptr) { - host_slice = ::grpc::SliceFromCopiedString(*host_str); + host_slice = grpc::SliceFromCopiedString(*host_str); } c_call = grpc_channel_create_call( c_channel_, context->propagate_from_call_, @@ -151,17 +152,17 @@ void ChannelResetConnectionBackoff(Channel* channel) { interceptor_creators_, interceptor_pos); context->set_call(c_call, shared_from_this()); - return ::grpc::internal::Call(c_call, this, cq, info); + return grpc::internal::Call(c_call, this, cq, info); } -::grpc::internal::Call Channel::CreateCall( - const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context, +grpc::internal::Call Channel::CreateCall( + const grpc::internal::RpcMethod& method, grpc::ClientContext* context, CompletionQueue* cq) { return CreateCallInternal(method, context, cq, 0); } -void Channel::PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, - ::grpc::internal::Call* call) { +void Channel::PerformOpsOnCall(grpc::internal::CallOpSetInterface* ops, + grpc::internal::Call* call) { ops->FillOps( call); // Make a copy of call. It's fine since Call just has pointers } @@ -177,7 +178,7 @@ grpc_connectivity_state Channel::GetState(bool try_to_connect) { namespace { -class TagSaver final : public ::grpc::internal::CompletionQueueTag { +class TagSaver final : public grpc::internal::CompletionQueueTag { public: explicit TagSaver(void* tag) : tag_(tag) {} ~TagSaver() override {} @@ -195,7 +196,7 @@ class TagSaver final : public ::grpc::internal::CompletionQueueTag { void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, - ::grpc::CompletionQueue* cq, void* tag) { + grpc::CompletionQueue* cq, void* tag) { TagSaver* tag_saver = new TagSaver(tag); grpc_channel_watch_connectivity_state(c_channel_, last_observed, deadline, cq->cq(), tag_saver); @@ -203,7 +204,7 @@ void Channel::NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) { - ::grpc::CompletionQueue cq; + grpc::CompletionQueue cq; bool ok = false; void* tag = nullptr; NotifyOnStateChangeImpl(last_observed, deadline, &cq, nullptr); @@ -225,7 +226,7 @@ class ShutdownCallback : public grpc_completion_queue_functor { } // TakeCQ takes ownership of the cq into the shutdown callback // so that the shutdown callback will be responsible for destroying it - void TakeCQ(::grpc::CompletionQueue* cq) { cq_ = cq; } + void TakeCQ(grpc::CompletionQueue* cq) { cq_ = cq; } // The Run function will get invoked by the completion queue library // when the shutdown is actually complete @@ -236,7 +237,7 @@ class ShutdownCallback : public grpc_completion_queue_functor { } private: - ::grpc::CompletionQueue* cq_ = nullptr; + grpc::CompletionQueue* cq_ = nullptr; }; } // namespace @@ -256,10 +257,9 @@ class ShutdownCallback : public grpc_completion_queue_functor { // gRPC-core provides the backing needed for the preferred CQ type auto* shutdown_callback = new ShutdownCallback; - callback_cq = - new ::grpc::CompletionQueue(grpc_completion_queue_attributes{ - GRPC_CQ_CURRENT_VERSION, GRPC_CQ_CALLBACK, - GRPC_CQ_DEFAULT_POLLING, shutdown_callback}); + callback_cq = new grpc::CompletionQueue(grpc_completion_queue_attributes{ + GRPC_CQ_CURRENT_VERSION, GRPC_CQ_CALLBACK, GRPC_CQ_DEFAULT_POLLING, + shutdown_callback}); // Transfer ownership of the new cq to its own shutdown callback shutdown_callback->TakeCQ(callback_cq); diff --git a/contrib/libs/grpc/src/cpp/client/create_channel_internal.cc b/contrib/libs/grpc/src/cpp/client/create_channel_internal.cc index 15edfbf31a..e3f034ca22 100644 --- a/contrib/libs/grpc/src/cpp/client/create_channel_internal.cc +++ b/contrib/libs/grpc/src/cpp/client/create_channel_internal.cc @@ -32,8 +32,8 @@ namespace grpc { std::shared_ptr<Channel> CreateChannelInternal( const TString& host, grpc_channel* c_channel, - std::vector<std::unique_ptr< - ::grpc::experimental::ClientInterceptorFactoryInterface>> + std::vector< + std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> interceptor_creators) { return std::shared_ptr<Channel>( new Channel(host, c_channel, std::move(interceptor_creators))); diff --git a/contrib/libs/grpc/src/cpp/client/create_channel_internal.h b/contrib/libs/grpc/src/cpp/client/create_channel_internal.h index 31b0a38e92..c0e117ab35 100644 --- a/contrib/libs/grpc/src/cpp/client/create_channel_internal.h +++ b/contrib/libs/grpc/src/cpp/client/create_channel_internal.h @@ -34,8 +34,8 @@ namespace grpc { std::shared_ptr<Channel> CreateChannelInternal( const TString& host, grpc_channel* c_channel, - std::vector<std::unique_ptr< - ::grpc::experimental::ClientInterceptorFactoryInterface>> + std::vector< + std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> interceptor_creators); } // namespace grpc diff --git a/contrib/libs/grpc/src/cpp/client/create_channel_posix.cc b/contrib/libs/grpc/src/cpp/client/create_channel_posix.cc index db09eda8a6..deb03cae72 100644 --- a/contrib/libs/grpc/src/cpp/client/create_channel_posix.cc +++ b/contrib/libs/grpc/src/cpp/client/create_channel_posix.cc @@ -18,8 +18,10 @@ #include <grpc/grpc.h> #include <grpc/grpc_posix.h> +#include <grpc/grpc_security.h> #include <grpcpp/channel.h> #include <grpcpp/impl/grpc_library.h> +#include <grpcpp/security/credentials.h> #include <grpcpp/support/channel_arguments.h> #include "src/cpp/client/create_channel_internal.h" @@ -34,10 +36,13 @@ std::shared_ptr<Channel> CreateInsecureChannelFromFd(const TString& target, int fd) { grpc::internal::GrpcLibrary init_lib; init_lib.init(); - return CreateChannelInternal( - "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr), + grpc_channel_credentials* creds = grpc_insecure_credentials_create(); + auto channel = CreateChannelInternal( + "", grpc_channel_create_from_fd(target.c_str(), fd, creds, nullptr), std::vector< std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); + grpc_channel_credentials_release(creds); + return channel; } std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd( @@ -46,11 +51,13 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd( init_lib.init(); grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - return CreateChannelInternal( - "", - grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args), + grpc_channel_credentials* creds = grpc_insecure_credentials_create(); + auto channel = CreateChannelInternal( + "", grpc_channel_create_from_fd(target.c_str(), fd, creds, &channel_args), std::vector< std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); + grpc_channel_credentials_release(creds); + return channel; } namespace experimental { @@ -64,10 +71,12 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd( init_lib.init(); grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - return CreateChannelInternal( - "", - grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args), + grpc_channel_credentials* creds = grpc_insecure_credentials_create(); + auto channel = CreateChannelInternal( + "", grpc_channel_create_from_fd(target.c_str(), fd, creds, &channel_args), std::move(interceptor_creators)); + grpc_channel_credentials_release(creds); + return channel; } } // namespace experimental diff --git a/contrib/libs/grpc/src/cpp/client/insecure_credentials.cc b/contrib/libs/grpc/src/cpp/client/insecure_credentials.cc index d266e21435..5fafb5435e 100644 --- a/contrib/libs/grpc/src/cpp/client/insecure_credentials.cc +++ b/contrib/libs/grpc/src/cpp/client/insecure_credentials.cc @@ -16,6 +16,7 @@ * */ #include <grpc/grpc.h> +#include <grpc/grpc_security.h> #include <grpc/support/log.h> #include <grpcpp/channel.h> #include <grpcpp/security/credentials.h> @@ -44,10 +45,12 @@ class InsecureChannelCredentialsImpl final : public ChannelCredentials { interceptor_creators) override { grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - return ::grpc::CreateChannelInternal( - "", - grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr), + grpc_channel_credentials* creds = grpc_insecure_credentials_create(); + std::shared_ptr<Channel> channel = grpc::CreateChannelInternal( + "", grpc_channel_create(target.c_str(), creds, &channel_args), std::move(interceptor_creators)); + grpc_channel_credentials_release(creds); + return channel; } SecureChannelCredentials* AsSecureCredentials() override { return nullptr; } diff --git a/contrib/libs/grpc/src/cpp/client/secure_credentials.cc b/contrib/libs/grpc/src/cpp/client/secure_credentials.cc index ee3bde2eb2..e849c98f3e 100644 --- a/contrib/libs/grpc/src/cpp/client/secure_credentials.cc +++ b/contrib/libs/grpc/src/cpp/client/secure_credentials.cc @@ -66,10 +66,9 @@ SecureChannelCredentials::CreateChannelWithInterceptors( interceptor_creators) { grpc_channel_args channel_args; args.SetChannelArgs(&channel_args); - return ::grpc::CreateChannelInternal( + return grpc::CreateChannelInternal( args.GetSslTargetNameOverride(), - grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args, - nullptr), + grpc_channel_create(target.c_str(), c_creds_, &channel_args), std::move(interceptor_creators)); } diff --git a/contrib/libs/grpc/src/cpp/client/secure_credentials.h b/contrib/libs/grpc/src/cpp/client/secure_credentials.h index d6f1c89c2c..6296b9a04b 100644 --- a/contrib/libs/grpc/src/cpp/client/secure_credentials.h +++ b/contrib/libs/grpc/src/cpp/client/secure_credentials.h @@ -37,6 +37,7 @@ class SecureChannelCredentials final : public ChannelCredentials { public: explicit SecureChannelCredentials(grpc_channel_credentials* c_creds); ~SecureChannelCredentials() override { + grpc_core::ExecCtx exec_ctx; if (c_creds_ != nullptr) c_creds_->Unref(); } grpc_channel_credentials* GetRawCreds() { return c_creds_; } @@ -50,7 +51,7 @@ class SecureChannelCredentials final : public ChannelCredentials { std::shared_ptr<Channel> CreateChannelWithInterceptors( const TString& target, const ChannelArguments& args, std::vector<std::unique_ptr< - ::grpc::experimental::ClientInterceptorFactoryInterface>> + grpc::experimental::ClientInterceptorFactoryInterface>> interceptor_creators) override; grpc_channel_credentials* const c_creds_; }; @@ -59,6 +60,7 @@ class SecureCallCredentials final : public CallCredentials { public: explicit SecureCallCredentials(grpc_call_credentials* c_creds); ~SecureCallCredentials() override { + grpc_core::ExecCtx exec_ctx; if (c_creds_ != nullptr) c_creds_->Unref(); } grpc_call_credentials* GetRawCreds() { return c_creds_; } diff --git a/contrib/libs/grpc/src/cpp/common/alarm.cc b/contrib/libs/grpc/src/cpp/common/alarm.cc index a367b53d3a..913c0c7317 100644 --- a/contrib/libs/grpc/src/cpp/common/alarm.cc +++ b/contrib/libs/grpc/src/cpp/common/alarm.cc @@ -34,7 +34,7 @@ namespace grpc { namespace internal { -class AlarmImpl : public ::grpc::internal::CompletionQueueTag { +class AlarmImpl : public grpc::internal::CompletionQueueTag { public: AlarmImpl() : cq_(nullptr), tag_(nullptr) { gpr_ref_init(&refs_, 1); @@ -46,7 +46,7 @@ class AlarmImpl : public ::grpc::internal::CompletionQueueTag { Unref(); return true; } - void Set(::grpc::CompletionQueue* cq, gpr_timespec deadline, void* tag) { + void Set(grpc::CompletionQueue* cq, gpr_timespec deadline, void* tag) { grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; GRPC_CQ_INTERNAL_REF(cq->cq(), "alarm"); @@ -70,7 +70,8 @@ class AlarmImpl : public ::grpc::internal::CompletionQueueTag { GRPC_CQ_INTERNAL_UNREF(cq, "alarm"); }, this, grpc_schedule_on_exec_ctx); - grpc_timer_init(&timer_, grpc_timespec_to_millis_round_up(deadline), + grpc_timer_init(&timer_, + grpc_core::Timestamp::FromTimespecRoundUp(deadline), &on_alarm_); } void Set(gpr_timespec deadline, std::function<void(bool)> f) { @@ -93,7 +94,8 @@ class AlarmImpl : public ::grpc::internal::CompletionQueueTag { error); }, this, grpc_schedule_on_exec_ctx); - grpc_timer_init(&timer_, grpc_timespec_to_millis_round_up(deadline), + grpc_timer_init(&timer_, + grpc_core::Timestamp::FromTimespecRoundUp(deadline), &on_alarm_); } void Cancel() { @@ -125,13 +127,13 @@ class AlarmImpl : public ::grpc::internal::CompletionQueueTag { }; } // namespace internal -static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer; +static grpc::internal::GrpcLibraryInitializer g_gli_initializer; Alarm::Alarm() : alarm_(new internal::AlarmImpl()) { g_gli_initializer.summon(); } -void Alarm::SetInternal(::grpc::CompletionQueue* cq, gpr_timespec deadline, +void Alarm::SetInternal(grpc::CompletionQueue* cq, gpr_timespec deadline, void* tag) { // Note that we know that alarm_ is actually an internal::AlarmImpl // but we declared it as the base pointer to avoid a forward declaration diff --git a/contrib/libs/grpc/src/cpp/common/channel_filter.cc b/contrib/libs/grpc/src/cpp/common/channel_filter.cc index 739e2da74b..55c31adbed 100644 --- a/contrib/libs/grpc/src/cpp/common/channel_filter.cc +++ b/contrib/libs/grpc/src/cpp/common/channel_filter.cc @@ -71,14 +71,13 @@ void RegisterChannelFilter( std::function<bool(const grpc_channel_args&)> include_filter, const grpc_channel_filter* filter) { auto maybe_add_filter = [include_filter, - filter](grpc_channel_stack_builder* builder) { + filter](grpc_core::ChannelStackBuilder* builder) { if (include_filter != nullptr) { - const grpc_channel_args* args = - grpc_channel_stack_builder_get_channel_arguments(builder); + const grpc_channel_args* args = builder->channel_args(); if (!include_filter(*args)) return true; } - return grpc_channel_stack_builder_prepend_filter(builder, filter, nullptr, - nullptr); + builder->PrependFilter(filter, nullptr); + return true; }; grpc_core::CoreConfiguration::RegisterBuilder( [stack_type, priority, diff --git a/contrib/libs/grpc/src/cpp/common/channel_filter.h b/contrib/libs/grpc/src/cpp/common/channel_filter.h index 6e0830f977..b58af7ad0a 100644 --- a/contrib/libs/grpc/src/cpp/common/channel_filter.h +++ b/contrib/libs/grpc/src/cpp/common/channel_filter.h @@ -328,6 +328,7 @@ void RegisterChannelFilter( using FilterType = internal::ChannelFilter<ChannelDataType, CallDataType>; static const grpc_channel_filter filter = { FilterType::StartTransportStreamOpBatch, + nullptr, FilterType::StartTransportOp, FilterType::call_data_size, FilterType::InitCallElement, diff --git a/contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc b/contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc index f4834214d0..8b1415a2cf 100644 --- a/contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc +++ b/contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc @@ -151,7 +151,7 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal( return SHUTDOWN; case GRPC_OP_COMPLETE: auto core_cq_tag = - static_cast<::grpc::internal::CompletionQueueTag*>(ev.tag); + static_cast<grpc::internal::CompletionQueueTag*>(ev.tag); *ok = ev.success != 0; *tag = core_cq_tag; if (core_cq_tag->FinalizeResult(tag, ok)) { @@ -179,7 +179,7 @@ bool CompletionQueue::CompletionQueueTLSCache::Flush(void** tag, bool* ok) { if (grpc_completion_queue_thread_local_cache_flush(cq_->cq_, &res_tag, &res)) { auto core_cq_tag = - static_cast<::grpc::internal::CompletionQueueTag*>(res_tag); + static_cast<grpc::internal::CompletionQueueTag*>(res_tag); *ok = res == 1; if (core_cq_tag->FinalizeResult(tag, ok)) { return true; diff --git a/contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc b/contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc index e669f600b5..de9919a617 100644 --- a/contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc +++ b/contrib/libs/grpc/src/cpp/common/tls_credentials_options.cc @@ -59,6 +59,17 @@ void TlsCredentialsOptions::set_identity_cert_name( c_credentials_options_, identity_cert_name.c_str()); } +void TlsCredentialsOptions::set_crl_directory(const TString& path) { + grpc_tls_credentials_options_set_crl_directory(c_credentials_options_, + path.c_str()); +} + +void TlsCredentialsOptions::set_tls_session_key_log_file_path( + const TString& tls_session_key_log_file_path) { + grpc_tls_credentials_options_set_tls_session_key_log_file_path( + c_credentials_options_, tls_session_key_log_file_path.c_str()); +} + void TlsCredentialsOptions::set_certificate_verifier( std::shared_ptr<CertificateVerifier> certificate_verifier) { certificate_verifier_ = std::move(certificate_verifier); diff --git a/contrib/libs/grpc/src/cpp/common/validate_service_config.cc b/contrib/libs/grpc/src/cpp/common/validate_service_config.cc index e680d2c982..5fc5be74ce 100644 --- a/contrib/libs/grpc/src/cpp/common/validate_service_config.cc +++ b/contrib/libs/grpc/src/cpp/common/validate_service_config.cc @@ -19,15 +19,15 @@ #include <grpc/grpc.h> #include <grpcpp/support/validate_service_config.h> -#include "src/core/lib/service_config/service_config.h" +#include "src/core/lib/service_config/service_config_impl.h" namespace grpc { namespace experimental { TString ValidateServiceConfigJSON(const TString& service_config_json) { grpc_init(); grpc_error_handle error = GRPC_ERROR_NONE; - grpc_core::ServiceConfig::Create(/*args=*/nullptr, - service_config_json.c_str(), &error); + grpc_core::ServiceConfigImpl::Create(/*args=*/nullptr, + service_config_json.c_str(), &error); TString return_value; if (error != GRPC_ERROR_NONE) { return_value = grpc_error_std_string(error); diff --git a/contrib/libs/grpc/src/cpp/common/version_cc.cc b/contrib/libs/grpc/src/cpp/common/version_cc.cc index 24bf9866c3..0e0e709c03 100644 --- a/contrib/libs/grpc/src/cpp/common/version_cc.cc +++ b/contrib/libs/grpc/src/cpp/common/version_cc.cc @@ -22,5 +22,5 @@ #include <grpcpp/grpcpp.h> namespace grpc { -TString Version() { return "1.44.0"; } +TString Version() { return "1.45.2"; } } // namespace grpc diff --git a/contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc b/contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc index 007193d7f7..709943ea9e 100644 --- a/contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc +++ b/contrib/libs/grpc/src/cpp/ext/proto_server_reflection_plugin.cc @@ -58,15 +58,15 @@ bool ProtoServerReflectionPlugin::has_async_methods() const { return false; } -static std::unique_ptr< ::grpc::ServerBuilderPlugin> CreateProtoReflection() { - return std::unique_ptr< ::grpc::ServerBuilderPlugin>( +static std::unique_ptr<grpc::ServerBuilderPlugin> CreateProtoReflection() { + return std::unique_ptr<grpc::ServerBuilderPlugin>( new ProtoServerReflectionPlugin()); } void InitProtoReflectionServerBuilderPlugin() { static struct Initialize { Initialize() { - ::grpc::ServerBuilder::InternalAddPluginFactory(&CreateProtoReflection); + grpc::ServerBuilder::InternalAddPluginFactory(&CreateProtoReflection); } } initializer; } diff --git a/contrib/libs/grpc/src/cpp/server/async_generic_service.cc b/contrib/libs/grpc/src/cpp/server/async_generic_service.cc index fdb3da830c..9580219ec1 100644 --- a/contrib/libs/grpc/src/cpp/server/async_generic_service.cc +++ b/contrib/libs/grpc/src/cpp/server/async_generic_service.cc @@ -23,8 +23,8 @@ namespace grpc { void AsyncGenericService::RequestCall( GenericServerContext* ctx, GenericServerAsyncReaderWriter* reader_writer, - ::grpc::CompletionQueue* call_cq, - ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + grpc::CompletionQueue* call_cq, + grpc::ServerCompletionQueue* notification_cq, void* tag) { server_->RequestAsyncGenericCall(ctx, reader_writer, call_cq, notification_cq, tag); } diff --git a/contrib/libs/grpc/src/cpp/server/channelz/channelz_service_plugin.cc b/contrib/libs/grpc/src/cpp/server/channelz/channelz_service_plugin.cc index b18624e3b6..b7f20b8312 100644 --- a/contrib/libs/grpc/src/cpp/server/channelz/channelz_service_plugin.cc +++ b/contrib/libs/grpc/src/cpp/server/channelz/channelz_service_plugin.cc @@ -29,7 +29,7 @@ namespace grpc { namespace channelz { namespace experimental { -class ChannelzServicePlugin : public ::grpc::ServerBuilderPlugin { +class ChannelzServicePlugin : public grpc::ServerBuilderPlugin { public: ChannelzServicePlugin() : channelz_service_(new grpc::ChannelzService()) {} @@ -61,16 +61,16 @@ class ChannelzServicePlugin : public ::grpc::ServerBuilderPlugin { std::shared_ptr<grpc::ChannelzService> channelz_service_; }; -static std::unique_ptr< ::grpc::ServerBuilderPlugin> +static std::unique_ptr<grpc::ServerBuilderPlugin> CreateChannelzServicePlugin() { - return std::unique_ptr< ::grpc::ServerBuilderPlugin>( + return std::unique_ptr<grpc::ServerBuilderPlugin>( new ChannelzServicePlugin()); } void InitChannelzService() { static struct Initializer { Initializer() { - ::grpc::ServerBuilder::InternalAddPluginFactory( + grpc::ServerBuilder::InternalAddPluginFactory( &grpc::channelz::experimental::CreateChannelzServicePlugin); } } initialize; diff --git a/contrib/libs/grpc/src/cpp/server/external_connection_acceptor_impl.h b/contrib/libs/grpc/src/cpp/server/external_connection_acceptor_impl.h index 430c72862e..ed356c1705 100644 --- a/contrib/libs/grpc/src/cpp/server/external_connection_acceptor_impl.h +++ b/contrib/libs/grpc/src/cpp/server/external_connection_acceptor_impl.h @@ -53,7 +53,7 @@ class ExternalConnectionAcceptorImpl ServerCredentials* GetCredentials() { return creds_.get(); } - void SetToChannelArgs(::grpc::ChannelArguments* args); + void SetToChannelArgs(grpc::ChannelArguments* args); private: const TString name_; diff --git a/contrib/libs/grpc/src/cpp/server/health/default_health_check_service.cc b/contrib/libs/grpc/src/cpp/server/health/default_health_check_service.cc index 52341c1612..d77f33ab79 100644 --- a/contrib/libs/grpc/src/cpp/server/health/default_health_check_service.cc +++ b/contrib/libs/grpc/src/cpp/server/health/default_health_check_service.cc @@ -161,8 +161,8 @@ DefaultHealthCheckService::HealthCheckServiceImpl::HealthCheckServiceImpl( AddMethod(new internal::RpcServiceMethod( kHealthWatchMethodName, internal::RpcMethod::SERVER_STREAMING, nullptr)); // Create serving thread. - thread_ = y_absl::make_unique<::grpc_core::Thread>("grpc_health_check_service", - Serve, this); + thread_ = y_absl::make_unique<grpc_core::Thread>("grpc_health_check_service", + Serve, this); } DefaultHealthCheckService::HealthCheckServiceImpl::~HealthCheckServiceImpl() { @@ -215,7 +215,7 @@ bool DefaultHealthCheckService::HealthCheckServiceImpl::DecodeRequest( if (request_struct == nullptr) { return false; } - upb_strview service = + upb_StringView service = grpc_health_v1_HealthCheckRequest_service(request_struct); if (service.size > MAX_SERVICE_NAME_LENGTH) { return false; diff --git a/contrib/libs/grpc/src/cpp/server/health/default_health_check_service.h b/contrib/libs/grpc/src/cpp/server/health/default_health_check_service.h index fe3d2b219a..88a1cf3927 100644 --- a/contrib/libs/grpc/src/cpp/server/health/default_health_check_service.h +++ b/contrib/libs/grpc/src/cpp/server/health/default_health_check_service.h @@ -229,7 +229,7 @@ class DefaultHealthCheckService final : public HealthCheckServiceInterface { // we don't enqueue new tags into cq_ after it is already shut down. grpc_core::Mutex cq_shutdown_mu_; std::atomic_bool shutdown_{false}; - std::unique_ptr<::grpc_core::Thread> thread_; + std::unique_ptr<grpc_core::Thread> thread_; }; DefaultHealthCheckService(); diff --git a/contrib/libs/grpc/src/cpp/server/insecure_server_credentials.cc b/contrib/libs/grpc/src/cpp/server/insecure_server_credentials.cc index 133647a5ed..893c54cc8a 100644 --- a/contrib/libs/grpc/src/cpp/server/insecure_server_credentials.cc +++ b/contrib/libs/grpc/src/cpp/server/insecure_server_credentials.cc @@ -17,6 +17,7 @@ */ #include <grpc/grpc.h> +#include <grpc/grpc_security.h> #include <grpc/support/log.h> #include <grpcpp/security/server_credentials.h> @@ -25,7 +26,11 @@ namespace { class InsecureServerCredentialsImpl final : public ServerCredentials { public: int AddPortToServer(const TString& addr, grpc_server* server) override { - return grpc_server_add_insecure_http2_port(server, addr.c_str()); + grpc_server_credentials* server_creds = + grpc_insecure_server_credentials_create(); + int result = grpc_server_add_http2_port(server, addr.c_str(), server_creds); + grpc_server_credentials_release(server_creds); + return result; } void SetAuthMetadataProcessor( const std::shared_ptr<grpc::AuthMetadataProcessor>& processor) override { diff --git a/contrib/libs/grpc/src/cpp/server/secure_server_credentials.cc b/contrib/libs/grpc/src/cpp/server/secure_server_credentials.cc index 819a12e294..487e738673 100644 --- a/contrib/libs/grpc/src/cpp/server/secure_server_credentials.cc +++ b/contrib/libs/grpc/src/cpp/server/secure_server_credentials.cc @@ -93,7 +93,7 @@ void AuthMetadataProcessorAyncWrapper::InvokeProcessor( int SecureServerCredentials::AddPortToServer(const TString& addr, grpc_server* server) { - return grpc_server_add_secure_http2_port(server, addr.c_str(), creds_); + return grpc_server_add_http2_port(server, addr.c_str(), creds_); } void SecureServerCredentials::SetAuthMetadataProcessor( diff --git a/contrib/libs/grpc/src/cpp/server/server_cc.cc b/contrib/libs/grpc/src/cpp/server/server_cc.cc index 02a52263c9..2a994a655a 100644 --- a/contrib/libs/grpc/src/cpp/server/server_cc.cc +++ b/contrib/libs/grpc/src/cpp/server/server_cc.cc @@ -226,26 +226,17 @@ ServerInterface::GenericAsyncRequest::GenericAsyncRequest( ServerInterface* server, GenericServerContext* context, internal::ServerAsyncStreamingInterface* stream, CompletionQueue* call_cq, ServerCompletionQueue* notification_cq, void* tag, bool delete_on_finalize, - bool delay_start) + bool issue_request) : BaseAsyncRequest(server, context, stream, call_cq, notification_cq, tag, delete_on_finalize) { grpc_call_details_init(&call_details_); - if (!delay_start) { - Start(); + GPR_ASSERT(notification_cq); + GPR_ASSERT(call_cq); + if (issue_request) { + IssueRequest(); } } -void ServerInterface::GenericAsyncRequest::Start() { - GPR_ASSERT(notification_cq_); - GPR_ASSERT(call_cq_); - // The following call_start_batch is internally-generated so no need for an - // explanatory log on failure. - GPR_ASSERT(grpc_server_request_call(server_->server(), &call_, &call_details_, - context_->client_metadata_.arr(), - call_cq_->cq(), notification_cq_->cq(), - this) == GRPC_CALL_OK); -} - bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag, bool* status) { // If we are done intercepting, there is nothing more for us to do @@ -271,6 +262,15 @@ bool ServerInterface::GenericAsyncRequest::FinalizeResult(void** tag, return BaseAsyncRequest::FinalizeResult(tag, status); } +void ServerInterface::GenericAsyncRequest::IssueRequest() { + // The following call_start_batch is internally-generated so no need for an + // explanatory log on failure. + GPR_ASSERT(grpc_server_request_call(server_->server(), &call_, &call_details_, + context_->client_metadata_.arr(), + call_cq_->cq(), notification_cq_->cq(), + this) == GRPC_CALL_OK); +} + namespace { class ShutdownCallback : public grpc_completion_queue_functor { public: @@ -310,8 +310,10 @@ class Server::UnimplementedAsyncRequest final UnimplementedAsyncRequest(ServerInterface* server, grpc::ServerCompletionQueue* cq) : GenericAsyncRequest(server, &server_context_, &generic_stream_, cq, cq, - nullptr, false, true) { - Start(); + /*tag=*/nullptr, /*delete_on_finalize=*/false, + /*issue_request=*/false) { + // Issue request here instead of the base class to prevent race on vptr. + IssueRequest(); } bool FinalizeResult(void** tag, bool* status) override; diff --git a/contrib/libs/grpc/src/cpp/server/server_context.cc b/contrib/libs/grpc/src/cpp/server/server_context.cc index c8ace3d914..7c0c37d82b 100644 --- a/contrib/libs/grpc/src/cpp/server/server_context.cc +++ b/contrib/libs/grpc/src/cpp/server/server_context.cc @@ -48,7 +48,7 @@ class ServerContextBase::CompletionOp final // initial refs: one in the server context, one in the cq // must ref the call before calling constructor and after deleting this CompletionOp(internal::Call* call, - ::grpc::internal::ServerCallbackCall* callback_controller) + grpc::internal::ServerCallbackCall* callback_controller) : call_(*call), callback_controller_(callback_controller), has_tag_(false), @@ -141,7 +141,7 @@ class ServerContextBase::CompletionOp final } internal::Call call_; - ::grpc::internal::ServerCallbackCall* const callback_controller_; + grpc::internal::ServerCallbackCall* const callback_controller_; bool has_tag_; void* tag_; void* core_cq_tag_; @@ -275,7 +275,7 @@ ServerContextBase::CallWrapper::~CallWrapper() { void ServerContextBase::BeginCompletionOp( internal::Call* call, std::function<void(bool)> callback, - ::grpc::internal::ServerCallbackCall* callback_controller) { + grpc::internal::ServerCallbackCall* callback_controller) { GPR_ASSERT(!completion_op_); if (rpc_info_) { rpc_info_->Ref(); diff --git a/contrib/libs/grpc/src/cpp/server/server_posix.cc b/contrib/libs/grpc/src/cpp/server/server_posix.cc index f2452cc326..5854242176 100644 --- a/contrib/libs/grpc/src/cpp/server/server_posix.cc +++ b/contrib/libs/grpc/src/cpp/server/server_posix.cc @@ -17,6 +17,7 @@ */ #include <grpc/grpc_posix.h> +#include <grpc/grpc_security.h> #include <grpcpp/server_posix.h> namespace grpc { @@ -24,7 +25,9 @@ namespace grpc { #ifdef GPR_SUPPORT_CHANNELS_FROM_FD void AddInsecureChannelFromFd(grpc::Server* server, int fd) { - grpc_server_add_insecure_channel_from_fd(server->c_server(), nullptr, fd); + grpc_server_credentials* creds = grpc_insecure_server_credentials_create(); + grpc_server_add_channel_from_fd(server->c_server(), fd, creds); + grpc_server_credentials_release(creds); } #endif // GPR_SUPPORT_CHANNELS_FROM_FD |