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/server | |
parent | 1911ec1bf2da9ae39eb5f31511a92b06b9631da1 (diff) | |
download | ydb-14a9357e8d2d937e22b789d5aea09219a3e92c31.tar.gz |
Update contrib/libs/grpc to 1.45.2
Diffstat (limited to 'contrib/libs/grpc/src/cpp/server')
10 files changed, 43 insertions, 33 deletions
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 |