grpc 1.53.1 → 1.54.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 +78 -66
- data/include/grpc/event_engine/event_engine.h +30 -14
- data/include/grpc/grpc_security.h +4 -0
- data/include/grpc/support/port_platform.h +4 -4
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +11 -0
- data/src/core/ext/filters/client_channel/backend_metric.cc +6 -0
- data/src/core/ext/filters/client_channel/backup_poller.cc +2 -11
- data/src/core/ext/filters/client_channel/backup_poller.h +0 -3
- data/src/core/ext/filters/client_channel/client_channel.cc +848 -813
- data/src/core/ext/filters/client_channel/client_channel.h +131 -173
- data/src/core/ext/filters/client_channel/client_channel_internal.h +114 -0
- data/src/core/ext/filters/client_channel/config_selector.h +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +6 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +17 -18
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +134 -151
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +2 -16
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +14 -10
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +68 -30
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -3
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +8 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -5
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +30 -38
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +20 -26
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +31 -179
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +1 -2
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +1 -2
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +4 -2
- data/src/core/ext/filters/client_channel/retry_filter.cc +95 -102
- data/src/core/ext/filters/client_channel/subchannel.cc +2 -4
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +26 -27
- data/src/core/ext/filters/client_channel/subchannel_stream_client.h +8 -5
- data/src/core/ext/filters/http/client/http_client_filter.cc +3 -3
- data/src/core/ext/filters/http/http_filters_plugin.cc +1 -12
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +27 -11
- data/src/core/ext/filters/message_size/message_size_filter.cc +141 -224
- data/src/core/ext/filters/message_size/message_size_filter.h +48 -3
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +7 -6
- data/src/core/ext/gcp/metadata_query.cc +142 -0
- data/src/core/ext/gcp/metadata_query.h +82 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +70 -55
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +8 -12
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +116 -58
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +5 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +222 -118
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +113 -295
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +0 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +0 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +277 -451
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +1 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +12 -14
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +1 -9
- data/src/core/ext/transport/chttp2/transport/internal.h +16 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/writing.cc +10 -5
- data/src/core/ext/transport/inproc/inproc_transport.cc +20 -14
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +5 -3
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +22 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +5 -3
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +22 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +23 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +94 -3
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +23 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -0
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +6 -3
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +22 -0
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +24 -6
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +111 -12
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +9 -7
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +27 -9
- data/src/core/ext/upb-generated/envoy/config/trace/v3/opentelemetry.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +11 -7
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +56 -12
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.c +5 -3
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h +24 -0
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.c +5 -3
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.h +24 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.c +13 -2
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.h +49 -0
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +24 -9
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +66 -12
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +191 -187
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +139 -136
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +31 -15
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +12 -9
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +15 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +54 -45
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +135 -119
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +100 -97
- data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/opentelemetry.upbdefs.c +15 -18
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +272 -264
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +117 -117
- data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c +5 -5
- data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +5 -5
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +5 -5
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/http_inputs.upbdefs.c +12 -9
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/http_inputs.upbdefs.h +5 -0
- data/src/core/ext/xds/xds_channel_stack_modifier.cc +1 -2
- data/src/core/ext/xds/xds_client_stats.cc +29 -15
- data/src/core/ext/xds/xds_client_stats.h +24 -20
- data/src/core/ext/xds/xds_endpoint.cc +5 -2
- data/src/core/ext/xds/xds_endpoint.h +9 -1
- data/src/core/ext/xds/xds_http_rbac_filter.cc +1 -1
- data/src/core/ext/xds/xds_lb_policy_registry.cc +13 -0
- data/src/core/ext/xds/xds_transport_grpc.cc +1 -1
- data/src/core/lib/channel/call_finalization.h +1 -1
- data/src/core/lib/channel/call_tracer.cc +51 -0
- data/src/core/lib/channel/call_tracer.h +101 -38
- data/src/core/lib/channel/connected_channel.cc +483 -1050
- data/src/core/lib/channel/context.h +8 -1
- data/src/core/lib/channel/promise_based_filter.cc +106 -42
- data/src/core/lib/channel/promise_based_filter.h +27 -13
- data/src/core/lib/channel/server_call_tracer_filter.cc +110 -0
- data/src/core/lib/config/config_vars.cc +151 -0
- data/src/core/lib/config/config_vars.h +127 -0
- data/src/core/lib/config/config_vars_non_generated.cc +51 -0
- data/src/core/lib/config/load_config.cc +66 -0
- data/src/core/lib/config/load_config.h +49 -0
- data/src/core/lib/debug/trace.cc +5 -6
- data/src/core/lib/debug/trace.h +0 -5
- data/src/core/lib/event_engine/event_engine.cc +37 -2
- data/src/core/lib/event_engine/handle_containers.h +7 -22
- data/src/core/lib/event_engine/memory_allocator_factory.h +47 -0
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +0 -4
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +3 -9
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +48 -15
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +8 -8
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +6 -5
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +6 -3
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +27 -18
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +0 -3
- data/src/core/lib/event_engine/resolved_address.cc +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +0 -1
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +129 -82
- data/src/core/lib/event_engine/windows/windows_endpoint.h +21 -5
- data/src/core/lib/event_engine/windows/windows_engine.cc +39 -18
- data/src/core/lib/event_engine/windows/windows_engine.h +2 -1
- data/src/core/lib/event_engine/windows/windows_listener.cc +370 -0
- data/src/core/lib/event_engine/windows/windows_listener.h +155 -0
- data/src/core/lib/experiments/config.cc +3 -10
- data/src/core/lib/experiments/experiments.cc +7 -0
- data/src/core/lib/experiments/experiments.h +9 -1
- data/src/core/lib/gpr/log.cc +15 -28
- data/src/core/lib/gprpp/fork.cc +8 -14
- data/src/core/lib/gprpp/orphanable.h +4 -3
- data/src/core/lib/gprpp/per_cpu.h +9 -3
- data/src/core/lib/gprpp/{thd_posix.cc → posix/thd.cc} +49 -37
- data/src/core/lib/gprpp/ref_counted.h +33 -34
- data/src/core/lib/gprpp/thd.h +16 -0
- data/src/core/lib/gprpp/time.cc +1 -0
- data/src/core/lib/gprpp/time.h +4 -4
- data/src/core/lib/gprpp/{thd_windows.cc → windows/thd.cc} +2 -2
- data/src/core/lib/iomgr/call_combiner.h +2 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +4 -2
- data/src/core/lib/iomgr/ev_posix.cc +13 -53
- data/src/core/lib/iomgr/ev_posix.h +0 -3
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +103 -76
- data/src/core/lib/iomgr/iomgr.cc +4 -8
- data/src/core/lib/iomgr/iomgr_windows.cc +8 -2
- data/src/core/lib/iomgr/pollset_set_windows.cc +9 -9
- data/src/core/lib/iomgr/pollset_windows.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +16 -3
- data/src/core/lib/iomgr/tcp_client_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_posix.cc +0 -1
- data/src/core/lib/iomgr/tcp_server_posix.cc +5 -16
- data/src/core/lib/iomgr/tcp_server_windows.cc +176 -9
- data/src/core/lib/iomgr/tcp_windows.cc +12 -8
- data/src/core/lib/load_balancing/lb_policy.cc +9 -13
- data/src/core/lib/load_balancing/lb_policy.h +4 -2
- data/src/core/lib/promise/activity.cc +22 -6
- data/src/core/lib/promise/activity.h +61 -24
- data/src/core/lib/promise/cancel_callback.h +77 -0
- data/src/core/lib/promise/detail/basic_seq.h +1 -1
- data/src/core/lib/promise/detail/promise_factory.h +4 -0
- data/src/core/lib/promise/for_each.h +176 -0
- data/src/core/lib/promise/if.h +9 -0
- data/src/core/lib/promise/interceptor_list.h +23 -2
- data/src/core/lib/promise/latch.h +89 -3
- data/src/core/lib/promise/loop.h +13 -9
- data/src/core/lib/promise/map.h +7 -0
- data/src/core/lib/promise/party.cc +286 -0
- data/src/core/lib/promise/party.h +499 -0
- data/src/core/lib/promise/pipe.h +197 -57
- data/src/core/lib/promise/poll.h +48 -0
- data/src/core/lib/promise/promise.h +2 -2
- data/src/core/lib/resource_quota/arena.cc +19 -3
- data/src/core/lib/resource_quota/arena.h +119 -5
- data/src/core/lib/resource_quota/memory_quota.cc +1 -1
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +12 -35
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +1 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +0 -59
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +10 -5
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +13 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +2 -0
- data/src/core/lib/security/security_connector/load_system_roots_supported.cc +5 -9
- data/src/core/lib/security/security_connector/ssl_utils.cc +11 -25
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +12 -0
- data/src/core/lib/security/transport/secure_endpoint.cc +4 -2
- data/src/core/lib/security/transport/server_auth_filter.cc +20 -2
- data/src/core/lib/slice/slice.cc +1 -1
- data/src/core/lib/surface/builtins.cc +2 -0
- data/src/core/lib/surface/call.cc +926 -1024
- data/src/core/lib/surface/call.h +10 -0
- data/src/core/lib/surface/lame_client.cc +1 -0
- data/src/core/lib/surface/validate_metadata.cc +42 -43
- data/src/core/lib/surface/validate_metadata.h +0 -9
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/batch_builder.cc +179 -0
- data/src/core/lib/transport/batch_builder.h +468 -0
- data/src/core/lib/transport/bdp_estimator.cc +7 -7
- data/src/core/lib/transport/bdp_estimator.h +10 -6
- data/src/core/lib/transport/custom_metadata.h +30 -0
- data/src/core/lib/transport/metadata_batch.cc +5 -2
- data/src/core/lib/transport/metadata_batch.h +17 -113
- data/src/core/lib/transport/parsed_metadata.h +6 -16
- data/src/core/lib/transport/timeout_encoding.cc +6 -1
- data/src/core/lib/transport/transport.cc +30 -2
- data/src/core/lib/transport/transport.h +70 -14
- data/src/core/lib/transport/transport_impl.h +7 -0
- data/src/core/lib/transport/transport_op_string.cc +52 -42
- data/src/core/plugin_registry/grpc_plugin_registry.cc +2 -2
- data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +1 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +21 -4
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +5 -0
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +4 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/abseil-cpp/absl/base/config.h +1 -1
- data/third_party/abseil-cpp/absl/flags/commandlineflag.cc +34 -0
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +200 -0
- data/third_party/abseil-cpp/absl/flags/config.h +68 -0
- data/third_party/abseil-cpp/absl/flags/declare.h +73 -0
- data/third_party/abseil-cpp/absl/flags/flag.cc +38 -0
- data/third_party/abseil-cpp/absl/flags/flag.h +310 -0
- data/{src/core/lib/gprpp/global_config_custom.h → third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc} +11 -14
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +68 -0
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +615 -0
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +800 -0
- data/third_party/abseil-cpp/absl/flags/internal/flag_msvc.inc +116 -0
- data/third_party/abseil-cpp/absl/flags/internal/path_util.h +62 -0
- data/third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.cc +65 -0
- data/third_party/abseil-cpp/absl/flags/internal/private_handle_accessor.h +61 -0
- data/third_party/abseil-cpp/absl/flags/internal/program_name.cc +60 -0
- data/third_party/abseil-cpp/absl/flags/internal/program_name.h +50 -0
- data/third_party/abseil-cpp/absl/flags/internal/registry.h +97 -0
- data/third_party/abseil-cpp/absl/flags/internal/sequence_lock.h +187 -0
- data/third_party/abseil-cpp/absl/flags/marshalling.cc +241 -0
- data/third_party/abseil-cpp/absl/flags/marshalling.h +356 -0
- data/third_party/abseil-cpp/absl/flags/reflection.cc +354 -0
- data/third_party/abseil-cpp/absl/flags/reflection.h +90 -0
- data/third_party/abseil-cpp/absl/flags/usage_config.cc +165 -0
- data/third_party/abseil-cpp/absl/flags/usage_config.h +135 -0
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +12 -8
- data/third_party/boringssl-with-bazel/err_data.c +728 -712
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +177 -177
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +28 -55
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.c +21 -23
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_dup.c +20 -23
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +66 -185
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_i2d_fp.c +18 -21
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +356 -311
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +174 -194
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +146 -210
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c +6 -9
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strex.c +346 -526
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +110 -131
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +130 -116
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +93 -60
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +93 -181
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +242 -305
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.c +41 -18
- data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +30 -33
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +36 -33
- data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +29 -26
- data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +133 -88
- data/third_party/boringssl-with-bazel/src/crypto/asn1/posix_time.c +230 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +791 -791
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +526 -526
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +114 -135
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +201 -207
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +21 -26
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +55 -68
- data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +11 -7
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +15 -9
- data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +17 -10
- data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/bio/printf.c +0 -13
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +3 -6
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +9 -5
- data/third_party/boringssl-with-bazel/src/crypto/bn_extra/convert.c +10 -23
- data/third_party/boringssl-with-bazel/src/crypto/buf/buf.c +2 -6
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/asn1_compat.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c +29 -28
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbb.c +161 -201
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +254 -39
- data/third_party/boringssl-with-bazel/src/crypto/bytestring/internal.h +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesctrhmac.c +9 -8
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_aesgcmsiv.c +37 -75
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_chacha20poly1305.c +8 -10
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/cipher → cipher_extra}/e_des.c +100 -78
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_null.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc2.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_rc4.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_tls.c +6 -12
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +14 -11
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +6 -10
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf_def.h +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +12 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.c +74 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_freebsd.c +62 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-aarch64-fuchsia.c → cpu_aarch64_fuchsia.c} +8 -7
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-aarch64-linux.c → cpu_aarch64_linux.c} +6 -4
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-aarch64-win.c → cpu_aarch64_win.c} +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-arm.c → cpu_arm.c} +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_freebsd.c +55 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-arm-linux.c → cpu_arm_linux.c} +11 -90
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-arm-linux.h → cpu_arm_linux.h} +0 -38
- data/third_party/boringssl-with-bazel/src/crypto/{cpu-intel.c → cpu_intel.c} +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/crypto.c +25 -20
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +16 -27
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c +17 -32
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/des → des}/des.c +232 -232
- data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/des → des}/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/dh_asn1.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/dh_extra/params.c +232 -29
- data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +0 -3
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +39 -16
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +37 -7
- data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +11 -36
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +214 -99
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +21 -5
- data/third_party/boringssl-with-bazel/src/crypto/ecdsa_extra/ecdsa_asn1.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +83 -60
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +46 -12
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp_ctx.c +25 -23
- data/third_party/boringssl-with-bazel/src/crypto/evp/internal.h +43 -9
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +75 -44
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec.c +19 -25
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.c +96 -45
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519.c +7 -8
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ed25519_asn1.c +26 -23
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_hkdf.c +233 -0
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_rsa_asn1.c +42 -25
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519.c +4 -5
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_x25519_asn1.c +35 -47
- data/third_party/boringssl-with-bazel/src/crypto/evp/print.c +135 -244
- data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/evp/sign.c +15 -10
- data/third_party/boringssl-with-bazel/src/crypto/ex_data.c +29 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +13 -14
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/internal.h +3 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/key_wrap.c +13 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +9 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +35 -27
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bn.c +16 -26
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bytes.c +88 -60
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/cmp.c +4 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/ctx.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div_extra.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.c +99 -113
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd_extra.c +5 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/generic.c +112 -168
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +86 -31
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +11 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery_inv.c +4 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.c +4 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +13 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/random.c +13 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.c +19 -108
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.h +19 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/shift.c +15 -16
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.c +22 -21
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/aead.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +79 -19
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +102 -99
- data/third_party/boringssl-with-bazel/src/crypto/{cipher_extra → fipsmodule/cipher}/e_aesccm.c +52 -46
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/internal.h +39 -0
- data/third_party/boringssl-with-bazel/src/crypto/{cmac → fipsmodule/cmac}/cmac.c +55 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/check.c +2 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +21 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +56 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +5 -3
- data/third_party/boringssl-with-bazel/src/crypto/{evp → fipsmodule/digestsign}/digestsign.c +51 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +25 -25
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +91 -17
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +34 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +54 -23
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +44 -60
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256-x86_64-table.h → p256-nistz-table.h} +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256-x86_64.c → p256-nistz.c} +60 -53
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256-x86_64.h → p256-nistz.h} +5 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +48 -36
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +2 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +2 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +2 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +8 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +42 -14
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +6 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hmac/hmac.c +52 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cbc.c +9 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/cfb.c +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ctr.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm.c +71 -43
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/internal.h +14 -16
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/ofb.c +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/ctrdrbg.c +31 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +16 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.h +3 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/getrandom_fillin.h +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +9 -38
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +73 -59
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +11 -45
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +22 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/padding.c +63 -52
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +107 -62
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +58 -31
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/fips.c +41 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +523 -422
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/internal.h +89 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/service_indicator.c +334 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/internal.h +3 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +12 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +14 -12
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/kdf.c +19 -6
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +32 -14
- data/third_party/boringssl-with-bazel/src/crypto/hrss/hrss.c +65 -29
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +373 -18
- data/third_party/boringssl-with-bazel/src/crypto/kyber/internal.h +61 -0
- data/third_party/boringssl-with-bazel/src/crypto/kyber/keccak.c +205 -0
- data/third_party/boringssl-with-bazel/src/crypto/lhash/internal.h +13 -1
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +220 -13
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +19 -7
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +13 -1
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_all.c +81 -90
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_info.c +150 -245
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +629 -613
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_oth.c +17 -17
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.c +142 -149
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.c +99 -131
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_x509.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pem/pem_xaux.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +0 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +36 -66
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +31 -38
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.c +2 -1
- data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.c +18 -31
- data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/pool/pool.c +8 -1
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +129 -5
- data/third_party/boringssl-with-bazel/src/crypto/refcount_c11.c +0 -2
- data/third_party/boringssl-with-bazel/src/crypto/refcount_lock.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c +8 -11
- data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +61 -27
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +10 -13
- data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +10 -13
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +66 -34
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +190 -77
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +81 -284
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +109 -42
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_digest.c +22 -24
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_sign.c +54 -55
- data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c +32 -34
- data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +32 -16
- data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +465 -704
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +284 -331
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +183 -178
- data/third_party/boringssl-with-bazel/src/crypto/x509/i2d_pr.c +11 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +67 -50
- data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +153 -150
- data/third_party/boringssl-with-bazel/src/crypto/x509/policy.c +786 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +95 -102
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +72 -57
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_req.c +12 -10
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +227 -252
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +52 -47
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +230 -224
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +161 -327
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c +37 -33
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_def.c +14 -31
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +55 -85
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +534 -618
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +129 -122
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +116 -182
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +132 -132
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +181 -202
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +64 -79
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +175 -160
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +1865 -2050
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +433 -462
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +156 -163
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +267 -263
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +40 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509spki.c +59 -63
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +63 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +114 -144
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +25 -26
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +326 -415
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c +8 -7
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_info.c +30 -28
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +354 -370
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pkey.c +37 -32
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +116 -119
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +36 -26
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_spki.c +10 -13
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_val.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +419 -261
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +113 -105
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +11 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +78 -170
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +126 -131
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akeya.c +3 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +465 -469
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bcons.c +56 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +46 -49
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +309 -346
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +341 -365
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c +429 -393
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +29 -24
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_extku.c +65 -59
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +125 -121
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ia5.c +43 -42
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +122 -125
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_int.c +50 -20
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +247 -253
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ncons.c +386 -389
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ocsp.c +45 -32
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcons.c +57 -54
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pmaps.c +63 -67
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +143 -136
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +664 -707
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +83 -75
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +1062 -1146
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +8 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +28 -48
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +211 -187
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +26 -78
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +19 -14
- data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +21 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +49 -17
- data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +99 -29
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +49 -60
- data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +2 -15
- data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +16 -200
- data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +34 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ctrdrbg.h +82 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +32 -30
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +7 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +48 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +37 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/err.h +33 -5
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +22 -30
- data/third_party/boringssl-with-bazel/src/include/openssl/ex_data.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/hmac.h +7 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +41 -16
- data/third_party/boringssl-with-bazel/src/include/openssl/kdf.h +91 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +74 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +13 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +11 -15
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +8 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +12 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +7 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/service_indicator.h +96 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/span.h +13 -21
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -75
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl3.h +1 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +384 -286
- data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +5 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/time.h +41 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +18 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +49 -23
- data/third_party/boringssl-with-bazel/src/include/openssl/type_check.h +0 -11
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +1592 -1074
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +202 -205
- data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +6 -13
- data/third_party/boringssl-with-bazel/src/ssl/d1_pkt.cc +17 -18
- data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +4 -5
- data/third_party/boringssl-with-bazel/src/ssl/dtls_record.cc +25 -33
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +34 -20
- data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +65 -34
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +198 -54
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +5 -5
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +32 -28
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +76 -44
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +130 -98
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +27 -11
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +91 -75
- data/third_party/boringssl-with-bazel/src/ssl/ssl_aead_ctx.cc +8 -10
- data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +39 -65
- data/third_party/boringssl-with-bazel/src/ssl/ssl_buffer.cc +1 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +5 -9
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +30 -33
- data/third_party/boringssl-with-bazel/src/ssl/ssl_file.cc +77 -100
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +120 -107
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +164 -30
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +150 -60
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +22 -11
- data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +22 -6
- data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +15 -13
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +5 -43
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +7 -4
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +22 -34
- data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +16 -98
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +1241 -657
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +751 -398
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +3551 -1938
- data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +1272 -487
- metadata +103 -70
- data/src/core/ext/filters/client_channel/lb_call_state_internal.h +0 -39
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +0 -30
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +0 -29
- data/src/core/lib/gprpp/global_config.h +0 -93
- data/src/core/lib/gprpp/global_config_env.cc +0 -140
- data/src/core/lib/gprpp/global_config_env.h +0 -133
- data/src/core/lib/gprpp/global_config_generic.h +0 -40
- data/src/core/lib/promise/intra_activity_waiter.h +0 -55
- data/src/core/lib/security/security_connector/ssl_utils_config.cc +0 -32
- data/src/core/lib/security/security_connector/ssl_utils_config.h +0 -29
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +0 -195
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_print.c +0 -83
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utf8.c +0 -236
- data/third_party/boringssl-with-bazel/src/crypto/asn1/charmap.h +0 -15
- data/third_party/boringssl-with-bazel/src/crypto/asn1/time_support.c +0 -206
- data/third_party/boringssl-with-bazel/src/crypto/cpu-ppc64le.c +0 -38
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1-altivec.c +0 -361
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_cache.c +0 -287
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +0 -132
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_lib.c +0 -155
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_map.c +0 -131
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_node.c +0 -189
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_tree.c +0 -843
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pci.c +0 -289
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pcia.c +0 -57
- /data/src/core/lib/gpr/{log_android.cc → android/log.cc} +0 -0
- /data/src/core/lib/gpr/{cpu_iphone.cc → iphone/cpu.cc} +0 -0
- /data/src/core/lib/gpr/{cpu_linux.cc → linux/cpu.cc} +0 -0
- /data/src/core/lib/gpr/{log_linux.cc → linux/log.cc} +0 -0
- /data/src/core/lib/gpr/{tmpfile_msys.cc → msys/tmpfile.cc} +0 -0
- /data/src/core/lib/gpr/{cpu_posix.cc → posix/cpu.cc} +0 -0
- /data/src/core/lib/gpr/{log_posix.cc → posix/log.cc} +0 -0
- /data/src/core/lib/gpr/{string_posix.cc → posix/string.cc} +0 -0
- /data/src/core/lib/gpr/{sync_posix.cc → posix/sync.cc} +0 -0
- /data/src/core/lib/gpr/{time_posix.cc → posix/time.cc} +0 -0
- /data/src/core/lib/gpr/{tmpfile_posix.cc → posix/tmpfile.cc} +0 -0
- /data/src/core/lib/gpr/{cpu_windows.cc → windows/cpu.cc} +0 -0
- /data/src/core/lib/gpr/{log_windows.cc → windows/log.cc} +0 -0
- /data/src/core/lib/gpr/{string_windows.cc → windows/string.cc} +0 -0
- /data/src/core/lib/gpr/{string_util_windows.cc → windows/string_util.cc} +0 -0
- /data/src/core/lib/gpr/{sync_windows.cc → windows/sync.cc} +0 -0
- /data/src/core/lib/gpr/{time_windows.cc → windows/time.cc} +0 -0
- /data/src/core/lib/gpr/{tmpfile_windows.cc → windows/tmpfile.cc} +0 -0
- /data/src/core/lib/gprpp/{env_linux.cc → linux/env.cc} +0 -0
- /data/src/core/lib/gprpp/{env_posix.cc → posix/env.cc} +0 -0
- /data/src/core/lib/gprpp/{stat_posix.cc → posix/stat.cc} +0 -0
- /data/src/core/lib/gprpp/{env_windows.cc → windows/env.cc} +0 -0
- /data/src/core/lib/gprpp/{stat_windows.cc → windows/stat.cc} +0 -0
@@ -24,9 +24,11 @@
|
|
24
24
|
#include <algorithm>
|
25
25
|
#include <functional>
|
26
26
|
#include <new>
|
27
|
-
#include <
|
27
|
+
#include <type_traits>
|
28
|
+
#include <utility>
|
28
29
|
#include <vector>
|
29
30
|
|
31
|
+
#include "absl/cleanup/cleanup.h"
|
30
32
|
#include "absl/status/status.h"
|
31
33
|
#include "absl/status/statusor.h"
|
32
34
|
#include "absl/strings/cord.h"
|
@@ -47,6 +49,7 @@
|
|
47
49
|
#include "src/core/ext/filters/client_channel/backend_metric.h"
|
48
50
|
#include "src/core/ext/filters/client_channel/backup_poller.h"
|
49
51
|
#include "src/core/ext/filters/client_channel/client_channel_channelz.h"
|
52
|
+
#include "src/core/ext/filters/client_channel/client_channel_internal.h"
|
50
53
|
#include "src/core/ext/filters/client_channel/client_channel_service_config.h"
|
51
54
|
#include "src/core/ext/filters/client_channel/config_selector.h"
|
52
55
|
#include "src/core/ext/filters/client_channel/dynamic_filters.h"
|
@@ -67,6 +70,7 @@
|
|
67
70
|
#include "src/core/lib/gprpp/debug_location.h"
|
68
71
|
#include "src/core/lib/gprpp/status_helper.h"
|
69
72
|
#include "src/core/lib/gprpp/sync.h"
|
73
|
+
#include "src/core/lib/gprpp/unique_type_name.h"
|
70
74
|
#include "src/core/lib/gprpp/work_serializer.h"
|
71
75
|
#include "src/core/lib/handshaker/proxy_mapper_registry.h"
|
72
76
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
@@ -79,6 +83,7 @@
|
|
79
83
|
#include "src/core/lib/resolver/server_address.h"
|
80
84
|
#include "src/core/lib/service_config/service_config_call_data.h"
|
81
85
|
#include "src/core/lib/service_config/service_config_impl.h"
|
86
|
+
#include "src/core/lib/slice/slice.h"
|
82
87
|
#include "src/core/lib/slice/slice_internal.h"
|
83
88
|
#include "src/core/lib/surface/channel.h"
|
84
89
|
#include "src/core/lib/transport/connectivity_state.h"
|
@@ -105,6 +110,75 @@ TraceFlag grpc_client_channel_lb_call_trace(false, "client_channel_lb_call");
|
|
105
110
|
//
|
106
111
|
|
107
112
|
class ClientChannel::CallData {
|
113
|
+
public:
|
114
|
+
// Removes the call from the channel's list of calls queued
|
115
|
+
// for name resolution.
|
116
|
+
void RemoveCallFromResolverQueuedCallsLocked()
|
117
|
+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_);
|
118
|
+
|
119
|
+
// Called by the channel for each queued call when a new resolution
|
120
|
+
// result becomes available.
|
121
|
+
virtual void RetryCheckResolutionLocked()
|
122
|
+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_) = 0;
|
123
|
+
|
124
|
+
RefCountedPtr<DynamicFilters> dynamic_filters() const {
|
125
|
+
return dynamic_filters_;
|
126
|
+
}
|
127
|
+
|
128
|
+
protected:
|
129
|
+
CallData() = default;
|
130
|
+
virtual ~CallData() = default;
|
131
|
+
|
132
|
+
// Checks whether a resolver result is available. The following
|
133
|
+
// outcomes are possible:
|
134
|
+
// - No resolver result is available yet. The call will be queued and
|
135
|
+
// absl::nullopt will be returned. Later, when a resolver result
|
136
|
+
// becomes available, RetryCheckResolutionLocked() will be called.
|
137
|
+
// - The resolver has returned a transient failure. If the call is
|
138
|
+
// not wait_for_ready, a non-OK status will be returned. (If the
|
139
|
+
// call *is* wait_for_ready, it will be queued instead.)
|
140
|
+
// - There is a valid resolver result. The service config will be
|
141
|
+
// stored in the call context and an OK status will be returned.
|
142
|
+
absl::optional<absl::Status> CheckResolution(bool was_queued);
|
143
|
+
|
144
|
+
private:
|
145
|
+
// Accessors for data stored in the subclass.
|
146
|
+
virtual ClientChannel* chand() const = 0;
|
147
|
+
virtual Arena* arena() const = 0;
|
148
|
+
virtual grpc_polling_entity* pollent() const = 0;
|
149
|
+
virtual grpc_metadata_batch* send_initial_metadata() = 0;
|
150
|
+
virtual grpc_call_context_element* call_context() const = 0;
|
151
|
+
|
152
|
+
// Helper function for CheckResolution(). Returns true if the call
|
153
|
+
// can continue (i.e., there is a valid resolution result, or there is
|
154
|
+
// an invalid resolution result but the call is not wait_for_ready).
|
155
|
+
bool CheckResolutionLocked(
|
156
|
+
absl::StatusOr<RefCountedPtr<ConfigSelector>>* config_selector)
|
157
|
+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_);
|
158
|
+
|
159
|
+
// Adds the call to the channel's list of calls queued for name resolution.
|
160
|
+
void AddCallToResolverQueuedCallsLocked()
|
161
|
+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_);
|
162
|
+
|
163
|
+
// Called when adding the call to the resolver queue.
|
164
|
+
virtual void OnAddToQueueLocked()
|
165
|
+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_) {}
|
166
|
+
|
167
|
+
// Applies service config to the call. Must be invoked once we know
|
168
|
+
// that the resolver has returned results to the channel.
|
169
|
+
// If an error is returned, the error indicates the status with which
|
170
|
+
// the call should be failed.
|
171
|
+
grpc_error_handle ApplyServiceConfigToCallLocked(
|
172
|
+
const absl::StatusOr<RefCountedPtr<ConfigSelector>>& config_selector);
|
173
|
+
|
174
|
+
// Called to reset the deadline based on the service config obtained
|
175
|
+
// from the resolver.
|
176
|
+
virtual void ResetDeadline(Duration timeout) = 0;
|
177
|
+
|
178
|
+
RefCountedPtr<DynamicFilters> dynamic_filters_;
|
179
|
+
};
|
180
|
+
|
181
|
+
class ClientChannel::FilterBasedCallData : public ClientChannel::CallData {
|
108
182
|
public:
|
109
183
|
static grpc_error_handle Init(grpc_call_element* elem,
|
110
184
|
const grpc_call_element_args* args);
|
@@ -115,31 +189,33 @@ class ClientChannel::CallData {
|
|
115
189
|
grpc_call_element* elem, grpc_transport_stream_op_batch* batch);
|
116
190
|
static void SetPollent(grpc_call_element* elem, grpc_polling_entity* pollent);
|
117
191
|
|
118
|
-
// Invoked by channel for queued calls when name resolution is completed.
|
119
|
-
static void CheckResolution(void* arg, grpc_error_handle error);
|
120
|
-
// Helper function for applying the service config to a call while
|
121
|
-
// holding ClientChannel::resolution_mu_.
|
122
|
-
// Returns true if the service config has been applied to the call, in which
|
123
|
-
// case the caller must invoke ResolutionDone() or AsyncResolutionDone()
|
124
|
-
// with the returned error.
|
125
|
-
bool CheckResolutionLocked(grpc_call_element* elem, grpc_error_handle* error)
|
126
|
-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_);
|
127
|
-
// Schedules a callback to continue processing the call once
|
128
|
-
// resolution is complete. The callback will not run until after this
|
129
|
-
// method returns.
|
130
|
-
void AsyncResolutionDone(grpc_call_element* elem, grpc_error_handle error);
|
131
|
-
|
132
192
|
private:
|
133
193
|
class ResolverQueuedCallCanceller;
|
134
194
|
|
135
|
-
|
136
|
-
|
137
|
-
~
|
195
|
+
FilterBasedCallData(grpc_call_element* elem,
|
196
|
+
const grpc_call_element_args& args);
|
197
|
+
~FilterBasedCallData() override;
|
198
|
+
|
199
|
+
grpc_call_element* elem() const { return deadline_state_.elem; }
|
200
|
+
grpc_call_stack* owning_call() const { return deadline_state_.call_stack; }
|
201
|
+
CallCombiner* call_combiner() const { return deadline_state_.call_combiner; }
|
202
|
+
|
203
|
+
ClientChannel* chand() const override {
|
204
|
+
return static_cast<ClientChannel*>(elem()->channel_data);
|
205
|
+
}
|
206
|
+
Arena* arena() const override { return deadline_state_.arena; }
|
207
|
+
grpc_polling_entity* pollent() const override { return pollent_; }
|
208
|
+
grpc_metadata_batch* send_initial_metadata() override {
|
209
|
+
return pending_batches_[0]
|
210
|
+
->payload->send_initial_metadata.send_initial_metadata;
|
211
|
+
}
|
212
|
+
grpc_call_context_element* call_context() const override {
|
213
|
+
return call_context_;
|
214
|
+
}
|
138
215
|
|
139
216
|
// Returns the index into pending_batches_ to be used for batch.
|
140
217
|
static size_t GetBatchIndex(grpc_transport_stream_op_batch* batch);
|
141
|
-
void PendingBatchesAdd(
|
142
|
-
grpc_transport_stream_op_batch* batch);
|
218
|
+
void PendingBatchesAdd(grpc_transport_stream_op_batch* batch);
|
143
219
|
static void FailPendingBatchInCallCombiner(void* arg,
|
144
220
|
grpc_error_handle error);
|
145
221
|
// A predicate type and some useful implementations for PendingBatchesFail().
|
@@ -159,67 +235,55 @@ class ClientChannel::CallData {
|
|
159
235
|
// If yield_call_combiner_predicate returns true, assumes responsibility for
|
160
236
|
// yielding the call combiner.
|
161
237
|
void PendingBatchesFail(
|
162
|
-
|
238
|
+
grpc_error_handle error,
|
163
239
|
YieldCallCombinerPredicate yield_call_combiner_predicate);
|
164
240
|
static void ResumePendingBatchInCallCombiner(void* arg,
|
165
241
|
grpc_error_handle ignored);
|
166
|
-
// Resumes all pending batches on
|
167
|
-
void PendingBatchesResume(
|
242
|
+
// Resumes all pending batches on dynamic_call_.
|
243
|
+
void PendingBatchesResume();
|
168
244
|
|
169
|
-
//
|
170
|
-
//
|
171
|
-
//
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_);
|
176
|
-
// Invoked when the resolver result is applied to the caller, on both
|
177
|
-
// success or failure.
|
178
|
-
static void ResolutionDone(void* arg, grpc_error_handle error);
|
179
|
-
// Removes the call (if present) from the channel's list of calls queued
|
180
|
-
// for name resolution.
|
181
|
-
void MaybeRemoveCallFromResolverQueuedCallsLocked(grpc_call_element* elem)
|
182
|
-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_);
|
183
|
-
// Adds the call (if not already present) to the channel's list of
|
184
|
-
// calls queued for name resolution.
|
185
|
-
void MaybeAddCallToResolverQueuedCallsLocked(grpc_call_element* elem)
|
245
|
+
// Called to check for a resolution result, both when the call is
|
246
|
+
// initially started and when it is queued and the channel gets a new
|
247
|
+
// resolution result.
|
248
|
+
void TryCheckResolution(bool was_queued);
|
249
|
+
|
250
|
+
void OnAddToQueueLocked() override
|
186
251
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_);
|
187
252
|
|
188
|
-
|
189
|
-
|
253
|
+
void RetryCheckResolutionLocked() override
|
254
|
+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::resolution_mu_);
|
190
255
|
|
191
|
-
void
|
256
|
+
void ResetDeadline(Duration timeout) override {
|
257
|
+
const Timestamp per_method_deadline =
|
258
|
+
Timestamp::FromCycleCounterRoundUp(call_start_time_) + timeout;
|
259
|
+
if (per_method_deadline < deadline_) {
|
260
|
+
deadline_ = per_method_deadline;
|
261
|
+
grpc_deadline_state_reset(&deadline_state_, deadline_);
|
262
|
+
}
|
263
|
+
}
|
192
264
|
|
193
|
-
|
194
|
-
grpc_call_stack* owning_call() const { return deadline_state_.call_stack; }
|
195
|
-
CallCombiner* call_combiner() const { return deadline_state_.call_combiner; }
|
265
|
+
void CreateDynamicCall();
|
196
266
|
|
197
|
-
|
198
|
-
|
267
|
+
static void RecvTrailingMetadataReadyForConfigSelectorCommitCallback(
|
268
|
+
void* arg, grpc_error_handle error);
|
199
269
|
|
200
270
|
grpc_slice path_; // Request path.
|
271
|
+
grpc_call_context_element* call_context_;
|
201
272
|
gpr_cycle_counter call_start_time_;
|
202
273
|
Timestamp deadline_;
|
203
|
-
grpc_call_context_element* call_context_;
|
204
274
|
|
205
|
-
|
275
|
+
// State for handling deadlines.
|
276
|
+
grpc_deadline_state deadline_state_;
|
206
277
|
|
207
|
-
|
278
|
+
grpc_polling_entity* pollent_ = nullptr;
|
208
279
|
|
209
280
|
// Accessed while holding ClientChannel::resolution_mu_.
|
210
|
-
bool service_config_applied_ ABSL_GUARDED_BY(&ClientChannel::resolution_mu_) =
|
211
|
-
false;
|
212
|
-
bool queued_pending_resolver_result_
|
213
|
-
ABSL_GUARDED_BY(&ClientChannel::resolution_mu_) = false;
|
214
|
-
ClientChannel::ResolverQueuedCall resolver_queued_call_
|
215
|
-
ABSL_GUARDED_BY(&ClientChannel::resolution_mu_);
|
216
281
|
ResolverQueuedCallCanceller* resolver_call_canceller_
|
217
282
|
ABSL_GUARDED_BY(&ClientChannel::resolution_mu_) = nullptr;
|
218
283
|
|
219
284
|
grpc_closure* original_recv_trailing_metadata_ready_ = nullptr;
|
220
285
|
grpc_closure recv_trailing_metadata_ready_;
|
221
286
|
|
222
|
-
RefCountedPtr<DynamicFilters> dynamic_filters_;
|
223
287
|
RefCountedPtr<DynamicFilters::Call> dynamic_call_;
|
224
288
|
|
225
289
|
// Batches are added to this list when received from above.
|
@@ -238,13 +302,13 @@ class ClientChannel::CallData {
|
|
238
302
|
//
|
239
303
|
|
240
304
|
const grpc_channel_filter ClientChannel::kFilterVtable = {
|
241
|
-
ClientChannel::
|
305
|
+
ClientChannel::FilterBasedCallData::StartTransportStreamOpBatch,
|
242
306
|
nullptr,
|
243
307
|
ClientChannel::StartTransportOp,
|
244
|
-
sizeof(ClientChannel::
|
245
|
-
ClientChannel::
|
246
|
-
ClientChannel::
|
247
|
-
ClientChannel::
|
308
|
+
sizeof(ClientChannel::FilterBasedCallData),
|
309
|
+
ClientChannel::FilterBasedCallData::Init,
|
310
|
+
ClientChannel::FilterBasedCallData::SetPollent,
|
311
|
+
ClientChannel::FilterBasedCallData::Destroy,
|
248
312
|
sizeof(ClientChannel),
|
249
313
|
ClientChannel::Init,
|
250
314
|
grpc_channel_stack_no_post_init,
|
@@ -363,7 +427,7 @@ class DynamicTerminationFilter::CallData {
|
|
363
427
|
CallCombiner* call_combiner_;
|
364
428
|
grpc_call_context_element* call_context_;
|
365
429
|
|
366
|
-
OrphanablePtr<ClientChannel::
|
430
|
+
OrphanablePtr<ClientChannel::FilterBasedLoadBalancedCall> lb_call_;
|
367
431
|
};
|
368
432
|
|
369
433
|
const grpc_channel_filter DynamicTerminationFilter::kFilterVtable = {
|
@@ -520,20 +584,18 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
|
|
520
584
|
}
|
521
585
|
|
522
586
|
private:
|
523
|
-
//
|
524
|
-
//
|
525
|
-
//
|
526
|
-
// the state, whereas the one in SubchannelInterface does not expose
|
527
|
-
// the ConnectedSubchannel.
|
528
|
-
//
|
529
|
-
// This wrapper provides a bridge between the two. It implements
|
530
|
-
// Subchannel::ConnectivityStateWatcherInterface and wraps
|
587
|
+
// This wrapper provides a bridge between the internal Subchannel API
|
588
|
+
// and the SubchannelInterface API that we expose to LB policies.
|
589
|
+
// It implements Subchannel::ConnectivityStateWatcherInterface and wraps
|
531
590
|
// the instance of SubchannelInterface::ConnectivityStateWatcherInterface
|
532
591
|
// that was passed in by the LB policy. We pass an instance of this
|
533
592
|
// class to the underlying Subchannel, and when we get updates from
|
534
593
|
// the subchannel, we pass those on to the wrapped watcher to return
|
535
|
-
// the update to the LB policy.
|
536
|
-
//
|
594
|
+
// the update to the LB policy.
|
595
|
+
//
|
596
|
+
// This class handles things like hopping into the WorkSerializer
|
597
|
+
// before passing notifications to the LB policy and propagating
|
598
|
+
// keepalive information betwen subchannels.
|
537
599
|
class WatcherWrapper : public Subchannel::ConnectivityStateWatcherInterface {
|
538
600
|
public:
|
539
601
|
WatcherWrapper(
|
@@ -571,16 +633,7 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
|
|
571
633
|
}
|
572
634
|
|
573
635
|
grpc_pollset_set* interested_parties() override {
|
574
|
-
|
575
|
-
watcher_.get();
|
576
|
-
if (watcher_ == nullptr) watcher = replacement_->watcher_.get();
|
577
|
-
return watcher->interested_parties();
|
578
|
-
}
|
579
|
-
|
580
|
-
WatcherWrapper* MakeReplacement() {
|
581
|
-
auto* replacement = new WatcherWrapper(std::move(watcher_), parent_);
|
582
|
-
replacement_ = replacement;
|
583
|
-
return replacement;
|
636
|
+
return watcher_->interested_parties();
|
584
637
|
}
|
585
638
|
|
586
639
|
private:
|
@@ -638,7 +691,6 @@ class ClientChannel::SubchannelWrapper : public SubchannelInterface {
|
|
638
691
|
std::unique_ptr<SubchannelInterface::ConnectivityStateWatcherInterface>
|
639
692
|
watcher_;
|
640
693
|
RefCountedPtr<SubchannelWrapper> parent_;
|
641
|
-
WatcherWrapper* replacement_ = nullptr;
|
642
694
|
};
|
643
695
|
|
644
696
|
ClientChannel* chand_;
|
@@ -1065,15 +1117,16 @@ ClientChannel::~ClientChannel() {
|
|
1065
1117
|
grpc_pollset_set_destroy(interested_parties_);
|
1066
1118
|
}
|
1067
1119
|
|
1068
|
-
OrphanablePtr<ClientChannel::
|
1120
|
+
OrphanablePtr<ClientChannel::FilterBasedLoadBalancedCall>
|
1069
1121
|
ClientChannel::CreateLoadBalancedCall(
|
1070
1122
|
const grpc_call_element_args& args, grpc_polling_entity* pollent,
|
1071
1123
|
grpc_closure* on_call_destruction_complete,
|
1072
1124
|
ConfigSelector::CallDispatchController* call_dispatch_controller,
|
1073
1125
|
bool is_transparent_retry) {
|
1074
|
-
return OrphanablePtr<
|
1075
|
-
|
1076
|
-
|
1126
|
+
return OrphanablePtr<FilterBasedLoadBalancedCall>(
|
1127
|
+
args.arena->New<FilterBasedLoadBalancedCall>(
|
1128
|
+
this, args, pollent, on_call_destruction_complete,
|
1129
|
+
call_dispatch_controller, is_transparent_retry));
|
1077
1130
|
}
|
1078
1131
|
|
1079
1132
|
ChannelArgs ClientChannel::MakeSubchannelArgs(
|
@@ -1099,6 +1152,14 @@ ChannelArgs ClientChannel::MakeSubchannelArgs(
|
|
1099
1152
|
.Remove(GRPC_ARG_CHANNELZ_CHANNEL_NODE);
|
1100
1153
|
}
|
1101
1154
|
|
1155
|
+
void ClientChannel::ReprocessQueuedResolverCalls() {
|
1156
|
+
for (CallData* calld : resolver_queued_calls_) {
|
1157
|
+
calld->RemoveCallFromResolverQueuedCallsLocked();
|
1158
|
+
calld->RetryCheckResolutionLocked();
|
1159
|
+
}
|
1160
|
+
resolver_queued_calls_.clear();
|
1161
|
+
}
|
1162
|
+
|
1102
1163
|
namespace {
|
1103
1164
|
|
1104
1165
|
RefCountedPtr<LoadBalancingPolicy::Config> ChooseLbPolicy(
|
@@ -1305,26 +1366,19 @@ void ClientChannel::OnResolverErrorLocked(absl::Status status) {
|
|
1305
1366
|
// result, then we continue to let it set the connectivity state.
|
1306
1367
|
// Otherwise, we go into TRANSIENT_FAILURE.
|
1307
1368
|
if (lb_policy_ == nullptr) {
|
1369
|
+
// Update connectivity state.
|
1370
|
+
// TODO(roth): We should be updating the connectivity state here but
|
1371
|
+
// not the picker.
|
1372
|
+
UpdateStateAndPickerLocked(
|
1373
|
+
GRPC_CHANNEL_TRANSIENT_FAILURE, status, "resolver failure",
|
1374
|
+
MakeRefCounted<LoadBalancingPolicy::TransientFailurePicker>(status));
|
1308
1375
|
{
|
1309
1376
|
MutexLock lock(&resolution_mu_);
|
1310
1377
|
// Update resolver transient failure.
|
1311
1378
|
resolver_transient_failure_error_ =
|
1312
1379
|
MaybeRewriteIllegalStatusCode(status, "resolver");
|
1313
|
-
|
1314
|
-
for (ResolverQueuedCall* call = resolver_queued_calls_; call != nullptr;
|
1315
|
-
call = call->next) {
|
1316
|
-
grpc_call_element* elem = call->elem;
|
1317
|
-
CallData* calld = static_cast<CallData*>(elem->call_data);
|
1318
|
-
grpc_error_handle error;
|
1319
|
-
if (calld->CheckResolutionLocked(elem, &error)) {
|
1320
|
-
calld->AsyncResolutionDone(elem, error);
|
1321
|
-
}
|
1322
|
-
}
|
1380
|
+
ReprocessQueuedResolverCalls();
|
1323
1381
|
}
|
1324
|
-
// Update connectivity state.
|
1325
|
-
UpdateStateAndPickerLocked(
|
1326
|
-
GRPC_CHANNEL_TRANSIENT_FAILURE, status, "resolver failure",
|
1327
|
-
MakeRefCounted<LoadBalancingPolicy::TransientFailurePicker>(status));
|
1328
1382
|
}
|
1329
1383
|
}
|
1330
1384
|
|
@@ -1378,30 +1432,6 @@ OrphanablePtr<LoadBalancingPolicy> ClientChannel::CreateLbPolicyLocked(
|
|
1378
1432
|
return lb_policy;
|
1379
1433
|
}
|
1380
1434
|
|
1381
|
-
void ClientChannel::AddResolverQueuedCall(ResolverQueuedCall* call,
|
1382
|
-
grpc_polling_entity* pollent) {
|
1383
|
-
// Add call to queued calls list.
|
1384
|
-
call->next = resolver_queued_calls_;
|
1385
|
-
resolver_queued_calls_ = call;
|
1386
|
-
// Add call's pollent to channel's interested_parties, so that I/O
|
1387
|
-
// can be done under the call's CQ.
|
1388
|
-
grpc_polling_entity_add_to_pollset_set(pollent, interested_parties_);
|
1389
|
-
}
|
1390
|
-
|
1391
|
-
void ClientChannel::RemoveResolverQueuedCall(ResolverQueuedCall* to_remove,
|
1392
|
-
grpc_polling_entity* pollent) {
|
1393
|
-
// Remove call's pollent from channel's interested_parties.
|
1394
|
-
grpc_polling_entity_del_from_pollset_set(pollent, interested_parties_);
|
1395
|
-
// Remove from queued calls list.
|
1396
|
-
for (ResolverQueuedCall** call = &resolver_queued_calls_; *call != nullptr;
|
1397
|
-
call = &(*call)->next) {
|
1398
|
-
if (*call == to_remove) {
|
1399
|
-
*call = to_remove->next;
|
1400
|
-
return;
|
1401
|
-
}
|
1402
|
-
}
|
1403
|
-
}
|
1404
|
-
|
1405
1435
|
void ClientChannel::UpdateServiceConfigInControlPlaneLocked(
|
1406
1436
|
RefCountedPtr<ServiceConfig> service_config,
|
1407
1437
|
RefCountedPtr<ConfigSelector> config_selector, std::string lb_policy_name) {
|
@@ -1468,25 +1498,8 @@ void ClientChannel::UpdateServiceConfigInDataPlaneLocked() {
|
|
1468
1498
|
service_config_.swap(service_config);
|
1469
1499
|
config_selector_.swap(config_selector);
|
1470
1500
|
dynamic_filters_.swap(dynamic_filters);
|
1471
|
-
//
|
1472
|
-
|
1473
|
-
call = call->next) {
|
1474
|
-
// If there are a lot of queued calls here, resuming them all may cause us
|
1475
|
-
// to stay inside C-core for a long period of time. All of that work would
|
1476
|
-
// be done using the same ExecCtx instance and therefore the same cached
|
1477
|
-
// value of "now". The longer it takes to finish all of this work and exit
|
1478
|
-
// from C-core, the more stale the cached value of "now" may become. This
|
1479
|
-
// can cause problems whereby (e.g.) we calculate a timer deadline based
|
1480
|
-
// on the stale value, which results in the timer firing too early. To
|
1481
|
-
// avoid this, we invalidate the cached value for each call we process.
|
1482
|
-
ExecCtx::Get()->InvalidateNow();
|
1483
|
-
grpc_call_element* elem = call->elem;
|
1484
|
-
CallData* calld = static_cast<CallData*>(elem->call_data);
|
1485
|
-
grpc_error_handle error;
|
1486
|
-
if (calld->CheckResolutionLocked(elem, &error)) {
|
1487
|
-
calld->AsyncResolutionDone(elem, error);
|
1488
|
-
}
|
1489
|
-
}
|
1501
|
+
// Re-process queued calls asynchronously.
|
1502
|
+
ReprocessQueuedResolverCalls();
|
1490
1503
|
}
|
1491
1504
|
// Old values will be unreffed after lock is released when they go out
|
1492
1505
|
// of scope.
|
@@ -1502,6 +1515,10 @@ void ClientChannel::CreateResolverLocked() {
|
|
1502
1515
|
// Since the validity of the args was checked when the channel was created,
|
1503
1516
|
// CreateResolver() must return a non-null result.
|
1504
1517
|
GPR_ASSERT(resolver_ != nullptr);
|
1518
|
+
// TODO(roth): We should be updating the connectivity state here but
|
1519
|
+
// not the picker. But we need to make sure that we are initializing
|
1520
|
+
// the picker to a queueing picker somewhere, in case the LB policy
|
1521
|
+
// does not immediately return a new picker.
|
1505
1522
|
UpdateStateAndPickerLocked(
|
1506
1523
|
GRPC_CHANNEL_CONNECTING, absl::Status(), "started resolving",
|
1507
1524
|
MakeRefCounted<LoadBalancingPolicy::QueuePicker>(nullptr));
|
@@ -1562,29 +1579,18 @@ void ClientChannel::UpdateStateAndPickerLocked(
|
|
1562
1579
|
channelz::ChannelNode::GetChannelConnectivityStateChangeString(
|
1563
1580
|
state)));
|
1564
1581
|
}
|
1565
|
-
// Grab
|
1582
|
+
// Grab the LB lock to update the picker and trigger reprocessing of the
|
1583
|
+
// queued picks.
|
1584
|
+
// Old picker will be unreffed after releasing the lock.
|
1566
1585
|
{
|
1567
|
-
MutexLock lock(&
|
1568
|
-
// Swap out the picker.
|
1569
|
-
// Note: Original value will be destroyed after the lock is released.
|
1586
|
+
MutexLock lock(&lb_mu_);
|
1570
1587
|
picker_.swap(picker);
|
1571
|
-
//
|
1572
|
-
for (
|
1573
|
-
|
1574
|
-
|
1575
|
-
// to stay inside C-core for a long period of time. All of that work would
|
1576
|
-
// be done using the same ExecCtx instance and therefore the same cached
|
1577
|
-
// value of "now". The longer it takes to finish all of this work and exit
|
1578
|
-
// from C-core, the more stale the cached value of "now" may become. This
|
1579
|
-
// can cause problems whereby (e.g.) we calculate a timer deadline based
|
1580
|
-
// on the stale value, which results in the timer firing too early. To
|
1581
|
-
// avoid this, we invalidate the cached value for each call we process.
|
1582
|
-
ExecCtx::Get()->InvalidateNow();
|
1583
|
-
grpc_error_handle error;
|
1584
|
-
if (call->lb_call->PickSubchannelLocked(&error)) {
|
1585
|
-
call->lb_call->AsyncPickDone(error);
|
1586
|
-
}
|
1588
|
+
// Reprocess queued picks.
|
1589
|
+
for (LoadBalancedCall* call : lb_queued_calls_) {
|
1590
|
+
call->RemoveCallFromLbQueuedCallsLocked();
|
1591
|
+
call->RetryPickLocked();
|
1587
1592
|
}
|
1593
|
+
lb_queued_calls_.clear();
|
1588
1594
|
}
|
1589
1595
|
}
|
1590
1596
|
|
@@ -1628,7 +1634,7 @@ grpc_error_handle ClientChannel::DoPingLocked(grpc_transport_op* op) {
|
|
1628
1634
|
}
|
1629
1635
|
LoadBalancingPolicy::PickResult result;
|
1630
1636
|
{
|
1631
|
-
MutexLock lock(&
|
1637
|
+
MutexLock lock(&lb_mu_);
|
1632
1638
|
result = picker_->Pick(LoadBalancingPolicy::PickArgs());
|
1633
1639
|
}
|
1634
1640
|
return HandlePickResult<grpc_error_handle>(
|
@@ -1712,6 +1718,9 @@ void ClientChannel::StartTransportOpLocked(grpc_transport_op* op) {
|
|
1712
1718
|
GRPC_CHANNEL_SHUTDOWN, absl::Status(), "shutdown from API",
|
1713
1719
|
MakeRefCounted<LoadBalancingPolicy::TransientFailurePicker>(
|
1714
1720
|
grpc_error_to_absl_status(op->disconnect_with_error)));
|
1721
|
+
// TODO(roth): If this happens when we're still waiting for a
|
1722
|
+
// resolver result, we need to trigger failures for all calls in
|
1723
|
+
// the resolver queue here.
|
1715
1724
|
}
|
1716
1725
|
}
|
1717
1726
|
GRPC_CHANNEL_STACK_UNREF(owning_stack_, "start_transport_op");
|
@@ -1748,30 +1757,6 @@ void ClientChannel::GetChannelInfo(grpc_channel_element* elem,
|
|
1748
1757
|
}
|
1749
1758
|
}
|
1750
1759
|
|
1751
|
-
void ClientChannel::AddLbQueuedCall(LbQueuedCall* call,
|
1752
|
-
grpc_polling_entity* pollent) {
|
1753
|
-
// Add call to queued picks list.
|
1754
|
-
call->next = lb_queued_calls_;
|
1755
|
-
lb_queued_calls_ = call;
|
1756
|
-
// Add call's pollent to channel's interested_parties, so that I/O
|
1757
|
-
// can be done under the call's CQ.
|
1758
|
-
grpc_polling_entity_add_to_pollset_set(pollent, interested_parties_);
|
1759
|
-
}
|
1760
|
-
|
1761
|
-
void ClientChannel::RemoveLbQueuedCall(LbQueuedCall* to_remove,
|
1762
|
-
grpc_polling_entity* pollent) {
|
1763
|
-
// Remove call's pollent from channel's interested_parties.
|
1764
|
-
grpc_polling_entity_del_from_pollset_set(pollent, interested_parties_);
|
1765
|
-
// Remove from queued picks list.
|
1766
|
-
for (LbQueuedCall** call = &lb_queued_calls_; *call != nullptr;
|
1767
|
-
call = &(*call)->next) {
|
1768
|
-
if (*call == to_remove) {
|
1769
|
-
*call = to_remove->next;
|
1770
|
-
return;
|
1771
|
-
}
|
1772
|
-
}
|
1773
|
-
}
|
1774
|
-
|
1775
1760
|
void ClientChannel::TryToConnectLocked() {
|
1776
1761
|
if (lb_policy_ != nullptr) {
|
1777
1762
|
lb_policy_->ExitIdleLocked();
|
@@ -1812,23 +1797,178 @@ void ClientChannel::RemoveConnectivityWatcher(
|
|
1812
1797
|
// CallData implementation
|
1813
1798
|
//
|
1814
1799
|
|
1815
|
-
ClientChannel::CallData::
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1800
|
+
void ClientChannel::CallData::RemoveCallFromResolverQueuedCallsLocked() {
|
1801
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
1802
|
+
gpr_log(GPR_INFO,
|
1803
|
+
"chand=%p calld=%p: removing from resolver queued picks list",
|
1804
|
+
chand(), this);
|
1805
|
+
}
|
1806
|
+
// Remove call's pollent from channel's interested_parties.
|
1807
|
+
grpc_polling_entity_del_from_pollset_set(pollent(),
|
1808
|
+
chand()->interested_parties_);
|
1809
|
+
// Note: There's no need to actually remove the call from the queue
|
1810
|
+
// here, because that will be done in
|
1811
|
+
// ResolverQueuedCallCanceller::CancelLocked() or
|
1812
|
+
// ClientChannel::ReprocessQueuedResolverCalls().
|
1813
|
+
}
|
1814
|
+
|
1815
|
+
void ClientChannel::CallData::AddCallToResolverQueuedCallsLocked() {
|
1816
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
1817
|
+
gpr_log(GPR_INFO, "chand=%p calld=%p: adding to resolver queued picks list",
|
1818
|
+
chand(), this);
|
1819
|
+
}
|
1820
|
+
// Add call's pollent to channel's interested_parties, so that I/O
|
1821
|
+
// can be done under the call's CQ.
|
1822
|
+
grpc_polling_entity_add_to_pollset_set(pollent(),
|
1823
|
+
chand()->interested_parties_);
|
1824
|
+
// Add to queue.
|
1825
|
+
chand()->resolver_queued_calls_.insert(this);
|
1826
|
+
OnAddToQueueLocked();
|
1827
|
+
}
|
1828
|
+
|
1829
|
+
grpc_error_handle ClientChannel::CallData::ApplyServiceConfigToCallLocked(
|
1830
|
+
const absl::StatusOr<RefCountedPtr<ConfigSelector>>& config_selector) {
|
1831
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
1832
|
+
gpr_log(GPR_INFO, "chand=%p calld=%p: applying service config to call",
|
1833
|
+
chand(), this);
|
1834
|
+
}
|
1835
|
+
if (!config_selector.ok()) return config_selector.status();
|
1836
|
+
// Use the ConfigSelector to determine the config for the call.
|
1837
|
+
auto call_config =
|
1838
|
+
(*config_selector)->GetCallConfig({send_initial_metadata(), arena()});
|
1839
|
+
if (!call_config.ok()) {
|
1840
|
+
return absl_status_to_grpc_error(
|
1841
|
+
MaybeRewriteIllegalStatusCode(call_config.status(), "ConfigSelector"));
|
1842
|
+
}
|
1843
|
+
// Create a ClientChannelServiceConfigCallData for the call. This stores
|
1844
|
+
// a ref to the ServiceConfig and caches the right set of parsed configs
|
1845
|
+
// to use for the call. The ClientChannelServiceConfigCallData will store
|
1846
|
+
// itself in the call context, so that it can be accessed by filters
|
1847
|
+
// below us in the stack, and it will be cleaned up when the call ends.
|
1848
|
+
auto* service_config_call_data =
|
1849
|
+
arena()->New<ClientChannelServiceConfigCallData>(
|
1850
|
+
std::move(call_config->service_config), call_config->method_configs,
|
1851
|
+
std::move(call_config->call_attributes),
|
1852
|
+
call_config->call_dispatch_controller, call_context());
|
1853
|
+
// Apply our own method params to the call.
|
1854
|
+
auto* method_params = static_cast<ClientChannelMethodParsedConfig*>(
|
1855
|
+
service_config_call_data->GetMethodParsedConfig(
|
1856
|
+
chand()->service_config_parser_index_));
|
1857
|
+
if (method_params != nullptr) {
|
1858
|
+
// If the deadline from the service config is shorter than the one
|
1859
|
+
// from the client API, reset the deadline timer.
|
1860
|
+
if (chand()->deadline_checking_enabled_ &&
|
1861
|
+
method_params->timeout() != Duration::Zero()) {
|
1862
|
+
ResetDeadline(method_params->timeout());
|
1863
|
+
}
|
1864
|
+
// If the service config set wait_for_ready and the application
|
1865
|
+
// did not explicitly set it, use the value from the service config.
|
1866
|
+
auto* wait_for_ready =
|
1867
|
+
send_initial_metadata()->GetOrCreatePointer(WaitForReady());
|
1868
|
+
if (method_params->wait_for_ready().has_value() &&
|
1869
|
+
!wait_for_ready->explicitly_set) {
|
1870
|
+
wait_for_ready->value = method_params->wait_for_ready().value();
|
1871
|
+
}
|
1872
|
+
}
|
1873
|
+
return absl::OkStatus();
|
1874
|
+
}
|
1875
|
+
|
1876
|
+
absl::optional<absl::Status> ClientChannel::CallData::CheckResolution(
|
1877
|
+
bool was_queued) {
|
1878
|
+
// Check if we have a resolver result to use.
|
1879
|
+
absl::StatusOr<RefCountedPtr<ConfigSelector>> config_selector;
|
1880
|
+
{
|
1881
|
+
MutexLock lock(&chand()->resolution_mu_);
|
1882
|
+
bool result_ready = CheckResolutionLocked(&config_selector);
|
1883
|
+
// If no result is available, queue the call.
|
1884
|
+
if (!result_ready) {
|
1885
|
+
AddCallToResolverQueuedCallsLocked();
|
1886
|
+
return absl::nullopt;
|
1887
|
+
}
|
1888
|
+
}
|
1889
|
+
// We have a result. Apply service config to call.
|
1890
|
+
grpc_error_handle error = ApplyServiceConfigToCallLocked(config_selector);
|
1891
|
+
// ConfigSelector must be unreffed inside the WorkSerializer.
|
1892
|
+
if (config_selector.ok()) {
|
1893
|
+
chand()->work_serializer_->Run(
|
1894
|
+
[config_selector = std::move(*config_selector)]() mutable {
|
1895
|
+
config_selector.reset();
|
1896
|
+
},
|
1897
|
+
DEBUG_LOCATION);
|
1898
|
+
}
|
1899
|
+
// Handle errors.
|
1900
|
+
if (!error.ok()) {
|
1901
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
1902
|
+
gpr_log(GPR_INFO,
|
1903
|
+
"chand=%p calld=%p: error applying config to call: error=%s",
|
1904
|
+
chand(), this, StatusToString(error).c_str());
|
1905
|
+
}
|
1906
|
+
return error;
|
1907
|
+
}
|
1908
|
+
// If the call was queued, add trace annotation.
|
1909
|
+
if (was_queued) {
|
1910
|
+
auto* call_tracer = static_cast<CallTracerAnnotationInterface*>(
|
1911
|
+
call_context()[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value);
|
1912
|
+
if (call_tracer != nullptr) {
|
1913
|
+
call_tracer->RecordAnnotation("Delayed name resolution complete.");
|
1914
|
+
}
|
1915
|
+
}
|
1916
|
+
return absl::OkStatus();
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
bool ClientChannel::CallData::CheckResolutionLocked(
|
1920
|
+
absl::StatusOr<RefCountedPtr<ConfigSelector>>* config_selector) {
|
1921
|
+
// If we don't yet have a resolver result, we need to queue the call
|
1922
|
+
// until we get one.
|
1923
|
+
if (GPR_UNLIKELY(!chand()->received_service_config_data_)) {
|
1924
|
+
// If the resolver returned transient failure before returning the
|
1925
|
+
// first service config, fail any non-wait_for_ready calls.
|
1926
|
+
absl::Status resolver_error = chand()->resolver_transient_failure_error_;
|
1927
|
+
if (!resolver_error.ok() &&
|
1928
|
+
!send_initial_metadata()->GetOrCreatePointer(WaitForReady())->value) {
|
1929
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
1930
|
+
gpr_log(GPR_INFO, "chand=%p calld=%p: resolution failed, failing call",
|
1931
|
+
chand(), this);
|
1932
|
+
}
|
1933
|
+
*config_selector = absl_status_to_grpc_error(resolver_error);
|
1934
|
+
return true;
|
1935
|
+
}
|
1936
|
+
// Either the resolver has not yet returned a result, or it has
|
1937
|
+
// returned transient failure but the call is wait_for_ready. In
|
1938
|
+
// either case, queue the call.
|
1939
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
1940
|
+
gpr_log(GPR_INFO, "chand=%p calld=%p: no resolver result yet", chand(),
|
1941
|
+
this);
|
1942
|
+
}
|
1943
|
+
return false;
|
1944
|
+
}
|
1945
|
+
// Result found.
|
1946
|
+
*config_selector = chand()->config_selector_;
|
1947
|
+
dynamic_filters_ = chand()->dynamic_filters_;
|
1948
|
+
return true;
|
1949
|
+
}
|
1950
|
+
|
1951
|
+
//
|
1952
|
+
// FilterBasedCallData implementation
|
1953
|
+
//
|
1954
|
+
|
1955
|
+
ClientChannel::FilterBasedCallData::FilterBasedCallData(
|
1956
|
+
grpc_call_element* elem, const grpc_call_element_args& args)
|
1957
|
+
: path_(CSliceRef(args.path)),
|
1958
|
+
call_context_(args.context),
|
1823
1959
|
call_start_time_(args.start_time),
|
1824
1960
|
deadline_(args.deadline),
|
1825
|
-
|
1961
|
+
deadline_state_(elem, args,
|
1962
|
+
GPR_LIKELY(static_cast<ClientChannel*>(elem->channel_data)
|
1963
|
+
->deadline_checking_enabled_)
|
1964
|
+
? args.deadline
|
1965
|
+
: Timestamp::InfFuture()) {
|
1826
1966
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
1827
|
-
gpr_log(GPR_INFO, "chand=%p calld=%p: created call",
|
1967
|
+
gpr_log(GPR_INFO, "chand=%p calld=%p: created call", chand(), this);
|
1828
1968
|
}
|
1829
1969
|
}
|
1830
1970
|
|
1831
|
-
ClientChannel::
|
1971
|
+
ClientChannel::FilterBasedCallData::~FilterBasedCallData() {
|
1832
1972
|
CSliceUnref(path_);
|
1833
1973
|
// Make sure there are no remaining pending batches.
|
1834
1974
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
|
@@ -1836,20 +1976,19 @@ ClientChannel::CallData::~CallData() {
|
|
1836
1976
|
}
|
1837
1977
|
}
|
1838
1978
|
|
1839
|
-
grpc_error_handle ClientChannel::
|
1979
|
+
grpc_error_handle ClientChannel::FilterBasedCallData::Init(
|
1840
1980
|
grpc_call_element* elem, const grpc_call_element_args* args) {
|
1841
|
-
|
1842
|
-
new (elem->call_data) CallData(elem, *chand, *args);
|
1981
|
+
new (elem->call_data) FilterBasedCallData(elem, *args);
|
1843
1982
|
return absl::OkStatus();
|
1844
1983
|
}
|
1845
1984
|
|
1846
|
-
void ClientChannel::
|
1985
|
+
void ClientChannel::FilterBasedCallData::Destroy(
|
1847
1986
|
grpc_call_element* elem, const grpc_call_final_info* /*final_info*/,
|
1848
1987
|
grpc_closure* then_schedule_closure) {
|
1849
|
-
|
1988
|
+
auto* calld = static_cast<FilterBasedCallData*>(elem->call_data);
|
1850
1989
|
RefCountedPtr<DynamicFilters::Call> dynamic_call =
|
1851
1990
|
std::move(calld->dynamic_call_);
|
1852
|
-
calld->~
|
1991
|
+
calld->~FilterBasedCallData();
|
1853
1992
|
if (GPR_LIKELY(dynamic_call != nullptr)) {
|
1854
1993
|
dynamic_call->SetAfterCallStackDestroy(then_schedule_closure);
|
1855
1994
|
} else {
|
@@ -1858,14 +1997,14 @@ void ClientChannel::CallData::Destroy(
|
|
1858
1997
|
}
|
1859
1998
|
}
|
1860
1999
|
|
1861
|
-
void ClientChannel::
|
2000
|
+
void ClientChannel::FilterBasedCallData::StartTransportStreamOpBatch(
|
1862
2001
|
grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
|
1863
|
-
|
2002
|
+
auto* calld = static_cast<FilterBasedCallData*>(elem->call_data);
|
1864
2003
|
ClientChannel* chand = static_cast<ClientChannel*>(elem->channel_data);
|
1865
2004
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace) &&
|
1866
2005
|
!GRPC_TRACE_FLAG_ENABLED(grpc_trace_channel)) {
|
1867
2006
|
gpr_log(GPR_INFO, "chand=%p calld=%p: batch started from above: %s", chand,
|
1868
|
-
calld, grpc_transport_stream_op_batch_string(batch).c_str());
|
2007
|
+
calld, grpc_transport_stream_op_batch_string(batch, false).c_str());
|
1869
2008
|
}
|
1870
2009
|
if (GPR_LIKELY(chand->deadline_checking_enabled_)) {
|
1871
2010
|
grpc_deadline_state_client_start_transport_stream_op_batch(
|
@@ -1879,7 +2018,7 @@ void ClientChannel::CallData::StartTransportStreamOpBatch(
|
|
1879
2018
|
batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready;
|
1880
2019
|
GRPC_CLOSURE_INIT(&calld->recv_trailing_metadata_ready_,
|
1881
2020
|
RecvTrailingMetadataReadyForConfigSelectorCommitCallback,
|
1882
|
-
|
2021
|
+
calld, nullptr);
|
1883
2022
|
batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready =
|
1884
2023
|
&calld->recv_trailing_metadata_ready_;
|
1885
2024
|
}
|
@@ -1920,14 +2059,14 @@ void ClientChannel::CallData::StartTransportStreamOpBatch(
|
|
1920
2059
|
calld, StatusToString(calld->cancel_error_).c_str());
|
1921
2060
|
}
|
1922
2061
|
// Fail all pending batches.
|
1923
|
-
calld->PendingBatchesFail(
|
2062
|
+
calld->PendingBatchesFail(calld->cancel_error_, NoYieldCallCombiner);
|
1924
2063
|
// Note: This will release the call combiner.
|
1925
2064
|
grpc_transport_stream_op_batch_finish_with_failure(
|
1926
2065
|
batch, calld->cancel_error_, calld->call_combiner());
|
1927
2066
|
return;
|
1928
2067
|
}
|
1929
2068
|
// Add the batch to the pending list.
|
1930
|
-
calld->PendingBatchesAdd(
|
2069
|
+
calld->PendingBatchesAdd(batch);
|
1931
2070
|
// For batches containing a send_initial_metadata op, acquire the
|
1932
2071
|
// channel's resolution mutex to apply the service config to the call,
|
1933
2072
|
// after which we will create a dynamic call.
|
@@ -1938,7 +2077,23 @@ void ClientChannel::CallData::StartTransportStreamOpBatch(
|
|
1938
2077
|
"config",
|
1939
2078
|
chand, calld);
|
1940
2079
|
}
|
1941
|
-
|
2080
|
+
// If we're still in IDLE, we need to start resolving.
|
2081
|
+
if (GPR_UNLIKELY(chand->CheckConnectivityState(false) ==
|
2082
|
+
GRPC_CHANNEL_IDLE)) {
|
2083
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2084
|
+
gpr_log(GPR_INFO, "chand=%p calld=%p: triggering exit idle", chand,
|
2085
|
+
calld);
|
2086
|
+
}
|
2087
|
+
// Bounce into the control plane work serializer to start resolving.
|
2088
|
+
GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "ExitIdle");
|
2089
|
+
chand->work_serializer_->Run(
|
2090
|
+
[chand]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand->work_serializer_) {
|
2091
|
+
chand->CheckConnectivityState(/*try_to_connect=*/true);
|
2092
|
+
GRPC_CHANNEL_STACK_UNREF(chand->owning_stack_, "ExitIdle");
|
2093
|
+
},
|
2094
|
+
DEBUG_LOCATION);
|
2095
|
+
}
|
2096
|
+
calld->TryCheckResolution(/*was_queued=*/false);
|
1942
2097
|
} else {
|
1943
2098
|
// For all other batches, release the call combiner.
|
1944
2099
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
@@ -1951,21 +2106,16 @@ void ClientChannel::CallData::StartTransportStreamOpBatch(
|
|
1951
2106
|
}
|
1952
2107
|
}
|
1953
2108
|
|
1954
|
-
void ClientChannel::
|
1955
|
-
|
1956
|
-
|
2109
|
+
void ClientChannel::FilterBasedCallData::SetPollent(
|
2110
|
+
grpc_call_element* elem, grpc_polling_entity* pollent) {
|
2111
|
+
auto* calld = static_cast<FilterBasedCallData*>(elem->call_data);
|
1957
2112
|
calld->pollent_ = pollent;
|
1958
2113
|
}
|
1959
2114
|
|
1960
|
-
|
1961
|
-
// pending_batches management
|
1962
|
-
//
|
1963
|
-
|
1964
|
-
size_t ClientChannel::CallData::GetBatchIndex(
|
2115
|
+
size_t ClientChannel::FilterBasedCallData::GetBatchIndex(
|
1965
2116
|
grpc_transport_stream_op_batch* batch) {
|
1966
2117
|
// Note: It is important the send_initial_metadata be the first entry
|
1967
|
-
// here, since the code in
|
1968
|
-
// CheckResolutionLocked() assumes it will be.
|
2118
|
+
// here, since the code in CheckResolution() assumes it will be.
|
1969
2119
|
if (batch->send_initial_metadata) return 0;
|
1970
2120
|
if (batch->send_message) return 1;
|
1971
2121
|
if (batch->send_trailing_metadata) return 2;
|
@@ -1976,14 +2126,13 @@ size_t ClientChannel::CallData::GetBatchIndex(
|
|
1976
2126
|
}
|
1977
2127
|
|
1978
2128
|
// This is called via the call combiner, so access to calld is synchronized.
|
1979
|
-
void ClientChannel::
|
1980
|
-
|
1981
|
-
ClientChannel* chand = static_cast<ClientChannel*>(elem->channel_data);
|
2129
|
+
void ClientChannel::FilterBasedCallData::PendingBatchesAdd(
|
2130
|
+
grpc_transport_stream_op_batch* batch) {
|
1982
2131
|
const size_t idx = GetBatchIndex(batch);
|
1983
2132
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
1984
2133
|
gpr_log(GPR_INFO,
|
1985
|
-
"chand=%p calld=%p: adding pending batch at index %" PRIuPTR,
|
1986
|
-
this, idx);
|
2134
|
+
"chand=%p calld=%p: adding pending batch at index %" PRIuPTR,
|
2135
|
+
chand(), this, idx);
|
1987
2136
|
}
|
1988
2137
|
grpc_transport_stream_op_batch*& pending = pending_batches_[idx];
|
1989
2138
|
GPR_ASSERT(pending == nullptr);
|
@@ -1991,19 +2140,20 @@ void ClientChannel::CallData::PendingBatchesAdd(
|
|
1991
2140
|
}
|
1992
2141
|
|
1993
2142
|
// This is called via the call combiner, so access to calld is synchronized.
|
1994
|
-
void ClientChannel::
|
2143
|
+
void ClientChannel::FilterBasedCallData::FailPendingBatchInCallCombiner(
|
1995
2144
|
void* arg, grpc_error_handle error) {
|
1996
2145
|
grpc_transport_stream_op_batch* batch =
|
1997
2146
|
static_cast<grpc_transport_stream_op_batch*>(arg);
|
1998
|
-
|
2147
|
+
auto* calld =
|
2148
|
+
static_cast<FilterBasedCallData*>(batch->handler_private.extra_arg);
|
1999
2149
|
// Note: This will release the call combiner.
|
2000
2150
|
grpc_transport_stream_op_batch_finish_with_failure(batch, error,
|
2001
2151
|
calld->call_combiner());
|
2002
2152
|
}
|
2003
2153
|
|
2004
2154
|
// This is called via the call combiner, so access to calld is synchronized.
|
2005
|
-
void ClientChannel::
|
2006
|
-
|
2155
|
+
void ClientChannel::FilterBasedCallData::PendingBatchesFail(
|
2156
|
+
grpc_error_handle error,
|
2007
2157
|
YieldCallCombinerPredicate yield_call_combiner_predicate) {
|
2008
2158
|
GPR_ASSERT(!error.ok());
|
2009
2159
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
@@ -2011,9 +2161,9 @@ void ClientChannel::CallData::PendingBatchesFail(
|
|
2011
2161
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
|
2012
2162
|
if (pending_batches_[i] != nullptr) ++num_batches;
|
2013
2163
|
}
|
2014
|
-
gpr_log(
|
2015
|
-
|
2016
|
-
|
2164
|
+
gpr_log(GPR_INFO,
|
2165
|
+
"chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s",
|
2166
|
+
chand(), this, num_batches, StatusToString(error).c_str());
|
2017
2167
|
}
|
2018
2168
|
CallCombinerClosureList closures;
|
2019
2169
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
|
@@ -2036,20 +2186,18 @@ void ClientChannel::CallData::PendingBatchesFail(
|
|
2036
2186
|
}
|
2037
2187
|
|
2038
2188
|
// This is called via the call combiner, so access to calld is synchronized.
|
2039
|
-
void ClientChannel::
|
2189
|
+
void ClientChannel::FilterBasedCallData::ResumePendingBatchInCallCombiner(
|
2040
2190
|
void* arg, grpc_error_handle /*ignored*/) {
|
2041
2191
|
grpc_transport_stream_op_batch* batch =
|
2042
2192
|
static_cast<grpc_transport_stream_op_batch*>(arg);
|
2043
|
-
auto*
|
2044
|
-
static_cast<
|
2045
|
-
auto* calld = static_cast<CallData*>(elem->call_data);
|
2193
|
+
auto* calld =
|
2194
|
+
static_cast<FilterBasedCallData*>(batch->handler_private.extra_arg);
|
2046
2195
|
// Note: This will release the call combiner.
|
2047
2196
|
calld->dynamic_call_->StartTransportStreamOpBatch(batch);
|
2048
2197
|
}
|
2049
2198
|
|
2050
2199
|
// This is called via the call combiner, so access to calld is synchronized.
|
2051
|
-
void ClientChannel::
|
2052
|
-
ClientChannel* chand = static_cast<ClientChannel*>(elem->channel_data);
|
2200
|
+
void ClientChannel::FilterBasedCallData::PendingBatchesResume() {
|
2053
2201
|
// Retries not enabled; send down batches as-is.
|
2054
2202
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2055
2203
|
size_t num_batches = 0;
|
@@ -2059,13 +2207,13 @@ void ClientChannel::CallData::PendingBatchesResume(grpc_call_element* elem) {
|
|
2059
2207
|
gpr_log(GPR_INFO,
|
2060
2208
|
"chand=%p calld=%p: starting %" PRIuPTR
|
2061
2209
|
" pending batches on dynamic_call=%p",
|
2062
|
-
chand, this, num_batches, dynamic_call_.get());
|
2210
|
+
chand(), this, num_batches, dynamic_call_.get());
|
2063
2211
|
}
|
2064
2212
|
CallCombinerClosureList closures;
|
2065
2213
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
|
2066
2214
|
grpc_transport_stream_op_batch*& batch = pending_batches_[i];
|
2067
2215
|
if (batch != nullptr) {
|
2068
|
-
batch->handler_private.extra_arg =
|
2216
|
+
batch->handler_private.extra_arg = this;
|
2069
2217
|
GRPC_CLOSURE_INIT(&batch->handler_private.closure,
|
2070
2218
|
ResumePendingBatchInCallCombiner, batch, nullptr);
|
2071
2219
|
closures.Add(&batch->handler_private.closure, absl::OkStatus(),
|
@@ -2077,16 +2225,12 @@ void ClientChannel::CallData::PendingBatchesResume(grpc_call_element* elem) {
|
|
2077
2225
|
closures.RunClosures(call_combiner());
|
2078
2226
|
}
|
2079
2227
|
|
2080
|
-
//
|
2081
|
-
// name resolution
|
2082
|
-
//
|
2083
|
-
|
2084
2228
|
// A class to handle the call combiner cancellation callback for a
|
2085
2229
|
// queued pick.
|
2086
|
-
class ClientChannel::
|
2230
|
+
class ClientChannel::FilterBasedCallData::ResolverQueuedCallCanceller {
|
2087
2231
|
public:
|
2088
|
-
explicit ResolverQueuedCallCanceller(
|
2089
|
-
|
2232
|
+
explicit ResolverQueuedCallCanceller(FilterBasedCallData* calld)
|
2233
|
+
: calld_(calld) {
|
2090
2234
|
GRPC_CALL_STACK_REF(calld->owning_call(), "ResolverQueuedCallCanceller");
|
2091
2235
|
GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this,
|
2092
2236
|
grpc_schedule_on_exec_ctx);
|
@@ -2096,8 +2240,8 @@ class ClientChannel::CallData::ResolverQueuedCallCanceller {
|
|
2096
2240
|
private:
|
2097
2241
|
static void CancelLocked(void* arg, grpc_error_handle error) {
|
2098
2242
|
auto* self = static_cast<ResolverQueuedCallCanceller*>(arg);
|
2099
|
-
auto*
|
2100
|
-
auto*
|
2243
|
+
auto* calld = self->calld_;
|
2244
|
+
auto* chand = calld->chand();
|
2101
2245
|
{
|
2102
2246
|
MutexLock lock(&chand->resolution_mu_);
|
2103
2247
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
@@ -2109,9 +2253,10 @@ class ClientChannel::CallData::ResolverQueuedCallCanceller {
|
|
2109
2253
|
}
|
2110
2254
|
if (calld->resolver_call_canceller_ == self && !error.ok()) {
|
2111
2255
|
// Remove pick from list of queued picks.
|
2112
|
-
calld->
|
2256
|
+
calld->RemoveCallFromResolverQueuedCallsLocked();
|
2257
|
+
chand->resolver_queued_calls_.erase(calld);
|
2113
2258
|
// Fail pending batches on the call.
|
2114
|
-
calld->PendingBatchesFail(
|
2259
|
+
calld->PendingBatchesFail(error,
|
2115
2260
|
YieldCallCombinerIfPendingBatchesFound);
|
2116
2261
|
}
|
2117
2262
|
}
|
@@ -2119,115 +2264,71 @@ class ClientChannel::CallData::ResolverQueuedCallCanceller {
|
|
2119
2264
|
delete self;
|
2120
2265
|
}
|
2121
2266
|
|
2122
|
-
|
2267
|
+
FilterBasedCallData* calld_;
|
2123
2268
|
grpc_closure closure_;
|
2124
2269
|
};
|
2125
2270
|
|
2126
|
-
void ClientChannel::
|
2127
|
-
|
2128
|
-
if (
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
}
|
2135
|
-
chand->RemoveResolverQueuedCall(&resolver_queued_call_, pollent_);
|
2136
|
-
queued_pending_resolver_result_ = false;
|
2137
|
-
// Lame the call combiner canceller.
|
2138
|
-
resolver_call_canceller_ = nullptr;
|
2139
|
-
// Add trace annotation
|
2140
|
-
auto* call_tracer =
|
2141
|
-
static_cast<CallTracer*>(call_context_[GRPC_CONTEXT_CALL_TRACER].value);
|
2142
|
-
if (call_tracer != nullptr) {
|
2143
|
-
call_tracer->RecordAnnotation("Delayed name resolution complete.");
|
2271
|
+
void ClientChannel::FilterBasedCallData::TryCheckResolution(bool was_queued) {
|
2272
|
+
auto result = CheckResolution(was_queued);
|
2273
|
+
if (result.has_value()) {
|
2274
|
+
if (!result->ok()) {
|
2275
|
+
PendingBatchesFail(*result, YieldCallCombiner);
|
2276
|
+
return;
|
2277
|
+
}
|
2278
|
+
CreateDynamicCall();
|
2144
2279
|
}
|
2145
2280
|
}
|
2146
2281
|
|
2147
|
-
void ClientChannel::
|
2148
|
-
grpc_call_element* elem) {
|
2149
|
-
if (queued_pending_resolver_result_) return;
|
2150
|
-
auto* chand = static_cast<ClientChannel*>(elem->channel_data);
|
2151
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2152
|
-
gpr_log(GPR_INFO, "chand=%p calld=%p: adding to resolver queued picks list",
|
2153
|
-
chand, this);
|
2154
|
-
}
|
2155
|
-
queued_pending_resolver_result_ = true;
|
2156
|
-
resolver_queued_call_.elem = elem;
|
2157
|
-
chand->AddResolverQueuedCall(&resolver_queued_call_, pollent_);
|
2282
|
+
void ClientChannel::FilterBasedCallData::OnAddToQueueLocked() {
|
2158
2283
|
// Register call combiner cancellation callback.
|
2159
|
-
resolver_call_canceller_ = new ResolverQueuedCallCanceller(
|
2284
|
+
resolver_call_canceller_ = new ResolverQueuedCallCanceller(this);
|
2160
2285
|
}
|
2161
2286
|
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2287
|
+
void ClientChannel::FilterBasedCallData::RetryCheckResolutionLocked() {
|
2288
|
+
// Lame the call combiner canceller.
|
2289
|
+
resolver_call_canceller_ = nullptr;
|
2290
|
+
// Do an async callback to resume call processing, so that we're not
|
2291
|
+
// doing it while holding the channel's resolution mutex.
|
2292
|
+
chand()->owning_stack_->EventEngine()->Run([this]() {
|
2293
|
+
ApplicationCallbackExecCtx application_exec_ctx;
|
2294
|
+
ExecCtx exec_ctx;
|
2295
|
+
TryCheckResolution(/*was_queued=*/true);
|
2296
|
+
});
|
2297
|
+
}
|
2298
|
+
|
2299
|
+
void ClientChannel::FilterBasedCallData::CreateDynamicCall() {
|
2300
|
+
DynamicFilters::Call::Args args = {dynamic_filters(), pollent_, path_,
|
2301
|
+
call_start_time_, deadline_, arena(),
|
2302
|
+
call_context_, call_combiner()};
|
2303
|
+
grpc_error_handle error;
|
2304
|
+
DynamicFilters* channel_stack = args.channel_stack.get();
|
2165
2305
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2166
|
-
gpr_log(
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
}
|
2178
|
-
// Create a ClientChannelServiceConfigCallData for the call. This stores
|
2179
|
-
// a ref to the ServiceConfig and caches the right set of parsed configs
|
2180
|
-
// to use for the call. The ClientChannelServiceConfigCallData will store
|
2181
|
-
// itself in the call context, so that it can be accessed by filters
|
2182
|
-
// below us in the stack, and it will be cleaned up when the call ends.
|
2183
|
-
auto* service_config_call_data =
|
2184
|
-
arena()->New<ClientChannelServiceConfigCallData>(
|
2185
|
-
std::move(call_config->service_config), call_config->method_configs,
|
2186
|
-
std::move(call_config->call_attributes),
|
2187
|
-
call_config->call_dispatch_controller, call_context_);
|
2188
|
-
// Apply our own method params to the call.
|
2189
|
-
auto* method_params = static_cast<ClientChannelMethodParsedConfig*>(
|
2190
|
-
service_config_call_data->GetMethodParsedConfig(
|
2191
|
-
chand->service_config_parser_index_));
|
2192
|
-
if (method_params != nullptr) {
|
2193
|
-
// If the deadline from the service config is shorter than the one
|
2194
|
-
// from the client API, reset the deadline timer.
|
2195
|
-
if (chand->deadline_checking_enabled_ &&
|
2196
|
-
method_params->timeout() != Duration::Zero()) {
|
2197
|
-
const Timestamp per_method_deadline =
|
2198
|
-
Timestamp::FromCycleCounterRoundUp(call_start_time_) +
|
2199
|
-
method_params->timeout();
|
2200
|
-
if (per_method_deadline < deadline_) {
|
2201
|
-
deadline_ = per_method_deadline;
|
2202
|
-
grpc_deadline_state_reset(&deadline_state_, deadline_);
|
2203
|
-
}
|
2204
|
-
}
|
2205
|
-
// If the service config set wait_for_ready and the application
|
2206
|
-
// did not explicitly set it, use the value from the service config.
|
2207
|
-
auto* wait_for_ready =
|
2208
|
-
pending_batches_[0]
|
2209
|
-
->payload->send_initial_metadata.send_initial_metadata
|
2210
|
-
->GetOrCreatePointer(WaitForReady());
|
2211
|
-
if (method_params->wait_for_ready().has_value() &&
|
2212
|
-
!wait_for_ready->explicitly_set) {
|
2213
|
-
wait_for_ready->value = method_params->wait_for_ready().value();
|
2214
|
-
}
|
2306
|
+
gpr_log(
|
2307
|
+
GPR_INFO,
|
2308
|
+
"chand=%p calld=%p: creating dynamic call stack on channel_stack=%p",
|
2309
|
+
chand(), this, channel_stack);
|
2310
|
+
}
|
2311
|
+
dynamic_call_ = channel_stack->CreateCall(std::move(args), &error);
|
2312
|
+
if (!error.ok()) {
|
2313
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2314
|
+
gpr_log(GPR_INFO,
|
2315
|
+
"chand=%p calld=%p: failed to create dynamic call: error=%s",
|
2316
|
+
chand(), this, StatusToString(error).c_str());
|
2215
2317
|
}
|
2216
|
-
|
2217
|
-
|
2318
|
+
PendingBatchesFail(error, YieldCallCombiner);
|
2319
|
+
return;
|
2218
2320
|
}
|
2219
|
-
|
2321
|
+
PendingBatchesResume();
|
2220
2322
|
}
|
2221
2323
|
|
2222
|
-
void ClientChannel::
|
2324
|
+
void ClientChannel::FilterBasedCallData::
|
2223
2325
|
RecvTrailingMetadataReadyForConfigSelectorCommitCallback(
|
2224
2326
|
void* arg, grpc_error_handle error) {
|
2225
|
-
auto*
|
2226
|
-
auto* chand =
|
2227
|
-
auto* calld = static_cast<CallData*>(elem->call_data);
|
2327
|
+
auto* calld = static_cast<FilterBasedCallData*>(arg);
|
2328
|
+
auto* chand = calld->chand();
|
2228
2329
|
auto* service_config_call_data =
|
2229
2330
|
static_cast<ClientChannelServiceConfigCallData*>(
|
2230
|
-
calld->
|
2331
|
+
calld->call_context()[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
|
2231
2332
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2232
2333
|
gpr_log(GPR_INFO,
|
2233
2334
|
"chand=%p calld=%p: got recv_trailing_metadata_ready: error=%s "
|
@@ -2243,145 +2344,24 @@ void ClientChannel::CallData::
|
|
2243
2344
|
error);
|
2244
2345
|
}
|
2245
2346
|
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
GRPC_CLOSURE_INIT(&resolution_done_closure_, ResolutionDone, elem, nullptr);
|
2250
|
-
ExecCtx::Run(DEBUG_LOCATION, &resolution_done_closure_, error);
|
2251
|
-
}
|
2347
|
+
//
|
2348
|
+
// ClientChannel::LoadBalancedCall::LbCallState
|
2349
|
+
//
|
2252
2350
|
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
CallData* calld = static_cast<CallData*>(elem->call_data);
|
2258
|
-
if (!error.ok()) {
|
2259
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2260
|
-
gpr_log(GPR_INFO,
|
2261
|
-
"chand=%p calld=%p: error applying config to call: error=%s",
|
2262
|
-
chand, calld, StatusToString(error).c_str());
|
2263
|
-
}
|
2264
|
-
calld->PendingBatchesFail(elem, error, YieldCallCombiner);
|
2265
|
-
return;
|
2266
|
-
}
|
2267
|
-
calld->CreateDynamicCall(elem);
|
2268
|
-
}
|
2351
|
+
class ClientChannel::LoadBalancedCall::LbCallState
|
2352
|
+
: public ClientChannelLbCallState {
|
2353
|
+
public:
|
2354
|
+
explicit LbCallState(LoadBalancedCall* lb_call) : lb_call_(lb_call) {}
|
2269
2355
|
|
2270
|
-
void
|
2271
|
-
grpc_error_handle error) {
|
2272
|
-
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
2273
|
-
CallData* calld = static_cast<CallData*>(elem->call_data);
|
2274
|
-
ClientChannel* chand = static_cast<ClientChannel*>(elem->channel_data);
|
2275
|
-
bool resolution_complete;
|
2276
|
-
{
|
2277
|
-
MutexLock lock(&chand->resolution_mu_);
|
2278
|
-
resolution_complete = calld->CheckResolutionLocked(elem, &error);
|
2279
|
-
}
|
2280
|
-
if (resolution_complete) {
|
2281
|
-
ResolutionDone(elem, error);
|
2282
|
-
}
|
2283
|
-
}
|
2356
|
+
void* Alloc(size_t size) override { return lb_call_->arena()->Alloc(size); }
|
2284
2357
|
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
// If we're still in IDLE, we need to start resolving.
|
2289
|
-
if (GPR_UNLIKELY(chand->CheckConnectivityState(false) == GRPC_CHANNEL_IDLE)) {
|
2290
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2291
|
-
gpr_log(GPR_INFO, "chand=%p calld=%p: triggering exit idle", chand, this);
|
2292
|
-
}
|
2293
|
-
// Bounce into the control plane work serializer to start resolving,
|
2294
|
-
// in case we are still in IDLE state. Since we are holding on to the
|
2295
|
-
// resolution mutex here, we offload it on the ExecCtx so that we don't
|
2296
|
-
// deadlock with ourselves.
|
2297
|
-
GRPC_CHANNEL_STACK_REF(chand->owning_stack_, "CheckResolutionLocked");
|
2298
|
-
ExecCtx::Run(
|
2299
|
-
DEBUG_LOCATION,
|
2300
|
-
GRPC_CLOSURE_CREATE(
|
2301
|
-
[](void* arg, grpc_error_handle /*error*/) {
|
2302
|
-
auto* chand = static_cast<ClientChannel*>(arg);
|
2303
|
-
chand->work_serializer_->Run(
|
2304
|
-
[chand]()
|
2305
|
-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(*chand->work_serializer_) {
|
2306
|
-
chand->CheckConnectivityState(/*try_to_connect=*/true);
|
2307
|
-
GRPC_CHANNEL_STACK_UNREF(chand->owning_stack_,
|
2308
|
-
"CheckResolutionLocked");
|
2309
|
-
},
|
2310
|
-
DEBUG_LOCATION);
|
2311
|
-
},
|
2312
|
-
chand, nullptr),
|
2313
|
-
absl::OkStatus());
|
2314
|
-
}
|
2315
|
-
// Get send_initial_metadata batch and flags.
|
2316
|
-
auto& send_initial_metadata =
|
2317
|
-
pending_batches_[0]->payload->send_initial_metadata;
|
2318
|
-
grpc_metadata_batch* initial_metadata_batch =
|
2319
|
-
send_initial_metadata.send_initial_metadata;
|
2320
|
-
// If we don't yet have a resolver result, we need to queue the call
|
2321
|
-
// until we get one.
|
2322
|
-
if (GPR_UNLIKELY(!chand->received_service_config_data_)) {
|
2323
|
-
// If the resolver returned transient failure before returning the
|
2324
|
-
// first service config, fail any non-wait_for_ready calls.
|
2325
|
-
absl::Status resolver_error = chand->resolver_transient_failure_error_;
|
2326
|
-
if (!resolver_error.ok() &&
|
2327
|
-
!initial_metadata_batch->GetOrCreatePointer(WaitForReady())->value) {
|
2328
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2329
|
-
gpr_log(GPR_INFO, "chand=%p calld=%p: resolution failed, failing call",
|
2330
|
-
chand, this);
|
2331
|
-
}
|
2332
|
-
MaybeRemoveCallFromResolverQueuedCallsLocked(elem);
|
2333
|
-
*error = absl_status_to_grpc_error(resolver_error);
|
2334
|
-
return true;
|
2335
|
-
}
|
2336
|
-
// Either the resolver has not yet returned a result, or it has
|
2337
|
-
// returned transient failure but the call is wait_for_ready. In
|
2338
|
-
// either case, queue the call.
|
2339
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2340
|
-
gpr_log(GPR_INFO, "chand=%p calld=%p: queuing to wait for resolution",
|
2341
|
-
chand, this);
|
2342
|
-
}
|
2343
|
-
MaybeAddCallToResolverQueuedCallsLocked(elem);
|
2344
|
-
return false;
|
2345
|
-
}
|
2346
|
-
// Apply service config to call if not yet applied.
|
2347
|
-
if (GPR_LIKELY(!service_config_applied_)) {
|
2348
|
-
service_config_applied_ = true;
|
2349
|
-
*error = ApplyServiceConfigToCallLocked(elem, initial_metadata_batch);
|
2350
|
-
}
|
2351
|
-
MaybeRemoveCallFromResolverQueuedCallsLocked(elem);
|
2352
|
-
return true;
|
2353
|
-
}
|
2358
|
+
// Internal API to allow first-party LB policies to access per-call
|
2359
|
+
// attributes set by the ConfigSelector.
|
2360
|
+
absl::string_view GetCallAttribute(UniqueTypeName type) override;
|
2354
2361
|
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2358
|
-
pollent_,
|
2359
|
-
path_,
|
2360
|
-
call_start_time_,
|
2361
|
-
deadline_,
|
2362
|
-
arena(),
|
2363
|
-
call_context_,
|
2364
|
-
call_combiner()};
|
2365
|
-
grpc_error_handle error;
|
2366
|
-
DynamicFilters* channel_stack = args.channel_stack.get();
|
2367
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2368
|
-
gpr_log(
|
2369
|
-
GPR_INFO,
|
2370
|
-
"chand=%p calld=%p: creating dynamic call stack on channel_stack=%p",
|
2371
|
-
chand, this, channel_stack);
|
2372
|
-
}
|
2373
|
-
dynamic_call_ = channel_stack->CreateCall(std::move(args), &error);
|
2374
|
-
if (!error.ok()) {
|
2375
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
|
2376
|
-
gpr_log(GPR_INFO,
|
2377
|
-
"chand=%p calld=%p: failed to create dynamic call: error=%s",
|
2378
|
-
chand, this, StatusToString(error).c_str());
|
2379
|
-
}
|
2380
|
-
PendingBatchesFail(elem, error, YieldCallCombiner);
|
2381
|
-
return;
|
2382
|
-
}
|
2383
|
-
PendingBatchesResume(elem);
|
2384
|
-
}
|
2362
|
+
private:
|
2363
|
+
LoadBalancedCall* lb_call_;
|
2364
|
+
};
|
2385
2365
|
|
2386
2366
|
//
|
2387
2367
|
// ClientChannel::LoadBalancedCall::Metadata
|
@@ -2466,7 +2446,7 @@ absl::string_view
|
|
2466
2446
|
ClientChannel::LoadBalancedCall::LbCallState::GetCallAttribute(
|
2467
2447
|
UniqueTypeName type) {
|
2468
2448
|
auto* service_config_call_data = static_cast<ServiceConfigCallData*>(
|
2469
|
-
lb_call_->
|
2449
|
+
lb_call_->call_context()[GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA].value);
|
2470
2450
|
auto& call_attributes = service_config_call_data->call_attributes();
|
2471
2451
|
auto it = call_attributes.find(type);
|
2472
2452
|
if (it == call_attributes.end()) return absl::string_view();
|
@@ -2480,15 +2460,16 @@ ClientChannel::LoadBalancedCall::LbCallState::GetCallAttribute(
|
|
2480
2460
|
class ClientChannel::LoadBalancedCall::BackendMetricAccessor
|
2481
2461
|
: public LoadBalancingPolicy::BackendMetricAccessor {
|
2482
2462
|
public:
|
2483
|
-
|
2484
|
-
|
2463
|
+
BackendMetricAccessor(LoadBalancedCall* lb_call,
|
2464
|
+
grpc_metadata_batch* recv_trailing_metadata)
|
2465
|
+
: lb_call_(lb_call), recv_trailing_metadata_(recv_trailing_metadata) {}
|
2485
2466
|
|
2486
2467
|
const BackendMetricData* GetBackendMetricData() override {
|
2487
2468
|
if (lb_call_->backend_metric_data_ == nullptr &&
|
2488
|
-
|
2489
|
-
if (const auto* md =
|
2469
|
+
recv_trailing_metadata_ != nullptr) {
|
2470
|
+
if (const auto* md = recv_trailing_metadata_->get_pointer(
|
2490
2471
|
EndpointLoadMetricsBinMetadata())) {
|
2491
|
-
BackendMetricAllocator allocator(lb_call_->
|
2472
|
+
BackendMetricAllocator allocator(lb_call_->arena());
|
2492
2473
|
lb_call_->backend_metric_data_ =
|
2493
2474
|
ParseBackendMetricData(md->as_string_view(), &allocator);
|
2494
2475
|
}
|
@@ -2514,6 +2495,7 @@ class ClientChannel::LoadBalancedCall::BackendMetricAccessor
|
|
2514
2495
|
};
|
2515
2496
|
|
2516
2497
|
LoadBalancedCall* lb_call_;
|
2498
|
+
grpc_metadata_batch* recv_trailing_metadata_;
|
2517
2499
|
};
|
2518
2500
|
|
2519
2501
|
//
|
@@ -2522,19 +2504,20 @@ class ClientChannel::LoadBalancedCall::BackendMetricAccessor
|
|
2522
2504
|
|
2523
2505
|
namespace {
|
2524
2506
|
|
2525
|
-
|
2507
|
+
ClientCallTracer::CallAttemptTracer* CreateCallAttemptTracer(
|
2526
2508
|
grpc_call_context_element* context, bool is_transparent_retry) {
|
2527
|
-
auto* call_tracer =
|
2528
|
-
|
2509
|
+
auto* call_tracer = static_cast<ClientCallTracer*>(
|
2510
|
+
context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value);
|
2529
2511
|
if (call_tracer == nullptr) return nullptr;
|
2530
|
-
|
2512
|
+
auto* tracer = call_tracer->StartNewAttempt(is_transparent_retry);
|
2513
|
+
context[GRPC_CONTEXT_CALL_TRACER].value = tracer;
|
2514
|
+
return tracer;
|
2531
2515
|
}
|
2532
2516
|
|
2533
2517
|
} // namespace
|
2534
2518
|
|
2535
2519
|
ClientChannel::LoadBalancedCall::LoadBalancedCall(
|
2536
|
-
ClientChannel* chand,
|
2537
|
-
grpc_polling_entity* pollent, grpc_closure* on_call_destruction_complete,
|
2520
|
+
ClientChannel* chand, grpc_call_context_element* call_context,
|
2538
2521
|
ConfigSelector::CallDispatchController* call_dispatch_controller,
|
2539
2522
|
bool is_transparent_retry)
|
2540
2523
|
: InternallyRefCounted(
|
@@ -2542,17 +2525,8 @@ ClientChannel::LoadBalancedCall::LoadBalancedCall(
|
|
2542
2525
|
? "LoadBalancedCall"
|
2543
2526
|
: nullptr),
|
2544
2527
|
chand_(chand),
|
2545
|
-
|
2546
|
-
|
2547
|
-
arena_(args.arena),
|
2548
|
-
owning_call_(args.call_stack),
|
2549
|
-
call_combiner_(args.call_combiner),
|
2550
|
-
call_context_(args.context),
|
2551
|
-
pollent_(pollent),
|
2552
|
-
on_call_destruction_complete_(on_call_destruction_complete),
|
2553
|
-
call_dispatch_controller_(call_dispatch_controller),
|
2554
|
-
call_attempt_tracer_(
|
2555
|
-
GetCallAttemptTracer(args.context, is_transparent_retry)) {
|
2528
|
+
call_dispatch_controller_(call_dispatch_controller) {
|
2529
|
+
CreateCallAttemptTracer(call_context, is_transparent_retry);
|
2556
2530
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2557
2531
|
gpr_log(GPR_INFO, "chand=%p lb_call=%p: created", chand_, this);
|
2558
2532
|
}
|
@@ -2562,6 +2536,245 @@ ClientChannel::LoadBalancedCall::~LoadBalancedCall() {
|
|
2562
2536
|
if (backend_metric_data_ != nullptr) {
|
2563
2537
|
backend_metric_data_->BackendMetricData::~BackendMetricData();
|
2564
2538
|
}
|
2539
|
+
}
|
2540
|
+
|
2541
|
+
void ClientChannel::LoadBalancedCall::Orphan() {
|
2542
|
+
// Compute latency and report it to the tracer.
|
2543
|
+
if (call_attempt_tracer() != nullptr) {
|
2544
|
+
gpr_timespec latency =
|
2545
|
+
gpr_cycle_counter_sub(gpr_get_cycle_counter(), lb_call_start_time_);
|
2546
|
+
call_attempt_tracer()->RecordEnd(latency);
|
2547
|
+
}
|
2548
|
+
Unref();
|
2549
|
+
}
|
2550
|
+
|
2551
|
+
void ClientChannel::LoadBalancedCall::RecordCallCompletion(
|
2552
|
+
absl::Status status, grpc_metadata_batch* recv_trailing_metadata,
|
2553
|
+
grpc_transport_stream_stats* transport_stream_stats,
|
2554
|
+
absl::string_view peer_address) {
|
2555
|
+
// If we have a tracer, notify it.
|
2556
|
+
if (call_attempt_tracer() != nullptr) {
|
2557
|
+
call_attempt_tracer()->RecordReceivedTrailingMetadata(
|
2558
|
+
status, recv_trailing_metadata, transport_stream_stats);
|
2559
|
+
}
|
2560
|
+
// If the LB policy requested a callback for trailing metadata, invoke
|
2561
|
+
// the callback.
|
2562
|
+
if (lb_subchannel_call_tracker_ != nullptr) {
|
2563
|
+
Metadata trailing_metadata(recv_trailing_metadata);
|
2564
|
+
BackendMetricAccessor backend_metric_accessor(this, recv_trailing_metadata);
|
2565
|
+
LoadBalancingPolicy::SubchannelCallTrackerInterface::FinishArgs args = {
|
2566
|
+
peer_address, status, &trailing_metadata, &backend_metric_accessor};
|
2567
|
+
lb_subchannel_call_tracker_->Finish(args);
|
2568
|
+
lb_subchannel_call_tracker_.reset();
|
2569
|
+
}
|
2570
|
+
}
|
2571
|
+
|
2572
|
+
void ClientChannel::LoadBalancedCall::RemoveCallFromLbQueuedCallsLocked() {
|
2573
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2574
|
+
gpr_log(GPR_INFO, "chand=%p lb_call=%p: removing from queued picks list",
|
2575
|
+
chand_, this);
|
2576
|
+
}
|
2577
|
+
// Remove pollset_set linkage.
|
2578
|
+
grpc_polling_entity_del_from_pollset_set(pollent(),
|
2579
|
+
chand_->interested_parties_);
|
2580
|
+
// Note: There's no need to actually remove the call from the queue
|
2581
|
+
// here, beacuse that will be done in either
|
2582
|
+
// LbQueuedCallCanceller::CancelLocked() or
|
2583
|
+
// in ClientChannel::UpdateStateAndPickerLocked().
|
2584
|
+
}
|
2585
|
+
|
2586
|
+
void ClientChannel::LoadBalancedCall::AddCallToLbQueuedCallsLocked() {
|
2587
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2588
|
+
gpr_log(GPR_INFO, "chand=%p lb_call=%p: adding to queued picks list",
|
2589
|
+
chand_, this);
|
2590
|
+
}
|
2591
|
+
// Add call's pollent to channel's interested_parties, so that I/O
|
2592
|
+
// can be done under the call's CQ.
|
2593
|
+
grpc_polling_entity_add_to_pollset_set(pollent(),
|
2594
|
+
chand_->interested_parties_);
|
2595
|
+
// Add to queue.
|
2596
|
+
chand_->lb_queued_calls_.insert(this);
|
2597
|
+
OnAddToQueueLocked();
|
2598
|
+
}
|
2599
|
+
|
2600
|
+
absl::optional<absl::Status> ClientChannel::LoadBalancedCall::PickSubchannel(
|
2601
|
+
bool was_queued) {
|
2602
|
+
// We may accumulate multiple pickers here, because if a picker says
|
2603
|
+
// to queue the call, we check again to see if the picker has been
|
2604
|
+
// updated before we queue it.
|
2605
|
+
// We need to unref pickers in the WorkSerializer.
|
2606
|
+
std::vector<RefCountedPtr<LoadBalancingPolicy::SubchannelPicker>> pickers;
|
2607
|
+
auto cleanup = absl::MakeCleanup([&]() {
|
2608
|
+
chand_->work_serializer_->Run(
|
2609
|
+
[pickers = std::move(pickers)]() mutable {
|
2610
|
+
for (auto& picker : pickers) {
|
2611
|
+
picker.reset(DEBUG_LOCATION, "PickSubchannel");
|
2612
|
+
}
|
2613
|
+
},
|
2614
|
+
DEBUG_LOCATION);
|
2615
|
+
});
|
2616
|
+
// Grab mutex and take a ref to the picker.
|
2617
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2618
|
+
gpr_log(GPR_INFO, "chand=%p lb_call=%p: grabbing LB mutex to get picker",
|
2619
|
+
chand_, this);
|
2620
|
+
}
|
2621
|
+
{
|
2622
|
+
MutexLock lock(&chand_->lb_mu_);
|
2623
|
+
pickers.emplace_back(chand_->picker_);
|
2624
|
+
}
|
2625
|
+
while (true) {
|
2626
|
+
// Do pick.
|
2627
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2628
|
+
gpr_log(GPR_INFO, "chand=%p lb_call=%p: performing pick with picker=%p",
|
2629
|
+
chand_, this, pickers.back().get());
|
2630
|
+
}
|
2631
|
+
grpc_error_handle error;
|
2632
|
+
bool pick_complete = PickSubchannelImpl(pickers.back().get(), &error);
|
2633
|
+
if (!pick_complete) {
|
2634
|
+
MutexLock lock(&chand_->lb_mu_);
|
2635
|
+
// If picker has been swapped out since we grabbed it, try again.
|
2636
|
+
if (chand_->picker_ != pickers.back()) {
|
2637
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2638
|
+
gpr_log(GPR_INFO,
|
2639
|
+
"chand=%p lb_call=%p: pick not complete, but picker changed",
|
2640
|
+
chand_, this);
|
2641
|
+
}
|
2642
|
+
pickers.emplace_back(chand_->picker_);
|
2643
|
+
continue;
|
2644
|
+
}
|
2645
|
+
// Otherwise queue the pick to try again later when we get a new picker.
|
2646
|
+
AddCallToLbQueuedCallsLocked();
|
2647
|
+
return absl::nullopt;
|
2648
|
+
}
|
2649
|
+
// Pick is complete.
|
2650
|
+
// If it was queued, add a trace annotation.
|
2651
|
+
if (was_queued && call_attempt_tracer() != nullptr) {
|
2652
|
+
call_attempt_tracer()->RecordAnnotation("Delayed LB pick complete.");
|
2653
|
+
}
|
2654
|
+
// If the pick failed, fail the call.
|
2655
|
+
if (!error.ok()) {
|
2656
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2657
|
+
gpr_log(GPR_INFO,
|
2658
|
+
"chand=%p lb_call=%p: failed to pick subchannel: error=%s",
|
2659
|
+
chand_, this, StatusToString(error).c_str());
|
2660
|
+
}
|
2661
|
+
return error;
|
2662
|
+
}
|
2663
|
+
// Pick succeeded.
|
2664
|
+
call_dispatch_controller_->Commit();
|
2665
|
+
return absl::OkStatus();
|
2666
|
+
}
|
2667
|
+
}
|
2668
|
+
|
2669
|
+
bool ClientChannel::LoadBalancedCall::PickSubchannelImpl(
|
2670
|
+
LoadBalancingPolicy::SubchannelPicker* picker, grpc_error_handle* error) {
|
2671
|
+
GPR_ASSERT(connected_subchannel_ == nullptr);
|
2672
|
+
// Perform LB pick.
|
2673
|
+
LoadBalancingPolicy::PickArgs pick_args;
|
2674
|
+
Slice* path = send_initial_metadata()->get_pointer(HttpPathMetadata());
|
2675
|
+
GPR_ASSERT(path != nullptr);
|
2676
|
+
pick_args.path = path->as_string_view();
|
2677
|
+
LbCallState lb_call_state(this);
|
2678
|
+
pick_args.call_state = &lb_call_state;
|
2679
|
+
Metadata initial_metadata(send_initial_metadata());
|
2680
|
+
pick_args.initial_metadata = &initial_metadata;
|
2681
|
+
auto result = picker->Pick(pick_args);
|
2682
|
+
return HandlePickResult<bool>(
|
2683
|
+
&result,
|
2684
|
+
// CompletePick
|
2685
|
+
[this](LoadBalancingPolicy::PickResult::Complete* complete_pick) {
|
2686
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2687
|
+
gpr_log(GPR_INFO,
|
2688
|
+
"chand=%p lb_call=%p: LB pick succeeded: subchannel=%p",
|
2689
|
+
chand_, this, complete_pick->subchannel.get());
|
2690
|
+
}
|
2691
|
+
GPR_ASSERT(complete_pick->subchannel != nullptr);
|
2692
|
+
// Grab a ref to the connected subchannel while we're still
|
2693
|
+
// holding the data plane mutex.
|
2694
|
+
SubchannelWrapper* subchannel =
|
2695
|
+
static_cast<SubchannelWrapper*>(complete_pick->subchannel.get());
|
2696
|
+
connected_subchannel_ = subchannel->connected_subchannel();
|
2697
|
+
// If the subchannel has no connected subchannel (e.g., if the
|
2698
|
+
// subchannel has moved out of state READY but the LB policy hasn't
|
2699
|
+
// yet seen that change and given us a new picker), then just
|
2700
|
+
// queue the pick. We'll try again as soon as we get a new picker.
|
2701
|
+
if (connected_subchannel_ == nullptr) {
|
2702
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2703
|
+
gpr_log(GPR_INFO,
|
2704
|
+
"chand=%p lb_call=%p: subchannel returned by LB picker "
|
2705
|
+
"has no connected subchannel; queueing pick",
|
2706
|
+
chand_, this);
|
2707
|
+
}
|
2708
|
+
return false;
|
2709
|
+
}
|
2710
|
+
lb_subchannel_call_tracker_ =
|
2711
|
+
std::move(complete_pick->subchannel_call_tracker);
|
2712
|
+
if (lb_subchannel_call_tracker_ != nullptr) {
|
2713
|
+
lb_subchannel_call_tracker_->Start();
|
2714
|
+
}
|
2715
|
+
return true;
|
2716
|
+
},
|
2717
|
+
// QueuePick
|
2718
|
+
[this](LoadBalancingPolicy::PickResult::Queue* /*queue_pick*/) {
|
2719
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2720
|
+
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick queued", chand_,
|
2721
|
+
this);
|
2722
|
+
}
|
2723
|
+
return false;
|
2724
|
+
},
|
2725
|
+
// FailPick
|
2726
|
+
[this, &error](LoadBalancingPolicy::PickResult::Fail* fail_pick) {
|
2727
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2728
|
+
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick failed: %s", chand_,
|
2729
|
+
this, fail_pick->status.ToString().c_str());
|
2730
|
+
}
|
2731
|
+
// If wait_for_ready is false, then the error indicates the RPC
|
2732
|
+
// attempt's final status.
|
2733
|
+
if (!send_initial_metadata()
|
2734
|
+
->GetOrCreatePointer(WaitForReady())
|
2735
|
+
->value) {
|
2736
|
+
*error = absl_status_to_grpc_error(MaybeRewriteIllegalStatusCode(
|
2737
|
+
std::move(fail_pick->status), "LB pick"));
|
2738
|
+
return true;
|
2739
|
+
}
|
2740
|
+
// If wait_for_ready is true, then queue to retry when we get a new
|
2741
|
+
// picker.
|
2742
|
+
return false;
|
2743
|
+
},
|
2744
|
+
// DropPick
|
2745
|
+
[this, &error](LoadBalancingPolicy::PickResult::Drop* drop_pick) {
|
2746
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2747
|
+
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick dropped: %s", chand_,
|
2748
|
+
this, drop_pick->status.ToString().c_str());
|
2749
|
+
}
|
2750
|
+
*error = grpc_error_set_int(
|
2751
|
+
absl_status_to_grpc_error(MaybeRewriteIllegalStatusCode(
|
2752
|
+
std::move(drop_pick->status), "LB drop")),
|
2753
|
+
StatusIntProperty::kLbPolicyDrop, 1);
|
2754
|
+
return true;
|
2755
|
+
});
|
2756
|
+
}
|
2757
|
+
|
2758
|
+
//
|
2759
|
+
// ClientChannel::FilterBasedLoadBalancedCall
|
2760
|
+
//
|
2761
|
+
|
2762
|
+
ClientChannel::FilterBasedLoadBalancedCall::FilterBasedLoadBalancedCall(
|
2763
|
+
ClientChannel* chand, const grpc_call_element_args& args,
|
2764
|
+
grpc_polling_entity* pollent, grpc_closure* on_call_destruction_complete,
|
2765
|
+
ConfigSelector::CallDispatchController* call_dispatch_controller,
|
2766
|
+
bool is_transparent_retry)
|
2767
|
+
: LoadBalancedCall(chand, args.context, call_dispatch_controller,
|
2768
|
+
is_transparent_retry),
|
2769
|
+
deadline_(args.deadline),
|
2770
|
+
arena_(args.arena),
|
2771
|
+
call_context_(args.context),
|
2772
|
+
owning_call_(args.call_stack),
|
2773
|
+
call_combiner_(args.call_combiner),
|
2774
|
+
pollent_(pollent),
|
2775
|
+
on_call_destruction_complete_(on_call_destruction_complete) {}
|
2776
|
+
|
2777
|
+
ClientChannel::FilterBasedLoadBalancedCall::~FilterBasedLoadBalancedCall() {
|
2565
2778
|
// Make sure there are no remaining pending batches.
|
2566
2779
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
|
2567
2780
|
GPR_ASSERT(pending_batches_[i] == nullptr);
|
@@ -2572,26 +2785,22 @@ ClientChannel::LoadBalancedCall::~LoadBalancedCall() {
|
|
2572
2785
|
}
|
2573
2786
|
}
|
2574
2787
|
|
2575
|
-
void ClientChannel::
|
2788
|
+
void ClientChannel::FilterBasedLoadBalancedCall::Orphan() {
|
2576
2789
|
// If the recv_trailing_metadata op was never started, then notify
|
2577
2790
|
// about call completion here, as best we can. We assume status
|
2578
2791
|
// CANCELLED in this case.
|
2579
2792
|
if (recv_trailing_metadata_ == nullptr) {
|
2580
|
-
RecordCallCompletion(absl::CancelledError("call cancelled")
|
2793
|
+
RecordCallCompletion(absl::CancelledError("call cancelled"), nullptr,
|
2794
|
+
nullptr, "");
|
2581
2795
|
}
|
2582
|
-
//
|
2583
|
-
|
2584
|
-
gpr_timespec latency =
|
2585
|
-
gpr_cycle_counter_sub(gpr_get_cycle_counter(), lb_call_start_time_);
|
2586
|
-
call_attempt_tracer_->RecordEnd(latency);
|
2587
|
-
}
|
2588
|
-
Unref();
|
2796
|
+
// Delegate to parent.
|
2797
|
+
LoadBalancedCall::Orphan();
|
2589
2798
|
}
|
2590
2799
|
|
2591
|
-
size_t ClientChannel::
|
2800
|
+
size_t ClientChannel::FilterBasedLoadBalancedCall::GetBatchIndex(
|
2592
2801
|
grpc_transport_stream_op_batch* batch) {
|
2593
2802
|
// Note: It is important the send_initial_metadata be the first entry
|
2594
|
-
// here, since the code in
|
2803
|
+
// here, since the code in PickSubchannelImpl() assumes it will be.
|
2595
2804
|
if (batch->send_initial_metadata) return 0;
|
2596
2805
|
if (batch->send_message) return 1;
|
2597
2806
|
if (batch->send_trailing_metadata) return 2;
|
@@ -2602,31 +2811,32 @@ size_t ClientChannel::LoadBalancedCall::GetBatchIndex(
|
|
2602
2811
|
}
|
2603
2812
|
|
2604
2813
|
// This is called via the call combiner, so access to calld is synchronized.
|
2605
|
-
void ClientChannel::
|
2814
|
+
void ClientChannel::FilterBasedLoadBalancedCall::PendingBatchesAdd(
|
2606
2815
|
grpc_transport_stream_op_batch* batch) {
|
2607
2816
|
const size_t idx = GetBatchIndex(batch);
|
2608
2817
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2609
2818
|
gpr_log(GPR_INFO,
|
2610
2819
|
"chand=%p lb_call=%p: adding pending batch at index %" PRIuPTR,
|
2611
|
-
|
2820
|
+
chand(), this, idx);
|
2612
2821
|
}
|
2613
2822
|
GPR_ASSERT(pending_batches_[idx] == nullptr);
|
2614
2823
|
pending_batches_[idx] = batch;
|
2615
2824
|
}
|
2616
2825
|
|
2617
2826
|
// This is called via the call combiner, so access to calld is synchronized.
|
2618
|
-
void ClientChannel::
|
2827
|
+
void ClientChannel::FilterBasedLoadBalancedCall::FailPendingBatchInCallCombiner(
|
2619
2828
|
void* arg, grpc_error_handle error) {
|
2620
2829
|
grpc_transport_stream_op_batch* batch =
|
2621
2830
|
static_cast<grpc_transport_stream_op_batch*>(arg);
|
2622
|
-
auto* self = static_cast<
|
2831
|
+
auto* self = static_cast<FilterBasedLoadBalancedCall*>(
|
2832
|
+
batch->handler_private.extra_arg);
|
2623
2833
|
// Note: This will release the call combiner.
|
2624
2834
|
grpc_transport_stream_op_batch_finish_with_failure(batch, error,
|
2625
2835
|
self->call_combiner_);
|
2626
2836
|
}
|
2627
2837
|
|
2628
2838
|
// This is called via the call combiner, so access to calld is synchronized.
|
2629
|
-
void ClientChannel::
|
2839
|
+
void ClientChannel::FilterBasedLoadBalancedCall::PendingBatchesFail(
|
2630
2840
|
grpc_error_handle error,
|
2631
2841
|
YieldCallCombinerPredicate yield_call_combiner_predicate) {
|
2632
2842
|
GPR_ASSERT(!error.ok());
|
@@ -2638,7 +2848,7 @@ void ClientChannel::LoadBalancedCall::PendingBatchesFail(
|
|
2638
2848
|
}
|
2639
2849
|
gpr_log(GPR_INFO,
|
2640
2850
|
"chand=%p lb_call=%p: failing %" PRIuPTR " pending batches: %s",
|
2641
|
-
|
2851
|
+
chand(), this, num_batches, StatusToString(error).c_str());
|
2642
2852
|
}
|
2643
2853
|
CallCombinerClosureList closures;
|
2644
2854
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
|
@@ -2661,8 +2871,8 @@ void ClientChannel::LoadBalancedCall::PendingBatchesFail(
|
|
2661
2871
|
}
|
2662
2872
|
|
2663
2873
|
// This is called via the call combiner, so access to calld is synchronized.
|
2664
|
-
void ClientChannel::
|
2665
|
-
void* arg, grpc_error_handle /*ignored*/) {
|
2874
|
+
void ClientChannel::FilterBasedLoadBalancedCall::
|
2875
|
+
ResumePendingBatchInCallCombiner(void* arg, grpc_error_handle /*ignored*/) {
|
2666
2876
|
grpc_transport_stream_op_batch* batch =
|
2667
2877
|
static_cast<grpc_transport_stream_op_batch*>(arg);
|
2668
2878
|
SubchannelCall* subchannel_call =
|
@@ -2672,7 +2882,7 @@ void ClientChannel::LoadBalancedCall::ResumePendingBatchInCallCombiner(
|
|
2672
2882
|
}
|
2673
2883
|
|
2674
2884
|
// This is called via the call combiner, so access to calld is synchronized.
|
2675
|
-
void ClientChannel::
|
2885
|
+
void ClientChannel::FilterBasedLoadBalancedCall::PendingBatchesResume() {
|
2676
2886
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2677
2887
|
size_t num_batches = 0;
|
2678
2888
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
|
@@ -2681,7 +2891,7 @@ void ClientChannel::LoadBalancedCall::PendingBatchesResume() {
|
|
2681
2891
|
gpr_log(GPR_INFO,
|
2682
2892
|
"chand=%p lb_call=%p: starting %" PRIuPTR
|
2683
2893
|
" pending batches on subchannel_call=%p",
|
2684
|
-
|
2894
|
+
chand(), this, num_batches, subchannel_call_.get());
|
2685
2895
|
}
|
2686
2896
|
CallCombinerClosureList closures;
|
2687
2897
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
|
@@ -2700,38 +2910,30 @@ void ClientChannel::LoadBalancedCall::PendingBatchesResume() {
|
|
2700
2910
|
closures.RunClosures(call_combiner_);
|
2701
2911
|
}
|
2702
2912
|
|
2703
|
-
void ClientChannel::
|
2913
|
+
void ClientChannel::FilterBasedLoadBalancedCall::StartTransportStreamOpBatch(
|
2704
2914
|
grpc_transport_stream_op_batch* batch) {
|
2705
2915
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace) ||
|
2706
2916
|
GRPC_TRACE_FLAG_ENABLED(grpc_trace_channel)) {
|
2707
2917
|
gpr_log(GPR_INFO,
|
2708
2918
|
"chand=%p lb_call=%p: batch started from above: %s, "
|
2709
|
-
"
|
2710
|
-
|
2711
|
-
|
2919
|
+
"call_attempt_tracer()=%p",
|
2920
|
+
chand(), this,
|
2921
|
+
grpc_transport_stream_op_batch_string(batch, false).c_str(),
|
2922
|
+
call_attempt_tracer());
|
2712
2923
|
}
|
2713
2924
|
// Handle call tracing.
|
2714
|
-
if (
|
2925
|
+
if (call_attempt_tracer() != nullptr) {
|
2715
2926
|
// Record send ops in tracer.
|
2716
2927
|
if (batch->cancel_stream) {
|
2717
|
-
|
2928
|
+
call_attempt_tracer()->RecordCancel(
|
2718
2929
|
batch->payload->cancel_stream.cancel_error);
|
2719
2930
|
}
|
2720
2931
|
if (batch->send_initial_metadata) {
|
2721
|
-
|
2932
|
+
call_attempt_tracer()->RecordSendInitialMetadata(
|
2722
2933
|
batch->payload->send_initial_metadata.send_initial_metadata);
|
2723
|
-
peer_string_ = batch->payload->send_initial_metadata.peer_string;
|
2724
|
-
original_send_initial_metadata_on_complete_ = batch->on_complete;
|
2725
|
-
GRPC_CLOSURE_INIT(&send_initial_metadata_on_complete_,
|
2726
|
-
SendInitialMetadataOnComplete, this, nullptr);
|
2727
|
-
batch->on_complete = &send_initial_metadata_on_complete_;
|
2728
|
-
}
|
2729
|
-
if (batch->send_message) {
|
2730
|
-
call_attempt_tracer_->RecordSendMessage(
|
2731
|
-
*batch->payload->send_message.send_message);
|
2732
2934
|
}
|
2733
2935
|
if (batch->send_trailing_metadata) {
|
2734
|
-
|
2936
|
+
call_attempt_tracer()->RecordSendTrailingMetadata(
|
2735
2937
|
batch->payload->send_trailing_metadata.send_trailing_metadata);
|
2736
2938
|
}
|
2737
2939
|
// Intercept recv ops.
|
@@ -2745,13 +2947,6 @@ void ClientChannel::LoadBalancedCall::StartTransportStreamOpBatch(
|
|
2745
2947
|
batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
|
2746
2948
|
&recv_initial_metadata_ready_;
|
2747
2949
|
}
|
2748
|
-
if (batch->recv_message) {
|
2749
|
-
recv_message_ = batch->payload->recv_message.recv_message;
|
2750
|
-
original_recv_message_ready_ =
|
2751
|
-
batch->payload->recv_message.recv_message_ready;
|
2752
|
-
GRPC_CLOSURE_INIT(&recv_message_ready_, RecvMessageReady, this, nullptr);
|
2753
|
-
batch->payload->recv_message.recv_message_ready = &recv_message_ready_;
|
2754
|
-
}
|
2755
2950
|
}
|
2756
2951
|
// Intercept recv_trailing_metadata even if there is no call tracer,
|
2757
2952
|
// since we may need to notify the LB policy about trailing metadata.
|
@@ -2775,7 +2970,7 @@ void ClientChannel::LoadBalancedCall::StartTransportStreamOpBatch(
|
|
2775
2970
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2776
2971
|
gpr_log(GPR_INFO,
|
2777
2972
|
"chand=%p lb_call=%p: starting batch on subchannel_call=%p",
|
2778
|
-
|
2973
|
+
chand(), this, subchannel_call_.get());
|
2779
2974
|
}
|
2780
2975
|
subchannel_call_->StartTransportStreamOpBatch(batch);
|
2781
2976
|
return;
|
@@ -2786,7 +2981,7 @@ void ClientChannel::LoadBalancedCall::StartTransportStreamOpBatch(
|
|
2786
2981
|
if (GPR_UNLIKELY(!cancel_error_.ok())) {
|
2787
2982
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2788
2983
|
gpr_log(GPR_INFO, "chand=%p lb_call=%p: failing batch with error: %s",
|
2789
|
-
|
2984
|
+
chand(), this, StatusToString(cancel_error_).c_str());
|
2790
2985
|
}
|
2791
2986
|
// Note: This will release the call combiner.
|
2792
2987
|
grpc_transport_stream_op_batch_finish_with_failure(batch, cancel_error_,
|
@@ -2803,7 +2998,7 @@ void ClientChannel::LoadBalancedCall::StartTransportStreamOpBatch(
|
|
2803
2998
|
cancel_error_ = batch->payload->cancel_stream.cancel_error;
|
2804
2999
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2805
3000
|
gpr_log(GPR_INFO, "chand=%p lb_call=%p: recording cancel_error=%s",
|
2806
|
-
|
3001
|
+
chand(), this, StatusToString(cancel_error_).c_str());
|
2807
3002
|
}
|
2808
3003
|
// Fail all pending batches.
|
2809
3004
|
PendingBatchesFail(cancel_error_, NoYieldCallCombiner);
|
@@ -2815,86 +3010,53 @@ void ClientChannel::LoadBalancedCall::StartTransportStreamOpBatch(
|
|
2815
3010
|
// Add the batch to the pending list.
|
2816
3011
|
PendingBatchesAdd(batch);
|
2817
3012
|
// For batches containing a send_initial_metadata op, acquire the
|
2818
|
-
// channel's
|
3013
|
+
// channel's LB mutex to pick a subchannel.
|
2819
3014
|
if (GPR_LIKELY(batch->send_initial_metadata)) {
|
2820
|
-
|
2821
|
-
gpr_log(GPR_INFO,
|
2822
|
-
"chand=%p lb_call=%p: grabbing data plane mutex to perform pick",
|
2823
|
-
chand_, this);
|
2824
|
-
}
|
2825
|
-
PickSubchannel(this, absl::OkStatus());
|
3015
|
+
TryPick(/*was_queued=*/false);
|
2826
3016
|
} else {
|
2827
3017
|
// For all other batches, release the call combiner.
|
2828
3018
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2829
3019
|
gpr_log(GPR_INFO,
|
2830
3020
|
"chand=%p lb_call=%p: saved batch, yielding call combiner",
|
2831
|
-
|
3021
|
+
chand(), this);
|
2832
3022
|
}
|
2833
3023
|
GRPC_CALL_COMBINER_STOP(call_combiner_,
|
2834
3024
|
"batch does not include send_initial_metadata");
|
2835
3025
|
}
|
2836
3026
|
}
|
2837
3027
|
|
2838
|
-
void ClientChannel::
|
3028
|
+
void ClientChannel::FilterBasedLoadBalancedCall::RecvInitialMetadataReady(
|
2839
3029
|
void* arg, grpc_error_handle error) {
|
2840
|
-
auto* self = static_cast<
|
2841
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2842
|
-
gpr_log(GPR_INFO,
|
2843
|
-
"chand=%p lb_call=%p: got on_complete for send_initial_metadata: "
|
2844
|
-
"error=%s",
|
2845
|
-
self->chand_, self, StatusToString(error).c_str());
|
2846
|
-
}
|
2847
|
-
self->call_attempt_tracer_->RecordOnDoneSendInitialMetadata(
|
2848
|
-
self->peer_string_);
|
2849
|
-
Closure::Run(DEBUG_LOCATION,
|
2850
|
-
self->original_send_initial_metadata_on_complete_, error);
|
2851
|
-
}
|
2852
|
-
|
2853
|
-
void ClientChannel::LoadBalancedCall::RecvInitialMetadataReady(
|
2854
|
-
void* arg, grpc_error_handle error) {
|
2855
|
-
auto* self = static_cast<LoadBalancedCall*>(arg);
|
3030
|
+
auto* self = static_cast<FilterBasedLoadBalancedCall*>(arg);
|
2856
3031
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2857
3032
|
gpr_log(GPR_INFO,
|
2858
3033
|
"chand=%p lb_call=%p: got recv_initial_metadata_ready: error=%s",
|
2859
|
-
self->
|
3034
|
+
self->chand(), self, StatusToString(error).c_str());
|
2860
3035
|
}
|
2861
3036
|
if (error.ok()) {
|
2862
3037
|
// recv_initial_metadata_flags is not populated for clients
|
2863
|
-
self->
|
2864
|
-
self->recv_initial_metadata_
|
3038
|
+
self->call_attempt_tracer()->RecordReceivedInitialMetadata(
|
3039
|
+
self->recv_initial_metadata_);
|
2865
3040
|
}
|
2866
3041
|
Closure::Run(DEBUG_LOCATION, self->original_recv_initial_metadata_ready_,
|
2867
3042
|
error);
|
2868
3043
|
}
|
2869
3044
|
|
2870
|
-
void ClientChannel::
|
2871
|
-
void* arg, grpc_error_handle error) {
|
2872
|
-
auto* self = static_cast<LoadBalancedCall*>(arg);
|
2873
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2874
|
-
gpr_log(GPR_INFO, "chand=%p lb_call=%p: got recv_message_ready: error=%s",
|
2875
|
-
self->chand_, self, StatusToString(error).c_str());
|
2876
|
-
}
|
2877
|
-
if (self->recv_message_->has_value()) {
|
2878
|
-
self->call_attempt_tracer_->RecordReceivedMessage(**self->recv_message_);
|
2879
|
-
}
|
2880
|
-
Closure::Run(DEBUG_LOCATION, self->original_recv_message_ready_, error);
|
2881
|
-
}
|
2882
|
-
|
2883
|
-
void ClientChannel::LoadBalancedCall::RecvTrailingMetadataReady(
|
3045
|
+
void ClientChannel::FilterBasedLoadBalancedCall::RecvTrailingMetadataReady(
|
2884
3046
|
void* arg, grpc_error_handle error) {
|
2885
|
-
auto* self = static_cast<
|
3047
|
+
auto* self = static_cast<FilterBasedLoadBalancedCall*>(arg);
|
2886
3048
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2887
3049
|
gpr_log(GPR_INFO,
|
2888
3050
|
"chand=%p lb_call=%p: got recv_trailing_metadata_ready: error=%s "
|
2889
|
-
"
|
3051
|
+
"call_attempt_tracer()=%p lb_subchannel_call_tracker_=%p "
|
2890
3052
|
"failure_error_=%s",
|
2891
|
-
self->
|
2892
|
-
self->
|
3053
|
+
self->chand(), self, StatusToString(error).c_str(),
|
3054
|
+
self->call_attempt_tracer(), self->lb_subchannel_call_tracker(),
|
2893
3055
|
StatusToString(self->failure_error_).c_str());
|
2894
3056
|
}
|
2895
3057
|
// Check if we have a tracer or an LB callback to invoke.
|
2896
|
-
if (self->
|
2897
|
-
self->
|
3058
|
+
if (self->call_attempt_tracer() != nullptr ||
|
3059
|
+
self->lb_subchannel_call_tracker() != nullptr) {
|
2898
3060
|
// Get the call's status.
|
2899
3061
|
absl::Status status;
|
2900
3062
|
if (!error.ok()) {
|
@@ -2917,7 +3079,16 @@ void ClientChannel::LoadBalancedCall::RecvTrailingMetadataReady(
|
|
2917
3079
|
status = absl::Status(static_cast<absl::StatusCode>(code), message);
|
2918
3080
|
}
|
2919
3081
|
}
|
2920
|
-
|
3082
|
+
absl::string_view peer_string;
|
3083
|
+
if (self->recv_initial_metadata_ != nullptr) {
|
3084
|
+
Slice* peer_string_slice =
|
3085
|
+
self->recv_initial_metadata_->get_pointer(PeerString());
|
3086
|
+
if (peer_string_slice != nullptr) {
|
3087
|
+
peer_string = peer_string_slice->as_string_view();
|
3088
|
+
}
|
3089
|
+
}
|
3090
|
+
self->RecordCallCompletion(status, self->recv_trailing_metadata_,
|
3091
|
+
self->transport_stream_stats_, peer_string);
|
2921
3092
|
}
|
2922
3093
|
// Chain to original callback.
|
2923
3094
|
if (!self->failure_error_.ok()) {
|
@@ -2928,54 +3099,6 @@ void ClientChannel::LoadBalancedCall::RecvTrailingMetadataReady(
|
|
2928
3099
|
error);
|
2929
3100
|
}
|
2930
3101
|
|
2931
|
-
void ClientChannel::LoadBalancedCall::RecordCallCompletion(
|
2932
|
-
absl::Status status) {
|
2933
|
-
// If we have a tracer, notify it.
|
2934
|
-
if (call_attempt_tracer_ != nullptr) {
|
2935
|
-
call_attempt_tracer_->RecordReceivedTrailingMetadata(
|
2936
|
-
status, recv_trailing_metadata_, transport_stream_stats_);
|
2937
|
-
}
|
2938
|
-
// If the LB policy requested a callback for trailing metadata, invoke
|
2939
|
-
// the callback.
|
2940
|
-
if (lb_subchannel_call_tracker_ != nullptr) {
|
2941
|
-
Metadata trailing_metadata(recv_trailing_metadata_);
|
2942
|
-
BackendMetricAccessor backend_metric_accessor(this);
|
2943
|
-
const char* peer_string =
|
2944
|
-
peer_string_ != nullptr
|
2945
|
-
? reinterpret_cast<char*>(gpr_atm_acq_load(peer_string_))
|
2946
|
-
: "";
|
2947
|
-
LoadBalancingPolicy::SubchannelCallTrackerInterface::FinishArgs args = {
|
2948
|
-
peer_string, status, &trailing_metadata, &backend_metric_accessor};
|
2949
|
-
lb_subchannel_call_tracker_->Finish(args);
|
2950
|
-
lb_subchannel_call_tracker_.reset();
|
2951
|
-
}
|
2952
|
-
}
|
2953
|
-
|
2954
|
-
void ClientChannel::LoadBalancedCall::CreateSubchannelCall() {
|
2955
|
-
SubchannelCall::Args call_args = {
|
2956
|
-
std::move(connected_subchannel_), pollent_, path_.Ref(), /*start_time=*/0,
|
2957
|
-
deadline_, arena_,
|
2958
|
-
// TODO(roth): When we implement hedging support, we will probably
|
2959
|
-
// need to use a separate call context for each subchannel call.
|
2960
|
-
call_context_, call_combiner_};
|
2961
|
-
grpc_error_handle error;
|
2962
|
-
subchannel_call_ = SubchannelCall::Create(std::move(call_args), &error);
|
2963
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
2964
|
-
gpr_log(GPR_INFO,
|
2965
|
-
"chand=%p lb_call=%p: create subchannel_call=%p: error=%s", chand_,
|
2966
|
-
this, subchannel_call_.get(), StatusToString(error).c_str());
|
2967
|
-
}
|
2968
|
-
if (on_call_destruction_complete_ != nullptr) {
|
2969
|
-
subchannel_call_->SetAfterCallStackDestroy(on_call_destruction_complete_);
|
2970
|
-
on_call_destruction_complete_ = nullptr;
|
2971
|
-
}
|
2972
|
-
if (GPR_UNLIKELY(!error.ok())) {
|
2973
|
-
PendingBatchesFail(error, YieldCallCombiner);
|
2974
|
-
} else {
|
2975
|
-
PendingBatchesResume();
|
2976
|
-
}
|
2977
|
-
}
|
2978
|
-
|
2979
3102
|
// A class to handle the call combiner cancellation callback for a
|
2980
3103
|
// queued pick.
|
2981
3104
|
// TODO(roth): When we implement hedging support, we won't be able to
|
@@ -2983,9 +3106,10 @@ void ClientChannel::LoadBalancedCall::CreateSubchannelCall() {
|
|
2983
3106
|
// because there may be multiple LB picks happening in parallel.
|
2984
3107
|
// Instead, we will probably need to maintain a list in the CallData
|
2985
3108
|
// object of pending LB picks to be cancelled when the closure runs.
|
2986
|
-
class ClientChannel::
|
3109
|
+
class ClientChannel::FilterBasedLoadBalancedCall::LbQueuedCallCanceller {
|
2987
3110
|
public:
|
2988
|
-
explicit LbQueuedCallCanceller(
|
3111
|
+
explicit LbQueuedCallCanceller(
|
3112
|
+
RefCountedPtr<FilterBasedLoadBalancedCall> lb_call)
|
2989
3113
|
: lb_call_(std::move(lb_call)) {
|
2990
3114
|
GRPC_CALL_STACK_REF(lb_call_->owning_call_, "LbQueuedCallCanceller");
|
2991
3115
|
GRPC_CLOSURE_INIT(&closure_, &CancelLocked, this, nullptr);
|
@@ -2996,9 +3120,9 @@ class ClientChannel::LoadBalancedCall::LbQueuedCallCanceller {
|
|
2996
3120
|
static void CancelLocked(void* arg, grpc_error_handle error) {
|
2997
3121
|
auto* self = static_cast<LbQueuedCallCanceller*>(arg);
|
2998
3122
|
auto* lb_call = self->lb_call_.get();
|
2999
|
-
auto* chand = lb_call->
|
3123
|
+
auto* chand = lb_call->chand();
|
3000
3124
|
{
|
3001
|
-
MutexLock lock(&chand->
|
3125
|
+
MutexLock lock(&chand->lb_mu_);
|
3002
3126
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
3003
3127
|
gpr_log(GPR_INFO,
|
3004
3128
|
"chand=%p lb_call=%p: cancelling queued pick: "
|
@@ -3007,187 +3131,98 @@ class ClientChannel::LoadBalancedCall::LbQueuedCallCanceller {
|
|
3007
3131
|
lb_call->lb_call_canceller_);
|
3008
3132
|
}
|
3009
3133
|
if (lb_call->lb_call_canceller_ == self && !error.ok()) {
|
3010
|
-
lb_call->
|
3134
|
+
lb_call->call_dispatch_controller()->Commit();
|
3011
3135
|
// Remove pick from list of queued picks.
|
3012
|
-
lb_call->
|
3136
|
+
lb_call->RemoveCallFromLbQueuedCallsLocked();
|
3137
|
+
// Remove from queued picks list.
|
3138
|
+
chand->lb_queued_calls_.erase(lb_call);
|
3013
3139
|
// Fail pending batches on the call.
|
3014
3140
|
lb_call->PendingBatchesFail(error,
|
3015
3141
|
YieldCallCombinerIfPendingBatchesFound);
|
3016
3142
|
}
|
3017
3143
|
}
|
3018
|
-
|
3144
|
+
// Unref lb_call before unreffing the call stack, since unreffing
|
3145
|
+
// the call stack may destroy the arena in which lb_call is allocated.
|
3146
|
+
auto* owning_call = lb_call->owning_call_;
|
3147
|
+
self->lb_call_.reset();
|
3148
|
+
GRPC_CALL_STACK_UNREF(owning_call, "LbQueuedCallCanceller");
|
3019
3149
|
delete self;
|
3020
3150
|
}
|
3021
3151
|
|
3022
|
-
RefCountedPtr<
|
3152
|
+
RefCountedPtr<FilterBasedLoadBalancedCall> lb_call_;
|
3023
3153
|
grpc_closure closure_;
|
3024
3154
|
};
|
3025
3155
|
|
3026
|
-
void ClientChannel::
|
3027
|
-
|
3028
|
-
if (
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
|
3033
|
-
|
3034
|
-
// Lame the call combiner canceller.
|
3035
|
-
lb_call_canceller_ = nullptr;
|
3036
|
-
// Add trace annotation
|
3037
|
-
if (call_attempt_tracer_ != nullptr) {
|
3038
|
-
call_attempt_tracer_->RecordAnnotation("Delayed LB pick complete.");
|
3156
|
+
void ClientChannel::FilterBasedLoadBalancedCall::TryPick(bool was_queued) {
|
3157
|
+
auto result = PickSubchannel(was_queued);
|
3158
|
+
if (result.has_value()) {
|
3159
|
+
if (!result->ok()) {
|
3160
|
+
PendingBatchesFail(*result, YieldCallCombiner);
|
3161
|
+
return;
|
3162
|
+
}
|
3163
|
+
CreateSubchannelCall();
|
3039
3164
|
}
|
3040
3165
|
}
|
3041
3166
|
|
3042
|
-
void ClientChannel::
|
3043
|
-
if (queued_pending_lb_pick_) return;
|
3044
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
3045
|
-
gpr_log(GPR_INFO, "chand=%p lb_call=%p: adding to queued picks list",
|
3046
|
-
chand_, this);
|
3047
|
-
}
|
3048
|
-
queued_pending_lb_pick_ = true;
|
3049
|
-
queued_call_.lb_call = this;
|
3050
|
-
chand_->AddLbQueuedCall(&queued_call_, pollent_);
|
3167
|
+
void ClientChannel::FilterBasedLoadBalancedCall::OnAddToQueueLocked() {
|
3051
3168
|
// Register call combiner cancellation callback.
|
3052
3169
|
lb_call_canceller_ = new LbQueuedCallCanceller(Ref());
|
3053
3170
|
}
|
3054
3171
|
|
3055
|
-
void ClientChannel::
|
3056
|
-
//
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3069
|
-
|
3070
|
-
|
3071
|
-
|
3172
|
+
void ClientChannel::FilterBasedLoadBalancedCall::RetryPickLocked() {
|
3173
|
+
// Lame the call combiner canceller.
|
3174
|
+
lb_call_canceller_ = nullptr;
|
3175
|
+
// Do an async callback to resume call processing, so that we're not
|
3176
|
+
// doing it while holding the channel's LB mutex.
|
3177
|
+
// TODO(roth): We should really be using EventEngine::Run() here
|
3178
|
+
// instead of ExecCtx::Run(). Unfortunately, doing that seems to cause
|
3179
|
+
// a flaky TSAN failure for reasons that I do not fully understand.
|
3180
|
+
// However, given that we are working toward eliminating this code as
|
3181
|
+
// part of the promise conversion, it doesn't seem worth further
|
3182
|
+
// investigation right now.
|
3183
|
+
ExecCtx::Run(DEBUG_LOCATION, NewClosure([this](grpc_error_handle) {
|
3184
|
+
// If there are a lot of queued calls here, resuming them
|
3185
|
+
// all may cause us to stay inside C-core for a long period
|
3186
|
+
// of time. All of that work would be done using the same
|
3187
|
+
// ExecCtx instance and therefore the same cached value of
|
3188
|
+
// "now". The longer it takes to finish all of this work
|
3189
|
+
// and exit from C-core, the more stale the cached value of
|
3190
|
+
// "now" may become. This can cause problems whereby (e.g.)
|
3191
|
+
// we calculate a timer deadline based on the stale value,
|
3192
|
+
// which results in the timer firing too early. To avoid
|
3193
|
+
// this, we invalidate the cached value for each call we
|
3194
|
+
// process.
|
3195
|
+
ExecCtx::Get()->InvalidateNow();
|
3196
|
+
TryPick(/*was_queued=*/true);
|
3197
|
+
}),
|
3198
|
+
absl::OkStatus());
|
3199
|
+
}
|
3200
|
+
|
3201
|
+
void ClientChannel::FilterBasedLoadBalancedCall::CreateSubchannelCall() {
|
3202
|
+
Slice* path = send_initial_metadata()->get_pointer(HttpPathMetadata());
|
3203
|
+
GPR_ASSERT(path != nullptr);
|
3204
|
+
SubchannelCall::Args call_args = {
|
3205
|
+
connected_subchannel()->Ref(), pollent_, path->Ref(), /*start_time=*/0,
|
3206
|
+
deadline_, arena_,
|
3207
|
+
// TODO(roth): When we implement hedging support, we will probably
|
3208
|
+
// need to use a separate call context for each subchannel call.
|
3209
|
+
call_context_, call_combiner_};
|
3210
|
+
grpc_error_handle error;
|
3211
|
+
subchannel_call_ = SubchannelCall::Create(std::move(call_args), &error);
|
3212
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
3213
|
+
gpr_log(GPR_INFO,
|
3214
|
+
"chand=%p lb_call=%p: create subchannel_call=%p: error=%s", chand(),
|
3215
|
+
this, subchannel_call_.get(), StatusToString(error).c_str());
|
3072
3216
|
}
|
3073
|
-
|
3074
|
-
|
3075
|
-
|
3076
|
-
|
3077
|
-
void ClientChannel::LoadBalancedCall::PickSubchannel(void* arg,
|
3078
|
-
grpc_error_handle error) {
|
3079
|
-
auto* self = static_cast<LoadBalancedCall*>(arg);
|
3080
|
-
bool pick_complete;
|
3081
|
-
{
|
3082
|
-
MutexLock lock(&self->chand_->data_plane_mu_);
|
3083
|
-
pick_complete = self->PickSubchannelLocked(&error);
|
3217
|
+
if (on_call_destruction_complete_ != nullptr) {
|
3218
|
+
subchannel_call_->SetAfterCallStackDestroy(on_call_destruction_complete_);
|
3219
|
+
on_call_destruction_complete_ = nullptr;
|
3084
3220
|
}
|
3085
|
-
if (
|
3086
|
-
|
3221
|
+
if (GPR_UNLIKELY(!error.ok())) {
|
3222
|
+
PendingBatchesFail(error, YieldCallCombiner);
|
3223
|
+
} else {
|
3224
|
+
PendingBatchesResume();
|
3087
3225
|
}
|
3088
3226
|
}
|
3089
3227
|
|
3090
|
-
bool ClientChannel::LoadBalancedCall::PickSubchannelLocked(
|
3091
|
-
grpc_error_handle* error) {
|
3092
|
-
GPR_ASSERT(connected_subchannel_ == nullptr);
|
3093
|
-
GPR_ASSERT(subchannel_call_ == nullptr);
|
3094
|
-
// Grab initial metadata.
|
3095
|
-
auto& send_initial_metadata =
|
3096
|
-
pending_batches_[0]->payload->send_initial_metadata;
|
3097
|
-
grpc_metadata_batch* initial_metadata_batch =
|
3098
|
-
send_initial_metadata.send_initial_metadata;
|
3099
|
-
// Perform LB pick.
|
3100
|
-
LoadBalancingPolicy::PickArgs pick_args;
|
3101
|
-
pick_args.path = path_.as_string_view();
|
3102
|
-
LbCallState lb_call_state(this);
|
3103
|
-
pick_args.call_state = &lb_call_state;
|
3104
|
-
Metadata initial_metadata(initial_metadata_batch);
|
3105
|
-
pick_args.initial_metadata = &initial_metadata;
|
3106
|
-
auto result = chand_->picker_->Pick(pick_args);
|
3107
|
-
return HandlePickResult<bool>(
|
3108
|
-
&result,
|
3109
|
-
// CompletePick
|
3110
|
-
[this](LoadBalancingPolicy::PickResult::Complete* complete_pick)
|
3111
|
-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::data_plane_mu_) {
|
3112
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
3113
|
-
gpr_log(GPR_INFO,
|
3114
|
-
"chand=%p lb_call=%p: LB pick succeeded: subchannel=%p",
|
3115
|
-
chand_, this, complete_pick->subchannel.get());
|
3116
|
-
}
|
3117
|
-
GPR_ASSERT(complete_pick->subchannel != nullptr);
|
3118
|
-
// Grab a ref to the connected subchannel while we're still
|
3119
|
-
// holding the data plane mutex.
|
3120
|
-
SubchannelWrapper* subchannel = static_cast<SubchannelWrapper*>(
|
3121
|
-
complete_pick->subchannel.get());
|
3122
|
-
connected_subchannel_ = subchannel->connected_subchannel();
|
3123
|
-
// If the subchannel has no connected subchannel (e.g., if the
|
3124
|
-
// subchannel has moved out of state READY but the LB policy hasn't
|
3125
|
-
// yet seen that change and given us a new picker), then just
|
3126
|
-
// queue the pick. We'll try again as soon as we get a new picker.
|
3127
|
-
if (connected_subchannel_ == nullptr) {
|
3128
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
3129
|
-
gpr_log(GPR_INFO,
|
3130
|
-
"chand=%p lb_call=%p: subchannel returned by LB picker "
|
3131
|
-
"has no connected subchannel; queueing pick",
|
3132
|
-
chand_, this);
|
3133
|
-
}
|
3134
|
-
MaybeAddCallToLbQueuedCallsLocked();
|
3135
|
-
return false;
|
3136
|
-
}
|
3137
|
-
lb_subchannel_call_tracker_ =
|
3138
|
-
std::move(complete_pick->subchannel_call_tracker);
|
3139
|
-
if (lb_subchannel_call_tracker_ != nullptr) {
|
3140
|
-
lb_subchannel_call_tracker_->Start();
|
3141
|
-
}
|
3142
|
-
MaybeRemoveCallFromLbQueuedCallsLocked();
|
3143
|
-
return true;
|
3144
|
-
},
|
3145
|
-
// QueuePick
|
3146
|
-
[this](LoadBalancingPolicy::PickResult::Queue* /*queue_pick*/)
|
3147
|
-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::data_plane_mu_) {
|
3148
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
3149
|
-
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick queued", chand_,
|
3150
|
-
this);
|
3151
|
-
}
|
3152
|
-
MaybeAddCallToLbQueuedCallsLocked();
|
3153
|
-
return false;
|
3154
|
-
},
|
3155
|
-
// FailPick
|
3156
|
-
[this, initial_metadata_batch,
|
3157
|
-
&error](LoadBalancingPolicy::PickResult::Fail* fail_pick)
|
3158
|
-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::data_plane_mu_) {
|
3159
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
3160
|
-
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick failed: %s",
|
3161
|
-
chand_, this, fail_pick->status.ToString().c_str());
|
3162
|
-
}
|
3163
|
-
// If wait_for_ready is false, then the error indicates the RPC
|
3164
|
-
// attempt's final status.
|
3165
|
-
if (!initial_metadata_batch->GetOrCreatePointer(WaitForReady())
|
3166
|
-
->value) {
|
3167
|
-
*error = absl_status_to_grpc_error(MaybeRewriteIllegalStatusCode(
|
3168
|
-
std::move(fail_pick->status), "LB pick"));
|
3169
|
-
MaybeRemoveCallFromLbQueuedCallsLocked();
|
3170
|
-
return true;
|
3171
|
-
}
|
3172
|
-
// If wait_for_ready is true, then queue to retry when we get a new
|
3173
|
-
// picker.
|
3174
|
-
MaybeAddCallToLbQueuedCallsLocked();
|
3175
|
-
return false;
|
3176
|
-
},
|
3177
|
-
// DropPick
|
3178
|
-
[this, &error](LoadBalancingPolicy::PickResult::Drop* drop_pick)
|
3179
|
-
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&ClientChannel::data_plane_mu_) {
|
3180
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_lb_call_trace)) {
|
3181
|
-
gpr_log(GPR_INFO, "chand=%p lb_call=%p: LB pick dropped: %s",
|
3182
|
-
chand_, this, drop_pick->status.ToString().c_str());
|
3183
|
-
}
|
3184
|
-
*error = grpc_error_set_int(
|
3185
|
-
absl_status_to_grpc_error(MaybeRewriteIllegalStatusCode(
|
3186
|
-
std::move(drop_pick->status), "LB drop")),
|
3187
|
-
StatusIntProperty::kLbPolicyDrop, 1);
|
3188
|
-
MaybeRemoveCallFromLbQueuedCallsLocked();
|
3189
|
-
return true;
|
3190
|
-
});
|
3191
|
-
}
|
3192
|
-
|
3193
3228
|
} // namespace grpc_core
|