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
@@ -202,7 +202,9 @@ static void run_poller(void* bp, grpc_error* /*error_ignored*/) {
|
|
202
202
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {
|
203
203
|
gpr_log(GPR_INFO, "BACKUP_POLLER:%p reschedule", p);
|
204
204
|
}
|
205
|
-
|
205
|
+
grpc_core::Executor::Run(&p->run_poller, GRPC_ERROR_NONE,
|
206
|
+
grpc_core::ExecutorType::DEFAULT,
|
207
|
+
grpc_core::ExecutorJobType::LONG);
|
206
208
|
}
|
207
209
|
}
|
208
210
|
|
@@ -241,10 +243,10 @@ static void cover_self(grpc_tcp* tcp) {
|
|
241
243
|
}
|
242
244
|
grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
|
243
245
|
gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p);
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
246
|
+
grpc_core::Executor::Run(
|
247
|
+
GRPC_CLOSURE_INIT(&p->run_poller, run_poller, p, nullptr),
|
248
|
+
GRPC_ERROR_NONE, grpc_core::ExecutorType::DEFAULT,
|
249
|
+
grpc_core::ExecutorJobType::LONG);
|
248
250
|
} else {
|
249
251
|
while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) ==
|
250
252
|
nullptr) {
|
@@ -415,7 +417,7 @@ static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
|
|
415
417
|
|
416
418
|
tcp->read_cb = nullptr;
|
417
419
|
tcp->incoming_buffer = nullptr;
|
418
|
-
|
420
|
+
grpc_core::Closure::Run(DEBUG_LOCATION, cb, error);
|
419
421
|
}
|
420
422
|
|
421
423
|
#define MAX_READ_IOVEC 4
|
@@ -643,7 +645,8 @@ static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
|
|
643
645
|
* right thing (i.e calls tcp_do_read() which either reads the available
|
644
646
|
* bytes or calls notify_on_read() to be notified when new bytes become
|
645
647
|
* available */
|
646
|
-
|
648
|
+
grpc_core::Closure::Run(DEBUG_LOCATION, &tcp->read_done_closure,
|
649
|
+
GRPC_ERROR_NONE);
|
647
650
|
}
|
648
651
|
}
|
649
652
|
|
@@ -1024,7 +1027,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
1024
1027
|
if (error != GRPC_ERROR_NONE) {
|
1025
1028
|
cb = tcp->write_cb;
|
1026
1029
|
tcp->write_cb = nullptr;
|
1027
|
-
|
1030
|
+
grpc_core::Closure::Run(DEBUG_LOCATION, cb, GRPC_ERROR_REF(error));
|
1028
1031
|
TCP_UNREF(tcp, "write");
|
1029
1032
|
return;
|
1030
1033
|
}
|
@@ -1044,7 +1047,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
1044
1047
|
gpr_log(GPR_INFO, "write: %s", str);
|
1045
1048
|
}
|
1046
1049
|
// No need to take a ref on error since tcp_flush provides a ref.
|
1047
|
-
|
1050
|
+
grpc_core::Closure::Run(DEBUG_LOCATION, cb, error);
|
1048
1051
|
TCP_UNREF(tcp, "write");
|
1049
1052
|
}
|
1050
1053
|
}
|
@@ -1073,11 +1076,12 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
|
|
1073
1076
|
|
1074
1077
|
tcp->outgoing_buffer_arg = arg;
|
1075
1078
|
if (buf->length == 0) {
|
1076
|
-
|
1077
|
-
cb,
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1079
|
+
grpc_core::Closure::Run(
|
1080
|
+
DEBUG_LOCATION, cb,
|
1081
|
+
grpc_fd_is_shutdown(tcp->em_fd)
|
1082
|
+
? tcp_annotate_error(GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"),
|
1083
|
+
tcp)
|
1084
|
+
: GRPC_ERROR_NONE);
|
1081
1085
|
tcp_shutdown_buffer_list(tcp);
|
1082
1086
|
return;
|
1083
1087
|
}
|
@@ -1099,7 +1103,7 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
|
|
1099
1103
|
const char* str = grpc_error_string(error);
|
1100
1104
|
gpr_log(GPR_INFO, "write: %s", str);
|
1101
1105
|
}
|
1102
|
-
|
1106
|
+
grpc_core::Closure::Run(DEBUG_LOCATION, cb, error);
|
1103
1107
|
}
|
1104
1108
|
}
|
1105
1109
|
|
@@ -124,7 +124,8 @@ static void tcp_server_shutdown_starting_add(grpc_tcp_server* s,
|
|
124
124
|
static void finish_shutdown(grpc_tcp_server* s) {
|
125
125
|
GPR_ASSERT(s->shutdown);
|
126
126
|
if (s->shutdown_complete != nullptr) {
|
127
|
-
|
127
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, s->shutdown_complete,
|
128
|
+
GRPC_ERROR_NONE);
|
128
129
|
}
|
129
130
|
|
130
131
|
while (s->head) {
|
@@ -195,7 +196,7 @@ static void tcp_server_unref(grpc_tcp_server* s) {
|
|
195
196
|
if (gpr_unref(&s->refs)) {
|
196
197
|
/* Complete shutdown_starting work before destroying. */
|
197
198
|
grpc_core::ExecCtx exec_ctx;
|
198
|
-
|
199
|
+
grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_starting);
|
199
200
|
grpc_core::ExecCtx::Get()->Flush();
|
200
201
|
tcp_server_destroy(s);
|
201
202
|
}
|
@@ -108,7 +108,8 @@ static void finish_shutdown(grpc_tcp_server* s) {
|
|
108
108
|
GPR_ASSERT(s->shutdown);
|
109
109
|
gpr_mu_unlock(&s->mu);
|
110
110
|
if (s->shutdown_complete != nullptr) {
|
111
|
-
|
111
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, s->shutdown_complete,
|
112
|
+
GRPC_ERROR_NONE);
|
112
113
|
}
|
113
114
|
|
114
115
|
gpr_mu_destroy(&s->mu);
|
@@ -119,7 +120,7 @@ static void finish_shutdown(grpc_tcp_server* s) {
|
|
119
120
|
gpr_free(sp);
|
120
121
|
}
|
121
122
|
grpc_channel_args_destroy(s->channel_args);
|
122
|
-
|
123
|
+
delete s->fd_handler;
|
123
124
|
|
124
125
|
gpr_free(s);
|
125
126
|
}
|
@@ -546,7 +547,7 @@ static void tcp_server_unref(grpc_tcp_server* s) {
|
|
546
547
|
if (gpr_unref(&s->refs)) {
|
547
548
|
grpc_tcp_server_shutdown_listeners(s);
|
548
549
|
gpr_mu_lock(&s->mu);
|
549
|
-
|
550
|
+
grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_starting);
|
550
551
|
gpr_mu_unlock(&s->mu);
|
551
552
|
tcp_server_destroy(s);
|
552
553
|
}
|
@@ -622,7 +623,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler {
|
|
622
623
|
|
623
624
|
static grpc_core::TcpServerFdHandler* tcp_server_create_fd_handler(
|
624
625
|
grpc_tcp_server* s) {
|
625
|
-
s->fd_handler =
|
626
|
+
s->fd_handler = new ExternalConnectionHandler(s);
|
626
627
|
return s->fd_handler;
|
627
628
|
}
|
628
629
|
|
@@ -135,10 +135,12 @@ static void destroy_server(void* arg, grpc_error* error) {
|
|
135
135
|
|
136
136
|
static void finish_shutdown_locked(grpc_tcp_server* s) {
|
137
137
|
if (s->shutdown_complete != NULL) {
|
138
|
-
|
138
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, s->shutdown_complete,
|
139
|
+
GRPC_ERROR_NONE);
|
139
140
|
}
|
140
141
|
|
141
|
-
|
142
|
+
grpc_core::ExecCtx::Run(
|
143
|
+
DEBUG_LOCATION,
|
142
144
|
GRPC_CLOSURE_CREATE(destroy_server, s, grpc_schedule_on_exec_ctx),
|
143
145
|
GRPC_ERROR_NONE);
|
144
146
|
}
|
@@ -177,7 +179,7 @@ static void tcp_server_unref(grpc_tcp_server* s) {
|
|
177
179
|
if (gpr_unref(&s->refs)) {
|
178
180
|
grpc_tcp_server_shutdown_listeners(s);
|
179
181
|
gpr_mu_lock(&s->mu);
|
180
|
-
|
182
|
+
grpc_core::ExecCtx::RunList(DEBUG_LOCATION, &s->shutdown_starting);
|
181
183
|
gpr_mu_unlock(&s->mu);
|
182
184
|
tcp_server_destroy(s);
|
183
185
|
}
|
@@ -233,7 +233,7 @@ static void on_read(void* tcpp, grpc_error* error) {
|
|
233
233
|
|
234
234
|
tcp->read_cb = NULL;
|
235
235
|
TCP_UNREF(tcp, "read");
|
236
|
-
|
236
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, error);
|
237
237
|
}
|
238
238
|
|
239
239
|
#define DEFAULT_TARGET_READ_SIZE 8192
|
@@ -254,9 +254,10 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
|
|
254
254
|
}
|
255
255
|
|
256
256
|
if (tcp->shutting_down) {
|
257
|
-
|
258
|
-
cb,
|
259
|
-
|
257
|
+
grpc_core::ExecCtx::Run(
|
258
|
+
DEBUG_LOCATION, cb,
|
259
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
260
|
+
"TCP socket is shutting down", &tcp->shutdown_error, 1));
|
260
261
|
return;
|
261
262
|
}
|
262
263
|
|
@@ -289,7 +290,7 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
|
|
289
290
|
/* Did we get data immediately ? Yay. */
|
290
291
|
if (info->wsa_error != WSAEWOULDBLOCK) {
|
291
292
|
info->bytes_transferred = bytes_read;
|
292
|
-
|
293
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, &tcp->on_read, GRPC_ERROR_NONE);
|
293
294
|
return;
|
294
295
|
}
|
295
296
|
|
@@ -302,8 +303,8 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
|
|
302
303
|
int wsa_error = WSAGetLastError();
|
303
304
|
if (wsa_error != WSA_IO_PENDING) {
|
304
305
|
info->wsa_error = wsa_error;
|
305
|
-
|
306
|
-
|
306
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, &tcp->on_read,
|
307
|
+
GRPC_WSA_ERROR(info->wsa_error, "WSARecv"));
|
307
308
|
return;
|
308
309
|
}
|
309
310
|
}
|
@@ -338,7 +339,7 @@ static void on_write(void* tcpp, grpc_error* error) {
|
|
338
339
|
}
|
339
340
|
|
340
341
|
TCP_UNREF(tcp, "write");
|
341
|
-
|
342
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, error);
|
342
343
|
}
|
343
344
|
|
344
345
|
/* Initiates a write. */
|
@@ -366,9 +367,10 @@ static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
|
|
366
367
|
}
|
367
368
|
|
368
369
|
if (tcp->shutting_down) {
|
369
|
-
|
370
|
-
cb,
|
371
|
-
|
370
|
+
grpc_core::ExecCtx::Run(
|
371
|
+
DEBUG_LOCATION, cb,
|
372
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
373
|
+
"TCP socket is shutting down", &tcp->shutdown_error, 1));
|
372
374
|
return;
|
373
375
|
}
|
374
376
|
|
@@ -399,7 +401,7 @@ static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
|
|
399
401
|
grpc_error* error = status == 0
|
400
402
|
? GRPC_ERROR_NONE
|
401
403
|
: GRPC_WSA_ERROR(info->wsa_error, "WSASend");
|
402
|
-
|
404
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb, error);
|
403
405
|
if (allocated) gpr_free(allocated);
|
404
406
|
return;
|
405
407
|
}
|
@@ -417,7 +419,8 @@ static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
|
|
417
419
|
int wsa_error = WSAGetLastError();
|
418
420
|
if (wsa_error != WSA_IO_PENDING) {
|
419
421
|
TCP_UNREF(tcp, "write");
|
420
|
-
|
422
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, cb,
|
423
|
+
GRPC_WSA_ERROR(wsa_error, "WSASend"));
|
421
424
|
return;
|
422
425
|
}
|
423
426
|
}
|
@@ -37,7 +37,7 @@ void grpc_custom_timer_callback(grpc_custom_timer* t, grpc_error* /*error*/) {
|
|
37
37
|
grpc_timer* timer = t->original;
|
38
38
|
GPR_ASSERT(timer->pending);
|
39
39
|
timer->pending = 0;
|
40
|
-
|
40
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, timer->closure, GRPC_ERROR_NONE);
|
41
41
|
custom_timer_impl->stop(t);
|
42
42
|
gpr_free(t);
|
43
43
|
}
|
@@ -48,7 +48,7 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline,
|
|
48
48
|
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
|
49
49
|
grpc_millis now = grpc_core::ExecCtx::Get()->Now();
|
50
50
|
if (deadline <= grpc_core::ExecCtx::Get()->Now()) {
|
51
|
-
|
51
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
|
52
52
|
timer->pending = false;
|
53
53
|
return;
|
54
54
|
} else {
|
@@ -69,7 +69,8 @@ static void timer_cancel(grpc_timer* timer) {
|
|
69
69
|
grpc_custom_timer* tw = (grpc_custom_timer*)timer->custom_timer;
|
70
70
|
if (timer->pending) {
|
71
71
|
timer->pending = 0;
|
72
|
-
|
72
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, timer->closure,
|
73
|
+
GRPC_ERROR_CANCELLED);
|
73
74
|
custom_timer_impl->stop(tw);
|
74
75
|
gpr_free(tw);
|
75
76
|
}
|
@@ -369,9 +369,10 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline,
|
|
369
369
|
|
370
370
|
if (!g_shared_mutables.initialized) {
|
371
371
|
timer->pending = false;
|
372
|
-
|
373
|
-
|
374
|
-
|
372
|
+
grpc_core::ExecCtx::Run(
|
373
|
+
DEBUG_LOCATION, timer->closure,
|
374
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
375
|
+
"Attempt to create timer before initialization"));
|
375
376
|
return;
|
376
377
|
}
|
377
378
|
|
@@ -380,7 +381,7 @@ static void timer_init(grpc_timer* timer, grpc_millis deadline,
|
|
380
381
|
grpc_millis now = grpc_core::ExecCtx::Get()->Now();
|
381
382
|
if (deadline <= now) {
|
382
383
|
timer->pending = false;
|
383
|
-
|
384
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, timer->closure, GRPC_ERROR_NONE);
|
384
385
|
gpr_mu_unlock(&shard->mu);
|
385
386
|
/* early out */
|
386
387
|
return;
|
@@ -471,7 +472,8 @@ static void timer_cancel(grpc_timer* timer) {
|
|
471
472
|
if (timer->pending) {
|
472
473
|
REMOVE_FROM_HASH_TABLE(timer);
|
473
474
|
|
474
|
-
|
475
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, timer->closure,
|
476
|
+
GRPC_ERROR_CANCELLED);
|
475
477
|
timer->pending = false;
|
476
478
|
if (timer->heap_index == INVALID_HEAP_INDEX) {
|
477
479
|
list_remove(timer);
|
@@ -546,9 +548,8 @@ static grpc_timer* pop_one(timer_shard* shard, grpc_millis now) {
|
|
546
548
|
}
|
547
549
|
if (timer->deadline > now) return nullptr;
|
548
550
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_timer_trace)) {
|
549
|
-
gpr_log(GPR_INFO, "TIMER %p: FIRE %" PRId64 "ms late
|
550
|
-
|
551
|
-
timer->closure->scheduler->vtable->name);
|
551
|
+
gpr_log(GPR_INFO, "TIMER %p: FIRE %" PRId64 "ms late", timer,
|
552
|
+
now - timer->deadline);
|
552
553
|
}
|
553
554
|
timer->pending = false;
|
554
555
|
grpc_timer_heap_pop(&shard->heap);
|
@@ -564,7 +565,8 @@ static size_t pop_timers(timer_shard* shard, grpc_millis now,
|
|
564
565
|
gpr_mu_lock(&shard->mu);
|
565
566
|
while ((timer = pop_one(shard, now))) {
|
566
567
|
REMOVE_FROM_HASH_TABLE(timer);
|
567
|
-
|
568
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, timer->closure,
|
569
|
+
GRPC_ERROR_REF(error));
|
568
570
|
n++;
|
569
571
|
}
|
570
572
|
*new_min_deadline = compute_min_deadline(shard);
|
@@ -29,7 +29,7 @@
|
|
29
29
|
|
30
30
|
#include "src/core/lib/iomgr/port.h"
|
31
31
|
|
32
|
-
#ifdef
|
32
|
+
#ifdef GRPC_POSIX_SOCKET_UDP_SERVER
|
33
33
|
|
34
34
|
#include "src/core/lib/iomgr/udp_server.h"
|
35
35
|
|
@@ -208,7 +208,7 @@ static grpc_socket_factory* get_socket_factory(const grpc_channel_args* args) {
|
|
208
208
|
}
|
209
209
|
|
210
210
|
grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) {
|
211
|
-
grpc_udp_server* s =
|
211
|
+
grpc_udp_server* s = new grpc_udp_server();
|
212
212
|
gpr_mu_init(&s->mu);
|
213
213
|
s->socket_factory = get_socket_factory(args);
|
214
214
|
if (s->socket_factory) {
|
@@ -243,7 +243,8 @@ void GrpcUdpListener::shutdown_fd(void* args, grpc_error* error) {
|
|
243
243
|
|
244
244
|
static void finish_shutdown(grpc_udp_server* s) {
|
245
245
|
if (s->shutdown_complete != nullptr) {
|
246
|
-
|
246
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, s->shutdown_complete,
|
247
|
+
GRPC_ERROR_NONE);
|
247
248
|
}
|
248
249
|
|
249
250
|
gpr_mu_destroy(&s->mu);
|
@@ -257,7 +258,7 @@ static void finish_shutdown(grpc_udp_server* s) {
|
|
257
258
|
grpc_socket_factory_unref(s->socket_factory);
|
258
259
|
}
|
259
260
|
|
260
|
-
|
261
|
+
delete s;
|
261
262
|
}
|
262
263
|
|
263
264
|
static void destroyed_port(void* server, grpc_error* /*error*/) {
|
@@ -448,7 +449,9 @@ void GrpcUdpListener::do_read(void* arg, grpc_error* error) {
|
|
448
449
|
if (!sp->already_shutdown_ && sp->udp_handler_->Read()) {
|
449
450
|
/* There maybe more packets to read. Schedule read_more_cb_ closure to run
|
450
451
|
* after finishing this event loop. */
|
451
|
-
|
452
|
+
grpc_core::Executor::Run(&sp->do_read_closure_, GRPC_ERROR_NONE,
|
453
|
+
grpc_core::ExecutorType::DEFAULT,
|
454
|
+
grpc_core::ExecutorJobType::LONG);
|
452
455
|
} else {
|
453
456
|
/* Finish reading all the packets, re-arm the notification event so we can
|
454
457
|
* get another chance to read. Or fd already shutdown, re-arm to get a
|
@@ -481,10 +484,10 @@ void GrpcUdpListener::OnRead(grpc_error* error, void* do_read_arg) {
|
|
481
484
|
if (udp_handler_->Read()) {
|
482
485
|
/* There maybe more packets to read. Schedule read_more_cb_ closure to run
|
483
486
|
* after finishing this event loop. */
|
484
|
-
GRPC_CLOSURE_INIT(
|
485
|
-
|
486
|
-
|
487
|
-
|
487
|
+
GRPC_CLOSURE_INIT(&do_read_closure_, do_read, do_read_arg, nullptr);
|
488
|
+
grpc_core::Executor::Run(&do_read_closure_, GRPC_ERROR_NONE,
|
489
|
+
grpc_core::ExecutorType::DEFAULT,
|
490
|
+
grpc_core::ExecutorJobType::LONG);
|
488
491
|
} else {
|
489
492
|
/* Finish reading all the packets, re-arm the notification event so we can
|
490
493
|
* get another chance to read. Or fd already shutdown, re-arm to get a
|
@@ -544,11 +547,11 @@ void GrpcUdpListener::OnCanWrite(grpc_error* error, void* do_write_arg) {
|
|
544
547
|
}
|
545
548
|
|
546
549
|
/* Schedule actual write in another thread. */
|
547
|
-
GRPC_CLOSURE_INIT(
|
548
|
-
&do_write_closure_, do_write, do_write_arg,
|
549
|
-
grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::LONG));
|
550
|
+
GRPC_CLOSURE_INIT(&do_write_closure_, do_write, do_write_arg, nullptr);
|
550
551
|
|
551
|
-
|
552
|
+
grpc_core::Executor::Run(&do_write_closure_, GRPC_ERROR_NONE,
|
553
|
+
grpc_core::ExecutorType::DEFAULT,
|
554
|
+
grpc_core::ExecutorJobType::LONG);
|
552
555
|
}
|
553
556
|
|
554
557
|
static int add_socket_to_server(grpc_udp_server* s, int fd,
|
@@ -40,7 +40,9 @@ grpc_alts_credentials::grpc_alts_credentials(
|
|
40
40
|
options_(grpc_alts_credentials_options_copy(options)),
|
41
41
|
handshaker_service_url_(handshaker_service_url == nullptr
|
42
42
|
? gpr_strdup(GRPC_ALTS_HANDSHAKER_SERVICE_URL)
|
43
|
-
: gpr_strdup(handshaker_service_url)) {
|
43
|
+
: gpr_strdup(handshaker_service_url)) {
|
44
|
+
grpc_alts_set_rpc_protocol_versions(&options_->rpc_versions);
|
45
|
+
}
|
44
46
|
|
45
47
|
grpc_alts_credentials::~grpc_alts_credentials() {
|
46
48
|
grpc_alts_credentials_options_destroy(options_);
|
@@ -63,7 +65,9 @@ grpc_alts_server_credentials::grpc_alts_server_credentials(
|
|
63
65
|
options_(grpc_alts_credentials_options_copy(options)),
|
64
66
|
handshaker_service_url_(handshaker_service_url == nullptr
|
65
67
|
? gpr_strdup(GRPC_ALTS_HANDSHAKER_SERVICE_URL)
|
66
|
-
: gpr_strdup(handshaker_service_url)) {
|
68
|
+
: gpr_strdup(handshaker_service_url)) {
|
69
|
+
grpc_alts_set_rpc_protocol_versions(&options_->rpc_versions);
|
70
|
+
}
|
67
71
|
|
68
72
|
grpc_core::RefCountedPtr<grpc_server_security_connector>
|
69
73
|
grpc_alts_server_credentials::create_security_connector() {
|
@@ -81,7 +85,7 @@ grpc_channel_credentials* grpc_alts_credentials_create_customized(
|
|
81
85
|
if (!enable_untrusted_alts && !grpc_alts_is_running_on_gcp()) {
|
82
86
|
return nullptr;
|
83
87
|
}
|
84
|
-
return
|
88
|
+
return new grpc_alts_credentials(options, handshaker_service_url);
|
85
89
|
}
|
86
90
|
|
87
91
|
grpc_server_credentials* grpc_alts_server_credentials_create_customized(
|
@@ -90,8 +94,7 @@ grpc_server_credentials* grpc_alts_server_credentials_create_customized(
|
|
90
94
|
if (!enable_untrusted_alts && !grpc_alts_is_running_on_gcp()) {
|
91
95
|
return nullptr;
|
92
96
|
}
|
93
|
-
return
|
94
|
-
handshaker_service_url);
|
97
|
+
return new grpc_alts_server_credentials(options, handshaker_service_url);
|
95
98
|
}
|
96
99
|
|
97
100
|
grpc_channel_credentials* grpc_alts_credentials_create(
|
@@ -31,80 +31,68 @@
|
|
31
31
|
#include <grpc/support/log.h>
|
32
32
|
#include <grpc/support/sync.h>
|
33
33
|
|
34
|
-
#define GRPC_ALTS_EXPECT_NAME_GOOGLE "Google"
|
35
|
-
#define GRPC_ALTS_WINDOWS_CHECK_COMMAND "powershell.exe"
|
36
|
-
#define GRPC_ALTS_WINDOWS_CHECK_COMMAND_ARGS \
|
37
|
-
"(Get-WmiObject -Class Win32_BIOS).Manufacturer"
|
38
|
-
#define GRPC_ALTS_WINDOWS_CHECK_BIOS_FILE "windows_bios.data"
|
39
|
-
|
40
|
-
const size_t kBiosDataBufferSize = 256;
|
41
|
-
|
42
|
-
static bool g_compute_engine_detection_done = false;
|
43
|
-
static bool g_is_on_compute_engine = false;
|
44
|
-
static gpr_mu g_mu;
|
45
|
-
static gpr_once g_once = GPR_ONCE_INIT;
|
46
|
-
|
47
34
|
namespace grpc_core {
|
48
35
|
namespace internal {
|
49
36
|
|
50
|
-
bool check_bios_data(const char*
|
51
|
-
char* bios_data = read_bios_file(bios_data_file);
|
52
|
-
bool result = !strcmp(bios_data, GRPC_ALTS_EXPECT_NAME_GOOGLE);
|
53
|
-
remove(GRPC_ALTS_WINDOWS_CHECK_BIOS_FILE);
|
54
|
-
gpr_free(bios_data);
|
55
|
-
return result;
|
56
|
-
}
|
37
|
+
bool check_bios_data(const char*) { return false; }
|
57
38
|
|
58
|
-
|
59
|
-
|
39
|
+
bool check_windows_registry_product_name(HKEY root_key,
|
40
|
+
const char* reg_key_path,
|
41
|
+
const char* reg_key_name) {
|
42
|
+
const size_t kProductNameBufferSize = 256;
|
43
|
+
char const expected_substr[] = "Google";
|
60
44
|
|
61
|
-
|
45
|
+
// Get the size of the string first to allocate our buffer. This includes
|
46
|
+
// enough space for the trailing NUL character that will be included.
|
47
|
+
DWORD buffer_size{};
|
48
|
+
auto rc = ::RegGetValueA(
|
49
|
+
root_key, reg_key_path, reg_key_name, RRF_RT_REG_SZ,
|
50
|
+
nullptr, // We know the type will be REG_SZ.
|
51
|
+
nullptr, // We're only fetching the size; no buffer given yet.
|
52
|
+
&buffer_size); // Fetch the size in bytes of the value, if it exists.
|
53
|
+
if (rc != 0) {
|
54
|
+
return false;
|
55
|
+
}
|
62
56
|
|
63
|
-
|
64
|
-
SECURITY_ATTRIBUTES sa;
|
65
|
-
sa.nLength = sizeof(sa);
|
66
|
-
sa.lpSecurityDescriptor = NULL;
|
67
|
-
sa.bInheritHandle = TRUE;
|
68
|
-
HANDLE h = CreateFile(_T(GRPC_ALTS_WINDOWS_CHECK_BIOS_FILE), GENERIC_WRITE,
|
69
|
-
FILE_SHARE_WRITE | FILE_SHARE_READ, &sa, OPEN_ALWAYS,
|
70
|
-
FILE_ATTRIBUTE_NORMAL, NULL);
|
71
|
-
if (h == INVALID_HANDLE_VALUE) {
|
72
|
-
gpr_log(GPR_ERROR, "CreateFile failed (%d).", GetLastError());
|
57
|
+
if (buffer_size > kProductNameBufferSize) {
|
73
58
|
return false;
|
74
59
|
}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
TCHAR cmd[kBiosDataBufferSize];
|
86
|
-
_sntprintf(cmd, kBiosDataBufferSize, _T("%s %s"),
|
87
|
-
_T(GRPC_ALTS_WINDOWS_CHECK_COMMAND),
|
88
|
-
_T(GRPC_ALTS_WINDOWS_CHECK_COMMAND_ARGS));
|
89
|
-
if (!CreateProcess(NULL, cmd, NULL, NULL, TRUE, flags, NULL, NULL, &si,
|
90
|
-
&pi)) {
|
91
|
-
gpr_log(GPR_ERROR, "CreateProcess failed (%d).\n", GetLastError());
|
60
|
+
|
61
|
+
// Retrieve the product name string.
|
62
|
+
char buffer[kProductNameBufferSize];
|
63
|
+
buffer_size = kProductNameBufferSize;
|
64
|
+
rc = ::RegGetValueA(
|
65
|
+
root_key, reg_key_path, reg_key_name, RRF_RT_REG_SZ,
|
66
|
+
nullptr, // We know the type will be REG_SZ.
|
67
|
+
static_cast<void*>(buffer), // Fetch the string value this time.
|
68
|
+
&buffer_size); // The string size in bytes, not including trailing NUL.
|
69
|
+
if (rc != 0) {
|
92
70
|
return false;
|
93
71
|
}
|
94
|
-
|
95
|
-
|
96
|
-
CloseHandle(pi.hThread);
|
97
|
-
CloseHandle(h);
|
98
|
-
return true;
|
72
|
+
|
73
|
+
return strstr(buffer, expected_substr) != nullptr;
|
99
74
|
}
|
100
75
|
|
76
|
+
} // namespace internal
|
77
|
+
} // namespace grpc_core
|
78
|
+
|
79
|
+
static bool g_compute_engine_detection_done = false;
|
80
|
+
static bool g_is_on_compute_engine = false;
|
81
|
+
static gpr_mu g_mu;
|
82
|
+
static gpr_once g_once = GPR_ONCE_INIT;
|
83
|
+
|
84
|
+
static void init_mu(void) { gpr_mu_init(&g_mu); }
|
85
|
+
|
101
86
|
bool grpc_alts_is_running_on_gcp() {
|
87
|
+
char const reg_key_path[] = "SYSTEM\\HardwareConfig\\Current\\";
|
88
|
+
char const reg_key_name[] = "SystemProductName";
|
89
|
+
|
102
90
|
gpr_once_init(&g_once, init_mu);
|
103
91
|
gpr_mu_lock(&g_mu);
|
104
92
|
if (!g_compute_engine_detection_done) {
|
105
93
|
g_is_on_compute_engine =
|
106
|
-
|
107
|
-
|
94
|
+
grpc_core::internal::check_windows_registry_product_name(
|
95
|
+
HKEY_LOCAL_MACHINE, reg_key_path, reg_key_name);
|
108
96
|
g_compute_engine_detection_done = true;
|
109
97
|
}
|
110
98
|
gpr_mu_unlock(&g_mu);
|