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
@@ -169,7 +169,7 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error* error) {
|
|
169
169
|
// Cancel deadline timer, since we're invoking the on_handshake_done
|
170
170
|
// callback now.
|
171
171
|
grpc_timer_cancel(&deadline_timer_);
|
172
|
-
|
172
|
+
ExecCtx::Run(DEBUG_LOCATION, &on_handshake_done_, error);
|
173
173
|
is_shutdown_ = true;
|
174
174
|
} else {
|
175
175
|
auto handshaker = handshakers_[index_];
|
@@ -38,21 +38,21 @@ namespace {
|
|
38
38
|
|
39
39
|
class HandshakerFactoryList {
|
40
40
|
public:
|
41
|
-
void Register(bool at_start,
|
41
|
+
void Register(bool at_start, std::unique_ptr<HandshakerFactory> factory);
|
42
42
|
void AddHandshakers(const grpc_channel_args* args,
|
43
43
|
grpc_pollset_set* interested_parties,
|
44
44
|
HandshakeManager* handshake_mgr);
|
45
45
|
|
46
46
|
private:
|
47
|
-
InlinedVector<
|
47
|
+
InlinedVector<std::unique_ptr<HandshakerFactory>, 2> factories_;
|
48
48
|
};
|
49
49
|
|
50
50
|
HandshakerFactoryList* g_handshaker_factory_lists = nullptr;
|
51
51
|
|
52
52
|
} // namespace
|
53
53
|
|
54
|
-
void HandshakerFactoryList::Register(
|
55
|
-
|
54
|
+
void HandshakerFactoryList::Register(
|
55
|
+
bool at_start, std::unique_ptr<HandshakerFactory> factory) {
|
56
56
|
factories_.push_back(std::move(factory));
|
57
57
|
if (at_start) {
|
58
58
|
auto* end = &factories_[factories_.size() - 1];
|
@@ -99,7 +99,7 @@ void HandshakerRegistry::Shutdown() {
|
|
99
99
|
|
100
100
|
void HandshakerRegistry::RegisterHandshakerFactory(
|
101
101
|
bool at_start, HandshakerType handshaker_type,
|
102
|
-
|
102
|
+
std::unique_ptr<HandshakerFactory> factory) {
|
103
103
|
GPR_ASSERT(g_handshaker_factory_lists != nullptr);
|
104
104
|
auto& factory_list = g_handshaker_factory_lists[handshaker_type];
|
105
105
|
factory_list.Register(at_start, std::move(factory));
|
@@ -38,9 +38,9 @@ class HandshakerRegistry {
|
|
38
38
|
/// Registers a new handshaker factory. Takes ownership.
|
39
39
|
/// If \a at_start is true, the new handshaker will be at the beginning of
|
40
40
|
/// the list. Otherwise, it will be added to the end.
|
41
|
-
static void RegisterHandshakerFactory(
|
42
|
-
|
43
|
-
|
41
|
+
static void RegisterHandshakerFactory(
|
42
|
+
bool at_start, HandshakerType handshaker_type,
|
43
|
+
std::unique_ptr<HandshakerFactory> factory);
|
44
44
|
static void AddHandshakers(HandshakerType handshaker_type,
|
45
45
|
const grpc_channel_args* args,
|
46
46
|
grpc_pollset_set* interested_parties,
|
@@ -80,11 +80,12 @@ error:
|
|
80
80
|
return 0;
|
81
81
|
}
|
82
82
|
|
83
|
-
static void* zalloc_gpr(void* opaque
|
83
|
+
static void* zalloc_gpr(void* /*opaque*/, unsigned int items,
|
84
|
+
unsigned int size) {
|
84
85
|
return gpr_malloc(items * size);
|
85
86
|
}
|
86
87
|
|
87
|
-
static void zfree_gpr(void* opaque
|
88
|
+
static void zfree_gpr(void* /*opaque*/, void* address) { gpr_free(address); }
|
88
89
|
|
89
90
|
static int zlib_compress(grpc_slice_buffer* input, grpc_slice_buffer* output,
|
90
91
|
int gzip) {
|
@@ -47,12 +47,10 @@ static void grpc_stream_compression_pass_through(grpc_slice_buffer* in,
|
|
47
47
|
}
|
48
48
|
}
|
49
49
|
|
50
|
-
static bool grpc_stream_compress_identity(
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
size_t max_output_size,
|
55
|
-
grpc_stream_compression_flush flush) {
|
50
|
+
static bool grpc_stream_compress_identity(
|
51
|
+
grpc_stream_compression_context* ctx, grpc_slice_buffer* in,
|
52
|
+
grpc_slice_buffer* out, size_t* output_size, size_t max_output_size,
|
53
|
+
grpc_stream_compression_flush /*flush*/) {
|
56
54
|
if (ctx == nullptr) {
|
57
55
|
return false;
|
58
56
|
}
|
@@ -84,7 +82,7 @@ grpc_stream_compression_context_create_identity(
|
|
84
82
|
}
|
85
83
|
|
86
84
|
static void grpc_stream_compression_context_destroy_identity(
|
87
|
-
grpc_stream_compression_context* ctx) {
|
85
|
+
grpc_stream_compression_context* /*ctx*/) {
|
88
86
|
return;
|
89
87
|
}
|
90
88
|
|
data/src/core/lib/gpr/alloc.cc
CHANGED
@@ -25,36 +25,11 @@
|
|
25
25
|
#include <string.h>
|
26
26
|
#include "src/core/lib/profiling/timers.h"
|
27
27
|
|
28
|
-
static void* zalloc_with_calloc(size_t sz) { return calloc(sz, 1); }
|
29
|
-
|
30
|
-
static void* zalloc_with_gpr_malloc(size_t sz) {
|
31
|
-
void* p = gpr_malloc(sz);
|
32
|
-
memset(p, 0, sz);
|
33
|
-
return p;
|
34
|
-
}
|
35
|
-
|
36
|
-
static gpr_allocation_functions g_alloc_functions = {malloc, zalloc_with_calloc,
|
37
|
-
realloc, free};
|
38
|
-
|
39
|
-
gpr_allocation_functions gpr_get_allocation_functions() {
|
40
|
-
return g_alloc_functions;
|
41
|
-
}
|
42
|
-
|
43
|
-
void gpr_set_allocation_functions(gpr_allocation_functions functions) {
|
44
|
-
GPR_ASSERT(functions.malloc_fn != nullptr);
|
45
|
-
GPR_ASSERT(functions.realloc_fn != nullptr);
|
46
|
-
GPR_ASSERT(functions.free_fn != nullptr);
|
47
|
-
if (functions.zalloc_fn == nullptr) {
|
48
|
-
functions.zalloc_fn = zalloc_with_gpr_malloc;
|
49
|
-
}
|
50
|
-
g_alloc_functions = functions;
|
51
|
-
}
|
52
|
-
|
53
28
|
void* gpr_malloc(size_t size) {
|
54
29
|
GPR_TIMER_SCOPE("gpr_malloc", 0);
|
55
30
|
void* p;
|
56
31
|
if (size == 0) return nullptr;
|
57
|
-
p =
|
32
|
+
p = malloc(size);
|
58
33
|
if (!p) {
|
59
34
|
abort();
|
60
35
|
}
|
@@ -65,7 +40,7 @@ void* gpr_zalloc(size_t size) {
|
|
65
40
|
GPR_TIMER_SCOPE("gpr_zalloc", 0);
|
66
41
|
void* p;
|
67
42
|
if (size == 0) return nullptr;
|
68
|
-
p =
|
43
|
+
p = calloc(size, 1);
|
69
44
|
if (!p) {
|
70
45
|
abort();
|
71
46
|
}
|
@@ -74,13 +49,13 @@ void* gpr_zalloc(size_t size) {
|
|
74
49
|
|
75
50
|
void gpr_free(void* p) {
|
76
51
|
GPR_TIMER_SCOPE("gpr_free", 0);
|
77
|
-
|
52
|
+
free(p);
|
78
53
|
}
|
79
54
|
|
80
55
|
void* gpr_realloc(void* p, size_t size) {
|
81
56
|
GPR_TIMER_SCOPE("gpr_realloc", 0);
|
82
57
|
if ((size == 0) && (p == nullptr)) return nullptr;
|
83
|
-
p =
|
58
|
+
p = realloc(p, size);
|
84
59
|
if (!p) {
|
85
60
|
abort();
|
86
61
|
}
|
@@ -72,7 +72,7 @@ unsigned gpr_cpu_current_cpu(void) {
|
|
72
72
|
return 0;
|
73
73
|
}
|
74
74
|
if (static_cast<unsigned>(cpu) >= gpr_cpu_num_cores()) {
|
75
|
-
gpr_log(
|
75
|
+
gpr_log(GPR_DEBUG, "Cannot handle hot-plugged CPUs");
|
76
76
|
return 0;
|
77
77
|
}
|
78
78
|
return static_cast<unsigned>(cpu);
|
data/src/core/lib/gprpp/fork.cc
CHANGED
@@ -172,15 +172,15 @@ void Fork::GlobalInit() {
|
|
172
172
|
MemoryOrder::RELAXED);
|
173
173
|
}
|
174
174
|
if (support_enabled_.Load(MemoryOrder::RELAXED)) {
|
175
|
-
exec_ctx_state_ =
|
176
|
-
thread_state_ =
|
175
|
+
exec_ctx_state_ = new internal::ExecCtxState();
|
176
|
+
thread_state_ = new internal::ThreadState();
|
177
177
|
}
|
178
178
|
}
|
179
179
|
|
180
180
|
void Fork::GlobalShutdown() {
|
181
181
|
if (support_enabled_.Load(MemoryOrder::RELAXED)) {
|
182
|
-
|
183
|
-
|
182
|
+
delete exec_ctx_state_;
|
183
|
+
delete thread_state_;
|
184
184
|
}
|
185
185
|
}
|
186
186
|
|
@@ -56,8 +56,8 @@ void SetGlobalConfigEnvErrorFunction(GlobalConfigEnvErrorFunctionType func) {
|
|
56
56
|
g_global_config_env_error_func = func;
|
57
57
|
}
|
58
58
|
|
59
|
-
UniquePtr<char> GlobalConfigEnv::GetValue() {
|
60
|
-
return UniquePtr<char>(gpr_getenv(GetName()));
|
59
|
+
grpc_core::UniquePtr<char> GlobalConfigEnv::GetValue() {
|
60
|
+
return grpc_core::UniquePtr<char>(gpr_getenv(GetName()));
|
61
61
|
}
|
62
62
|
|
63
63
|
void GlobalConfigEnv::SetValue(const char* value) {
|
@@ -78,7 +78,7 @@ static_assert(std::is_trivially_destructible<GlobalConfigEnvBool>::value,
|
|
78
78
|
"GlobalConfigEnvBool needs to be trivially destructible.");
|
79
79
|
|
80
80
|
bool GlobalConfigEnvBool::Get() {
|
81
|
-
UniquePtr<char> str = GetValue();
|
81
|
+
grpc_core::UniquePtr<char> str = GetValue();
|
82
82
|
if (str == nullptr) {
|
83
83
|
return default_value_;
|
84
84
|
}
|
@@ -99,7 +99,7 @@ static_assert(std::is_trivially_destructible<GlobalConfigEnvInt32>::value,
|
|
99
99
|
"GlobalConfigEnvInt32 needs to be trivially destructible.");
|
100
100
|
|
101
101
|
int32_t GlobalConfigEnvInt32::Get() {
|
102
|
-
UniquePtr<char> str = GetValue();
|
102
|
+
grpc_core::UniquePtr<char> str = GetValue();
|
103
103
|
if (str == nullptr) {
|
104
104
|
return default_value_;
|
105
105
|
}
|
@@ -122,10 +122,10 @@ void GlobalConfigEnvInt32::Set(int32_t value) {
|
|
122
122
|
static_assert(std::is_trivially_destructible<GlobalConfigEnvString>::value,
|
123
123
|
"GlobalConfigEnvString needs to be trivially destructible.");
|
124
124
|
|
125
|
-
UniquePtr<char> GlobalConfigEnvString::Get() {
|
126
|
-
UniquePtr<char> str = GetValue();
|
125
|
+
grpc_core::UniquePtr<char> GlobalConfigEnvString::Get() {
|
126
|
+
grpc_core::UniquePtr<char> str = GetValue();
|
127
127
|
if (str == nullptr) {
|
128
|
-
return UniquePtr<char>(gpr_strdup(default_value_));
|
128
|
+
return grpc_core::UniquePtr<char>(gpr_strdup(default_value_));
|
129
129
|
}
|
130
130
|
return str;
|
131
131
|
}
|
@@ -43,7 +43,7 @@ class GlobalConfigEnv {
|
|
43
43
|
|
44
44
|
public:
|
45
45
|
// Returns the value of `name` variable.
|
46
|
-
UniquePtr<char> GetValue();
|
46
|
+
grpc_core::UniquePtr<char> GetValue();
|
47
47
|
|
48
48
|
// Sets the value of `name` variable.
|
49
49
|
void SetValue(const char* value);
|
@@ -87,7 +87,7 @@ class GlobalConfigEnvString : public GlobalConfigEnv {
|
|
87
87
|
constexpr GlobalConfigEnvString(char* name, const char* default_value)
|
88
88
|
: GlobalConfigEnv(name), default_value_(default_value) {}
|
89
89
|
|
90
|
-
UniquePtr<char> Get();
|
90
|
+
grpc_core::UniquePtr<char> Get();
|
91
91
|
void Set(const char* value);
|
92
92
|
|
93
93
|
private:
|
@@ -30,7 +30,7 @@
|
|
30
30
|
#include "src/core/lib/gprpp/string_view.h"
|
31
31
|
|
32
32
|
namespace grpc_core {
|
33
|
-
int JoinHostPort(UniquePtr<char>* out, const char* host, int port) {
|
33
|
+
int JoinHostPort(grpc_core::UniquePtr<char>* out, const char* host, int port) {
|
34
34
|
char* tmp;
|
35
35
|
int ret;
|
36
36
|
if (host[0] != '[' && strchr(host, ':') != nullptr) {
|
@@ -57,7 +57,7 @@ bool DoSplitHostPort(StringView name, StringView* host, StringView* port,
|
|
57
57
|
}
|
58
58
|
if (rbracket == name.size() - 1) {
|
59
59
|
/* ]<end> */
|
60
|
-
port
|
60
|
+
*port = StringView();
|
61
61
|
} else if (name[rbracket + 1] == ':') {
|
62
62
|
/* ]:<port?> */
|
63
63
|
*port = name.substr(rbracket + 2, name.size() - rbracket - 2);
|
@@ -70,7 +70,7 @@ bool DoSplitHostPort(StringView name, StringView* host, StringView* port,
|
|
70
70
|
if (host->find(':') == grpc_core::StringView::npos) {
|
71
71
|
/* Require all bracketed hosts to contain a colon, because a hostname or
|
72
72
|
IPv4 address should never use brackets. */
|
73
|
-
host
|
73
|
+
*host = StringView();
|
74
74
|
return false;
|
75
75
|
}
|
76
76
|
} else {
|
@@ -84,7 +84,7 @@ bool DoSplitHostPort(StringView name, StringView* host, StringView* port,
|
|
84
84
|
} else {
|
85
85
|
/* 0 or 2+ colons. Bare hostname or IPv6 litearal. */
|
86
86
|
*host = name;
|
87
|
-
port
|
87
|
+
*port = StringView();
|
88
88
|
}
|
89
89
|
}
|
90
90
|
return true;
|
@@ -96,8 +96,8 @@ bool SplitHostPort(StringView name, StringView* host, StringView* port) {
|
|
96
96
|
return DoSplitHostPort(name, host, port, &unused);
|
97
97
|
}
|
98
98
|
|
99
|
-
bool SplitHostPort(StringView name, UniquePtr<char>* host,
|
100
|
-
UniquePtr<char>* port) {
|
99
|
+
bool SplitHostPort(StringView name, grpc_core::UniquePtr<char>* host,
|
100
|
+
grpc_core::UniquePtr<char>* port) {
|
101
101
|
GPR_DEBUG_ASSERT(host != nullptr && *host == nullptr);
|
102
102
|
GPR_DEBUG_ASSERT(port != nullptr && *port == nullptr);
|
103
103
|
StringView host_view;
|
@@ -108,9 +108,9 @@ bool SplitHostPort(StringView name, UniquePtr<char>* host,
|
|
108
108
|
// We always set the host, but port is set only when DoSplitHostPort find a
|
109
109
|
// port in the string, to remain backward compatible with the old
|
110
110
|
// gpr_split_host_port API.
|
111
|
-
*host = host_view
|
111
|
+
*host = StringViewToCString(host_view);
|
112
112
|
if (has_port) {
|
113
|
-
*port = port_view
|
113
|
+
*port = StringViewToCString(port_view);
|
114
114
|
}
|
115
115
|
}
|
116
116
|
return ret;
|
@@ -35,7 +35,7 @@ namespace grpc_core {
|
|
35
35
|
(excluding the final '\0'), and *out points to a string.
|
36
36
|
|
37
37
|
In the unlikely event of an error, returns -1 and sets *out to NULL. */
|
38
|
-
int JoinHostPort(UniquePtr<char>* out, const char* host, int port);
|
38
|
+
int JoinHostPort(grpc_core::UniquePtr<char>* out, const char* host, int port);
|
39
39
|
|
40
40
|
/** Given a name in the form "host:port" or "[ho:st]:port", split into hostname
|
41
41
|
and port number.
|
@@ -51,8 +51,8 @@ int JoinHostPort(UniquePtr<char>* out, const char* host, int port);
|
|
51
51
|
Return true on success, false on failure. Guarantees *host and *port are
|
52
52
|
cleared on failure. */
|
53
53
|
bool SplitHostPort(StringView name, StringView* host, StringView* port);
|
54
|
-
bool SplitHostPort(StringView name, UniquePtr<char>* host,
|
55
|
-
UniquePtr<char>* port);
|
54
|
+
bool SplitHostPort(StringView name, grpc_core::UniquePtr<char>* host,
|
55
|
+
grpc_core::UniquePtr<char>* port);
|
56
56
|
|
57
57
|
} // namespace grpc_core
|
58
58
|
|
@@ -26,8 +26,19 @@
|
|
26
26
|
|
27
27
|
#include "src/core/lib/gprpp/memory.h"
|
28
28
|
|
29
|
+
#if GRPC_USE_ABSL
|
30
|
+
#include "absl/container/inlined_vector.h"
|
31
|
+
#endif
|
32
|
+
|
29
33
|
namespace grpc_core {
|
30
34
|
|
35
|
+
#if GRPC_USE_ABSL
|
36
|
+
|
37
|
+
template <typename T, size_t N, typename A = std::allocator<T>>
|
38
|
+
using InlinedVector = absl::InlinedVector<T, N, A>;
|
39
|
+
|
40
|
+
#else
|
41
|
+
|
31
42
|
// NOTE: We eventually want to use absl::InlinedVector here. However,
|
32
43
|
// there are currently build problems that prevent us from using absl.
|
33
44
|
// In the interim, we define a custom implementation as a place-holder,
|
@@ -228,6 +239,8 @@ class InlinedVector {
|
|
228
239
|
size_t capacity_;
|
229
240
|
};
|
230
241
|
|
242
|
+
#endif
|
243
|
+
|
231
244
|
} // namespace grpc_core
|
232
245
|
|
233
246
|
#endif /* GRPC_CORE_LIB_GPRPP_INLINED_VECTOR_H */
|
data/src/core/lib/gprpp/map.h
CHANGED
@@ -23,26 +23,19 @@
|
|
23
23
|
|
24
24
|
#include <string.h>
|
25
25
|
|
26
|
-
#include <algorithm>
|
27
|
-
#include <functional>
|
28
|
-
#include <iterator>
|
29
26
|
#include <map>
|
30
27
|
|
31
|
-
#include "src/core/lib/gpr/useful.h"
|
32
|
-
#include "src/core/lib/gprpp/memory.h"
|
33
28
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
34
29
|
#include "src/core/lib/gprpp/string_view.h"
|
35
30
|
|
36
31
|
namespace grpc_core {
|
37
32
|
|
38
|
-
template <class Key, class T, class Compare = std::less<Key>>
|
39
|
-
using Map = std::map<Key, T, Compare, Allocator<std::pair<const Key, T>>>;
|
40
|
-
|
41
33
|
struct StringLess {
|
42
34
|
bool operator()(const char* a, const char* b) const {
|
43
35
|
return strcmp(a, b) < 0;
|
44
36
|
}
|
45
|
-
bool operator()(const UniquePtr<char>& a,
|
37
|
+
bool operator()(const grpc_core::UniquePtr<char>& a,
|
38
|
+
const grpc_core::UniquePtr<char>& b) const {
|
46
39
|
return strcmp(a.get(), b.get()) < 0;
|
47
40
|
}
|
48
41
|
bool operator()(const StringView& a, const StringView& b) const {
|
data/src/core/lib/gprpp/memory.h
CHANGED
@@ -30,110 +30,24 @@
|
|
30
30
|
|
31
31
|
namespace grpc_core {
|
32
32
|
|
33
|
-
|
34
|
-
template <typename T, typename... Args>
|
35
|
-
inline T* New(Args&&... args) {
|
36
|
-
void* p = gpr_malloc(sizeof(T));
|
37
|
-
return new (p) T(std::forward<Args>(args)...);
|
38
|
-
}
|
39
|
-
|
40
|
-
// Gets the base pointer of any class, in case of multiple inheritance.
|
41
|
-
// Used by Delete and friends.
|
42
|
-
template <typename T, bool isPolymorphic>
|
43
|
-
struct BasePointerGetter {
|
44
|
-
static void* get(T* p) { return p; }
|
45
|
-
};
|
46
|
-
|
47
|
-
template <typename T>
|
48
|
-
struct BasePointerGetter<T, true> {
|
49
|
-
static void* get(T* p) { return dynamic_cast<void*>(p); }
|
50
|
-
};
|
51
|
-
|
52
|
-
// Alternative to delete, to ensure memory allocation being wrapped to gpr_free
|
53
|
-
template <typename T>
|
54
|
-
inline void Delete(T* p) {
|
55
|
-
if (p == nullptr) return;
|
56
|
-
void* basePtr = BasePointerGetter<T, std::is_polymorphic<T>::value>::get(p);
|
57
|
-
p->~T();
|
58
|
-
gpr_free(basePtr);
|
59
|
-
}
|
60
|
-
|
61
|
-
class DefaultDelete {
|
33
|
+
class DefaultDeleteChar {
|
62
34
|
public:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
// guaranteed not to call the deleter if the pointer is nullptr
|
67
|
-
// (i.e., it already does this check for us), and we don't want to
|
68
|
-
// do the check twice. So, instead of calling Delete() here, we
|
69
|
-
// manually call the object's dtor and free it.
|
70
|
-
void* basePtr = BasePointerGetter<T, std::is_polymorphic<T>::value>::get(p);
|
71
|
-
p->~T();
|
72
|
-
gpr_free(basePtr);
|
35
|
+
void operator()(char* p) {
|
36
|
+
if (p == nullptr) return;
|
37
|
+
gpr_free(p);
|
73
38
|
}
|
74
39
|
};
|
75
40
|
|
76
|
-
|
77
|
-
|
41
|
+
// UniquePtr<T> is only allowed for char and UniquePtr<char> is deprecated
|
42
|
+
// in favor of std::string. UniquePtr<char> is equivalent std::unique_ptr
|
43
|
+
// except that it uses gpr_free for deleter.
|
44
|
+
template <typename T>
|
45
|
+
using UniquePtr = std::unique_ptr<T, DefaultDeleteChar>;
|
78
46
|
|
47
|
+
// TODO(veblush): Replace this with absl::make_unique once abseil is added.
|
79
48
|
template <typename T, typename... Args>
|
80
|
-
inline
|
81
|
-
return
|
82
|
-
}
|
83
|
-
|
84
|
-
// an allocator that uses gpr_malloc/gpr_free
|
85
|
-
template <class T>
|
86
|
-
class Allocator {
|
87
|
-
public:
|
88
|
-
typedef T value_type;
|
89
|
-
typedef T* pointer;
|
90
|
-
typedef const T* const_pointer;
|
91
|
-
typedef T& reference;
|
92
|
-
typedef const T& const_reference;
|
93
|
-
typedef std::size_t size_type;
|
94
|
-
typedef std::ptrdiff_t difference_type;
|
95
|
-
typedef std::false_type propagate_on_container_move_assignment;
|
96
|
-
template <class U>
|
97
|
-
struct rebind {
|
98
|
-
typedef Allocator<U> other;
|
99
|
-
};
|
100
|
-
typedef std::true_type is_always_equal;
|
101
|
-
|
102
|
-
Allocator() = default;
|
103
|
-
|
104
|
-
template <class U>
|
105
|
-
Allocator(const Allocator<U>&) {}
|
106
|
-
|
107
|
-
pointer address(reference x) const { return &x; }
|
108
|
-
const_pointer address(const_reference x) const { return &x; }
|
109
|
-
pointer allocate(std::size_t n,
|
110
|
-
std::allocator<void>::const_pointer /*hint*/ = nullptr) {
|
111
|
-
return static_cast<pointer>(gpr_malloc(n * sizeof(T)));
|
112
|
-
}
|
113
|
-
void deallocate(T* p, std::size_t /* n */) { gpr_free(p); }
|
114
|
-
size_t max_size() const {
|
115
|
-
return std::numeric_limits<size_type>::max() / sizeof(value_type);
|
116
|
-
}
|
117
|
-
void construct(pointer p, const_reference val) { new ((void*)p) T(val); }
|
118
|
-
template <class U, class... Args>
|
119
|
-
void construct(U* p, Args&&... args) {
|
120
|
-
::new ((void*)p) U(std::forward<Args>(args)...);
|
121
|
-
}
|
122
|
-
void destroy(pointer p) { p->~T(); }
|
123
|
-
template <class U>
|
124
|
-
void destroy(U* p) {
|
125
|
-
p->~U();
|
126
|
-
}
|
127
|
-
};
|
128
|
-
|
129
|
-
template <class T, class U>
|
130
|
-
bool operator==(Allocator<T> const&, Allocator<U> const&) noexcept {
|
131
|
-
return true;
|
132
|
-
}
|
133
|
-
|
134
|
-
template <class T, class U>
|
135
|
-
bool operator!=(Allocator<T> const& /*x*/, Allocator<U> const& /*y*/) noexcept {
|
136
|
-
return false;
|
49
|
+
inline std::unique_ptr<T> MakeUnique(Args&&... args) {
|
50
|
+
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
137
51
|
}
|
138
52
|
|
139
53
|
} // namespace grpc_core
|