From bd97b1361df0a2d7ac0bbd02a2a7e618fab299cc Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 29 May 2019 12:04:40 -0700 Subject: [PATCH] Delete wrapper in executor thread to avoid self-joining deadlock --- src/cpp/client/secure_credentials.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 2d041a28664..3d2a123180b 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -22,6 +22,7 @@ #include #include #include +#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/security/transport/auth_filters.h" #include "src/cpp/client/create_channel_internal.h" #include "src/cpp/common/secure_auth_context.h" @@ -224,13 +225,23 @@ std::shared_ptr MetadataCredentialsFromPlugin( } // namespace grpc_impl namespace grpc { - -void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) { - if (wrapper == nullptr) return; +namespace { +void DeleteWrapper(void* wrapper, grpc_error* ignored) { MetadataCredentialsPluginWrapper* w = static_cast(wrapper); delete w; } +} // namespace + +void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) { + if (wrapper == nullptr) return; + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; + grpc_core::ExecCtx exec_ctx; + GRPC_CLOSURE_RUN(GRPC_CLOSURE_CREATE(DeleteWrapper, wrapper, + grpc_core::Executor::Scheduler( + grpc_core::ExecutorJobType::SHORT)), + GRPC_ERROR_NONE); +} int MetadataCredentialsPluginWrapper::GetMetadata( void* wrapper, grpc_auth_metadata_context context,