grpc 1.25.0 → 1.26.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +782 -291
- data/include/grpc/impl/codegen/grpc_types.h +4 -0
- data/include/grpc/impl/codegen/port_platform.h +7 -0
- data/include/grpc/support/alloc.h +0 -16
- data/src/core/ext/filters/client_channel/backend_metric.cc +2 -2
- data/src/core/ext/filters/client_channel/backup_poller.cc +1 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +95 -88
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +7 -7
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +4 -2
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -3
- data/src/core/ext/filters/client_channel/connector.h +40 -45
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +10 -10
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -13
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +66 -37
- data/src/core/ext/filters/client_channel/http_proxy.cc +107 -116
- data/src/core/ext/filters/client_channel/http_proxy.h +5 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy.h +9 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +10 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +18 -19
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +4 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +6 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +368 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +157 -77
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +5 -5
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +8 -8
- data/src/core/ext/filters/client_channel/proxy_mapper.h +14 -34
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +46 -79
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +23 -17
- data/src/core/ext/filters/client_channel/resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver.h +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +13 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +3 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +9 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +17 -16
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +9 -9
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -3
- data/src/core/ext/filters/client_channel/resolver_registry.cc +14 -12
- data/src/core/ext/filters/client_channel/resolver_registry.h +6 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +6 -6
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +6 -6
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +5 -5
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +3 -3
- data/src/core/ext/filters/client_channel/service_config.cc +15 -14
- data/src/core/ext/filters/client_channel/service_config.h +14 -19
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -36
- data/src/core/ext/filters/client_channel/subchannel.h +11 -12
- data/src/core/ext/filters/client_channel/subchannel_interface.h +1 -1
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +19 -9
- data/src/core/ext/filters/client_channel/xds/xds_api.h +19 -9
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +3 -3
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +6 -5
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +58 -31
- data/src/core/ext/filters/client_channel/xds/xds_client.h +20 -15
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -3
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -15
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +10 -10
- data/src/core/ext/filters/deadline/deadline_filter.cc +15 -13
- data/src/core/ext/filters/http/client/http_client_filter.cc +12 -12
- data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +13 -7
- data/src/core/ext/filters/http/server/http_server_filter.cc +14 -13
- data/src/core/ext/filters/max_age/max_age_filter.cc +16 -14
- data/src/core/ext/filters/message_size/message_size_filter.cc +10 -8
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +9 -8
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +141 -174
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +31 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +7 -6
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +14 -12
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +8 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +46 -38
- data/src/core/ext/transport/chttp2/transport/context_list.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +0 -5
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +6 -7
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +11 -8
- data/src/core/ext/transport/chttp2/transport/internal.h +3 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -2
- data/src/core/ext/transport/inproc/inproc_transport.cc +65 -41
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +141 -70
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +352 -118
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +8 -4
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +65 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +16 -2
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +36 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +12 -5
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +13 -12
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +28 -24
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +5 -4
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +13 -0
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +23 -23
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +48 -44
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/http.upb.c +16 -0
- data/src/core/ext/upb-generated/envoy/type/http.upb.h +36 -0
- data/src/core/ext/upb-generated/envoy/type/percent.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/range.upb.c +0 -1
- data/src/core/lib/avl/avl.cc +1 -1
- data/src/core/lib/channel/channel_stack.cc +1 -1
- data/src/core/lib/channel/channel_stack.h +16 -4
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channelz.cc +46 -46
- data/src/core/lib/channel/channelz.h +37 -35
- data/src/core/lib/channel/channelz_registry.cc +2 -2
- data/src/core/lib/channel/channelz_registry.h +1 -1
- data/src/core/lib/channel/connected_channel.cc +3 -2
- data/src/core/lib/channel/handshaker.cc +1 -1
- data/src/core/lib/channel/handshaker_registry.cc +5 -5
- data/src/core/lib/channel/handshaker_registry.h +3 -3
- data/src/core/lib/compression/message_compress.cc +3 -2
- data/src/core/lib/compression/stream_compression_identity.cc +5 -7
- data/src/core/lib/gpr/alloc.cc +4 -29
- data/src/core/lib/gpr/cpu_linux.cc +1 -1
- data/src/core/lib/gprpp/fork.cc +4 -4
- data/src/core/lib/gprpp/global_config_env.cc +7 -7
- data/src/core/lib/gprpp/global_config_env.h +2 -2
- data/src/core/lib/gprpp/host_port.cc +8 -8
- data/src/core/lib/gprpp/host_port.h +3 -3
- data/src/core/lib/gprpp/inlined_vector.h +13 -0
- data/src/core/lib/gprpp/map.h +2 -9
- data/src/core/lib/gprpp/memory.h +12 -98
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/ref_counted.h +3 -3
- data/src/core/lib/gprpp/ref_counted_ptr.h +1 -1
- data/src/core/lib/gprpp/string_view.h +45 -23
- data/src/core/lib/gprpp/thd.h +1 -1
- data/src/core/lib/gprpp/thd_posix.cc +6 -5
- data/src/core/lib/gprpp/thd_windows.cc +3 -3
- data/src/core/lib/http/httpcli.cc +1 -1
- data/src/core/lib/http/httpcli_security_connector.cc +3 -3
- data/src/core/lib/iomgr/buffer_list.cc +10 -5
- data/src/core/lib/iomgr/call_combiner.cc +7 -6
- data/src/core/lib/iomgr/call_combiner.h +4 -3
- data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
- data/src/core/lib/iomgr/closure.h +33 -135
- data/src/core/lib/iomgr/combiner.cc +10 -17
- data/src/core/lib/iomgr/combiner.h +0 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +2 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -2
- data/src/core/lib/iomgr/ev_epollex_linux.cc +23 -13
- data/src/core/lib/iomgr/ev_poll_posix.cc +30 -17
- data/src/core/lib/iomgr/exec_ctx.cc +52 -5
- data/src/core/lib/iomgr/exec_ctx.h +6 -2
- data/src/core/lib/iomgr/executor.cc +16 -37
- data/src/core/lib/iomgr/executor.h +4 -7
- data/src/core/lib/iomgr/executor/threadpool.cc +4 -4
- data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
- data/src/core/lib/iomgr/lockfree_event.cc +9 -8
- data/src/core/lib/iomgr/logical_thread.cc +103 -0
- data/src/core/lib/iomgr/logical_thread.h +52 -0
- data/src/core/lib/iomgr/pollset_custom.cc +5 -5
- data/src/core/lib/iomgr/pollset_set_custom.cc +9 -9
- data/src/core/lib/iomgr/pollset_windows.cc +16 -2
- data/src/core/lib/iomgr/port.h +3 -0
- data/src/core/lib/iomgr/resolve_address_custom.cc +4 -4
- data/src/core/lib/iomgr/resolve_address_posix.cc +8 -9
- data/src/core/lib/iomgr/resolve_address_windows.cc +4 -6
- data/src/core/lib/iomgr/resource_quota.cc +26 -21
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +11 -0
- data/src/core/lib/iomgr/socket_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +5 -4
- data/src/core/lib/iomgr/tcp_client_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_custom.cc +10 -9
- data/src/core/lib/iomgr/tcp_posix.cc +19 -15
- data/src/core/lib/iomgr/tcp_server_custom.cc +3 -2
- data/src/core/lib/iomgr/tcp_server_posix.cc +5 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +5 -3
- data/src/core/lib/iomgr/tcp_windows.cc +16 -13
- data/src/core/lib/iomgr/timer_custom.cc +4 -3
- data/src/core/lib/iomgr/timer_generic.cc +11 -9
- data/src/core/lib/iomgr/udp_server.cc +16 -13
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +8 -5
- data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +45 -57
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -6
- data/src/core/lib/security/credentials/credentials.cc +8 -8
- data/src/core/lib/security/credentials/credentials.h +5 -5
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -5
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -1
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +4 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -4
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -2
- data/src/core/lib/security/credentials/local/local_credentials.cc +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +13 -11
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -5
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +4 -4
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +5 -5
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +2 -2
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +28 -22
- data/src/core/lib/security/security_connector/alts/alts_security_connector.h +5 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +10 -10
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -1
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +8 -8
- data/src/core/lib/security/security_connector/security_connector.h +1 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +9 -9
- data/src/core/lib/security/security_connector/ssl_utils.cc +5 -4
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -15
- data/src/core/lib/security/transport/client_auth_filter.cc +4 -3
- data/src/core/lib/security/transport/secure_endpoint.cc +9 -8
- data/src/core/lib/security/transport/security_handshaker.cc +67 -23
- data/src/core/lib/security/transport/server_auth_filter.cc +6 -5
- data/src/core/lib/security/transport/target_authority_table.h +1 -1
- data/src/core/lib/slice/b64.cc +3 -4
- data/src/core/lib/slice/b64.h +1 -2
- data/src/core/lib/slice/slice.cc +8 -13
- data/src/core/lib/surface/call.cc +19 -19
- data/src/core/lib/surface/call.h +6 -7
- data/src/core/lib/surface/call_log_batch.cc +1 -2
- data/src/core/lib/surface/channel.cc +17 -18
- data/src/core/lib/surface/channel.h +4 -19
- data/src/core/lib/surface/channel_ping.cc +1 -1
- data/src/core/lib/surface/completion_queue.cc +21 -22
- data/src/core/lib/surface/completion_queue_factory.cc +1 -1
- data/src/core/lib/surface/init.cc +1 -1
- data/src/core/lib/surface/init_secure.cc +2 -2
- data/src/core/lib/surface/lame_client.cc +10 -12
- data/src/core/lib/surface/server.cc +24 -18
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +2 -2
- data/src/core/lib/transport/byte_stream.h +2 -1
- data/src/core/lib/transport/connectivity_state.cc +4 -4
- data/src/core/lib/transport/connectivity_state.h +2 -2
- data/src/core/lib/transport/metadata.cc +8 -10
- data/src/core/lib/transport/metadata.h +5 -8
- data/src/core/lib/transport/metadata_batch.cc +6 -0
- data/src/core/lib/transport/static_metadata.cc +2 -4
- data/src/core/lib/transport/status_metadata.cc +7 -0
- data/src/core/lib/transport/status_metadata.h +18 -0
- data/src/core/lib/transport/transport.cc +9 -7
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +292 -43
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +197 -46
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +4 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +5 -0
- data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -4
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +0 -6
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/upb/upb/decode.c +1 -0
- metadata +34 -32
- data/src/core/ext/filters/client_channel/connector.cc +0 -41
- data/src/core/ext/filters/client_channel/proxy_mapper.cc +0 -48
- data/src/core/lib/gprpp/set.h +0 -33
@@ -23,6 +23,6 @@
|
|
23
23
|
|
24
24
|
#include <grpc/grpc.h>
|
25
25
|
|
26
|
-
const char* grpc_version_string(void) { return "
|
26
|
+
const char* grpc_version_string(void) { return "9.0.0"; }
|
27
27
|
|
28
|
-
const char* grpc_g_stands_for(void) { return "
|
28
|
+
const char* grpc_g_stands_for(void) { return "gon"; }
|
@@ -53,8 +53,8 @@ void SliceBufferByteStream::Orphan() {
|
|
53
53
|
// filter stack.
|
54
54
|
}
|
55
55
|
|
56
|
-
bool SliceBufferByteStream::Next(size_t max_size_hint
|
57
|
-
grpc_closure* on_complete) {
|
56
|
+
bool SliceBufferByteStream::Next(size_t /*max_size_hint*/,
|
57
|
+
grpc_closure* /*on_complete*/) {
|
58
58
|
GPR_DEBUG_ASSERT(backing_buffer_.count > 0);
|
59
59
|
return true;
|
60
60
|
}
|
@@ -40,7 +40,8 @@ class ByteStream : public Orphanable {
|
|
40
40
|
// Returns true if the bytes are available immediately (in which case
|
41
41
|
// on_complete will not be called), or false if the bytes will be available
|
42
42
|
// asynchronously (in which case on_complete will be called when they
|
43
|
-
// are available).
|
43
|
+
// are available). Should not be called if there is no data left on the
|
44
|
+
// stream.
|
44
45
|
//
|
45
46
|
// max_size_hint can be set as a hint as to the maximum number
|
46
47
|
// of bytes that would be acceptable to read.
|
@@ -67,19 +67,19 @@ class AsyncConnectivityStateWatcherInterface::Notifier {
|
|
67
67
|
} else {
|
68
68
|
GRPC_CLOSURE_INIT(&closure_, SendNotification, this,
|
69
69
|
grpc_schedule_on_exec_ctx);
|
70
|
-
|
70
|
+
ExecCtx::Run(DEBUG_LOCATION, &closure_, GRPC_ERROR_NONE);
|
71
71
|
}
|
72
72
|
}
|
73
73
|
|
74
74
|
private:
|
75
|
-
static void SendNotification(void* arg, grpc_error* ignored) {
|
75
|
+
static void SendNotification(void* arg, grpc_error* /*ignored*/) {
|
76
76
|
Notifier* self = static_cast<Notifier*>(arg);
|
77
77
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_connectivity_state_trace)) {
|
78
78
|
gpr_log(GPR_INFO, "watcher %p: delivering async notification for %s",
|
79
79
|
self->watcher_.get(), ConnectivityStateName(self->state_));
|
80
80
|
}
|
81
81
|
self->watcher_->OnConnectivityStateChange(self->state_);
|
82
|
-
|
82
|
+
delete self;
|
83
83
|
}
|
84
84
|
|
85
85
|
RefCountedPtr<AsyncConnectivityStateWatcherInterface> watcher_;
|
@@ -89,7 +89,7 @@ class AsyncConnectivityStateWatcherInterface::Notifier {
|
|
89
89
|
|
90
90
|
void AsyncConnectivityStateWatcherInterface::Notify(
|
91
91
|
grpc_connectivity_state state) {
|
92
|
-
|
92
|
+
new Notifier(Ref(), state, combiner_); // Deletes itself when done.
|
93
93
|
}
|
94
94
|
|
95
95
|
//
|
@@ -119,8 +119,8 @@ class ConnectivityStateTracker {
|
|
119
119
|
Atomic<grpc_connectivity_state> state_;
|
120
120
|
// TODO(roth): Once we can use C++-14 heterogeneous lookups, this can
|
121
121
|
// be a set instead of a map.
|
122
|
-
|
123
|
-
|
122
|
+
std::map<ConnectivityStateWatcherInterface*,
|
123
|
+
OrphanablePtr<ConnectivityStateWatcherInterface>>
|
124
124
|
watchers_;
|
125
125
|
};
|
126
126
|
|
@@ -207,7 +207,7 @@ size_t InternedMetadata::CleanupLinkedMetadata(
|
|
207
207
|
next = md->link_.next;
|
208
208
|
if (md->AllRefsDropped()) {
|
209
209
|
prev_next->next = next;
|
210
|
-
|
210
|
+
delete md;
|
211
211
|
num_freed++;
|
212
212
|
} else {
|
213
213
|
prev_next = &md->link_;
|
@@ -373,14 +373,13 @@ static grpc_mdelem md_create(
|
|
373
373
|
// We allocate backing store.
|
374
374
|
return key_definitely_static
|
375
375
|
? GRPC_MAKE_MDELEM(
|
376
|
-
|
376
|
+
new AllocatedMetadata(
|
377
377
|
key, value,
|
378
378
|
static_cast<const AllocatedMetadata::NoRefKey*>(
|
379
379
|
nullptr)),
|
380
380
|
GRPC_MDELEM_STORAGE_ALLOCATED)
|
381
|
-
: GRPC_MAKE_MDELEM(
|
382
|
-
|
383
|
-
GRPC_MDELEM_STORAGE_ALLOCATED);
|
381
|
+
: GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value),
|
382
|
+
GRPC_MDELEM_STORAGE_ALLOCATED);
|
384
383
|
}
|
385
384
|
}
|
386
385
|
return md_create_maybe_static<key_definitely_static, value_definitely_static>(
|
@@ -456,11 +455,10 @@ static grpc_mdelem md_create_must_intern(const grpc_slice& key,
|
|
456
455
|
|
457
456
|
/* not found: create a new pair */
|
458
457
|
md = key_definitely_static
|
459
|
-
?
|
458
|
+
? new InternedMetadata(
|
460
459
|
key, value, hash, shard->elems[idx].next,
|
461
460
|
static_cast<const InternedMetadata::NoRefKey*>(nullptr))
|
462
|
-
:
|
463
|
-
shard->elems[idx].next);
|
461
|
+
: new InternedMetadata(key, value, hash, shard->elems[idx].next);
|
464
462
|
shard->elems[idx].next = md;
|
465
463
|
shard->count++;
|
466
464
|
|
@@ -656,7 +654,7 @@ void grpc_mdelem_do_unref(grpc_mdelem gmd DEBUG_ARGS) {
|
|
656
654
|
case GRPC_MDELEM_STORAGE_ALLOCATED: {
|
657
655
|
auto* md = reinterpret_cast<AllocatedMetadata*> GRPC_MDELEM_DATA(gmd);
|
658
656
|
if (GPR_UNLIKELY(md->Unref(FWD_DEBUG_ARGS))) {
|
659
|
-
|
657
|
+
delete md;
|
660
658
|
}
|
661
659
|
break;
|
662
660
|
}
|
@@ -674,7 +672,7 @@ void grpc_mdelem_on_final_unref(grpc_mdelem_data_storage storage, void* ptr,
|
|
674
672
|
break;
|
675
673
|
}
|
676
674
|
case GRPC_MDELEM_STORAGE_ALLOCATED: {
|
677
|
-
|
675
|
+
delete reinterpret_cast<AllocatedMetadata*>(ptr);
|
678
676
|
break;
|
679
677
|
}
|
680
678
|
}
|
@@ -37,11 +37,8 @@ extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata;
|
|
37
37
|
/* This file provides a mechanism for tracking metadata through the grpc stack.
|
38
38
|
It's not intended for consumption outside of the library.
|
39
39
|
|
40
|
-
Metadata is tracked in the context of a grpc_mdctx.
|
41
|
-
|
42
|
-
use and lock contention.
|
43
|
-
|
44
|
-
The context tracks unique strings (grpc_mdstr) and pairs of strings
|
40
|
+
Metadata is tracked in the context of a sharded global grpc_mdctx. The
|
41
|
+
context tracks unique strings (grpc_mdstr) and pairs of strings
|
45
42
|
(grpc_mdelem). Any of these objects can be checked for equality by comparing
|
46
43
|
their pointers. These objects are reference counted.
|
47
44
|
|
@@ -426,7 +423,7 @@ inline grpc_mdelem grpc_mdelem_from_slices(
|
|
426
423
|
const grpc_core::ManagedMemorySlice& key,
|
427
424
|
const grpc_core::UnmanagedMemorySlice& value) {
|
428
425
|
using grpc_core::AllocatedMetadata;
|
429
|
-
return GRPC_MAKE_MDELEM(
|
426
|
+
return GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value),
|
430
427
|
GRPC_MDELEM_STORAGE_ALLOCATED);
|
431
428
|
}
|
432
429
|
|
@@ -434,7 +431,7 @@ inline grpc_mdelem grpc_mdelem_from_slices(
|
|
434
431
|
const grpc_core::ExternallyManagedSlice& key,
|
435
432
|
const grpc_core::UnmanagedMemorySlice& value) {
|
436
433
|
using grpc_core::AllocatedMetadata;
|
437
|
-
return GRPC_MAKE_MDELEM(
|
434
|
+
return GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value),
|
438
435
|
GRPC_MDELEM_STORAGE_ALLOCATED);
|
439
436
|
}
|
440
437
|
|
@@ -442,7 +439,7 @@ inline grpc_mdelem grpc_mdelem_from_slices(
|
|
442
439
|
const grpc_core::StaticMetadataSlice& key,
|
443
440
|
const grpc_core::UnmanagedMemorySlice& value) {
|
444
441
|
using grpc_core::AllocatedMetadata;
|
445
|
-
return GRPC_MAKE_MDELEM(
|
442
|
+
return GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value),
|
446
443
|
GRPC_MDELEM_STORAGE_ALLOCATED);
|
447
444
|
}
|
448
445
|
|
@@ -50,6 +50,9 @@ static void assert_valid_list(grpc_mdelem_list* list) {
|
|
50
50
|
verified_count++;
|
51
51
|
}
|
52
52
|
GPR_ASSERT(list->count == verified_count);
|
53
|
+
#else
|
54
|
+
// Avoid unused-parameter warning for debug-only parameter
|
55
|
+
(void)list;
|
53
56
|
#endif /* NDEBUG */
|
54
57
|
}
|
55
58
|
|
@@ -64,6 +67,9 @@ static void assert_valid_callouts(grpc_metadata_batch* batch) {
|
|
64
67
|
}
|
65
68
|
grpc_slice_unref_internal(key_interned);
|
66
69
|
}
|
70
|
+
#else
|
71
|
+
// Avoid unused-parameter warning for debug-only parameter
|
72
|
+
(void)batch;
|
67
73
|
#endif
|
68
74
|
}
|
69
75
|
|
@@ -1149,8 +1149,7 @@ uint64_t StaticMetadataInitCanary() {
|
|
1149
1149
|
} // namespace grpc_core
|
1150
1150
|
|
1151
1151
|
void grpc_init_static_metadata_ctx(void) {
|
1152
|
-
grpc_core::g_static_metadata_slice_ctx =
|
1153
|
-
grpc_core::New<grpc_core::StaticMetadataCtx>();
|
1152
|
+
grpc_core::g_static_metadata_slice_ctx = new grpc_core::StaticMetadataCtx();
|
1154
1153
|
grpc_core::g_static_metadata_slice_table =
|
1155
1154
|
grpc_core::g_static_metadata_slice_ctx->slices;
|
1156
1155
|
grpc_core::g_static_metadata_slice_refcounts =
|
@@ -1162,8 +1161,7 @@ void grpc_init_static_metadata_ctx(void) {
|
|
1162
1161
|
}
|
1163
1162
|
|
1164
1163
|
void grpc_destroy_static_metadata_ctx(void) {
|
1165
|
-
grpc_core::
|
1166
|
-
grpc_core::g_static_metadata_slice_ctx);
|
1164
|
+
delete grpc_core::g_static_metadata_slice_ctx;
|
1167
1165
|
grpc_core::g_static_metadata_slice_ctx = nullptr;
|
1168
1166
|
grpc_core::g_static_metadata_slice_table = nullptr;
|
1169
1167
|
grpc_core::g_static_metadata_slice_refcounts = nullptr;
|
@@ -52,3 +52,10 @@ grpc_status_code grpc_get_status_code_from_metadata(grpc_mdelem md) {
|
|
52
52
|
md, destroy_status, (void*)static_cast<intptr_t>(status + STATUS_OFFSET));
|
53
53
|
return static_cast<grpc_status_code>(status);
|
54
54
|
}
|
55
|
+
|
56
|
+
grpc_mdelem grpc_get_reffed_status_elem_slowpath(int status_code) {
|
57
|
+
char tmp[GPR_LTOA_MIN_BUFSIZE];
|
58
|
+
gpr_ltoa(status_code, tmp);
|
59
|
+
return grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_STATUS,
|
60
|
+
grpc_core::UnmanagedMemorySlice(tmp));
|
61
|
+
}
|
@@ -24,7 +24,25 @@
|
|
24
24
|
#include <grpc/status.h>
|
25
25
|
|
26
26
|
#include "src/core/lib/transport/metadata.h"
|
27
|
+
#include "src/core/lib/transport/static_metadata.h"
|
27
28
|
|
28
29
|
grpc_status_code grpc_get_status_code_from_metadata(grpc_mdelem md);
|
29
30
|
|
31
|
+
/** Get a grpc_mdelem of grpc-status: X where X is the numeric value of
|
32
|
+
status_code.
|
33
|
+
|
34
|
+
The returned elem is owned by the caller. */
|
35
|
+
grpc_mdelem grpc_get_reffed_status_elem_slowpath(int status_code);
|
36
|
+
inline grpc_mdelem grpc_get_reffed_status_elem(int status_code) {
|
37
|
+
switch (status_code) {
|
38
|
+
case 0:
|
39
|
+
return GRPC_MDELEM_GRPC_STATUS_0;
|
40
|
+
case 1:
|
41
|
+
return GRPC_MDELEM_GRPC_STATUS_1;
|
42
|
+
case 2:
|
43
|
+
return GRPC_MDELEM_GRPC_STATUS_2;
|
44
|
+
}
|
45
|
+
return grpc_get_reffed_status_elem_slowpath(status_code);
|
46
|
+
}
|
47
|
+
|
30
48
|
#endif /* GRPC_CORE_LIB_TRANSPORT_STATUS_METADATA_H */
|
@@ -50,10 +50,11 @@ void grpc_stream_destroy(grpc_stream_refcount* refcount) {
|
|
50
50
|
cope with.
|
51
51
|
Throw this over to the executor (on a core-owned thread) and process it
|
52
52
|
there. */
|
53
|
-
refcount->destroy
|
54
|
-
|
53
|
+
grpc_core::Executor::Run(&refcount->destroy, GRPC_ERROR_NONE);
|
54
|
+
} else {
|
55
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, &refcount->destroy,
|
56
|
+
GRPC_ERROR_NONE);
|
55
57
|
}
|
56
|
-
GRPC_CLOSURE_SCHED(&refcount->destroy, GRPC_ERROR_NONE);
|
57
58
|
}
|
58
59
|
|
59
60
|
void slice_stream_destroy(void* arg) {
|
@@ -218,12 +219,13 @@ struct made_transport_op {
|
|
218
219
|
|
219
220
|
static void destroy_made_transport_op(void* arg, grpc_error* error) {
|
220
221
|
made_transport_op* op = static_cast<made_transport_op*>(arg);
|
221
|
-
|
222
|
-
|
222
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, op->inner_on_complete,
|
223
|
+
GRPC_ERROR_REF(error));
|
224
|
+
delete op;
|
223
225
|
}
|
224
226
|
|
225
227
|
grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) {
|
226
|
-
made_transport_op* op =
|
228
|
+
made_transport_op* op = new made_transport_op();
|
227
229
|
GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op,
|
228
230
|
grpc_schedule_on_exec_ctx);
|
229
231
|
op->inner_on_complete = on_complete;
|
@@ -242,7 +244,7 @@ static void destroy_made_transport_stream_op(void* arg, grpc_error* error) {
|
|
242
244
|
made_transport_stream_op* op = static_cast<made_transport_stream_op*>(arg);
|
243
245
|
grpc_closure* c = op->inner_on_complete;
|
244
246
|
gpr_free(op);
|
245
|
-
|
247
|
+
grpc_core::Closure::Run(DEBUG_LOCATION, c, GRPC_ERROR_REF(error));
|
246
248
|
}
|
247
249
|
|
248
250
|
grpc_transport_stream_op_batch* grpc_make_transport_stream_op(
|
@@ -34,6 +34,8 @@ void grpc_resolver_fake_init(void);
|
|
34
34
|
void grpc_resolver_fake_shutdown(void);
|
35
35
|
void grpc_lb_policy_grpclb_init(void);
|
36
36
|
void grpc_lb_policy_grpclb_shutdown(void);
|
37
|
+
void grpc_lb_policy_cds_init(void);
|
38
|
+
void grpc_lb_policy_cds_shutdown(void);
|
37
39
|
void grpc_lb_policy_xds_init(void);
|
38
40
|
void grpc_lb_policy_xds_shutdown(void);
|
39
41
|
void grpc_lb_policy_pick_first_init(void);
|
@@ -74,6 +76,8 @@ void grpc_register_built_in_plugins(void) {
|
|
74
76
|
grpc_resolver_fake_shutdown);
|
75
77
|
grpc_register_plugin(grpc_lb_policy_grpclb_init,
|
76
78
|
grpc_lb_policy_grpclb_shutdown);
|
79
|
+
grpc_register_plugin(grpc_lb_policy_cds_init,
|
80
|
+
grpc_lb_policy_cds_shutdown);
|
77
81
|
grpc_register_plugin(grpc_lb_policy_xds_init,
|
78
82
|
grpc_lb_policy_xds_shutdown);
|
79
83
|
grpc_register_plugin(grpc_lb_policy_pick_first_init,
|
@@ -18,12 +18,15 @@
|
|
18
18
|
|
19
19
|
#include <grpc/support/port_platform.h>
|
20
20
|
|
21
|
+
#include <list>
|
22
|
+
|
21
23
|
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
|
22
24
|
|
23
25
|
#include <grpc/byte_buffer.h>
|
24
26
|
#include <grpc/support/alloc.h>
|
25
27
|
#include <grpc/support/log.h>
|
26
28
|
|
29
|
+
#include "src/core/lib/gprpp/sync.h"
|
27
30
|
#include "src/core/lib/slice/slice_internal.h"
|
28
31
|
#include "src/core/lib/surface/call.h"
|
29
32
|
#include "src/core/lib/surface/channel.h"
|
@@ -39,8 +42,18 @@ struct alts_handshaker_client {
|
|
39
42
|
const alts_handshaker_client_vtable* vtable;
|
40
43
|
};
|
41
44
|
|
45
|
+
struct recv_message_result {
|
46
|
+
tsi_result status;
|
47
|
+
const unsigned char* bytes_to_send;
|
48
|
+
size_t bytes_to_send_size;
|
49
|
+
tsi_handshaker_result* result;
|
50
|
+
};
|
51
|
+
|
42
52
|
typedef struct alts_grpc_handshaker_client {
|
43
53
|
alts_handshaker_client base;
|
54
|
+
/* One ref is held by the entity that created this handshaker_client, and
|
55
|
+
* another ref is held by the pending RECEIVE_STATUS_ON_CLIENT op. */
|
56
|
+
gpr_refcount refs;
|
44
57
|
alts_tsi_handshaker* handshaker;
|
45
58
|
grpc_call* call;
|
46
59
|
/* A pointer to a function handling the interaction with handshaker service.
|
@@ -49,12 +62,8 @@ typedef struct alts_grpc_handshaker_client {
|
|
49
62
|
* that validates the data to be sent to handshaker service in a testing use
|
50
63
|
* case. */
|
51
64
|
alts_grpc_caller grpc_caller;
|
52
|
-
/* A callback function provided by gRPC to handle the response returned from
|
53
|
-
* handshaker service. It also serves to bring the control safely back to
|
54
|
-
* application when dedicated CQ and thread are used. */
|
55
|
-
grpc_iomgr_cb_func grpc_cb;
|
56
65
|
/* A gRPC closure to be scheduled when the response from handshaker service
|
57
|
-
* is received. It will be initialized with
|
66
|
+
* is received. It will be initialized with the injected grpc RPC callback. */
|
58
67
|
grpc_closure on_handshaker_service_resp_recv;
|
59
68
|
/* Buffers containing information to be sent (or received) to (or from) the
|
60
69
|
* handshaker service. */
|
@@ -81,6 +90,18 @@ typedef struct alts_grpc_handshaker_client {
|
|
81
90
|
/* a buffer containing data to be sent to the grpc client or server's peer. */
|
82
91
|
unsigned char* buffer;
|
83
92
|
size_t buffer_size;
|
93
|
+
/** callback for receiving handshake call status */
|
94
|
+
grpc_closure on_status_received;
|
95
|
+
/** gRPC status code of handshake call */
|
96
|
+
grpc_status_code handshake_status_code;
|
97
|
+
/** gRPC status details of handshake call */
|
98
|
+
grpc_slice handshake_status_details;
|
99
|
+
/* mu synchronizes all fields below including their internal fields. */
|
100
|
+
gpr_mu mu;
|
101
|
+
/* indicates if the handshaker call's RECV_STATUS_ON_CLIENT op is done. */
|
102
|
+
bool receive_status_finished;
|
103
|
+
/* if non-null, contains arguments to complete a TSI next callback. */
|
104
|
+
recv_message_result* pending_recv_message_result;
|
84
105
|
} alts_grpc_handshaker_client;
|
85
106
|
|
86
107
|
static void handshaker_client_send_buffer_destroy(
|
@@ -98,6 +119,75 @@ static bool is_handshake_finished_properly(grpc_gcp_HandshakerResp* resp) {
|
|
98
119
|
return false;
|
99
120
|
}
|
100
121
|
|
122
|
+
static void alts_grpc_handshaker_client_unref(
|
123
|
+
alts_grpc_handshaker_client* client) {
|
124
|
+
if (gpr_unref(&client->refs)) {
|
125
|
+
if (client->base.vtable != nullptr &&
|
126
|
+
client->base.vtable->destruct != nullptr) {
|
127
|
+
client->base.vtable->destruct(&client->base);
|
128
|
+
}
|
129
|
+
grpc_byte_buffer_destroy(client->send_buffer);
|
130
|
+
grpc_byte_buffer_destroy(client->recv_buffer);
|
131
|
+
client->send_buffer = nullptr;
|
132
|
+
client->recv_buffer = nullptr;
|
133
|
+
grpc_metadata_array_destroy(&client->recv_initial_metadata);
|
134
|
+
grpc_slice_unref_internal(client->recv_bytes);
|
135
|
+
grpc_slice_unref_internal(client->target_name);
|
136
|
+
grpc_alts_credentials_options_destroy(client->options);
|
137
|
+
gpr_free(client->buffer);
|
138
|
+
grpc_slice_unref_internal(client->handshake_status_details);
|
139
|
+
gpr_mu_destroy(&client->mu);
|
140
|
+
gpr_free(client);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
static void maybe_complete_tsi_next(
|
145
|
+
alts_grpc_handshaker_client* client, bool receive_status_finished,
|
146
|
+
recv_message_result* pending_recv_message_result) {
|
147
|
+
recv_message_result* r;
|
148
|
+
{
|
149
|
+
grpc_core::MutexLock lock(&client->mu);
|
150
|
+
client->receive_status_finished |= receive_status_finished;
|
151
|
+
if (pending_recv_message_result != nullptr) {
|
152
|
+
GPR_ASSERT(client->pending_recv_message_result == nullptr);
|
153
|
+
client->pending_recv_message_result = pending_recv_message_result;
|
154
|
+
}
|
155
|
+
if (client->pending_recv_message_result == nullptr) {
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
const bool have_final_result =
|
159
|
+
client->pending_recv_message_result->result != nullptr ||
|
160
|
+
client->pending_recv_message_result->status != TSI_OK;
|
161
|
+
if (have_final_result && !client->receive_status_finished) {
|
162
|
+
// If we've received the final message from the handshake
|
163
|
+
// server, or we're about to invoke the TSI next callback
|
164
|
+
// with a status other than TSI_OK (which terminates the
|
165
|
+
// handshake), then first wait for the RECV_STATUS op to complete.
|
166
|
+
return;
|
167
|
+
}
|
168
|
+
r = client->pending_recv_message_result;
|
169
|
+
client->pending_recv_message_result = nullptr;
|
170
|
+
}
|
171
|
+
client->cb(r->status, client->user_data, r->bytes_to_send,
|
172
|
+
r->bytes_to_send_size, r->result);
|
173
|
+
gpr_free(r);
|
174
|
+
}
|
175
|
+
|
176
|
+
static void handle_response_done(alts_grpc_handshaker_client* client,
|
177
|
+
tsi_result status,
|
178
|
+
const unsigned char* bytes_to_send,
|
179
|
+
size_t bytes_to_send_size,
|
180
|
+
tsi_handshaker_result* result) {
|
181
|
+
recv_message_result* p =
|
182
|
+
static_cast<recv_message_result*>(gpr_zalloc(sizeof(*p)));
|
183
|
+
p->status = status;
|
184
|
+
p->bytes_to_send = bytes_to_send;
|
185
|
+
p->bytes_to_send_size = bytes_to_send_size;
|
186
|
+
p->result = result;
|
187
|
+
maybe_complete_tsi_next(client, false /* receive_status_finished */,
|
188
|
+
p /* pending_recv_message_result */);
|
189
|
+
}
|
190
|
+
|
101
191
|
void alts_handshaker_client_handle_response(alts_handshaker_client* c,
|
102
192
|
bool is_ok) {
|
103
193
|
GPR_ASSERT(c != nullptr);
|
@@ -105,38 +195,35 @@ void alts_handshaker_client_handle_response(alts_handshaker_client* c,
|
|
105
195
|
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
106
196
|
grpc_byte_buffer* recv_buffer = client->recv_buffer;
|
107
197
|
grpc_status_code status = client->status;
|
108
|
-
tsi_handshaker_on_next_done_cb cb = client->cb;
|
109
|
-
void* user_data = client->user_data;
|
110
198
|
alts_tsi_handshaker* handshaker = client->handshaker;
|
111
|
-
|
112
199
|
/* Invalid input check. */
|
113
|
-
if (cb == nullptr) {
|
200
|
+
if (client->cb == nullptr) {
|
114
201
|
gpr_log(GPR_ERROR,
|
115
|
-
"cb is nullptr in alts_tsi_handshaker_handle_response()");
|
202
|
+
"client->cb is nullptr in alts_tsi_handshaker_handle_response()");
|
116
203
|
return;
|
117
204
|
}
|
118
205
|
if (handshaker == nullptr) {
|
119
206
|
gpr_log(GPR_ERROR,
|
120
207
|
"handshaker is nullptr in alts_tsi_handshaker_handle_response()");
|
121
|
-
|
208
|
+
handle_response_done(client, TSI_INTERNAL_ERROR, nullptr, 0, nullptr);
|
122
209
|
return;
|
123
210
|
}
|
124
211
|
/* TSI handshake has been shutdown. */
|
125
212
|
if (alts_tsi_handshaker_has_shutdown(handshaker)) {
|
126
213
|
gpr_log(GPR_ERROR, "TSI handshake shutdown");
|
127
|
-
|
214
|
+
handle_response_done(client, TSI_HANDSHAKE_SHUTDOWN, nullptr, 0, nullptr);
|
128
215
|
return;
|
129
216
|
}
|
130
217
|
/* Failed grpc call check. */
|
131
218
|
if (!is_ok || status != GRPC_STATUS_OK) {
|
132
219
|
gpr_log(GPR_ERROR, "grpc call made to handshaker service failed");
|
133
|
-
|
220
|
+
handle_response_done(client, TSI_INTERNAL_ERROR, nullptr, 0, nullptr);
|
134
221
|
return;
|
135
222
|
}
|
136
223
|
if (recv_buffer == nullptr) {
|
137
224
|
gpr_log(GPR_ERROR,
|
138
225
|
"recv_buffer is nullptr in alts_tsi_handshaker_handle_response()");
|
139
|
-
|
226
|
+
handle_response_done(client, TSI_INTERNAL_ERROR, nullptr, 0, nullptr);
|
140
227
|
return;
|
141
228
|
}
|
142
229
|
upb::Arena arena;
|
@@ -147,14 +234,14 @@ void alts_handshaker_client_handle_response(alts_handshaker_client* c,
|
|
147
234
|
/* Invalid handshaker response check. */
|
148
235
|
if (resp == nullptr) {
|
149
236
|
gpr_log(GPR_ERROR, "alts_tsi_utils_deserialize_response() failed");
|
150
|
-
|
237
|
+
handle_response_done(client, TSI_DATA_CORRUPTED, nullptr, 0, nullptr);
|
151
238
|
return;
|
152
239
|
}
|
153
240
|
const grpc_gcp_HandshakerStatus* resp_status =
|
154
241
|
grpc_gcp_HandshakerResp_status(resp);
|
155
242
|
if (resp_status == nullptr) {
|
156
243
|
gpr_log(GPR_ERROR, "No status in HandshakerResp");
|
157
|
-
|
244
|
+
handle_response_done(client, TSI_DATA_CORRUPTED, nullptr, 0, nullptr);
|
158
245
|
return;
|
159
246
|
}
|
160
247
|
upb_strview out_frames = grpc_gcp_HandshakerResp_out_frames(resp);
|
@@ -188,22 +275,38 @@ void alts_handshaker_client_handle_response(alts_handshaker_client* c,
|
|
188
275
|
gpr_free(error_details);
|
189
276
|
}
|
190
277
|
}
|
191
|
-
|
192
|
-
|
278
|
+
// TODO(apolcyn): consider short ciruiting handle_response_done and
|
279
|
+
// invoking the TSI callback directly if we aren't done yet, if
|
280
|
+
// handle_response_done's allocation per message received causes
|
281
|
+
// a performance issue.
|
282
|
+
handle_response_done(client, alts_tsi_utils_convert_to_tsi_result(code),
|
283
|
+
bytes_to_send, bytes_to_send_size, result);
|
193
284
|
}
|
194
285
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
*/
|
199
|
-
static tsi_result make_grpc_call(alts_handshaker_client* c, bool is_start) {
|
200
|
-
GPR_ASSERT(c != nullptr);
|
201
|
-
alts_grpc_handshaker_client* client =
|
202
|
-
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
286
|
+
static tsi_result continue_make_grpc_call(alts_grpc_handshaker_client* client,
|
287
|
+
bool is_start) {
|
288
|
+
GPR_ASSERT(client != nullptr);
|
203
289
|
grpc_op ops[kHandshakerClientOpNum];
|
204
290
|
memset(ops, 0, sizeof(ops));
|
205
291
|
grpc_op* op = ops;
|
206
292
|
if (is_start) {
|
293
|
+
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
|
294
|
+
op->data.recv_status_on_client.trailing_metadata = nullptr;
|
295
|
+
op->data.recv_status_on_client.status = &client->handshake_status_code;
|
296
|
+
op->data.recv_status_on_client.status_details =
|
297
|
+
&client->handshake_status_details;
|
298
|
+
op->flags = 0;
|
299
|
+
op->reserved = nullptr;
|
300
|
+
op++;
|
301
|
+
GPR_ASSERT(op - ops <= kHandshakerClientOpNum);
|
302
|
+
gpr_ref(&client->refs);
|
303
|
+
grpc_call_error call_error =
|
304
|
+
client->grpc_caller(client->call, ops, static_cast<size_t>(op - ops),
|
305
|
+
&client->on_status_received);
|
306
|
+
// TODO(apolcyn): return the error here instead, as done for other ops?
|
307
|
+
GPR_ASSERT(call_error == GRPC_CALL_OK);
|
308
|
+
memset(ops, 0, sizeof(ops));
|
309
|
+
op = ops;
|
207
310
|
op->op = GRPC_OP_SEND_INITIAL_METADATA;
|
208
311
|
op->data.send_initial_metadata.count = 0;
|
209
312
|
op++;
|
@@ -232,6 +335,125 @@ static tsi_result make_grpc_call(alts_handshaker_client* c, bool is_start) {
|
|
232
335
|
return TSI_OK;
|
233
336
|
}
|
234
337
|
|
338
|
+
// TODO(apolcyn): remove this global queue when we can safely rely
|
339
|
+
// on a MAX_CONCURRENT_STREAMS setting in the ALTS handshake server to
|
340
|
+
// limit the number of concurrent handshakes.
|
341
|
+
namespace {
|
342
|
+
|
343
|
+
class HandshakeQueue {
|
344
|
+
public:
|
345
|
+
explicit HandshakeQueue(size_t max_outstanding_handshakes)
|
346
|
+
: max_outstanding_handshakes_(max_outstanding_handshakes) {}
|
347
|
+
|
348
|
+
void RequestHandshake(alts_grpc_handshaker_client* client) {
|
349
|
+
{
|
350
|
+
grpc_core::MutexLock lock(&mu_);
|
351
|
+
if (outstanding_handshakes_ == max_outstanding_handshakes_) {
|
352
|
+
// Max number already running, add to queue.
|
353
|
+
queued_handshakes_.push_back(client);
|
354
|
+
return;
|
355
|
+
}
|
356
|
+
// Start the handshake immediately.
|
357
|
+
++outstanding_handshakes_;
|
358
|
+
}
|
359
|
+
continue_make_grpc_call(client, true /* is_start */);
|
360
|
+
}
|
361
|
+
|
362
|
+
void HandshakeDone() {
|
363
|
+
alts_grpc_handshaker_client* client = nullptr;
|
364
|
+
{
|
365
|
+
grpc_core::MutexLock lock(&mu_);
|
366
|
+
if (queued_handshakes_.empty()) {
|
367
|
+
// Nothing more in queue. Decrement count and return immediately.
|
368
|
+
--outstanding_handshakes_;
|
369
|
+
return;
|
370
|
+
}
|
371
|
+
// Remove next entry from queue and start the handshake.
|
372
|
+
client = queued_handshakes_.front();
|
373
|
+
queued_handshakes_.pop_front();
|
374
|
+
}
|
375
|
+
continue_make_grpc_call(client, true /* is_start */);
|
376
|
+
}
|
377
|
+
|
378
|
+
private:
|
379
|
+
grpc_core::Mutex mu_;
|
380
|
+
std::list<alts_grpc_handshaker_client*> queued_handshakes_;
|
381
|
+
size_t outstanding_handshakes_ = 0;
|
382
|
+
const size_t max_outstanding_handshakes_;
|
383
|
+
};
|
384
|
+
|
385
|
+
gpr_once g_queued_handshakes_init = GPR_ONCE_INIT;
|
386
|
+
/* Using separate queues for client and server handshakes is a
|
387
|
+
* hack that's mainly intended to satisfy the alts_concurrent_connectivity_test,
|
388
|
+
* which runs many concurrent handshakes where both endpoints
|
389
|
+
* are in the same process; this situation is problematic with a
|
390
|
+
* single queue because we have a high chance of using up all outstanding
|
391
|
+
* slots in the queue, such that there aren't any
|
392
|
+
* mutual client/server handshakes outstanding at the same time and
|
393
|
+
* able to make progress. */
|
394
|
+
HandshakeQueue* g_client_handshake_queue;
|
395
|
+
HandshakeQueue* g_server_handshake_queue;
|
396
|
+
|
397
|
+
void DoHandshakeQueuesInit(void) {
|
398
|
+
const size_t per_queue_max_outstanding_handshakes = 40;
|
399
|
+
g_client_handshake_queue =
|
400
|
+
new HandshakeQueue(per_queue_max_outstanding_handshakes);
|
401
|
+
g_server_handshake_queue =
|
402
|
+
new HandshakeQueue(per_queue_max_outstanding_handshakes);
|
403
|
+
}
|
404
|
+
|
405
|
+
void RequestHandshake(alts_grpc_handshaker_client* client, bool is_client) {
|
406
|
+
gpr_once_init(&g_queued_handshakes_init, DoHandshakeQueuesInit);
|
407
|
+
HandshakeQueue* queue =
|
408
|
+
is_client ? g_client_handshake_queue : g_server_handshake_queue;
|
409
|
+
queue->RequestHandshake(client);
|
410
|
+
}
|
411
|
+
|
412
|
+
void HandshakeDone(bool is_client) {
|
413
|
+
HandshakeQueue* queue =
|
414
|
+
is_client ? g_client_handshake_queue : g_server_handshake_queue;
|
415
|
+
queue->HandshakeDone();
|
416
|
+
}
|
417
|
+
|
418
|
+
}; // namespace
|
419
|
+
|
420
|
+
/**
|
421
|
+
* Populate grpc operation data with the fields of ALTS handshaker client and
|
422
|
+
* make a grpc call.
|
423
|
+
*/
|
424
|
+
static tsi_result make_grpc_call(alts_handshaker_client* c, bool is_start) {
|
425
|
+
GPR_ASSERT(c != nullptr);
|
426
|
+
alts_grpc_handshaker_client* client =
|
427
|
+
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
428
|
+
if (is_start) {
|
429
|
+
RequestHandshake(client, client->is_client);
|
430
|
+
return TSI_OK;
|
431
|
+
} else {
|
432
|
+
return continue_make_grpc_call(client, is_start);
|
433
|
+
}
|
434
|
+
}
|
435
|
+
|
436
|
+
static void on_status_received(void* arg, grpc_error* error) {
|
437
|
+
alts_grpc_handshaker_client* client =
|
438
|
+
static_cast<alts_grpc_handshaker_client*>(arg);
|
439
|
+
if (client->handshake_status_code != GRPC_STATUS_OK) {
|
440
|
+
// TODO(apolcyn): consider overriding the handshake result's
|
441
|
+
// status from the final ALTS message with the status here.
|
442
|
+
char* status_details =
|
443
|
+
grpc_slice_to_c_string(client->handshake_status_details);
|
444
|
+
gpr_log(GPR_INFO,
|
445
|
+
"alts_grpc_handshaker_client:%p on_status_received "
|
446
|
+
"status:%d details:|%s| error:|%s|",
|
447
|
+
client, client->handshake_status_code, status_details,
|
448
|
+
grpc_error_string(error));
|
449
|
+
gpr_free(status_details);
|
450
|
+
}
|
451
|
+
maybe_complete_tsi_next(client, true /* receive_status_finished */,
|
452
|
+
nullptr /* pending_recv_message_result */);
|
453
|
+
HandshakeDone(client->is_client);
|
454
|
+
alts_grpc_handshaker_client_unref(client);
|
455
|
+
}
|
456
|
+
|
235
457
|
/* Serializes a grpc_gcp_HandshakerReq message into a buffer and returns newly
|
236
458
|
* grpc_byte_buffer holding it. */
|
237
459
|
static grpc_byte_buffer* get_serialized_handshaker_req(
|
@@ -415,6 +637,11 @@ static void handshaker_client_shutdown(alts_handshaker_client* c) {
|
|
415
637
|
}
|
416
638
|
}
|
417
639
|
|
640
|
+
static void handshaker_call_unref(void* arg, grpc_error* error) {
|
641
|
+
grpc_call* call = static_cast<grpc_call*>(arg);
|
642
|
+
grpc_call_unref(call);
|
643
|
+
}
|
644
|
+
|
418
645
|
static void handshaker_client_destruct(alts_handshaker_client* c) {
|
419
646
|
if (c == nullptr) {
|
420
647
|
return;
|
@@ -422,7 +649,17 @@ static void handshaker_client_destruct(alts_handshaker_client* c) {
|
|
422
649
|
alts_grpc_handshaker_client* client =
|
423
650
|
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
424
651
|
if (client->call != nullptr) {
|
425
|
-
grpc_call_unref
|
652
|
+
// Throw this grpc_call_unref over to the ExecCtx so that
|
653
|
+
// we invoke it at the bottom of the call stack and
|
654
|
+
// prevent lock inversion problems due to nested ExecCtx flushing.
|
655
|
+
// TODO(apolcyn): we could remove this indirection and call
|
656
|
+
// grpc_call_unref inline if there was an internal variant of
|
657
|
+
// grpc_call_unref that didn't need to flush an ExecCtx.
|
658
|
+
grpc_core::ExecCtx::Run(
|
659
|
+
DEBUG_LOCATION,
|
660
|
+
GRPC_CLOSURE_CREATE(handshaker_call_unref, client->call,
|
661
|
+
grpc_schedule_on_exec_ctx),
|
662
|
+
GRPC_ERROR_NONE);
|
426
663
|
}
|
427
664
|
}
|
428
665
|
|
@@ -444,6 +681,8 @@ alts_handshaker_client* alts_grpc_handshaker_client_create(
|
|
444
681
|
}
|
445
682
|
alts_grpc_handshaker_client* client =
|
446
683
|
static_cast<alts_grpc_handshaker_client*>(gpr_zalloc(sizeof(*client)));
|
684
|
+
gpr_mu_init(&client->mu);
|
685
|
+
gpr_ref_init(&client->refs, 1);
|
447
686
|
client->grpc_caller = grpc_call_start_batch_and_execute;
|
448
687
|
client->handshaker = handshaker;
|
449
688
|
client->cb = cb;
|
@@ -454,7 +693,6 @@ alts_handshaker_client* alts_grpc_handshaker_client_create(
|
|
454
693
|
client->target_name = grpc_slice_copy(target_name);
|
455
694
|
client->recv_bytes = grpc_empty_slice();
|
456
695
|
grpc_metadata_array_init(&client->recv_initial_metadata);
|
457
|
-
client->grpc_cb = grpc_cb;
|
458
696
|
client->is_client = is_client;
|
459
697
|
client->buffer_size = TSI_ALTS_INITIAL_BUFFER_SIZE;
|
460
698
|
client->buffer = static_cast<unsigned char*>(gpr_zalloc(client->buffer_size));
|
@@ -469,8 +707,10 @@ alts_handshaker_client* alts_grpc_handshaker_client_create(
|
|
469
707
|
GRPC_MILLIS_INF_FUTURE, nullptr);
|
470
708
|
client->base.vtable =
|
471
709
|
vtable_for_testing == nullptr ? &vtable : vtable_for_testing;
|
472
|
-
GRPC_CLOSURE_INIT(&client->on_handshaker_service_resp_recv,
|
473
|
-
|
710
|
+
GRPC_CLOSURE_INIT(&client->on_handshaker_service_resp_recv, grpc_cb, client,
|
711
|
+
grpc_schedule_on_exec_ctx);
|
712
|
+
GRPC_CLOSURE_INIT(&client->on_status_received, on_status_received, client,
|
713
|
+
grpc_schedule_on_exec_ctx);
|
474
714
|
grpc_slice_unref_internal(slice);
|
475
715
|
return &client->base;
|
476
716
|
}
|
@@ -580,6 +820,27 @@ grpc_closure* alts_handshaker_client_get_closure_for_testing(
|
|
580
820
|
return &client->on_handshaker_service_resp_recv;
|
581
821
|
}
|
582
822
|
|
823
|
+
void alts_handshaker_client_ref_for_testing(alts_handshaker_client* c) {
|
824
|
+
alts_grpc_handshaker_client* client =
|
825
|
+
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
826
|
+
gpr_ref(&client->refs);
|
827
|
+
}
|
828
|
+
|
829
|
+
void alts_handshaker_client_on_status_received_for_testing(
|
830
|
+
alts_handshaker_client* c, grpc_status_code status, grpc_error* error) {
|
831
|
+
// We first make sure that the handshake queue has been initialized
|
832
|
+
// here because there are tests that use this API that mock out
|
833
|
+
// other parts of the alts_handshaker_client in such a way that the
|
834
|
+
// code path that would normally ensure that the handshake queue
|
835
|
+
// has been initialized isn't taken.
|
836
|
+
gpr_once_init(&g_queued_handshakes_init, DoHandshakeQueuesInit);
|
837
|
+
alts_grpc_handshaker_client* client =
|
838
|
+
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
839
|
+
client->handshake_status_code = status;
|
840
|
+
client->handshake_status_details = grpc_empty_slice();
|
841
|
+
grpc_core::Closure::Run(DEBUG_LOCATION, &client->on_status_received, error);
|
842
|
+
}
|
843
|
+
|
583
844
|
} // namespace internal
|
584
845
|
} // namespace grpc_core
|
585
846
|
|
@@ -624,20 +885,8 @@ void alts_handshaker_client_shutdown(alts_handshaker_client* client) {
|
|
624
885
|
|
625
886
|
void alts_handshaker_client_destroy(alts_handshaker_client* c) {
|
626
887
|
if (c != nullptr) {
|
627
|
-
if (c->vtable != nullptr && c->vtable->destruct != nullptr) {
|
628
|
-
c->vtable->destruct(c);
|
629
|
-
}
|
630
888
|
alts_grpc_handshaker_client* client =
|
631
889
|
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
632
|
-
|
633
|
-
grpc_byte_buffer_destroy(client->recv_buffer);
|
634
|
-
client->send_buffer = nullptr;
|
635
|
-
client->recv_buffer = nullptr;
|
636
|
-
grpc_metadata_array_destroy(&client->recv_initial_metadata);
|
637
|
-
grpc_slice_unref_internal(client->recv_bytes);
|
638
|
-
grpc_slice_unref_internal(client->target_name);
|
639
|
-
grpc_alts_credentials_options_destroy(client->options);
|
640
|
-
gpr_free(client->buffer);
|
641
|
-
gpr_free(client);
|
890
|
+
alts_grpc_handshaker_client_unref(client);
|
642
891
|
}
|
643
892
|
}
|