Merge pull request #17149 from yihuazhang/remove_alts_shared_resource

Do not use ALTS shared resource.
pull/17211/head
yihuaz 6 years ago committed by GitHub
commit 4125631471
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      BUILD
  2. 2
      CMakeLists.txt
  3. 3
      Makefile
  4. 3
      build.yaml
  5. 1
      config.m4
  6. 1
      config.w32
  7. 1
      gRPC-C++.podspec
  8. 3
      gRPC-Core.podspec
  9. 2
      grpc.gemspec
  10. 1
      grpc.gyp
  11. 2
      package.xml
  12. 4
      src/core/plugin_registry/grpc_cronet_plugin_registry.cc
  13. 4
      src/core/plugin_registry/grpc_plugin_registry.cc
  14. 28
      src/core/tsi/alts/handshaker/alts_shared_resource.cc
  15. 5
      src/core/tsi/alts/handshaker/alts_shared_resource.h
  16. 54
      src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
  17. 1
      src/core/tsi/alts/handshaker/alts_tsi_handshaker.h
  18. 41
      src/core/tsi/alts_transport_security.cc
  19. 38
      src/core/tsi/alts_transport_security.h
  20. 1
      src/python/grpcio/grpc_core_dependencies.py
  21. 2
      tools/doxygen/Doxyfile.core.internal
  22. 3
      tools/run_tests/generated/sources_and_headers.json

@ -1962,7 +1962,6 @@ grpc_cc_library(
"src/core/tsi/alts/handshaker/alts_shared_resource.cc", "src/core/tsi/alts/handshaker/alts_shared_resource.cc",
"src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc", "src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc",
"src/core/tsi/alts/handshaker/alts_tsi_utils.cc", "src/core/tsi/alts/handshaker/alts_tsi_utils.cc",
"src/core/tsi/alts_transport_security.cc",
"src/core/tsi/fake_transport_security.cc", "src/core/tsi/fake_transport_security.cc",
"src/core/tsi/local_transport_security.cc", "src/core/tsi/local_transport_security.cc",
"src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc", "src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc",
@ -1977,7 +1976,6 @@ grpc_cc_library(
"src/core/tsi/alts/handshaker/alts_tsi_handshaker.h", "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h",
"src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h", "src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h",
"src/core/tsi/alts/handshaker/alts_tsi_utils.h", "src/core/tsi/alts/handshaker/alts_tsi_utils.h",
"src/core/tsi/alts_transport_security.h",
"src/core/tsi/fake_transport_security.h", "src/core/tsi/fake_transport_security.h",
"src/core/tsi/local_transport_security.h", "src/core/tsi/local_transport_security.h",
"src/core/tsi/ssl/session_cache/ssl_session.h", "src/core/tsi/ssl/session_cache/ssl_session.h",

@ -1251,7 +1251,6 @@ add_library(grpc
src/core/ext/filters/client_channel/subchannel_index.cc src/core/ext/filters/client_channel/subchannel_index.cc
src/core/ext/filters/deadline/deadline_filter.cc src/core/ext/filters/deadline/deadline_filter.cc
src/core/ext/filters/client_channel/health/health.pb.c src/core/ext/filters/client_channel/health/health.pb.c
src/core/tsi/alts_transport_security.cc
src/core/tsi/fake_transport_security.cc src/core/tsi/fake_transport_security.cc
src/core/tsi/local_transport_security.cc src/core/tsi/local_transport_security.cc
src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc
@ -1675,7 +1674,6 @@ add_library(grpc_cronet
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc
src/core/ext/transport/chttp2/client/authority.cc src/core/ext/transport/chttp2/client/authority.cc
src/core/ext/transport/chttp2/client/chttp2_connector.cc src/core/ext/transport/chttp2/client/chttp2_connector.cc
src/core/tsi/alts_transport_security.cc
src/core/tsi/fake_transport_security.cc src/core/tsi/fake_transport_security.cc
src/core/tsi/local_transport_security.cc src/core/tsi/local_transport_security.cc
src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc

@ -3726,7 +3726,6 @@ LIBGRPC_SRC = \
src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/filters/deadline/deadline_filter.cc \
src/core/ext/filters/client_channel/health/health.pb.c \ src/core/ext/filters/client_channel/health/health.pb.c \
src/core/tsi/alts_transport_security.cc \
src/core/tsi/fake_transport_security.cc \ src/core/tsi/fake_transport_security.cc \
src/core/tsi/local_transport_security.cc \ src/core/tsi/local_transport_security.cc \
src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \ src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \
@ -4144,7 +4143,6 @@ LIBGRPC_CRONET_SRC = \
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc \
src/core/ext/transport/chttp2/client/authority.cc \ src/core/ext/transport/chttp2/client/authority.cc \
src/core/ext/transport/chttp2/client/chttp2_connector.cc \ src/core/ext/transport/chttp2/client/chttp2_connector.cc \
src/core/tsi/alts_transport_security.cc \
src/core/tsi/fake_transport_security.cc \ src/core/tsi/fake_transport_security.cc \
src/core/tsi/local_transport_security.cc \ src/core/tsi/local_transport_security.cc \
src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \ src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \
@ -25037,7 +25035,6 @@ src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_p
src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc: $(OPENSSL_DEP) src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc: $(OPENSSL_DEP)
src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc: $(OPENSSL_DEP) src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc: $(OPENSSL_DEP)
src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc: $(OPENSSL_DEP) src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc: $(OPENSSL_DEP)
src/core/tsi/alts_transport_security.cc: $(OPENSSL_DEP)
src/core/tsi/fake_transport_security.cc: $(OPENSSL_DEP) src/core/tsi/fake_transport_security.cc: $(OPENSSL_DEP)
src/core/tsi/local_transport_security.cc: $(OPENSSL_DEP) src/core/tsi/local_transport_security.cc: $(OPENSSL_DEP)
src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc: $(OPENSSL_DEP) src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc: $(OPENSSL_DEP)

@ -1146,7 +1146,6 @@ filegroups:
- grpc - grpc
- name: tsi - name: tsi
headers: headers:
- src/core/tsi/alts_transport_security.h
- src/core/tsi/fake_transport_security.h - src/core/tsi/fake_transport_security.h
- src/core/tsi/local_transport_security.h - src/core/tsi/local_transport_security.h
- src/core/tsi/ssl/session_cache/ssl_session.h - src/core/tsi/ssl/session_cache/ssl_session.h
@ -1155,7 +1154,6 @@ filegroups:
- src/core/tsi/ssl_types.h - src/core/tsi/ssl_types.h
- src/core/tsi/transport_security_grpc.h - src/core/tsi/transport_security_grpc.h
src: src:
- src/core/tsi/alts_transport_security.cc
- src/core/tsi/fake_transport_security.cc - src/core/tsi/fake_transport_security.cc
- src/core/tsi/local_transport_security.cc - src/core/tsi/local_transport_security.cc
- src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc - src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc
@ -1165,7 +1163,6 @@ filegroups:
- src/core/tsi/transport_security_grpc.cc - src/core/tsi/transport_security_grpc.cc
deps: deps:
- gpr - gpr
plugin: grpc_tsi_alts
secure: true secure: true
uses: uses:
- tsi_interface - tsi_interface

@ -360,7 +360,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/filters/client_channel/subchannel_index.cc \ src/core/ext/filters/client_channel/subchannel_index.cc \
src/core/ext/filters/deadline/deadline_filter.cc \ src/core/ext/filters/deadline/deadline_filter.cc \
src/core/ext/filters/client_channel/health/health.pb.c \ src/core/ext/filters/client_channel/health/health.pb.c \
src/core/tsi/alts_transport_security.cc \
src/core/tsi/fake_transport_security.cc \ src/core/tsi/fake_transport_security.cc \
src/core/tsi/local_transport_security.cc \ src/core/tsi/local_transport_security.cc \
src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \ src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc \

@ -335,7 +335,6 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\filters\\client_channel\\subchannel_index.cc " + "src\\core\\ext\\filters\\client_channel\\subchannel_index.cc " +
"src\\core\\ext\\filters\\deadline\\deadline_filter.cc " + "src\\core\\ext\\filters\\deadline\\deadline_filter.cc " +
"src\\core\\ext\\filters\\client_channel\\health\\health.pb.c " + "src\\core\\ext\\filters\\client_channel\\health\\health.pb.c " +
"src\\core\\tsi\\alts_transport_security.cc " +
"src\\core\\tsi\\fake_transport_security.cc " + "src\\core\\tsi\\fake_transport_security.cc " +
"src\\core\\tsi\\local_transport_security.cc " + "src\\core\\tsi\\local_transport_security.cc " +
"src\\core\\tsi\\ssl\\session_cache\\ssl_session_boringssl.cc " + "src\\core\\tsi\\ssl\\session_cache\\ssl_session_boringssl.cc " +

@ -359,7 +359,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/subchannel_index.h',
'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/ext/filters/client_channel/health/health.pb.h',
'src/core/tsi/alts_transport_security.h',
'src/core/tsi/fake_transport_security.h', 'src/core/tsi/fake_transport_security.h',
'src/core/tsi/local_transport_security.h', 'src/core/tsi/local_transport_security.h',
'src/core/tsi/ssl/session_cache/ssl_session.h', 'src/core/tsi/ssl/session_cache/ssl_session.h',

@ -357,7 +357,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/subchannel_index.h',
'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/ext/filters/client_channel/health/health.pb.h',
'src/core/tsi/alts_transport_security.h',
'src/core/tsi/fake_transport_security.h', 'src/core/tsi/fake_transport_security.h',
'src/core/tsi/local_transport_security.h', 'src/core/tsi/local_transport_security.h',
'src/core/tsi/ssl/session_cache/ssl_session.h', 'src/core/tsi/ssl/session_cache/ssl_session.h',
@ -797,7 +796,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/ext/filters/client_channel/health/health.pb.c',
'src/core/tsi/alts_transport_security.cc',
'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/fake_transport_security.cc',
'src/core/tsi/local_transport_security.cc', 'src/core/tsi/local_transport_security.cc',
'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc',
@ -976,7 +974,6 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/subchannel_index.h',
'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/filters/client_channel/health/health.pb.h', 'src/core/ext/filters/client_channel/health/health.pb.h',
'src/core/tsi/alts_transport_security.h',
'src/core/tsi/fake_transport_security.h', 'src/core/tsi/fake_transport_security.h',
'src/core/tsi/local_transport_security.h', 'src/core/tsi/local_transport_security.h',
'src/core/tsi/ssl/session_cache/ssl_session.h', 'src/core/tsi/ssl/session_cache/ssl_session.h',

@ -293,7 +293,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/subchannel_index.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.h )
s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.h )
s.files += %w( src/core/ext/filters/client_channel/health/health.pb.h ) s.files += %w( src/core/ext/filters/client_channel/health/health.pb.h )
s.files += %w( src/core/tsi/alts_transport_security.h )
s.files += %w( src/core/tsi/fake_transport_security.h ) s.files += %w( src/core/tsi/fake_transport_security.h )
s.files += %w( src/core/tsi/local_transport_security.h ) s.files += %w( src/core/tsi/local_transport_security.h )
s.files += %w( src/core/tsi/ssl/session_cache/ssl_session.h ) s.files += %w( src/core/tsi/ssl/session_cache/ssl_session.h )
@ -736,7 +735,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/subchannel_index.cc ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.cc )
s.files += %w( src/core/ext/filters/deadline/deadline_filter.cc ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.cc )
s.files += %w( src/core/ext/filters/client_channel/health/health.pb.c ) s.files += %w( src/core/ext/filters/client_channel/health/health.pb.c )
s.files += %w( src/core/tsi/alts_transport_security.cc )
s.files += %w( src/core/tsi/fake_transport_security.cc ) s.files += %w( src/core/tsi/fake_transport_security.cc )
s.files += %w( src/core/tsi/local_transport_security.cc ) s.files += %w( src/core/tsi/local_transport_security.cc )
s.files += %w( src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc ) s.files += %w( src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc )

@ -552,7 +552,6 @@
'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/ext/filters/client_channel/health/health.pb.c',
'src/core/tsi/alts_transport_security.cc',
'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/fake_transport_security.cc',
'src/core/tsi/local_transport_security.cc', 'src/core/tsi/local_transport_security.cc',
'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc',

@ -298,7 +298,6 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_index.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_index.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/health/health.pb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/health/health.pb.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/alts_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/fake_transport_security.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/fake_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/local_transport_security.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/local_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl/session_cache/ssl_session.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/ssl/session_cache/ssl_session.h" role="src" />
@ -741,7 +740,6 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_index.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/subchannel_index.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/health/health.pb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/health/health.pb.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/alts_transport_security.cc" role="src" />
<file baseinstalldir="/" name="src/core/tsi/fake_transport_security.cc" role="src" /> <file baseinstalldir="/" name="src/core/tsi/fake_transport_security.cc" role="src" />
<file baseinstalldir="/" name="src/core/tsi/local_transport_security.cc" role="src" /> <file baseinstalldir="/" name="src/core/tsi/local_transport_security.cc" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc" role="src" /> <file baseinstalldir="/" name="src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc" role="src" />

@ -28,8 +28,6 @@ void grpc_deadline_filter_init(void);
void grpc_deadline_filter_shutdown(void); void grpc_deadline_filter_shutdown(void);
void grpc_client_channel_init(void); void grpc_client_channel_init(void);
void grpc_client_channel_shutdown(void); void grpc_client_channel_shutdown(void);
void grpc_tsi_alts_init(void);
void grpc_tsi_alts_shutdown(void);
void grpc_register_built_in_plugins(void) { void grpc_register_built_in_plugins(void) {
grpc_register_plugin(grpc_http_filters_init, grpc_register_plugin(grpc_http_filters_init,
@ -40,6 +38,4 @@ void grpc_register_built_in_plugins(void) {
grpc_deadline_filter_shutdown); grpc_deadline_filter_shutdown);
grpc_register_plugin(grpc_client_channel_init, grpc_register_plugin(grpc_client_channel_init,
grpc_client_channel_shutdown); grpc_client_channel_shutdown);
grpc_register_plugin(grpc_tsi_alts_init,
grpc_tsi_alts_shutdown);
} }

@ -28,8 +28,6 @@ void grpc_deadline_filter_init(void);
void grpc_deadline_filter_shutdown(void); void grpc_deadline_filter_shutdown(void);
void grpc_client_channel_init(void); void grpc_client_channel_init(void);
void grpc_client_channel_shutdown(void); void grpc_client_channel_shutdown(void);
void grpc_tsi_alts_init(void);
void grpc_tsi_alts_shutdown(void);
void grpc_inproc_plugin_init(void); void grpc_inproc_plugin_init(void);
void grpc_inproc_plugin_shutdown(void); void grpc_inproc_plugin_shutdown(void);
void grpc_resolver_fake_init(void); void grpc_resolver_fake_init(void);
@ -66,8 +64,6 @@ void grpc_register_built_in_plugins(void) {
grpc_deadline_filter_shutdown); grpc_deadline_filter_shutdown);
grpc_register_plugin(grpc_client_channel_init, grpc_register_plugin(grpc_client_channel_init,
grpc_client_channel_shutdown); grpc_client_channel_shutdown);
grpc_register_plugin(grpc_tsi_alts_init,
grpc_tsi_alts_shutdown);
grpc_register_plugin(grpc_inproc_plugin_init, grpc_register_plugin(grpc_inproc_plugin_init,
grpc_inproc_plugin_shutdown); grpc_inproc_plugin_shutdown);
grpc_register_plugin(grpc_resolver_fake_init, grpc_register_plugin(grpc_resolver_fake_init,

@ -25,7 +25,6 @@
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h" #include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
static alts_shared_resource_dedicated g_alts_resource_dedicated; static alts_shared_resource_dedicated g_alts_resource_dedicated;
static alts_shared_resource* g_shared_resources = alts_get_shared_resource();
alts_shared_resource_dedicated* grpc_alts_get_shared_resource_dedicated(void) { alts_shared_resource_dedicated* grpc_alts_get_shared_resource_dedicated(void) {
return &g_alts_resource_dedicated; return &g_alts_resource_dedicated;
@ -49,16 +48,25 @@ static void thread_worker(void* arg) {
void grpc_alts_shared_resource_dedicated_init() { void grpc_alts_shared_resource_dedicated_init() {
g_alts_resource_dedicated.cq = nullptr; g_alts_resource_dedicated.cq = nullptr;
gpr_mu_init(&g_alts_resource_dedicated.mu);
} }
void grpc_alts_shared_resource_dedicated_start() { void grpc_alts_shared_resource_dedicated_start(
g_alts_resource_dedicated.cq = grpc_completion_queue_create_for_next(nullptr); const char* handshaker_service_url) {
g_alts_resource_dedicated.thread = gpr_mu_lock(&g_alts_resource_dedicated.mu);
grpc_core::Thread("alts_tsi_handshaker", &thread_worker, nullptr); if (g_alts_resource_dedicated.cq == nullptr) {
g_alts_resource_dedicated.interested_parties = grpc_pollset_set_create(); g_alts_resource_dedicated.channel =
grpc_pollset_set_add_pollset(g_alts_resource_dedicated.interested_parties, grpc_insecure_channel_create(handshaker_service_url, nullptr, nullptr);
grpc_cq_pollset(g_alts_resource_dedicated.cq)); g_alts_resource_dedicated.cq =
g_alts_resource_dedicated.thread.Start(); grpc_completion_queue_create_for_next(nullptr);
g_alts_resource_dedicated.thread =
grpc_core::Thread("alts_tsi_handshaker", &thread_worker, nullptr);
g_alts_resource_dedicated.interested_parties = grpc_pollset_set_create();
grpc_pollset_set_add_pollset(g_alts_resource_dedicated.interested_parties,
grpc_cq_pollset(g_alts_resource_dedicated.cq));
g_alts_resource_dedicated.thread.Start();
}
gpr_mu_unlock(&g_alts_resource_dedicated.mu);
} }
void grpc_alts_shared_resource_dedicated_shutdown() { void grpc_alts_shared_resource_dedicated_shutdown() {
@ -69,5 +77,7 @@ void grpc_alts_shared_resource_dedicated_shutdown() {
g_alts_resource_dedicated.thread.Join(); g_alts_resource_dedicated.thread.Join();
grpc_pollset_set_destroy(g_alts_resource_dedicated.interested_parties); grpc_pollset_set_destroy(g_alts_resource_dedicated.interested_parties);
grpc_completion_queue_destroy(g_alts_resource_dedicated.cq); grpc_completion_queue_destroy(g_alts_resource_dedicated.cq);
grpc_channel_destroy(g_alts_resource_dedicated.channel);
} }
gpr_mu_destroy(&g_alts_resource_dedicated.mu);
} }

@ -37,6 +37,8 @@ typedef struct alts_shared_resource_dedicated {
grpc_completion_queue* cq; grpc_completion_queue* cq;
grpc_pollset_set* interested_parties; grpc_pollset_set* interested_parties;
grpc_cq_completion storage; grpc_cq_completion storage;
gpr_mu mu;
grpc_channel* channel;
} alts_shared_resource_dedicated; } alts_shared_resource_dedicated;
/* This method returns the address of alts_shared_resource_dedicated /* This method returns the address of alts_shared_resource_dedicated
@ -64,7 +66,8 @@ void grpc_alts_shared_resource_dedicated_init();
* The API will be invoked by the caller in a lazy manner. That is, * The API will be invoked by the caller in a lazy manner. That is,
* it will get invoked when ALTS TSI handshake occurs for the first time. * it will get invoked when ALTS TSI handshake occurs for the first time.
*/ */
void grpc_alts_shared_resource_dedicated_start(); void grpc_alts_shared_resource_dedicated_start(
const char* handshaker_service_url);
#endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_SHARED_RESOURCE_H \ #endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_SHARED_RESOURCE_H \
*/ */

@ -39,9 +39,6 @@
#include "src/core/tsi/alts/handshaker/alts_shared_resource.h" #include "src/core/tsi/alts/handshaker/alts_shared_resource.h"
#include "src/core/tsi/alts/handshaker/alts_tsi_utils.h" #include "src/core/tsi/alts/handshaker/alts_tsi_utils.h"
#include "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h" #include "src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h"
#include "src/core/tsi/alts_transport_security.h"
static alts_shared_resource* g_shared_resources = alts_get_shared_resource();
/* Main struct for ALTS TSI handshaker. */ /* Main struct for ALTS TSI handshaker. */
struct alts_tsi_handshaker { struct alts_tsi_handshaker {
@ -51,11 +48,11 @@ struct alts_tsi_handshaker {
bool is_client; bool is_client;
bool has_sent_start_message; bool has_sent_start_message;
bool has_created_handshaker_client; bool has_created_handshaker_client;
bool use_dedicated_cq;
char* handshaker_service_url; char* handshaker_service_url;
grpc_pollset_set* interested_parties; grpc_pollset_set* interested_parties;
grpc_alts_credentials_options* options; grpc_alts_credentials_options* options;
alts_handshaker_client_vtable* client_vtable_for_testing; alts_handshaker_client_vtable* client_vtable_for_testing;
grpc_channel* channel;
}; };
/* Main struct for ALTS TSI handshaker result. */ /* Main struct for ALTS TSI handshaker result. */
@ -237,20 +234,6 @@ tsi_result alts_tsi_handshaker_result_create(grpc_gcp_handshaker_resp* resp,
return TSI_OK; return TSI_OK;
} }
static void init_shared_resources(const char* handshaker_service_url,
bool use_dedicated_cq) {
GPR_ASSERT(handshaker_service_url != nullptr);
gpr_mu_lock(&g_shared_resources->mu);
if (g_shared_resources->channel == nullptr) {
g_shared_resources->channel =
grpc_insecure_channel_create(handshaker_service_url, nullptr, nullptr);
if (use_dedicated_cq) {
grpc_alts_shared_resource_dedicated_start();
}
}
gpr_mu_unlock(&g_shared_resources->mu);
}
/* gRPC provided callback used when gRPC thread model is applied. */ /* gRPC provided callback used when gRPC thread model is applied. */
static void on_handshaker_service_resp_recv(void* arg, grpc_error* error) { static void on_handshaker_service_resp_recv(void* arg, grpc_error* error) {
alts_handshaker_client* client = static_cast<alts_handshaker_client*>(arg); alts_handshaker_client* client = static_cast<alts_handshaker_client*>(arg);
@ -289,20 +272,24 @@ static tsi_result handshaker_next(
reinterpret_cast<alts_tsi_handshaker*>(self); reinterpret_cast<alts_tsi_handshaker*>(self);
tsi_result ok = TSI_OK; tsi_result ok = TSI_OK;
if (!handshaker->has_created_handshaker_client) { if (!handshaker->has_created_handshaker_client) {
init_shared_resources(handshaker->handshaker_service_url, if (handshaker->channel == nullptr) {
handshaker->use_dedicated_cq); grpc_alts_shared_resource_dedicated_start(
if (handshaker->use_dedicated_cq) { handshaker->handshaker_service_url);
handshaker->interested_parties = handshaker->interested_parties =
grpc_alts_get_shared_resource_dedicated()->interested_parties; grpc_alts_get_shared_resource_dedicated()->interested_parties;
GPR_ASSERT(handshaker->interested_parties != nullptr); GPR_ASSERT(handshaker->interested_parties != nullptr);
} }
grpc_iomgr_cb_func grpc_cb = handshaker->use_dedicated_cq grpc_iomgr_cb_func grpc_cb = handshaker->channel == nullptr
? on_handshaker_service_resp_recv_dedicated ? on_handshaker_service_resp_recv_dedicated
: on_handshaker_service_resp_recv; : on_handshaker_service_resp_recv;
grpc_channel* channel =
handshaker->channel == nullptr
? grpc_alts_get_shared_resource_dedicated()->channel
: handshaker->channel;
handshaker->client = alts_grpc_handshaker_client_create( handshaker->client = alts_grpc_handshaker_client_create(
handshaker, g_shared_resources->channel, handshaker, channel, handshaker->handshaker_service_url,
handshaker->handshaker_service_url, handshaker->interested_parties, handshaker->interested_parties, handshaker->options,
handshaker->options, handshaker->target_name, grpc_cb, cb, user_data, handshaker->target_name, grpc_cb, cb, user_data,
handshaker->client_vtable_for_testing, handshaker->is_client); handshaker->client_vtable_for_testing, handshaker->is_client);
if (handshaker->client == nullptr) { if (handshaker->client == nullptr) {
gpr_log(GPR_ERROR, "Failed to create ALTS handshaker client"); gpr_log(GPR_ERROR, "Failed to create ALTS handshaker client");
@ -310,7 +297,7 @@ static tsi_result handshaker_next(
} }
handshaker->has_created_handshaker_client = true; handshaker->has_created_handshaker_client = true;
} }
if (handshaker->use_dedicated_cq && if (handshaker->channel == nullptr &&
handshaker->client_vtable_for_testing == nullptr) { handshaker->client_vtable_for_testing == nullptr) {
GPR_ASSERT(grpc_cq_begin_op(grpc_alts_get_shared_resource_dedicated()->cq, GPR_ASSERT(grpc_cq_begin_op(grpc_alts_get_shared_resource_dedicated()->cq,
handshaker->client)); handshaker->client));
@ -371,6 +358,9 @@ static void handshaker_destroy(tsi_handshaker* self) {
alts_handshaker_client_destroy(handshaker->client); alts_handshaker_client_destroy(handshaker->client);
grpc_slice_unref_internal(handshaker->target_name); grpc_slice_unref_internal(handshaker->target_name);
grpc_alts_credentials_options_destroy(handshaker->options); grpc_alts_credentials_options_destroy(handshaker->options);
if (handshaker->channel != nullptr) {
grpc_channel_destroy(handshaker->channel);
}
gpr_free(handshaker->handshaker_service_url); gpr_free(handshaker->handshaker_service_url);
gpr_free(handshaker); gpr_free(handshaker);
} }
@ -407,7 +397,7 @@ tsi_result alts_tsi_handshaker_create(
} }
alts_tsi_handshaker* handshaker = alts_tsi_handshaker* handshaker =
static_cast<alts_tsi_handshaker*>(gpr_zalloc(sizeof(*handshaker))); static_cast<alts_tsi_handshaker*>(gpr_zalloc(sizeof(*handshaker)));
handshaker->use_dedicated_cq = interested_parties == nullptr; bool use_dedicated_cq = interested_parties == nullptr;
handshaker->client = nullptr; handshaker->client = nullptr;
handshaker->is_client = is_client; handshaker->is_client = is_client;
handshaker->has_sent_start_message = false; handshaker->has_sent_start_message = false;
@ -418,9 +408,13 @@ tsi_result alts_tsi_handshaker_create(
handshaker->has_created_handshaker_client = false; handshaker->has_created_handshaker_client = false;
handshaker->handshaker_service_url = gpr_strdup(handshaker_service_url); handshaker->handshaker_service_url = gpr_strdup(handshaker_service_url);
handshaker->options = grpc_alts_credentials_options_copy(options); handshaker->options = grpc_alts_credentials_options_copy(options);
handshaker->base.vtable = handshaker->use_dedicated_cq handshaker->base.vtable =
? &handshaker_vtable_dedicated use_dedicated_cq ? &handshaker_vtable_dedicated : &handshaker_vtable;
: &handshaker_vtable; handshaker->channel =
use_dedicated_cq
? nullptr
: grpc_insecure_channel_create(handshaker->handshaker_service_url,
nullptr, nullptr);
*self = &handshaker->base; *self = &handshaker->base;
return TSI_OK; return TSI_OK;
} }

@ -27,7 +27,6 @@
#include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h" #include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h"
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h" #include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
#include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h" #include "src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h"
#include "src/core/tsi/alts_transport_security.h"
#include "src/core/tsi/transport_security.h" #include "src/core/tsi/transport_security.h"
#include "src/core/tsi/transport_security_interface.h" #include "src/core/tsi/transport_security_interface.h"

@ -1,41 +0,0 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/port_platform.h>
#include <string.h>
#include "src/core/tsi/alts_transport_security.h"
static alts_shared_resource g_alts_resource;
alts_shared_resource* alts_get_shared_resource(void) {
return &g_alts_resource;
}
void grpc_tsi_alts_init() {
g_alts_resource.channel = nullptr;
gpr_mu_init(&g_alts_resource.mu);
}
void grpc_tsi_alts_shutdown() {
if (g_alts_resource.channel != nullptr) {
grpc_channel_destroy(g_alts_resource.channel);
}
gpr_mu_destroy(&g_alts_resource.mu);
}

@ -1,38 +0,0 @@
/*
*
* Copyright 2017 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_TSI_ALTS_TRANSPORT_SECURITY_H
#define GRPC_CORE_TSI_ALTS_TRANSPORT_SECURITY_H
#include <grpc/support/port_platform.h>
#include <grpc/grpc.h>
#include <grpc/support/sync.h>
#include "src/core/lib/gprpp/thd.h"
typedef struct alts_shared_resource {
grpc_channel* channel;
gpr_mu mu;
} alts_shared_resource;
/* This method returns the address of alts_shared_resource object shared by all
* TSI handshakes. */
alts_shared_resource* alts_get_shared_resource(void);
#endif /* GRPC_CORE_TSI_ALTS_TRANSPORT_SECURITY_H */

@ -334,7 +334,6 @@ CORE_SOURCE_FILES = [
'src/core/ext/filters/client_channel/subchannel_index.cc', 'src/core/ext/filters/client_channel/subchannel_index.cc',
'src/core/ext/filters/deadline/deadline_filter.cc', 'src/core/ext/filters/deadline/deadline_filter.cc',
'src/core/ext/filters/client_channel/health/health.pb.c', 'src/core/ext/filters/client_channel/health/health.pb.c',
'src/core/tsi/alts_transport_security.cc',
'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/fake_transport_security.cc',
'src/core/tsi/local_transport_security.cc', 'src/core/tsi/local_transport_security.cc',
'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc',

@ -1527,8 +1527,6 @@ src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc \
src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h \ src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h \
src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc \ src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc \
src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h \ src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h \
src/core/tsi/alts_transport_security.cc \
src/core/tsi/alts_transport_security.h \
src/core/tsi/fake_transport_security.cc \ src/core/tsi/fake_transport_security.cc \
src/core/tsi/fake_transport_security.h \ src/core/tsi/fake_transport_security.h \
src/core/tsi/grpc_shadow_boringssl.h \ src/core/tsi/grpc_shadow_boringssl.h \

@ -11111,7 +11111,6 @@
"tsi_interface" "tsi_interface"
], ],
"headers": [ "headers": [
"src/core/tsi/alts_transport_security.h",
"src/core/tsi/fake_transport_security.h", "src/core/tsi/fake_transport_security.h",
"src/core/tsi/local_transport_security.h", "src/core/tsi/local_transport_security.h",
"src/core/tsi/ssl/session_cache/ssl_session.h", "src/core/tsi/ssl/session_cache/ssl_session.h",
@ -11124,8 +11123,6 @@
"language": "c", "language": "c",
"name": "tsi", "name": "tsi",
"src": [ "src": [
"src/core/tsi/alts_transport_security.cc",
"src/core/tsi/alts_transport_security.h",
"src/core/tsi/fake_transport_security.cc", "src/core/tsi/fake_transport_security.cc",
"src/core/tsi/fake_transport_security.h", "src/core/tsi/fake_transport_security.h",
"src/core/tsi/local_transport_security.cc", "src/core/tsi/local_transport_security.cc",

Loading…
Cancel
Save