aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/src/cpp/client
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-03-25 12:34:53 +0300
committerheretic <heretic@yandex-team.ru>2022-03-25 12:34:53 +0300
commita41f3739eed6fceb6f62056a7620d220958a47e7 (patch)
tree278103258b510cb4a96761ea79d6ccd397ca05a0 /contrib/libs/grpc/src/cpp/client
parent73d3613a82e5c217fcbe0ab8bbf8120c1ed1af55 (diff)
downloadydb-a41f3739eed6fceb6f62056a7620d220958a47e7.tar.gz
Update grpc to 1.43.2 DTCC-864
ref:50a492c335cda70f458797cf945e49fe739c2715
Diffstat (limited to 'contrib/libs/grpc/src/cpp/client')
-rw-r--r--contrib/libs/grpc/src/cpp/client/channel_cc.cc38
-rw-r--r--contrib/libs/grpc/src/cpp/client/client_callback.cc7
-rw-r--r--contrib/libs/grpc/src/cpp/client/client_context.cc6
-rw-r--r--contrib/libs/grpc/src/cpp/client/create_channel_internal.cc5
-rw-r--r--contrib/libs/grpc/src/cpp/client/create_channel_internal.h2
-rw-r--r--contrib/libs/grpc/src/cpp/client/insecure_credentials.cc4
-rw-r--r--contrib/libs/grpc/src/cpp/client/secure_credentials.cc21
-rw-r--r--contrib/libs/grpc/src/cpp/client/secure_credentials.h5
-rw-r--r--contrib/libs/grpc/src/cpp/client/xds_credentials.cc8
9 files changed, 61 insertions, 35 deletions
diff --git a/contrib/libs/grpc/src/cpp/client/channel_cc.cc b/contrib/libs/grpc/src/cpp/client/channel_cc.cc
index 1793161d6c..280537bbbd 100644
--- a/contrib/libs/grpc/src/cpp/client/channel_cc.cc
+++ b/contrib/libs/grpc/src/cpp/client/channel_cc.cc
@@ -16,8 +16,6 @@
*
*/
-#include <grpcpp/channel.h>
-
#include <cstring>
#include <memory>
@@ -27,6 +25,7 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
+#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/completion_queue.h>
#include <grpcpp/impl/call.h>
@@ -57,12 +56,13 @@ Channel::Channel(const TString& host, grpc_channel* channel,
Channel::~Channel() {
grpc_channel_destroy(c_channel_);
- if (callback_cq_ != nullptr) {
+ CompletionQueue* callback_cq = callback_cq_.load(std::memory_order_relaxed);
+ if (callback_cq != nullptr) {
if (grpc_iomgr_run_in_background()) {
// gRPC-core provides the backing needed for the preferred CQ type
- callback_cq_->Shutdown();
+ callback_cq->Shutdown();
} else {
- CompletionQueue::ReleaseCallbackAlternativeCQ(callback_cq_);
+ CompletionQueue::ReleaseCallbackAlternativeCQ(callback_cq);
}
}
}
@@ -146,9 +146,9 @@ void ChannelResetConnectionBackoff(Channel* channel) {
// ClientRpcInfo should be set before call because set_call also checks
// whether the call has been cancelled, and if the call was cancelled, we
// should notify the interceptors too.
- auto* info =
- context->set_client_rpc_info(method.name(), method.method_type(), this,
- interceptor_creators_, interceptor_pos);
+ auto* info = context->set_client_rpc_info(
+ method.name(), method.suffix_for_stats(), method.method_type(), this,
+ interceptor_creators_, interceptor_pos);
context->set_call(c_call, shared_from_this());
return ::grpc::internal::Call(c_call, this, cq, info);
@@ -213,7 +213,7 @@ bool Channel::WaitForStateChangeImpl(grpc_connectivity_state last_observed,
}
namespace {
-class ShutdownCallback : public grpc_experimental_completion_queue_functor {
+class ShutdownCallback : public grpc_completion_queue_functor {
public:
ShutdownCallback() {
functor_run = &ShutdownCallback::Run;
@@ -229,7 +229,7 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor {
// The Run function will get invoked by the completion queue library
// when the shutdown is actually complete
- static void Run(grpc_experimental_completion_queue_functor* cb, int) {
+ static void Run(grpc_completion_queue_functor* cb, int) {
auto* callback = static_cast<ShutdownCallback*>(cb);
delete callback->cq_;
delete callback;
@@ -243,25 +243,33 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor {
::grpc::CompletionQueue* Channel::CallbackCQ() {
// TODO(vjpai): Consider using a single global CQ for the default CQ
// if there is no explicit per-channel CQ registered
+ CompletionQueue* callback_cq = callback_cq_.load(std::memory_order_acquire);
+ if (callback_cq != nullptr) {
+ return callback_cq;
+ }
+ // The callback_cq_ wasn't already set, so grab a lock and set it up exactly
+ // once for this channel.
grpc::internal::MutexLock l(&mu_);
- if (callback_cq_ == nullptr) {
+ callback_cq = callback_cq_.load(std::memory_order_relaxed);
+ if (callback_cq == nullptr) {
if (grpc_iomgr_run_in_background()) {
// gRPC-core provides the backing needed for the preferred CQ type
auto* shutdown_callback = new ShutdownCallback;
- callback_cq_ =
+ 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_);
+ shutdown_callback->TakeCQ(callback_cq);
} else {
// Otherwise we need to use the alternative CQ variant
- callback_cq_ = CompletionQueue::CallbackAlternativeCQ();
+ callback_cq = CompletionQueue::CallbackAlternativeCQ();
}
+ callback_cq_.store(callback_cq, std::memory_order_release);
}
- return callback_cq_;
+ return callback_cq;
}
} // namespace grpc
diff --git a/contrib/libs/grpc/src/cpp/client/client_callback.cc b/contrib/libs/grpc/src/cpp/client/client_callback.cc
index a05761ad06..9e4ebbb3f8 100644
--- a/contrib/libs/grpc/src/cpp/client/client_callback.cc
+++ b/contrib/libs/grpc/src/cpp/client/client_callback.cc
@@ -20,6 +20,7 @@
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/surface/call.h"
namespace grpc {
namespace internal {
@@ -36,7 +37,7 @@ void ClientReactor::InternalScheduleOnDone(grpc::Status s) {
: reactor(reactor_arg), status(std::move(s)) {
GRPC_CLOSURE_INIT(
&closure,
- [](void* void_arg, grpc_error*) {
+ [](void* void_arg, grpc_error_handle) {
ClosureWithArg* arg = static_cast<ClosureWithArg*>(void_arg);
arg->reactor->OnDone(arg->status);
delete arg;
@@ -48,5 +49,9 @@ void ClientReactor::InternalScheduleOnDone(grpc::Status s) {
grpc_core::Executor::Run(&arg->closure, GRPC_ERROR_NONE);
}
+bool ClientReactor::InternalTrailersOnly(const grpc_call* call) const {
+ return grpc_call_is_trailers_only(call);
+}
+
} // namespace internal
} // namespace grpc
diff --git a/contrib/libs/grpc/src/cpp/client/client_context.cc b/contrib/libs/grpc/src/cpp/client/client_context.cc
index 8f18bfe724..fd4a52c88e 100644
--- a/contrib/libs/grpc/src/cpp/client/client_context.cc
+++ b/contrib/libs/grpc/src/cpp/client/client_context.cc
@@ -16,14 +16,12 @@
*
*/
-#include <grpcpp/client_context.h>
-
#include <grpc/compression.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-
+#include <grpcpp/client_context.h>
#include <grpcpp/impl/codegen/interceptor_common.h>
#include <grpcpp/impl/codegen/sync.h>
#include <grpcpp/impl/grpc_library.h>
@@ -98,7 +96,7 @@ std::unique_ptr<ClientContext> ClientContext::FromInternalServerContext(
}
std::unique_ptr<ClientContext> ClientContext::FromServerContext(
- const grpc::ServerContext& server_context, PropagationOptions options) {
+ const grpc::ServerContextBase& server_context, PropagationOptions options) {
return FromInternalServerContext(server_context, options);
}
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 da2a878a22..77ab7ac8b5 100644
--- a/contrib/libs/grpc/src/cpp/client/create_channel_internal.cc
+++ b/contrib/libs/grpc/src/cpp/client/create_channel_internal.cc
@@ -16,7 +16,12 @@
*
*/
+#include "src/cpp/client/create_channel_internal.h"
+
#include <memory>
+#include <util/generic/string.h>
+#include <utility>
+#include <vector>
#include <grpcpp/channel.h>
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 09d4e56b02..730051694b 100644
--- a/contrib/libs/grpc/src/cpp/client/create_channel_internal.h
+++ b/contrib/libs/grpc/src/cpp/client/create_channel_internal.h
@@ -20,6 +20,8 @@
#define GRPC_INTERNAL_CPP_CLIENT_CREATE_CHANNEL_INTERNAL_H
#include <memory>
+#include <util/generic/string.h>
+#include <vector>
#include <grpcpp/channel.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
diff --git a/contrib/libs/grpc/src/cpp/client/insecure_credentials.cc b/contrib/libs/grpc/src/cpp/client/insecure_credentials.cc
index b7036e541c..d266e21435 100644
--- a/contrib/libs/grpc/src/cpp/client/insecure_credentials.cc
+++ b/contrib/libs/grpc/src/cpp/client/insecure_credentials.cc
@@ -15,13 +15,13 @@
* limitations under the License.
*
*/
-#include <grpcpp/security/credentials.h>
-
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpcpp/channel.h>
+#include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/config.h>
+
#include "src/cpp/client/create_channel_internal.h"
namespace grpc {
diff --git a/contrib/libs/grpc/src/cpp/client/secure_credentials.cc b/contrib/libs/grpc/src/cpp/client/secure_credentials.cc
index 109b50448d..ee3bde2eb2 100644
--- a/contrib/libs/grpc/src/cpp/client/secure_credentials.cc
+++ b/contrib/libs/grpc/src/cpp/client/secure_credentials.cc
@@ -18,6 +18,8 @@
#include "src/cpp/client/secure_credentials.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/impl/codegen/slice.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
@@ -28,8 +30,6 @@
#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/channel_arguments.h>
-#include "y_absl/strings/str_join.h"
-
// TODO(yashykt): We shouldn't be including "src/core" headers.
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/error.h"
@@ -157,7 +157,7 @@ grpc::Status StsCredentialsOptionsFromJson(const TString& json_string,
"options cannot be nullptr.");
}
ClearStsCredentialsOptions(options);
- grpc_error* error = GRPC_ERROR_NONE;
+ grpc_error_handle error = GRPC_ERROR_NONE;
grpc_core::Json json = grpc_core::Json::Parse(json_string.c_str(), &error);
if (error != GRPC_ERROR_NONE ||
json.type() != grpc_core::Json::Type::OBJECT) {
@@ -215,8 +215,9 @@ grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options) {
ClearStsCredentialsOptions(options);
grpc_slice json_string = grpc_empty_slice();
char* sts_creds_path = gpr_getenv("STS_CREDENTIALS");
- grpc_error* error = GRPC_ERROR_NONE;
+ grpc_error_handle error = GRPC_ERROR_NONE;
grpc::Status status;
+ // NOLINTNEXTLINE(clang-diagnostic-unused-lambda-capture)
auto cleanup = [&json_string, &sts_creds_path, &error, &status]() {
grpc_slice_unref_internal(json_string);
gpr_free(sts_creds_path);
@@ -232,7 +233,7 @@ grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options) {
error = grpc_load_file(sts_creds_path, 1, &json_string);
if (error != GRPC_ERROR_NONE) {
status =
- grpc::Status(grpc::StatusCode::NOT_FOUND, grpc_error_string(error));
+ grpc::Status(grpc::StatusCode::NOT_FOUND, grpc_error_std_string(error));
return cleanup();
}
status = StsCredentialsOptionsFromJson(
@@ -406,7 +407,7 @@ std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
}
namespace {
-void DeleteWrapper(void* wrapper, grpc_error* /*ignored*/) {
+void DeleteWrapper(void* wrapper, grpc_error_handle /*ignored*/) {
MetadataCredentialsPluginWrapper* w =
static_cast<MetadataCredentialsPluginWrapper*>(wrapper);
delete w;
@@ -492,7 +493,6 @@ void MetadataCredentialsPluginWrapper::InvokePlugin(
grpc_metadata md_entry;
md_entry.key = SliceFromCopiedString(metadatum.first);
md_entry.value = SliceFromCopiedString(metadatum.second);
- md_entry.flags = 0;
md.push_back(md_entry);
}
if (creds_md != nullptr) {
@@ -507,7 +507,6 @@ void MetadataCredentialsPluginWrapper::InvokePlugin(
for (const auto& elem : md) {
creds_md[*num_creds_md].key = elem.key;
creds_md[*num_creds_md].value = elem.value;
- creds_md[*num_creds_md].flags = elem.flags;
++(*num_creds_md);
}
*status_code = static_cast<grpc_status_code>(status.error_code());
@@ -525,6 +524,10 @@ void MetadataCredentialsPluginWrapper::InvokePlugin(
MetadataCredentialsPluginWrapper::MetadataCredentialsPluginWrapper(
std::unique_ptr<MetadataCredentialsPlugin> plugin)
- : thread_pool_(CreateDefaultThreadPool()), plugin_(std::move(plugin)) {}
+ : plugin_(std::move(plugin)) {
+ if (plugin_->IsBlocking()) {
+ thread_pool_.reset(CreateDefaultThreadPool());
+ }
+}
} // namespace grpc
diff --git a/contrib/libs/grpc/src/cpp/client/secure_credentials.h b/contrib/libs/grpc/src/cpp/client/secure_credentials.h
index 9325f365b1..d6f1c89c2c 100644
--- a/contrib/libs/grpc/src/cpp/client/secure_credentials.h
+++ b/contrib/libs/grpc/src/cpp/client/secure_credentials.h
@@ -19,13 +19,12 @@
#ifndef GRPC_INTERNAL_CPP_CLIENT_SECURE_CREDENTIALS_H
#define GRPC_INTERNAL_CPP_CLIENT_SECURE_CREDENTIALS_H
-#include <grpc/grpc_security.h>
+#include "y_absl/strings/str_cat.h"
+#include <grpc/grpc_security.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/security/tls_credentials_options.h>
#include <grpcpp/support/config.h>
-
-#include "y_absl/strings/str_cat.h"
// TODO(yashykt): We shouldn't be including "src/core" headers.
#include "src/core/lib/security/credentials/credentials.h"
#include "src/cpp/server/thread_pool_interface.h"
diff --git a/contrib/libs/grpc/src/cpp/client/xds_credentials.cc b/contrib/libs/grpc/src/cpp/client/xds_credentials.cc
index 63b48837ef..d5446a02fe 100644
--- a/contrib/libs/grpc/src/cpp/client/xds_credentials.cc
+++ b/contrib/libs/grpc/src/cpp/client/xds_credentials.cc
@@ -19,7 +19,6 @@
#include "src/cpp/client/secure_credentials.h"
namespace grpc {
-namespace experimental {
std::shared_ptr<ChannelCredentials> XdsCredentials(
const std::shared_ptr<ChannelCredentials>& fallback_creds) {
@@ -37,5 +36,12 @@ std::shared_ptr<ChannelCredentials> XdsCredentials(
}
}
+namespace experimental {
+
+std::shared_ptr<ChannelCredentials> XdsCredentials(
+ const std::shared_ptr<ChannelCredentials>& fallback_creds) {
+ return grpc::XdsCredentials(fallback_creds);
+}
+
} // namespace experimental
} // namespace grpc