grpc 1.23.0 → 1.24.0
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 +765 -485
- data/include/grpc/grpc.h +3 -1
- data/include/grpc/grpc_security.h +20 -4
- data/include/grpc/impl/codegen/grpc_types.h +6 -5
- data/include/grpc/impl/codegen/port_platform.h +25 -0
- data/src/core/ext/filters/client_channel/backend_metric.cc +78 -0
- data/src/core/ext/filters/client_channel/backend_metric.h +36 -0
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +16 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +325 -267
- data/src/core/ext/filters/client_channel/client_channel_factory.h +0 -4
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +23 -32
- data/src/core/ext/filters/client_channel/http_proxy.cc +7 -3
- data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +58 -34
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +46 -50
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +9 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +35 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +130 -215
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +34 -21
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +1120 -802
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h +8 -2
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +33 -12
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.cc +151 -40
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h +184 -26
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +389 -245
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +98 -60
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +6 -1
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +89 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +3 -8
- data/src/core/ext/filters/client_channel/server_address.cc +1 -3
- data/src/core/ext/filters/client_channel/server_address.h +1 -1
- data/src/core/ext/filters/client_channel/subchannel.h +2 -1
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +207 -29
- data/src/core/ext/filters/http/client/http_client_filter.cc +10 -8
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +10 -7
- data/src/core/ext/filters/http/server/http_server_filter.cc +52 -26
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +23 -20
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +24 -21
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +37 -24
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +237 -191
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +29 -27
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +19 -4
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +13 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +0 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +99 -71
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +222 -0
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +818 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +314 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +1142 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +53 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +158 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +69 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +49 -0
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +240 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +110 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +324 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +235 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +661 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +84 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +274 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +175 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +572 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +150 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +596 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +35 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +80 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +95 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +308 -0
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +128 -0
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +392 -0
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +91 -0
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +236 -0
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +88 -0
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +258 -0
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +111 -0
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +324 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c +23 -0
- data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +50 -0
- data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +52 -0
- data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +130 -0
- data/src/core/ext/upb-generated/envoy/type/percent.upb.c +39 -0
- data/src/core/ext/upb-generated/envoy/type/percent.upb.h +87 -0
- data/src/core/ext/upb-generated/envoy/type/range.upb.c +39 -0
- data/src/core/ext/upb-generated/envoy/type/range.upb.h +85 -0
- data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +17 -0
- data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +30 -0
- data/src/core/ext/upb-generated/google/api/annotations.upb.c +18 -0
- data/src/core/ext/upb-generated/google/api/annotations.upb.h +30 -0
- data/src/core/ext/upb-generated/google/api/http.upb.c +66 -0
- data/src/core/ext/upb-generated/google/api/http.upb.h +190 -0
- data/src/core/ext/upb-generated/google/protobuf/any.upb.c +27 -0
- data/src/core/ext/upb-generated/google/protobuf/any.upb.h +58 -0
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +485 -0
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +1690 -0
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +27 -0
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +58 -0
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +22 -0
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +50 -0
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +79 -0
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +215 -0
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +27 -0
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +58 -0
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +106 -0
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +238 -0
- data/src/core/ext/upb-generated/google/rpc/status.upb.c +33 -0
- data/src/core/ext/upb-generated/google/rpc/status.upb.h +74 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +49 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +126 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +209 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +681 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +42 -0
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +109 -0
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +36 -0
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +84 -0
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +133 -0
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +359 -0
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +58 -0
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +144 -0
- data/src/core/ext/upb-generated/validate/validate.upb.c +443 -0
- data/src/core/ext/upb-generated/validate/validate.upb.h +2037 -0
- data/src/core/lib/channel/channel_args.cc +21 -0
- data/src/core/lib/channel/channel_args.h +16 -2
- data/src/core/lib/channel/channel_stack.h +2 -1
- data/src/core/lib/channel/channelz.cc +54 -56
- data/src/core/lib/channel/channelz.h +29 -12
- data/src/core/lib/compression/compression.cc +2 -1
- data/src/core/lib/compression/compression_internal.h +8 -0
- data/src/core/lib/gpr/log_linux.cc +2 -2
- data/src/core/lib/gpr/log_posix.cc +2 -2
- data/src/core/lib/gpr/time_precise.cc +123 -36
- data/src/core/lib/gpr/time_precise.h +37 -0
- data/src/core/lib/gprpp/abstract.h +10 -0
- data/src/core/lib/gprpp/atomic.h +4 -0
- data/src/core/lib/gprpp/inlined_vector.h +20 -4
- data/src/core/lib/gprpp/map.h +109 -6
- data/src/core/lib/gprpp/memory.h +6 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +2 -0
- data/src/core/lib/iomgr/ev_epollex_linux.cc +29 -54
- data/src/core/lib/iomgr/exec_ctx.cc +27 -17
- data/src/core/lib/iomgr/exec_ctx.h +3 -0
- data/src/core/lib/iomgr/sockaddr_utils.cc +1 -3
- data/src/core/lib/iomgr/tcp_posix.cc +16 -25
- data/src/core/lib/iomgr/tcp_server_custom.cc +1 -1
- data/src/core/lib/iomgr/timer_manager.cc +8 -1
- data/src/core/lib/iomgr/timer_manager.h +2 -0
- data/src/core/lib/security/credentials/credentials.h +8 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +23 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +3 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +3 -3
- data/src/core/lib/security/security_connector/ssl_utils.cc +1 -12
- data/src/core/lib/security/security_connector/ssl_utils.h +10 -6
- data/src/core/lib/security/security_connector/ssl_utils_config.cc +32 -0
- data/src/core/lib/security/security_connector/ssl_utils_config.h +30 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +161 -49
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +34 -1
- data/src/core/lib/slice/slice_intern.cc +17 -9
- data/src/core/lib/slice/slice_internal.h +34 -7
- data/src/core/lib/slice/slice_utils.h +7 -3
- data/src/core/lib/surface/call.cc +97 -57
- data/src/core/lib/surface/channel.cc +2 -2
- data/src/core/lib/surface/completion_queue.cc +10 -16
- data/src/core/lib/surface/init.cc +3 -0
- data/src/core/lib/surface/server.cc +11 -14
- data/src/core/lib/surface/validate_metadata.cc +4 -0
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/metadata.cc +4 -4
- data/src/core/lib/transport/metadata_batch.cc +72 -16
- data/src/core/lib/transport/metadata_batch.h +38 -0
- data/src/core/lib/transport/static_metadata.cc +814 -1023
- data/src/core/lib/transport/static_metadata.h +271 -213
- data/src/core/lib/transport/transport.h +12 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +104 -76
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +34 -16
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +2 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_utils.cc +10 -6
- data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +4 -3
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +74 -48
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +34 -26
- data/src/core/tsi/ssl_transport_security.cc +14 -6
- data/src/core/tsi/ssl_transport_security.h +4 -0
- data/src/ruby/ext/grpc/ext-export.clang +1 -0
- data/src/ruby/ext/grpc/ext-export.gcc +6 -0
- data/src/ruby/ext/grpc/extconf.rb +5 -0
- data/src/ruby/ext/grpc/rb_enable_cpp.cc +22 -0
- data/src/ruby/ext/grpc/rb_grpc.c +1 -42
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
- data/src/ruby/lib/grpc.rb +2 -0
- data/src/ruby/lib/grpc/core/status_codes.rb +135 -0
- data/src/ruby/lib/grpc/errors.rb +4 -7
- data/src/ruby/lib/grpc/google_rpc_status_utils.rb +9 -4
- data/src/ruby/lib/grpc/structs.rb +15 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/errors_spec.rb +1 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto +22 -0
- data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +34 -0
- data/src/ruby/spec/pb/codegen/package_option_spec.rb +53 -29
- data/third_party/upb/upb/decode.c +604 -0
- data/third_party/upb/upb/decode.h +21 -0
- data/third_party/upb/upb/encode.c +378 -0
- data/third_party/upb/upb/encode.h +21 -0
- data/third_party/upb/upb/generated_util.h +105 -0
- data/third_party/upb/upb/msg.c +111 -0
- data/third_party/upb/upb/msg.h +69 -0
- data/third_party/upb/upb/port.c +27 -0
- data/third_party/upb/upb/port_def.inc +152 -0
- data/third_party/upb/upb/port_undef.inc +21 -0
- data/third_party/upb/upb/table.c +911 -0
- data/third_party/upb/upb/table.int.h +507 -0
- data/third_party/upb/upb/upb.c +261 -0
- data/third_party/upb/upb/upb.h +364 -0
- metadata +129 -50
- data/src/core/ext/filters/client_channel/health/health.pb.c +0 -23
- data/src/core/ext/filters/client_channel/health/health.pb.h +0 -73
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.c +0 -19
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/duration.pb.h +0 -54
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.c +0 -19
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/google/protobuf/timestamp.pb.h +0 -54
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +0 -89
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -164
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.cc +0 -520
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api.h +0 -323
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.cc +0 -145
- data/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +0 -149
- data/src/core/tsi/alts/handshaker/altscontext.pb.c +0 -47
- data/src/core/tsi/alts/handshaker/altscontext.pb.h +0 -63
- data/src/core/tsi/alts/handshaker/handshaker.pb.c +0 -122
- data/src/core/tsi/alts/handshaker/handshaker.pb.h +0 -254
- data/src/core/tsi/alts/handshaker/transport_security_common.pb.c +0 -49
- data/src/core/tsi/alts/handshaker/transport_security_common.pb.h +0 -78
- data/third_party/nanopb/pb.h +0 -579
- data/third_party/nanopb/pb_common.c +0 -97
- data/third_party/nanopb/pb_common.h +0 -42
- data/third_party/nanopb/pb_decode.c +0 -1347
- data/third_party/nanopb/pb_decode.h +0 -149
- data/third_party/nanopb/pb_encode.c +0 -696
- data/third_party/nanopb/pb_encode.h +0 -154
@@ -52,16 +52,9 @@ static void exec_ctx_sched(grpc_closure* closure, grpc_error* error) {
|
|
52
52
|
}
|
53
53
|
|
54
54
|
static gpr_timespec g_start_time;
|
55
|
+
static gpr_cycle_counter g_start_cycle;
|
55
56
|
|
56
|
-
|
57
|
-
// TODO (mxyan): remove after bug is fixed.
|
58
|
-
#ifdef GRPC_DEBUG_TIMER_MANAGER
|
59
|
-
extern int64_t g_start_time_sec;
|
60
|
-
extern int64_t g_start_time_nsec;
|
61
|
-
#endif // GRPC_DEBUG_TIMER_MANAGER
|
62
|
-
|
63
|
-
static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) {
|
64
|
-
ts = gpr_time_sub(ts, g_start_time);
|
57
|
+
static grpc_millis timespan_to_millis_round_down(gpr_timespec ts) {
|
65
58
|
double x = GPR_MS_PER_SEC * static_cast<double>(ts.tv_sec) +
|
66
59
|
static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS;
|
67
60
|
if (x < 0) return 0;
|
@@ -69,8 +62,11 @@ static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) {
|
|
69
62
|
return static_cast<grpc_millis>(x);
|
70
63
|
}
|
71
64
|
|
72
|
-
static grpc_millis
|
73
|
-
|
65
|
+
static grpc_millis timespec_to_millis_round_down(gpr_timespec ts) {
|
66
|
+
return timespan_to_millis_round_down(gpr_time_sub(ts, g_start_time));
|
67
|
+
}
|
68
|
+
|
69
|
+
static grpc_millis timespan_to_millis_round_up(gpr_timespec ts) {
|
74
70
|
double x = GPR_MS_PER_SEC * static_cast<double>(ts.tv_sec) +
|
75
71
|
static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS +
|
76
72
|
static_cast<double>(GPR_NS_PER_SEC - 1) /
|
@@ -80,6 +76,10 @@ static grpc_millis timespec_to_millis_round_up(gpr_timespec ts) {
|
|
80
76
|
return static_cast<grpc_millis>(x);
|
81
77
|
}
|
82
78
|
|
79
|
+
static grpc_millis timespec_to_millis_round_up(gpr_timespec ts) {
|
80
|
+
return timespan_to_millis_round_up(gpr_time_sub(ts, g_start_time));
|
81
|
+
}
|
82
|
+
|
83
83
|
gpr_timespec grpc_millis_to_timespec(grpc_millis millis,
|
84
84
|
gpr_clock_type clock_type) {
|
85
85
|
// special-case infinities as grpc_millis can be 32bit on some platforms
|
@@ -108,6 +108,16 @@ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) {
|
|
108
108
|
gpr_convert_clock_type(ts, g_start_time.clock_type));
|
109
109
|
}
|
110
110
|
|
111
|
+
grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles) {
|
112
|
+
return timespan_to_millis_round_down(
|
113
|
+
gpr_cycle_counter_sub(cycles, g_start_cycle));
|
114
|
+
}
|
115
|
+
|
116
|
+
grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles) {
|
117
|
+
return timespan_to_millis_round_up(
|
118
|
+
gpr_cycle_counter_sub(cycles, g_start_cycle));
|
119
|
+
}
|
120
|
+
|
111
121
|
static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = {
|
112
122
|
exec_ctx_run, exec_ctx_sched, "exec_ctx"};
|
113
123
|
static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable};
|
@@ -124,13 +134,13 @@ void ExecCtx::TestOnlyGlobalInit(gpr_timespec new_val) {
|
|
124
134
|
}
|
125
135
|
|
126
136
|
void ExecCtx::GlobalInit(void) {
|
137
|
+
// gpr_now(GPR_CLOCK_MONOTONIC) incurs a syscall. We don't actually know the
|
138
|
+
// exact cycle the time was captured, so we use the average of cycles before
|
139
|
+
// and after the syscall as the starting cycle.
|
140
|
+
const gpr_cycle_counter cycle_before = gpr_get_cycle_counter();
|
127
141
|
g_start_time = gpr_now(GPR_CLOCK_MONOTONIC);
|
128
|
-
|
129
|
-
|
130
|
-
#ifdef GRPC_DEBUG_TIMER_MANAGER
|
131
|
-
g_start_time_sec = g_start_time.tv_sec;
|
132
|
-
g_start_time_nsec = g_start_time.tv_nsec;
|
133
|
-
#endif
|
142
|
+
const gpr_cycle_counter cycle_after = gpr_get_cycle_counter();
|
143
|
+
g_start_cycle = (cycle_before + cycle_after) / 2;
|
134
144
|
gpr_tls_init(&exec_ctx_);
|
135
145
|
}
|
136
146
|
|
@@ -26,6 +26,7 @@
|
|
26
26
|
#include <grpc/support/cpu.h>
|
27
27
|
#include <grpc/support/log.h>
|
28
28
|
|
29
|
+
#include "src/core/lib/gpr/time_precise.h"
|
29
30
|
#include "src/core/lib/gpr/tls.h"
|
30
31
|
#include "src/core/lib/gprpp/fork.h"
|
31
32
|
#include "src/core/lib/iomgr/closure.h"
|
@@ -58,6 +59,8 @@ extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;
|
|
58
59
|
gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock);
|
59
60
|
grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec);
|
60
61
|
grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec);
|
62
|
+
grpc_millis grpc_cycle_counter_to_millis_round_down(gpr_cycle_counter cycles);
|
63
|
+
grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles);
|
61
64
|
|
62
65
|
namespace grpc_core {
|
63
66
|
/** Execution context.
|
@@ -201,13 +201,11 @@ int grpc_sockaddr_to_string(char** out,
|
|
201
201
|
}
|
202
202
|
|
203
203
|
void grpc_string_to_sockaddr(grpc_resolved_address* out, char* addr, int port) {
|
204
|
+
memset(out, 0, sizeof(grpc_resolved_address));
|
204
205
|
grpc_sockaddr_in6* addr6 = (grpc_sockaddr_in6*)out->addr;
|
205
206
|
grpc_sockaddr_in* addr4 = (grpc_sockaddr_in*)out->addr;
|
206
|
-
|
207
207
|
if (grpc_inet_pton(GRPC_AF_INET6, addr, &addr6->sin6_addr) == 1) {
|
208
208
|
addr6->sin6_family = GRPC_AF_INET6;
|
209
|
-
addr6->sin6_flowinfo = 0;
|
210
|
-
addr6->sin6_scope_id = 0;
|
211
209
|
out->len = sizeof(grpc_sockaddr_in6);
|
212
210
|
} else if (grpc_inet_pton(GRPC_AF_INET, addr, &addr4->sin_addr) == 1) {
|
213
211
|
addr4->sin_family = GRPC_AF_INET;
|
@@ -89,7 +89,7 @@ struct grpc_tcp {
|
|
89
89
|
bool is_first_read;
|
90
90
|
double target_length;
|
91
91
|
double bytes_read_this_round;
|
92
|
-
|
92
|
+
grpc_core::RefCount refcount;
|
93
93
|
gpr_atm shutdown_count;
|
94
94
|
|
95
95
|
int min_read_chunk_size;
|
@@ -359,41 +359,29 @@ static void tcp_free(grpc_tcp* tcp) {
|
|
359
359
|
}
|
360
360
|
|
361
361
|
#ifndef NDEBUG
|
362
|
-
#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason),
|
363
|
-
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason),
|
364
|
-
static void tcp_unref(grpc_tcp* tcp, const char* reason,
|
365
|
-
|
366
|
-
if (
|
367
|
-
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
|
368
|
-
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
|
369
|
-
"TCP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
|
370
|
-
val - 1);
|
371
|
-
}
|
372
|
-
if (gpr_unref(&tcp->refcount)) {
|
362
|
+
#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), DEBUG_LOCATION)
|
363
|
+
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), DEBUG_LOCATION)
|
364
|
+
static void tcp_unref(grpc_tcp* tcp, const char* reason,
|
365
|
+
const grpc_core::DebugLocation& debug_location) {
|
366
|
+
if (GPR_UNLIKELY(tcp->refcount.Unref(debug_location, reason))) {
|
373
367
|
tcp_free(tcp);
|
374
368
|
}
|
375
369
|
}
|
376
370
|
|
377
|
-
static void tcp_ref(grpc_tcp* tcp, const char* reason,
|
378
|
-
|
379
|
-
|
380
|
-
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
|
381
|
-
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
|
382
|
-
"TCP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val,
|
383
|
-
val + 1);
|
384
|
-
}
|
385
|
-
gpr_ref(&tcp->refcount);
|
371
|
+
static void tcp_ref(grpc_tcp* tcp, const char* reason,
|
372
|
+
const grpc_core::DebugLocation& debug_location) {
|
373
|
+
tcp->refcount.Ref(debug_location, reason);
|
386
374
|
}
|
387
375
|
#else
|
388
376
|
#define TCP_UNREF(tcp, reason) tcp_unref((tcp))
|
389
377
|
#define TCP_REF(tcp, reason) tcp_ref((tcp))
|
390
378
|
static void tcp_unref(grpc_tcp* tcp) {
|
391
|
-
if (
|
379
|
+
if (GPR_UNLIKELY(tcp->refcount.Unref())) {
|
392
380
|
tcp_free(tcp);
|
393
381
|
}
|
394
382
|
}
|
395
383
|
|
396
|
-
static void tcp_ref(grpc_tcp* tcp) {
|
384
|
+
static void tcp_ref(grpc_tcp* tcp) { tcp->refcount.Ref(); }
|
397
385
|
#endif
|
398
386
|
|
399
387
|
static void tcp_destroy(grpc_endpoint* ep) {
|
@@ -1032,7 +1020,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
1032
1020
|
if (error != GRPC_ERROR_NONE) {
|
1033
1021
|
cb = tcp->write_cb;
|
1034
1022
|
tcp->write_cb = nullptr;
|
1035
|
-
|
1023
|
+
GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_REF(error));
|
1036
1024
|
TCP_UNREF(tcp, "write");
|
1037
1025
|
return;
|
1038
1026
|
}
|
@@ -1042,6 +1030,8 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
1042
1030
|
gpr_log(GPR_INFO, "write: delayed");
|
1043
1031
|
}
|
1044
1032
|
notify_on_write(tcp);
|
1033
|
+
// tcp_flush does not populate error if it has returned false.
|
1034
|
+
GPR_DEBUG_ASSERT(error == GRPC_ERROR_NONE);
|
1045
1035
|
} else {
|
1046
1036
|
cb = tcp->write_cb;
|
1047
1037
|
tcp->write_cb = nullptr;
|
@@ -1049,6 +1039,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
|
1049
1039
|
const char* str = grpc_error_string(error);
|
1050
1040
|
gpr_log(GPR_INFO, "write: %s", str);
|
1051
1041
|
}
|
1042
|
+
// No need to take a ref on error since tcp_flush provides a ref.
|
1052
1043
|
GRPC_CLOSURE_SCHED(cb, error);
|
1053
1044
|
TCP_UNREF(tcp, "write");
|
1054
1045
|
}
|
@@ -1230,7 +1221,7 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
|
|
1230
1221
|
tcp->ts_capable = true;
|
1231
1222
|
tcp->outgoing_buffer_arg = nullptr;
|
1232
1223
|
/* paired with unref in grpc_tcp_destroy */
|
1233
|
-
|
1224
|
+
new (&tcp->refcount) grpc_core::RefCount(1, &grpc_tcp_trace);
|
1234
1225
|
gpr_atm_no_barrier_store(&tcp->shutdown_count, 0);
|
1235
1226
|
tcp->em_fd = em_fd;
|
1236
1227
|
grpc_slice_buffer_init(&tcp->last_read_buffer);
|
@@ -392,7 +392,7 @@ static grpc_error* tcp_server_add_port(grpc_tcp_server* s,
|
|
392
392
|
socket->endpoint = nullptr;
|
393
393
|
socket->listener = nullptr;
|
394
394
|
socket->connector = nullptr;
|
395
|
-
grpc_custom_socket_vtable->init(socket, family);
|
395
|
+
error = grpc_custom_socket_vtable->init(socket, family);
|
396
396
|
|
397
397
|
if (error == GRPC_ERROR_NONE) {
|
398
398
|
error = add_socket_to_server(s, socket, addr, port_index, &sp);
|
@@ -18,6 +18,8 @@
|
|
18
18
|
|
19
19
|
#include <grpc/support/port_platform.h>
|
20
20
|
|
21
|
+
#include "src/core/lib/iomgr/timer_manager.h"
|
22
|
+
|
21
23
|
#include <inttypes.h>
|
22
24
|
|
23
25
|
#include <grpc/support/alloc.h>
|
@@ -26,7 +28,6 @@
|
|
26
28
|
#include "src/core/lib/debug/trace.h"
|
27
29
|
#include "src/core/lib/gprpp/thd.h"
|
28
30
|
#include "src/core/lib/iomgr/timer.h"
|
29
|
-
#include "src/core/lib/iomgr/timer_manager.h"
|
30
31
|
|
31
32
|
struct completed_thread {
|
32
33
|
grpc_core::Thread thd;
|
@@ -58,6 +59,8 @@ static bool g_has_timed_waiter;
|
|
58
59
|
static grpc_millis g_timed_waiter_deadline;
|
59
60
|
// generation counter to track which thread is waiting for the next timer
|
60
61
|
static uint64_t g_timed_waiter_generation;
|
62
|
+
// number of timer wakeups
|
63
|
+
static uint64_t g_wakeups;
|
61
64
|
|
62
65
|
static void timer_thread(void* completed_thread_ptr);
|
63
66
|
|
@@ -206,6 +209,7 @@ static bool wait_until(grpc_millis next) {
|
|
206
209
|
// that there's now no timed waiter... we'll look for a replacement if
|
207
210
|
// there's work to do after checking timers (code above)
|
208
211
|
if (my_timed_waiter_generation == g_timed_waiter_generation) {
|
212
|
+
++g_wakeups;
|
209
213
|
g_has_timed_waiter = false;
|
210
214
|
g_timed_waiter_deadline = GRPC_MILLIS_INF_FUTURE;
|
211
215
|
}
|
@@ -326,6 +330,7 @@ static void stop_threads(void) {
|
|
326
330
|
gc_completed_threads();
|
327
331
|
}
|
328
332
|
}
|
333
|
+
g_wakeups = 0;
|
329
334
|
gpr_mu_unlock(&g_mu);
|
330
335
|
}
|
331
336
|
|
@@ -354,3 +359,5 @@ void grpc_kick_poller(void) {
|
|
354
359
|
gpr_cv_signal(&g_cv_wait);
|
355
360
|
gpr_mu_unlock(&g_mu);
|
356
361
|
}
|
362
|
+
|
363
|
+
uint64_t grpc_timer_manager_get_wakeups_testonly(void) { return g_wakeups; }
|
@@ -35,5 +35,7 @@ void grpc_timer_manager_set_threading(bool enabled);
|
|
35
35
|
/* explicitly perform one tick of the timer system - for when threading is
|
36
36
|
* disabled */
|
37
37
|
void grpc_timer_manager_tick(void);
|
38
|
+
/* get global counter that tracks timer wakeups */
|
39
|
+
uint64_t grpc_timer_manager_get_wakeups_testonly(void);
|
38
40
|
|
39
41
|
#endif /* GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H */
|
@@ -110,11 +110,17 @@ struct grpc_channel_credentials
|
|
110
110
|
create_security_connector(
|
111
111
|
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
|
112
112
|
const char* target, const grpc_channel_args* args,
|
113
|
-
grpc_channel_args** new_args)
|
113
|
+
grpc_channel_args** new_args)
|
114
|
+
#if GRPC_USE_CPP_STD_LIB
|
115
|
+
= 0;
|
116
|
+
#else
|
117
|
+
{
|
114
118
|
// Tell clang-tidy that call_creds cannot be passed as const-ref.
|
115
119
|
call_creds.reset();
|
116
|
-
GRPC_ABSTRACT;
|
120
|
+
gpr_log(GPR_ERROR, "Function marked GRPC_ABSTRACT was not implemented");
|
121
|
+
GPR_ASSERT(false);
|
117
122
|
}
|
123
|
+
#endif
|
118
124
|
|
119
125
|
// Creates a version of the channel credentials without any attached call
|
120
126
|
// credentials. This can be used in order to open a channel to a non-trusted
|
@@ -157,6 +157,29 @@ int grpc_tls_key_materials_config_set_key_materials(
|
|
157
157
|
return 1;
|
158
158
|
}
|
159
159
|
|
160
|
+
int grpc_tls_key_materials_config_set_version(
|
161
|
+
grpc_tls_key_materials_config* config, int version) {
|
162
|
+
if (config == nullptr) {
|
163
|
+
gpr_log(GPR_ERROR,
|
164
|
+
"Invalid arguments to "
|
165
|
+
"grpc_tls_key_materials_config_set_version()");
|
166
|
+
return 0;
|
167
|
+
}
|
168
|
+
config->set_version(version);
|
169
|
+
return 1;
|
170
|
+
}
|
171
|
+
|
172
|
+
int grpc_tls_key_materials_config_get_version(
|
173
|
+
grpc_tls_key_materials_config* config) {
|
174
|
+
if (config == nullptr) {
|
175
|
+
gpr_log(GPR_ERROR,
|
176
|
+
"Invalid arguments to "
|
177
|
+
"grpc_tls_key_materials_config_get_version()");
|
178
|
+
return -1;
|
179
|
+
}
|
180
|
+
return config->version();
|
181
|
+
}
|
182
|
+
|
160
183
|
grpc_tls_credential_reload_config* grpc_tls_credential_reload_config_create(
|
161
184
|
const void* config_user_data,
|
162
185
|
int (*schedule)(void* config_user_data,
|
@@ -39,12 +39,15 @@ struct grpc_tls_key_materials_config
|
|
39
39
|
const PemKeyCertPairList& pem_key_cert_pair_list() const {
|
40
40
|
return pem_key_cert_pair_list_;
|
41
41
|
}
|
42
|
+
int version() const { return version_; }
|
42
43
|
|
43
44
|
/** Setters for member fields. **/
|
44
45
|
void set_key_materials(grpc_core::UniquePtr<char> pem_root_certs,
|
45
46
|
PemKeyCertPairList pem_key_cert_pair_list);
|
47
|
+
void set_version(int version) { version_ = version; }
|
46
48
|
|
47
49
|
private:
|
50
|
+
int version_ = 0;
|
48
51
|
PemKeyCertPairList pem_key_cert_pair_list_;
|
49
52
|
grpc_core::UniquePtr<char> pem_root_certs_;
|
50
53
|
};
|
@@ -84,7 +84,7 @@ SpiffeCredentials::create_security_connector(
|
|
84
84
|
static_cast<tsi_ssl_session_cache*>(arg->value.pointer.p);
|
85
85
|
}
|
86
86
|
}
|
87
|
-
grpc_core::RefCountedPtr<grpc_channel_security_connector> sc =
|
87
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector> sc = grpc_core::
|
88
88
|
SpiffeChannelSecurityConnector::CreateSpiffeChannelSecurityConnector(
|
89
89
|
this->Ref(), std::move(call_creds), target_name,
|
90
90
|
overridden_target_name, ssl_session_cache);
|
@@ -106,8 +106,8 @@ SpiffeServerCredentials::~SpiffeServerCredentials() {}
|
|
106
106
|
|
107
107
|
grpc_core::RefCountedPtr<grpc_server_security_connector>
|
108
108
|
SpiffeServerCredentials::create_security_connector() {
|
109
|
-
return SpiffeServerSecurityConnector::
|
110
|
-
this->Ref());
|
109
|
+
return grpc_core::SpiffeServerSecurityConnector::
|
110
|
+
CreateSpiffeServerSecurityConnector(this->Ref());
|
111
111
|
}
|
112
112
|
|
113
113
|
grpc_channel_credentials* grpc_tls_spiffe_credentials_create(
|
@@ -28,12 +28,12 @@
|
|
28
28
|
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
|
29
29
|
#include "src/core/lib/channel/channel_args.h"
|
30
30
|
#include "src/core/lib/gpr/string.h"
|
31
|
-
#include "src/core/lib/gprpp/global_config.h"
|
32
31
|
#include "src/core/lib/gprpp/host_port.h"
|
33
32
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
34
33
|
#include "src/core/lib/iomgr/load_file.h"
|
35
34
|
#include "src/core/lib/security/context/security_context.h"
|
36
35
|
#include "src/core/lib/security/security_connector/load_system_roots.h"
|
36
|
+
#include "src/core/lib/security/security_connector/ssl_utils_config.h"
|
37
37
|
#include "src/core/tsi/ssl_transport_security.h"
|
38
38
|
|
39
39
|
/* -- Constants. -- */
|
@@ -45,17 +45,6 @@ static const char* installed_roots_path =
|
|
45
45
|
INSTALL_PREFIX "/share/grpc/roots.pem";
|
46
46
|
#endif
|
47
47
|
|
48
|
-
/** Config variable that points to the default SSL roots file. This file
|
49
|
-
must be a PEM encoded file with all the roots such as the one that can be
|
50
|
-
downloaded from https://pki.google.com/roots.pem. */
|
51
|
-
GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "",
|
52
|
-
"Path to the default SSL roots file.");
|
53
|
-
|
54
|
-
/** Config variable used as a flag to enable/disable loading system root
|
55
|
-
certificates from the OS trust store. */
|
56
|
-
GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false,
|
57
|
-
"Disable loading system root certificates.");
|
58
|
-
|
59
48
|
#ifndef TSI_OPENSSL_ALPN_SUPPORT
|
60
49
|
#define TSI_OPENSSL_ALPN_SUPPORT 1
|
61
50
|
#endif
|
@@ -31,13 +31,11 @@
|
|
31
31
|
#include "src/core/lib/gprpp/string_view.h"
|
32
32
|
#include "src/core/lib/iomgr/error.h"
|
33
33
|
#include "src/core/lib/security/security_connector/security_connector.h"
|
34
|
+
#include "src/core/lib/security/security_connector/ssl_utils_config.h"
|
34
35
|
#include "src/core/tsi/ssl_transport_security.h"
|
35
36
|
#include "src/core/tsi/transport_security.h"
|
36
37
|
#include "src/core/tsi/transport_security_interface.h"
|
37
38
|
|
38
|
-
GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_default_ssl_roots_file_path);
|
39
|
-
GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_not_use_system_ssl_roots);
|
40
|
-
|
41
39
|
/* --- Util --- */
|
42
40
|
|
43
41
|
/* --- URL schemes. --- */
|
@@ -149,9 +147,15 @@ class PemKeyCertPair {
|
|
149
147
|
return *this;
|
150
148
|
}
|
151
149
|
|
152
|
-
//
|
153
|
-
PemKeyCertPair(const PemKeyCertPair&)
|
154
|
-
|
150
|
+
// Copyable.
|
151
|
+
PemKeyCertPair(const PemKeyCertPair& other)
|
152
|
+
: private_key_(gpr_strdup(other.private_key())),
|
153
|
+
cert_chain_(gpr_strdup(other.cert_chain())) {}
|
154
|
+
PemKeyCertPair& operator=(const PemKeyCertPair& other) {
|
155
|
+
private_key_ = grpc_core::UniquePtr<char>(gpr_strdup(other.private_key()));
|
156
|
+
cert_chain_ = grpc_core::UniquePtr<char>(gpr_strdup(other.cert_chain()));
|
157
|
+
return *this;
|
158
|
+
}
|
155
159
|
|
156
160
|
char* private_key() const { return private_key_.get(); }
|
157
161
|
char* cert_chain() const { return cert_chain_.get(); }
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2019 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <grpc/support/port_platform.h>
|
20
|
+
|
21
|
+
#include "src/core/lib/security/security_connector/ssl_utils_config.h"
|
22
|
+
|
23
|
+
/** Config variable that points to the default SSL roots file. This file
|
24
|
+
must be a PEM encoded file with all the roots such as the one that can be
|
25
|
+
downloaded from https://pki.google.com/roots.pem. */
|
26
|
+
GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_default_ssl_roots_file_path, "",
|
27
|
+
"Path to the default SSL roots file.");
|
28
|
+
|
29
|
+
/** Config variable used as a flag to enable/disable loading system root
|
30
|
+
certificates from the OS trust store. */
|
31
|
+
GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_not_use_system_ssl_roots, false,
|
32
|
+
"Disable loading system root certificates.");
|