Delete wrapper in executor thread to avoid self-joining deadlock

reviewable/pr19139/r3
yang-g 6 years ago
parent 9d3288e408
commit bd97b1361d
  1. 17
      src/cpp/client/secure_credentials.cc

@ -22,6 +22,7 @@
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <grpcpp/impl/grpc_library.h> #include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/channel_arguments.h> #include <grpcpp/support/channel_arguments.h>
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/security/transport/auth_filters.h" #include "src/core/lib/security/transport/auth_filters.h"
#include "src/cpp/client/create_channel_internal.h" #include "src/cpp/client/create_channel_internal.h"
#include "src/cpp/common/secure_auth_context.h" #include "src/cpp/common/secure_auth_context.h"
@ -224,13 +225,23 @@ std::shared_ptr<grpc_impl::CallCredentials> MetadataCredentialsFromPlugin(
} // namespace grpc_impl } // namespace grpc_impl
namespace grpc { namespace grpc {
namespace {
void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) { void DeleteWrapper(void* wrapper, grpc_error* ignored) {
if (wrapper == nullptr) return;
MetadataCredentialsPluginWrapper* w = MetadataCredentialsPluginWrapper* w =
static_cast<MetadataCredentialsPluginWrapper*>(wrapper); static_cast<MetadataCredentialsPluginWrapper*>(wrapper);
delete w; 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( int MetadataCredentialsPluginWrapper::GetMetadata(
void* wrapper, grpc_auth_metadata_context context, void* wrapper, grpc_auth_metadata_context context,

Loading…
Cancel
Save