grpc 1.45.0 → 1.46.3
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 +36 -29
- data/include/grpc/impl/codegen/grpc_types.h +7 -13
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +309 -0
- data/src/core/ext/filters/channel_idle/channel_idle_filter.h +122 -0
- data/src/core/ext/filters/{client_idle → channel_idle}/idle_filter_state.cc +1 -1
- data/src/core/ext/filters/{client_idle → channel_idle}/idle_filter_state.h +3 -3
- data/src/core/ext/filters/client_channel/client_channel.cc +163 -96
- data/src/core/ext/filters/client_channel/client_channel.h +2 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +124 -581
- data/src/core/ext/filters/client_channel/health/health_check_client.h +24 -160
- data/src/core/ext/filters/client_channel/http_proxy.cc +88 -110
- data/src/core/ext/filters/client_channel/http_proxy.h +17 -0
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +182 -142
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +2 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +1 -10
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +87 -58
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +51 -48
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +14 -7
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +229 -284
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +92 -257
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +51 -221
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +201 -0
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +106 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +102 -55
- data/src/core/ext/filters/client_channel/retry_filter.cc +18 -3
- data/src/core/ext/filters/client_channel/subchannel.cc +5 -5
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +544 -0
- data/src/core/ext/filters/client_channel/subchannel_stream_client.h +214 -0
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +127 -367
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +24 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +78 -458
- data/src/core/ext/filters/http/client/http_client_filter.h +21 -4
- data/src/core/ext/filters/http/client_authority_filter.cc +17 -22
- data/src/core/ext/filters/http/client_authority_filter.h +6 -5
- data/src/core/ext/filters/http/http_filters_plugin.cc +9 -6
- data/src/core/ext/filters/http/server/http_server_filter.cc +2 -116
- data/src/core/ext/filters/server_config_selector/server_config_selector.cc +2 -8
- data/src/core/ext/filters/server_config_selector/server_config_selector.h +2 -2
- data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +73 -201
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +139 -28
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -6
- data/src/core/ext/transport/chttp2/transport/internal.h +4 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +8 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +24 -13
- data/src/core/ext/upb-generated/envoy/admin/v3/certs.upb.c +27 -24
- data/src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h +143 -63
- data/src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.c +37 -35
- data/src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.h +177 -77
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +115 -111
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +547 -207
- data/src/core/ext/upb-generated/envoy/admin/v3/init_dump.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/admin/v3/init_dump.upb.h +26 -13
- data/src/core/ext/upb-generated/envoy/admin/v3/listeners.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/admin/v3/listeners.upb.h +23 -9
- data/src/core/ext/upb-generated/envoy/admin/v3/memory.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/admin/v3/memory.upb.h +18 -0
- data/src/core/ext/upb-generated/envoy/admin/v3/metrics.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/admin/v3/metrics.upb.h +13 -4
- data/src/core/ext/upb-generated/envoy/admin/v3/mutex_stats.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/admin/v3/mutex_stats.upb.h +9 -0
- data/src/core/ext/upb-generated/envoy/admin/v3/server_info.upb.c +49 -46
- data/src/core/ext/upb-generated/envoy/admin/v3/server_info.upb.h +217 -78
- data/src/core/ext/upb-generated/envoy/admin/v3/tap.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/admin/v3/tap.upb.h +10 -2
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +12 -12
- data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +40 -8
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +20 -2
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +55 -55
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +289 -110
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +133 -125
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +656 -267
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +24 -18
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +96 -23
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +185 -173
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +860 -309
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +10 -2
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +44 -24
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +165 -40
- data/src/core/ext/upb-generated/envoy/config/common/matcher/v3/matcher.upb.c +72 -63
- data/src/core/ext/upb-generated/envoy/config/common/matcher/v3/matcher.upb.h +433 -174
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +33 -31
- data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +154 -52
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +5 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +14 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +89 -89
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +460 -166
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +76 -33
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +379 -69
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +14 -6
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +5 -25
- data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +10 -91
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_method_list.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_method_list.upb.h +26 -13
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +70 -68
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +369 -131
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +94 -65
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +447 -161
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +27 -11
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +104 -85
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +378 -113
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +3 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +6 -6
- data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +30 -13
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +43 -16
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +58 -24
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +14 -4
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +18 -18
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +100 -43
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +31 -30
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +171 -71
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +32 -32
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +196 -95
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +7 -2
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +53 -46
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +284 -129
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +56 -50
- data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +337 -146
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +13 -11
- data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +49 -14
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +14 -4
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.h +20 -4
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +33 -32
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +205 -86
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +34 -34
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +175 -74
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +56 -52
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +370 -146
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +27 -23
- data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +173 -74
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +362 -341
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +2056 -845
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +11 -11
- data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +49 -16
- data/src/core/ext/upb-generated/envoy/config/tap/v3/common.upb.c +56 -50
- data/src/core/ext/upb-generated/envoy/config/tap/v3/common.upb.h +293 -111
- data/src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.h +6 -0
- data/src/core/ext/upb-generated/envoy/config/trace/v3/dynamic_ot.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/config/trace/v3/dynamic_ot.upb.h +10 -2
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +26 -10
- data/src/core/ext/upb-generated/envoy/config/trace/v3/lightstep.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/config/trace/v3/lightstep.upb.h +27 -12
- data/src/core/ext/upb-generated/envoy/config/trace/v3/opencensus.upb.c +17 -16
- data/src/core/ext/upb-generated/envoy/config/trace/v3/opencensus.upb.h +83 -36
- data/src/core/ext/upb-generated/envoy/config/trace/v3/service.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/config/trace/v3/service.upb.h +7 -2
- data/src/core/ext/upb-generated/envoy/config/trace/v3/skywalking.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/config/trace/v3/skywalking.upb.h +46 -17
- data/src/core/ext/upb-generated/envoy/config/trace/v3/xray.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/config/trace/v3/xray.upb.h +38 -12
- data/src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.h +30 -10
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +10 -6
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +15 -15
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +71 -28
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +25 -25
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +149 -65
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +8 -7
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +30 -12
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +42 -15
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +173 -144
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +898 -323
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +51 -45
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +261 -116
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +13 -13
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +70 -25
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +80 -55
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +410 -124
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls_spiffe_validator_config.upb.h +23 -9
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +1 -1
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +44 -44
- data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +261 -122
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +47 -21
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +32 -32
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +175 -66
- data/src/core/ext/upb-generated/envoy/type/http/v3/cookie.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/type/http/v3/cookie.upb.h +17 -6
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +38 -17
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/http_inputs.upb.h +12 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +43 -18
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +20 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +3 -3
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +24 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +14 -6
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +8 -8
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +40 -16
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +70 -25
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +37 -18
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +12 -12
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +81 -30
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +16 -16
- data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +76 -30
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +20 -20
- data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +90 -30
- data/src/core/ext/upb-generated/envoy/type/v3/hash_policy.upb.c +7 -7
- data/src/core/ext/upb-generated/envoy/type/v3/hash_policy.upb.h +28 -10
- data/src/core/ext/upb-generated/envoy/type/v3/http_status.upb.c +2 -2
- data/src/core/ext/upb-generated/envoy/type/v3/http_status.upb.h +3 -0
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +13 -4
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +9 -9
- data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +18 -0
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +4 -4
- data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +9 -0
- data/src/core/ext/upb-generated/envoy/type/v3/token_bucket.upb.c +5 -5
- data/src/core/ext/upb-generated/envoy/type/v3/token_bucket.upb.h +17 -4
- data/src/core/ext/upb-generated/google/api/annotations.upb.c +3 -3
- data/src/core/ext/upb-generated/google/api/annotations.upb.h +17 -2
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +70 -66
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +410 -162
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +80 -74
- data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +440 -158
- data/src/core/ext/upb-generated/google/api/http.upb.c +17 -17
- data/src/core/ext/upb-generated/google/api/http.upb.h +116 -43
- data/src/core/ext/upb-generated/google/api/httpbody.upb.c +4 -4
- data/src/core/ext/upb-generated/google/api/httpbody.upb.h +19 -7
- data/src/core/ext/upb-generated/google/protobuf/any.upb.c +3 -3
- data/src/core/ext/upb-generated/google/protobuf/any.upb.h +6 -0
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +163 -162
- data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +1157 -435
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +3 -3
- data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +10 -4
- data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +1 -1
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +15 -15
- data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +108 -40
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +3 -3
- data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +10 -4
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +18 -18
- data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +27 -0
- data/src/core/ext/upb-generated/google/rpc/status.upb.c +4 -4
- data/src/core/ext/upb-generated/google/rpc/status.upb.h +19 -7
- data/src/core/ext/upb-generated/opencensus/proto/trace/v1/trace_config.upb.c +15 -15
- data/src/core/ext/upb-generated/opencensus/proto/trace/v1/trace_config.upb.h +65 -22
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +12 -12
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +49 -12
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +69 -65
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +364 -149
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +8 -7
- data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +20 -4
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +4 -4
- data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +6 -0
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +31 -31
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +150 -58
- data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c +11 -11
- data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.h +51 -18
- data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls_config.upb.c +175 -0
- data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls_config.upb.h +764 -0
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +22 -22
- data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +97 -10
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +6 -6
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +23 -2
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +3 -3
- data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +10 -2
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +6 -6
- data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +27 -6
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +5 -5
- data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +20 -2
- data/src/core/ext/upb-generated/validate/validate.upb.c +261 -250
- data/src/core/ext/upb-generated/validate/validate.upb.h +1836 -663
- data/src/core/ext/upb-generated/xds/annotations/v3/migrate.upb.c +22 -22
- data/src/core/ext/upb-generated/xds/annotations/v3/migrate.upb.h +97 -10
- data/src/core/ext/upb-generated/xds/annotations/v3/security.upb.c +6 -6
- data/src/core/ext/upb-generated/xds/annotations/v3/security.upb.h +23 -2
- data/src/core/ext/upb-generated/xds/annotations/v3/sensitive.upb.c +3 -3
- data/src/core/ext/upb-generated/xds/annotations/v3/sensitive.upb.h +10 -2
- data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.c +18 -18
- data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.h +70 -10
- data/src/core/ext/upb-generated/xds/annotations/v3/versioning.upb.c +5 -5
- data/src/core/ext/upb-generated/xds/annotations/v3/versioning.upb.h +20 -2
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +2 -2
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +3 -0
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +8 -8
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +38 -12
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +5 -5
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +27 -10
- data/src/core/ext/upb-generated/xds/core/v3/extension.upb.c +3 -3
- data/src/core/ext/upb-generated/xds/core/v3/extension.upb.h +10 -2
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +5 -5
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +21 -8
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +10 -10
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +71 -30
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +5 -5
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +16 -2
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +12 -12
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +69 -26
- data/src/core/ext/upb-generated/xds/type/matcher/v3/matcher.upb.c +43 -39
- data/src/core/ext/upb-generated/xds/type/matcher/v3/matcher.upb.h +255 -103
- data/src/core/ext/upb-generated/xds/type/matcher/v3/regex.upb.c +4 -4
- data/src/core/ext/upb-generated/xds/type/matcher/v3/regex.upb.h +19 -8
- data/src/core/ext/upb-generated/xds/type/matcher/v3/string.upb.c +9 -9
- data/src/core/ext/upb-generated/xds/type/matcher/v3/string.upb.h +70 -25
- data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.c +3 -3
- data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.h +10 -2
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +50 -46
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +195 -185
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +16 -12
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +129 -94
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c +18 -33
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.h +0 -5
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +163 -155
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +141 -138
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +26 -20
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +738 -730
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +271 -251
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +207 -193
- data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/src/proto/grpc/lookup/v1/rls_config.upbdefs.c +99 -0
- data/src/core/ext/upbdefs-generated/src/proto/grpc/lookup/v1/rls_config.upbdefs.h +75 -0
- data/src/core/ext/xds/certificate_provider_store.cc +8 -0
- data/src/core/ext/xds/certificate_provider_store.h +9 -0
- data/src/core/ext/xds/xds_api.cc +20 -0
- data/src/core/ext/xds/xds_bootstrap.cc +2 -2
- data/src/core/ext/xds/xds_bootstrap.h +2 -0
- data/src/core/ext/xds/xds_certificate_provider.cc +2 -0
- data/src/core/ext/xds/xds_certificate_provider.h +8 -0
- data/src/core/ext/xds/xds_client.cc +87 -95
- data/src/core/ext/xds/xds_client.h +13 -5
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +142 -0
- data/src/core/ext/xds/xds_cluster_specifier_plugin.h +79 -0
- data/src/core/ext/xds/xds_common_types.cc +9 -9
- data/src/core/ext/xds/xds_common_types.h +3 -3
- data/src/core/ext/xds/xds_endpoint.cc +12 -5
- data/src/core/ext/xds/xds_http_fault_filter.cc +1 -1
- data/src/core/ext/xds/xds_listener.cc +1 -1
- data/src/core/ext/xds/xds_route_config.cc +162 -25
- data/src/core/ext/xds/xds_route_config.h +13 -10
- data/src/core/ext/xds/xds_server_config_fetcher.cc +17 -22
- data/src/core/lib/avl/avl.h +68 -5
- data/src/core/lib/channel/call_tracer.h +4 -1
- data/src/core/lib/channel/channel_args.cc +138 -59
- data/src/core/lib/channel/channel_args.h +210 -9
- data/src/core/lib/channel/channel_args_preconditioning.cc +3 -9
- data/src/core/lib/channel/channel_args_preconditioning.h +1 -2
- data/src/core/lib/channel/channel_stack.h +2 -5
- data/src/core/lib/channel/channel_stack_builder.cc +0 -65
- data/src/core/lib/channel/channel_stack_builder.h +27 -6
- data/src/core/lib/channel/channel_stack_builder_impl.cc +102 -0
- data/src/core/lib/channel/channel_stack_builder_impl.h +48 -0
- data/src/core/lib/channel/connected_channel.h +1 -0
- data/src/core/lib/channel/promise_based_filter.cc +495 -162
- data/src/core/lib/channel/promise_based_filter.h +55 -41
- data/src/core/lib/compression/compression_internal.cc +1 -7
- data/src/core/lib/debug/stats_data.cc +2 -6
- data/src/core/lib/debug/stats_data.h +18 -21
- data/src/core/lib/gpr/tls.h +1 -0
- data/src/core/lib/gprpp/bitset.h +12 -0
- data/src/core/lib/gprpp/cpp_impl_of.h +4 -0
- data/src/core/lib/gprpp/match.h +73 -0
- data/src/core/lib/gprpp/overload.h +59 -0
- data/src/core/lib/gprpp/ref_counted.h +2 -0
- data/src/core/lib/gprpp/single_set_ptr.h +87 -0
- data/src/core/lib/gprpp/status_helper.cc +18 -2
- data/src/core/lib/gprpp/time.cc +12 -0
- data/src/core/lib/gprpp/time.h +1 -1
- data/src/core/lib/http/format_request.cc +1 -2
- data/src/core/lib/http/httpcli_security_connector.cc +5 -5
- data/src/core/lib/http/parser.cc +80 -9
- data/src/core/lib/http/parser.h +14 -1
- data/src/core/lib/iomgr/ev_posix.cc +6 -7
- data/src/core/lib/iomgr/fork_posix.cc +1 -1
- data/src/core/lib/iomgr/port.h +0 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +2 -2
- data/src/core/lib/iomgr/tcp_posix.cc +93 -35
- data/src/core/lib/iomgr/tcp_server_posix.cc +26 -17
- data/src/core/lib/json/json_util.h +3 -3
- data/src/core/lib/promise/call_push_pull.h +144 -0
- data/src/core/lib/promise/detail/status.h +2 -1
- data/src/core/lib/promise/intra_activity_waiter.h +49 -0
- data/src/core/lib/promise/latch.h +104 -0
- data/src/core/lib/resource_quota/api.cc +5 -30
- data/src/core/lib/resource_quota/api.h +1 -1
- data/src/core/lib/resource_quota/resource_quota.h +8 -0
- data/src/core/lib/security/authorization/authorization_policy_provider.h +7 -0
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +9 -12
- data/src/core/lib/security/authorization/grpc_server_authz_filter.h +5 -6
- data/src/core/lib/security/context/security_context.h +8 -1
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +6 -5
- data/src/core/lib/security/credentials/alts/alts_credentials.h +4 -0
- data/src/core/lib/security/credentials/call_creds_util.cc +3 -3
- data/src/core/lib/security/credentials/call_creds_util.h +2 -2
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +15 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.h +9 -8
- data/src/core/lib/security/credentials/credentials.h +16 -33
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +8 -12
- data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -5
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +4 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +3 -3
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +5 -4
- data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -2
- data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +22 -29
- data/src/core/lib/security/credentials/insecure/insecure_credentials.h +57 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +7 -3
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +6 -2
- data/src/core/lib/security/credentials/local/local_credentials.cc +6 -6
- data/src/core/lib/security/credentials/local/local_credentials.h +4 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +17 -9
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +14 -6
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +8 -6
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +8 -6
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +6 -4
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +8 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +49 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc +8 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h +42 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +66 -95
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +9 -6
- data/src/core/lib/security/credentials/tls/tls_credentials.h +5 -5
- data/src/core/lib/security/credentials/xds/xds_credentials.cc +48 -50
- data/src/core/lib/security/credentials/xds/xds_credentials.h +31 -5
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +2 -2
- data/src/core/lib/security/security_connector/security_connector.h +9 -0
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -2
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +4 -2
- data/src/core/lib/security/transport/auth_filters.h +7 -7
- data/src/core/lib/security/transport/client_auth_filter.cc +28 -20
- data/src/core/lib/security/transport/secure_endpoint.cc +198 -129
- data/src/core/lib/security/transport/secure_endpoint.h +1 -1
- data/src/core/lib/security/transport/security_handshaker.cc +6 -4
- data/src/core/lib/surface/call.cc +1023 -903
- data/src/core/lib/surface/call.h +0 -14
- data/src/core/lib/surface/channel.cc +4 -3
- data/src/core/lib/surface/channel_init.cc +2 -3
- data/src/core/lib/surface/channel_init.h +2 -6
- data/src/core/lib/surface/init.cc +1 -1
- data/src/core/lib/surface/server.cc +3 -14
- data/src/core/lib/surface/server.h +1 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +2 -0
- data/src/core/lib/transport/metadata_batch.h +12 -8
- data/src/core/lib/transport/transport.h +20 -5
- data/src/core/lib/transport/transport_impl.h +4 -3
- data/src/core/plugin_registry/grpc_plugin_registry.cc +2 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -2
- data/src/core/tsi/ssl_transport_security.cc +75 -38
- data/src/core/tsi/ssl_transport_security.h +8 -2
- data/src/core/tsi/transport_security_interface.h +2 -0
- data/src/ruby/ext/grpc/extconf.rb +1 -1
- data/src/ruby/lib/grpc/generic/active_call.rb +7 -1
- data/src/ruby/lib/grpc/grpc.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/generate_proto_ruby.sh +1 -0
- data/src/ruby/pb/test/client.rb +769 -0
- data/src/ruby/pb/test/server.rb +252 -0
- data/src/ruby/pb/test/xds_client.rb +415 -0
- data/third_party/upb/third_party/utf8_range/utf8_range.h +1 -1
- data/third_party/upb/upb/decode.c +32 -16
- data/third_party/upb/upb/def.c +118 -55
- data/third_party/upb/upb/def.h +12 -3
- data/third_party/upb/upb/encode.c +14 -8
- data/third_party/upb/upb/json_encode.c +776 -0
- data/third_party/upb/upb/json_encode.h +62 -0
- data/third_party/upb/upb/msg.c +5 -7
- data/third_party/upb/upb/msg.h +1 -2
- data/third_party/upb/upb/msg_internal.h +49 -36
- data/third_party/upb/upb/port_def.inc +8 -0
- data/third_party/upb/upb/port_undef.inc +1 -0
- data/third_party/upb/upb/table.c +10 -6
- data/third_party/upb/upb/table_internal.h +2 -0
- data/third_party/upb/upb/upb.h +41 -11
- data/third_party/zlib/crc32.c +966 -292
- data/third_party/zlib/crc32.h +9441 -436
- data/third_party/zlib/deflate.c +78 -30
- data/third_party/zlib/deflate.h +12 -15
- data/third_party/zlib/gzguts.h +3 -2
- data/third_party/zlib/gzlib.c +5 -3
- data/third_party/zlib/gzread.c +5 -7
- data/third_party/zlib/gzwrite.c +25 -13
- data/third_party/zlib/infback.c +2 -1
- data/third_party/zlib/inffast.c +14 -14
- data/third_party/zlib/inflate.c +39 -8
- data/third_party/zlib/inflate.h +3 -2
- data/third_party/zlib/inftrees.c +3 -3
- data/third_party/zlib/trees.c +27 -48
- data/third_party/zlib/zlib.h +123 -100
- data/third_party/zlib/zutil.c +2 -2
- data/third_party/zlib/zutil.h +12 -9
- metadata +66 -45
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +0 -201
- data/src/core/ext/filters/max_age/max_age_filter.cc +0 -566
- data/src/core/ext/filters/max_age/max_age_filter.h +0 -26
- data/src/core/lib/iomgr/ev_epollex_linux.cc +0 -1657
- data/src/core/lib/iomgr/ev_epollex_linux.h +0 -30
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +0 -119
- data/src/core/lib/iomgr/is_epollexclusive_available.h +0 -36
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +0 -30
@@ -26,6 +26,7 @@
|
|
26
26
|
#include <stdlib.h>
|
27
27
|
#include <string.h>
|
28
28
|
|
29
|
+
#include <atomic>
|
29
30
|
#include <string>
|
30
31
|
|
31
32
|
#include "absl/strings/str_cat.h"
|
@@ -39,6 +40,7 @@
|
|
39
40
|
#include <grpc/support/string_util.h>
|
40
41
|
|
41
42
|
#include "src/core/lib/channel/channel_stack.h"
|
43
|
+
#include "src/core/lib/channel/context.h"
|
42
44
|
#include "src/core/lib/compression/compression_internal.h"
|
43
45
|
#include "src/core/lib/debug/stats.h"
|
44
46
|
#include "src/core/lib/gpr/alloc.h"
|
@@ -62,170 +64,333 @@
|
|
62
64
|
#include "src/core/lib/transport/error_utils.h"
|
63
65
|
#include "src/core/lib/transport/transport.h"
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
api:
|
68
|
-
- initial metadata send
|
69
|
-
- message send
|
70
|
-
- status/close send (depending on client/server)
|
71
|
-
- initial metadata recv
|
72
|
-
- message recv
|
73
|
-
- status/close recv (depending on client/server) */
|
74
|
-
#define MAX_CONCURRENT_BATCHES 6
|
75
|
-
|
76
|
-
struct batch_control {
|
77
|
-
batch_control() = default;
|
78
|
-
|
79
|
-
grpc_call* call = nullptr;
|
80
|
-
grpc_transport_stream_op_batch op;
|
81
|
-
/* Share memory for cq_completion and notify_tag as they are never needed
|
82
|
-
simultaneously. Each byte used in this data structure count as six bytes
|
83
|
-
per call, so any savings we can make are worthwhile,
|
84
|
-
|
85
|
-
We use notify_tag to determine whether or not to send notification to the
|
86
|
-
completion queue. Once we've made that determination, we can reuse the
|
87
|
-
memory for cq_completion. */
|
88
|
-
union {
|
89
|
-
grpc_cq_completion cq_completion;
|
90
|
-
struct {
|
91
|
-
/* Any given op indicates completion by either (a) calling a closure or
|
92
|
-
(b) sending a notification on the call's completion queue. If
|
93
|
-
\a is_closure is true, \a tag indicates a closure to be invoked;
|
94
|
-
otherwise, \a tag indicates the tag to be used in the notification to
|
95
|
-
be sent to the completion queue. */
|
96
|
-
void* tag;
|
97
|
-
bool is_closure;
|
98
|
-
} notify_tag;
|
99
|
-
} completion_data;
|
100
|
-
grpc_closure start_batch;
|
101
|
-
grpc_closure finish_batch;
|
102
|
-
std::atomic<intptr_t> steps_to_complete{0};
|
103
|
-
AtomicError batch_error;
|
104
|
-
void set_num_steps_to_complete(uintptr_t steps) {
|
105
|
-
steps_to_complete.store(steps, std::memory_order_release);
|
106
|
-
}
|
107
|
-
bool completed_batch_step() {
|
108
|
-
return steps_to_complete.fetch_sub(1, std::memory_order_acq_rel) == 1;
|
109
|
-
}
|
110
|
-
};
|
67
|
+
grpc_core::TraceFlag grpc_call_error_trace(false, "call_error");
|
68
|
+
grpc_core::TraceFlag grpc_compression_trace(false, "compression");
|
111
69
|
|
112
|
-
|
113
|
-
parent_call() { gpr_mu_init(&child_list_mu); }
|
114
|
-
~parent_call() { gpr_mu_destroy(&child_list_mu); }
|
70
|
+
namespace grpc_core {
|
115
71
|
|
116
|
-
|
117
|
-
|
118
|
-
}
|
72
|
+
class Call : public CppImplOf<Call, grpc_call> {
|
73
|
+
public:
|
74
|
+
Arena* arena() { return arena_; }
|
75
|
+
bool is_client() const { return is_client_; }
|
76
|
+
|
77
|
+
virtual void ContextSet(grpc_context_index elem, void* value,
|
78
|
+
void (*destroy)(void* value)) = 0;
|
79
|
+
virtual void* ContextGet(grpc_context_index elem) const = 0;
|
80
|
+
virtual bool Completed() = 0;
|
81
|
+
void CancelWithStatus(grpc_status_code status, const char* description);
|
82
|
+
virtual void CancelWithError(grpc_error_handle error) = 0;
|
83
|
+
virtual void SetCompletionQueue(grpc_completion_queue* cq) = 0;
|
84
|
+
virtual char* GetPeer() = 0;
|
85
|
+
virtual grpc_call_error StartBatch(const grpc_op* ops, size_t nops,
|
86
|
+
void* notify_tag,
|
87
|
+
bool is_notify_tag_closure) = 0;
|
88
|
+
virtual bool failed_before_recv_message() const = 0;
|
89
|
+
virtual bool is_trailers_only() const = 0;
|
90
|
+
virtual void ExternalRef() = 0;
|
91
|
+
virtual void ExternalUnref() = 0;
|
92
|
+
virtual void InternalRef(const char* reason) = 0;
|
93
|
+
virtual void InternalUnref(const char* reason) = 0;
|
94
|
+
|
95
|
+
virtual grpc_compression_algorithm test_only_compression_algorithm() = 0;
|
96
|
+
virtual uint32_t test_only_message_flags() = 0;
|
97
|
+
virtual uint32_t test_only_encodings_accepted_by_peer() = 0;
|
98
|
+
virtual grpc_compression_algorithm compression_for_level(
|
99
|
+
grpc_compression_level level) = 0;
|
100
|
+
|
101
|
+
// This should return nullptr for the promise stack (and alternative means
|
102
|
+
// for that functionality be invented)
|
103
|
+
virtual grpc_call_stack* call_stack() = 0;
|
104
|
+
|
105
|
+
protected:
|
106
|
+
Call(Arena* arena, bool is_client, Timestamp send_deadline)
|
107
|
+
: arena_(arena), send_deadline_(send_deadline), is_client_(is_client) {
|
108
|
+
GPR_DEBUG_ASSERT(arena_ != nullptr);
|
109
|
+
}
|
110
|
+
~Call() = default;
|
111
|
+
|
112
|
+
struct ParentCall {
|
113
|
+
Mutex child_list_mu;
|
114
|
+
Call* first_child ABSL_GUARDED_BY(child_list_mu) = nullptr;
|
115
|
+
};
|
116
|
+
|
117
|
+
struct ChildCall {
|
118
|
+
explicit ChildCall(Call* parent) : parent(parent) {}
|
119
|
+
Call* parent;
|
120
|
+
/** siblings: children of the same parent form a list, and this list is
|
121
|
+
protected under
|
122
|
+
parent->mu */
|
123
|
+
Call* sibling_next = nullptr;
|
124
|
+
Call* sibling_prev = nullptr;
|
125
|
+
};
|
126
|
+
|
127
|
+
ParentCall* GetOrCreateParentCall();
|
128
|
+
ParentCall* parent_call();
|
129
|
+
|
130
|
+
absl::Status InitParent(Call* parent, uint32_t propagation_mask);
|
131
|
+
void PublishToParent(Call* parent);
|
132
|
+
void MaybeUnpublishFromParent();
|
133
|
+
void PropagateCancellationToChildren();
|
134
|
+
|
135
|
+
Timestamp send_deadline() const { return send_deadline_; }
|
136
|
+
void set_send_deadline(Timestamp send_deadline) {
|
137
|
+
send_deadline_ = send_deadline;
|
138
|
+
}
|
119
139
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
140
|
+
private:
|
141
|
+
Arena* const arena_;
|
142
|
+
std::atomic<ParentCall*> parent_call_{nullptr};
|
143
|
+
ChildCall* child_ = nullptr;
|
144
|
+
Timestamp send_deadline_;
|
145
|
+
const bool is_client_;
|
146
|
+
// flag indicating that cancellation is inherited
|
147
|
+
bool cancellation_is_inherited_ = false;
|
128
148
|
};
|
129
149
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
struct grpc_call {
|
134
|
-
grpc_call(grpc_core::Arena* arena, const grpc_call_create_args& args)
|
135
|
-
: arena(arena),
|
136
|
-
cq(args.cq),
|
137
|
-
channel(args.channel),
|
138
|
-
is_client(args.server_transport_data == nullptr),
|
139
|
-
stream_op_payload(context) {}
|
140
|
-
|
141
|
-
~grpc_call() {
|
150
|
+
class FilterStackCall final : public Call {
|
151
|
+
public:
|
152
|
+
~FilterStackCall() {
|
142
153
|
for (int i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
|
143
|
-
if (
|
144
|
-
|
154
|
+
if (context_[i].destroy) {
|
155
|
+
context_[i].destroy(context_[i].value);
|
145
156
|
}
|
146
157
|
}
|
147
|
-
gpr_free(static_cast<void*>(const_cast<char*>(
|
158
|
+
gpr_free(static_cast<void*>(const_cast<char*>(final_info_.error_string)));
|
159
|
+
}
|
160
|
+
|
161
|
+
bool Completed() override {
|
162
|
+
return gpr_atm_acq_load(&received_final_op_atm_) != 0;
|
163
|
+
}
|
164
|
+
|
165
|
+
// TODO(ctiller): return absl::StatusOr<SomeSmartPointer<Call>>?
|
166
|
+
static grpc_error_handle Create(grpc_call_create_args* args,
|
167
|
+
grpc_call** out_call);
|
168
|
+
|
169
|
+
static Call* FromTopElem(grpc_call_element* elem) {
|
170
|
+
return FromCallStack(grpc_call_stack_from_top_element(elem));
|
171
|
+
}
|
172
|
+
|
173
|
+
grpc_call_stack* call_stack() override {
|
174
|
+
return reinterpret_cast<grpc_call_stack*>(
|
175
|
+
reinterpret_cast<char*>(this) +
|
176
|
+
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(*this)));
|
177
|
+
}
|
178
|
+
|
179
|
+
grpc_call_element* call_elem(size_t idx) {
|
180
|
+
return grpc_call_stack_element(call_stack(), idx);
|
181
|
+
}
|
182
|
+
|
183
|
+
CallCombiner* call_combiner() { return &call_combiner_; }
|
184
|
+
|
185
|
+
void CancelWithError(grpc_error_handle error) override;
|
186
|
+
void SetCompletionQueue(grpc_completion_queue* cq) override;
|
187
|
+
char* GetPeer() override;
|
188
|
+
grpc_call_error StartBatch(const grpc_op* ops, size_t nops, void* notify_tag,
|
189
|
+
bool is_notify_tag_closure) override;
|
190
|
+
void ExternalRef() override { ext_ref_.Ref(); }
|
191
|
+
void ExternalUnref() override;
|
192
|
+
void InternalRef(const char* reason) override {
|
193
|
+
GRPC_CALL_STACK_REF(call_stack(), reason);
|
194
|
+
}
|
195
|
+
void InternalUnref(const char* reason) override {
|
196
|
+
GRPC_CALL_STACK_UNREF(call_stack(), reason);
|
197
|
+
}
|
198
|
+
|
199
|
+
void ContextSet(grpc_context_index elem, void* value,
|
200
|
+
void (*destroy)(void* value)) override;
|
201
|
+
void* ContextGet(grpc_context_index elem) const override {
|
202
|
+
return context_[elem].value;
|
203
|
+
}
|
204
|
+
|
205
|
+
grpc_compression_algorithm compression_for_level(
|
206
|
+
grpc_compression_level level) override {
|
207
|
+
return encodings_accepted_by_peer_.CompressionAlgorithmForLevel(level);
|
148
208
|
}
|
149
209
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
210
|
+
bool is_trailers_only() const override {
|
211
|
+
bool result = is_trailers_only_;
|
212
|
+
GPR_DEBUG_ASSERT(!result || recv_initial_metadata_.TransportSize() == 0);
|
213
|
+
return result;
|
214
|
+
}
|
215
|
+
|
216
|
+
bool failed_before_recv_message() const override {
|
217
|
+
return call_failed_before_recv_message_;
|
218
|
+
}
|
219
|
+
|
220
|
+
grpc_compression_algorithm test_only_compression_algorithm() override {
|
221
|
+
return incoming_compression_algorithm_;
|
222
|
+
}
|
223
|
+
|
224
|
+
uint32_t test_only_message_flags() override {
|
225
|
+
return test_only_last_message_flags_;
|
226
|
+
}
|
227
|
+
|
228
|
+
uint32_t test_only_encodings_accepted_by_peer() override {
|
229
|
+
return encodings_accepted_by_peer_.ToLegacyBitmask();
|
230
|
+
}
|
231
|
+
|
232
|
+
static size_t InitialSizeEstimate() {
|
233
|
+
return sizeof(FilterStackCall) +
|
234
|
+
sizeof(BatchControl) * kMaxConcurrentBatches;
|
235
|
+
}
|
236
|
+
|
237
|
+
private:
|
238
|
+
// The maximum number of concurrent batches possible.
|
239
|
+
// Based upon the maximum number of individually queueable ops in the batch
|
240
|
+
// api:
|
241
|
+
// - initial metadata send
|
242
|
+
// - message send
|
243
|
+
// - status/close send (depending on client/server)
|
244
|
+
// - initial metadata recv
|
245
|
+
// - message recv
|
246
|
+
// - status/close recv (depending on client/server)
|
247
|
+
static constexpr size_t kMaxConcurrentBatches = 6;
|
248
|
+
|
249
|
+
static constexpr gpr_atm kRecvNone = 0;
|
250
|
+
static constexpr gpr_atm kRecvInitialMetadataFirst = 1;
|
251
|
+
|
252
|
+
struct BatchControl {
|
253
|
+
FilterStackCall* call_ = nullptr;
|
254
|
+
grpc_transport_stream_op_batch op_;
|
255
|
+
/* Share memory for cq_completion and notify_tag as they are never needed
|
256
|
+
simultaneously. Each byte used in this data structure count as six bytes
|
257
|
+
per call, so any savings we can make are worthwhile,
|
258
|
+
|
259
|
+
We use notify_tag to determine whether or not to send notification to the
|
260
|
+
completion queue. Once we've made that determination, we can reuse the
|
261
|
+
memory for cq_completion. */
|
262
|
+
union {
|
263
|
+
grpc_cq_completion cq_completion;
|
264
|
+
struct {
|
265
|
+
/* Any given op indicates completion by either (a) calling a closure or
|
266
|
+
(b) sending a notification on the call's completion queue. If
|
267
|
+
\a is_closure is true, \a tag indicates a closure to be invoked;
|
268
|
+
otherwise, \a tag indicates the tag to be used in the notification to
|
269
|
+
be sent to the completion queue. */
|
270
|
+
void* tag;
|
271
|
+
bool is_closure;
|
272
|
+
} notify_tag;
|
273
|
+
} completion_data_;
|
274
|
+
grpc_closure start_batch_;
|
275
|
+
grpc_closure finish_batch_;
|
276
|
+
std::atomic<intptr_t> steps_to_complete_{0};
|
277
|
+
AtomicError batch_error_;
|
278
|
+
void set_num_steps_to_complete(uintptr_t steps) {
|
279
|
+
steps_to_complete_.store(steps, std::memory_order_release);
|
280
|
+
}
|
281
|
+
bool completed_batch_step() {
|
282
|
+
return steps_to_complete_.fetch_sub(1, std::memory_order_acq_rel) == 1;
|
283
|
+
}
|
284
|
+
|
285
|
+
void PostCompletion();
|
286
|
+
void FinishStep();
|
287
|
+
void ContinueReceivingSlices();
|
288
|
+
void ReceivingSliceReady(grpc_error_handle error);
|
289
|
+
void ProcessDataAfterMetadata();
|
290
|
+
void ReceivingStreamReady(grpc_error_handle error);
|
291
|
+
void ValidateFilteredMetadata();
|
292
|
+
void ReceivingInitialMetadataReady(grpc_error_handle error);
|
293
|
+
void ReceivingTrailingMetadataReady(grpc_error_handle error);
|
294
|
+
void FinishBatch(grpc_error_handle error);
|
295
|
+
};
|
296
|
+
|
297
|
+
FilterStackCall(Arena* arena, const grpc_call_create_args& args)
|
298
|
+
: Call(arena, args.server_transport_data == nullptr, args.send_deadline),
|
299
|
+
cq_(args.cq),
|
300
|
+
channel_(args.channel),
|
301
|
+
stream_op_payload_(context_) {}
|
302
|
+
|
303
|
+
static void ReleaseCall(void* call, grpc_error_handle);
|
304
|
+
static void DestroyCall(void* call, grpc_error_handle);
|
305
|
+
|
306
|
+
static FilterStackCall* FromCallStack(grpc_call_stack* call_stack) {
|
307
|
+
return reinterpret_cast<FilterStackCall*>(
|
308
|
+
reinterpret_cast<char*>(call_stack) -
|
309
|
+
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(FilterStackCall)));
|
310
|
+
}
|
311
|
+
|
312
|
+
void ExecuteBatch(grpc_transport_stream_op_batch* batch,
|
313
|
+
grpc_closure* start_batch_closure);
|
314
|
+
void SetFinalStatus(grpc_error_handle error);
|
315
|
+
BatchControl* ReuseOrAllocateBatchControl(const grpc_op* ops);
|
316
|
+
void HandleCompressionAlgorithmDisabled(
|
317
|
+
grpc_compression_algorithm compression_algorithm) GPR_ATTRIBUTE_NOINLINE;
|
318
|
+
void HandleCompressionAlgorithmNotAccepted(
|
319
|
+
grpc_compression_algorithm compression_algorithm) GPR_ATTRIBUTE_NOINLINE;
|
320
|
+
bool PrepareApplicationMetadata(size_t count, grpc_metadata* metadata,
|
321
|
+
bool is_trailing);
|
322
|
+
void PublishAppMetadata(grpc_metadata_batch* b, bool is_trailing);
|
323
|
+
void RecvInitialFilter(grpc_metadata_batch* b);
|
324
|
+
void RecvTrailingFilter(grpc_metadata_batch* b,
|
325
|
+
grpc_error_handle batch_error);
|
326
|
+
|
327
|
+
RefCount ext_ref_;
|
328
|
+
CallCombiner call_combiner_;
|
329
|
+
grpc_completion_queue* cq_;
|
330
|
+
grpc_polling_entity pollent_;
|
331
|
+
grpc_channel* channel_;
|
332
|
+
gpr_cycle_counter start_time_ = gpr_get_cycle_counter();
|
159
333
|
|
160
|
-
/* client or server call */
|
161
|
-
bool is_client;
|
162
334
|
/** has grpc_call_unref been called */
|
163
|
-
bool
|
164
|
-
/** flag indicating that cancellation is inherited */
|
165
|
-
bool cancellation_is_inherited = false;
|
335
|
+
bool destroy_called_ = false;
|
166
336
|
// Trailers-only response status
|
167
|
-
bool
|
337
|
+
bool is_trailers_only_ = false;
|
168
338
|
/** which ops are in-flight */
|
169
|
-
bool
|
170
|
-
bool
|
171
|
-
bool
|
172
|
-
bool
|
173
|
-
bool
|
174
|
-
bool
|
175
|
-
gpr_atm
|
176
|
-
gpr_atm
|
177
|
-
|
178
|
-
|
179
|
-
grpc_transport_stream_op_batch_payload
|
339
|
+
bool sent_initial_metadata_ = false;
|
340
|
+
bool sending_message_ = false;
|
341
|
+
bool sent_final_op_ = false;
|
342
|
+
bool received_initial_metadata_ = false;
|
343
|
+
bool receiving_message_ = false;
|
344
|
+
bool requested_final_op_ = false;
|
345
|
+
gpr_atm any_ops_sent_atm_ = 0;
|
346
|
+
gpr_atm received_final_op_atm_ = 0;
|
347
|
+
|
348
|
+
BatchControl* active_batches_[kMaxConcurrentBatches] = {};
|
349
|
+
grpc_transport_stream_op_batch_payload stream_op_payload_;
|
180
350
|
|
181
351
|
/* first idx: is_receiving, second idx: is_trailing */
|
182
|
-
grpc_metadata_batch
|
183
|
-
grpc_metadata_batch
|
184
|
-
grpc_metadata_batch
|
185
|
-
grpc_metadata_batch
|
352
|
+
grpc_metadata_batch send_initial_metadata_{arena()};
|
353
|
+
grpc_metadata_batch send_trailing_metadata_{arena()};
|
354
|
+
grpc_metadata_batch recv_initial_metadata_{arena()};
|
355
|
+
grpc_metadata_batch recv_trailing_metadata_{arena()};
|
186
356
|
|
187
357
|
/* Buffered read metadata waiting to be returned to the application.
|
188
358
|
Element 0 is initial metadata, element 1 is trailing metadata. */
|
189
|
-
grpc_metadata_array*
|
359
|
+
grpc_metadata_array* buffered_metadata_[2] = {};
|
190
360
|
|
191
361
|
// A char* indicating the peer name.
|
192
|
-
gpr_atm
|
362
|
+
gpr_atm peer_string_ = 0;
|
193
363
|
|
194
364
|
/* Call data useful used for reporting. Only valid after the call has
|
195
365
|
* completed */
|
196
|
-
grpc_call_final_info
|
366
|
+
grpc_call_final_info final_info_;
|
197
367
|
|
198
368
|
/* Compression algorithm for *incoming* data */
|
199
|
-
grpc_compression_algorithm
|
369
|
+
grpc_compression_algorithm incoming_compression_algorithm_ =
|
200
370
|
GRPC_COMPRESS_NONE;
|
201
371
|
/* Supported encodings (compression algorithms), a bitset.
|
202
372
|
* Always support no compression. */
|
203
|
-
|
204
|
-
GRPC_COMPRESS_NONE};
|
205
|
-
/* Supported stream encodings (stream compression algorithms), a bitset */
|
206
|
-
uint32_t stream_encodings_accepted_by_peer = 0;
|
373
|
+
CompressionAlgorithmSet encodings_accepted_by_peer_{GRPC_COMPRESS_NONE};
|
207
374
|
|
208
375
|
/* Contexts for various subsystems (security, tracing, ...). */
|
209
|
-
grpc_call_context_element
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
grpc_closure
|
220
|
-
grpc_closure
|
221
|
-
|
222
|
-
grpc_closure receiving_trailing_metadata_ready;
|
223
|
-
uint32_t test_only_last_message_flags = 0;
|
376
|
+
grpc_call_context_element context_[GRPC_CONTEXT_COUNT] = {};
|
377
|
+
|
378
|
+
ManualConstructor<SliceBufferByteStream> sending_stream_;
|
379
|
+
|
380
|
+
OrphanablePtr<ByteStream> receiving_stream_;
|
381
|
+
bool call_failed_before_recv_message_ = false;
|
382
|
+
grpc_byte_buffer** receiving_buffer_ = nullptr;
|
383
|
+
grpc_slice receiving_slice_ = grpc_empty_slice();
|
384
|
+
grpc_closure receiving_slice_ready_;
|
385
|
+
grpc_closure receiving_stream_ready_;
|
386
|
+
grpc_closure receiving_initial_metadata_ready_;
|
387
|
+
grpc_closure receiving_trailing_metadata_ready_;
|
388
|
+
uint32_t test_only_last_message_flags_ = 0;
|
224
389
|
// Status about operation of call
|
225
|
-
bool
|
226
|
-
gpr_atm
|
390
|
+
bool sent_server_trailing_metadata_ = false;
|
391
|
+
gpr_atm cancelled_with_error_ = 0;
|
227
392
|
|
228
|
-
grpc_closure
|
393
|
+
grpc_closure release_call_;
|
229
394
|
|
230
395
|
union {
|
231
396
|
struct {
|
@@ -236,10 +401,10 @@ struct grpc_call {
|
|
236
401
|
struct {
|
237
402
|
int* cancelled;
|
238
403
|
// backpointer to owning server if this is a server side call.
|
239
|
-
|
404
|
+
Server* core_server;
|
240
405
|
} server;
|
241
|
-
}
|
242
|
-
AtomicError
|
406
|
+
} final_op_;
|
407
|
+
AtomicError status_error_;
|
243
408
|
|
244
409
|
/* recv_state can contain one of the following values:
|
245
410
|
RECV_NONE : : no initial metadata and messages received
|
@@ -257,220 +422,178 @@ struct grpc_call {
|
|
257
422
|
|
258
423
|
For 1, 4: See receiving_initial_metadata_ready() function
|
259
424
|
For 2, 3: See receiving_stream_ready() function */
|
260
|
-
gpr_atm
|
425
|
+
gpr_atm recv_state_ = 0;
|
261
426
|
};
|
262
427
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx)
|
275
|
-
#define CALL_FROM_TOP_ELEM(top_elem) \
|
276
|
-
CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem))
|
277
|
-
|
278
|
-
static void execute_batch(grpc_call* call,
|
279
|
-
grpc_transport_stream_op_batch* batch,
|
280
|
-
grpc_closure* start_batch_closure);
|
281
|
-
|
282
|
-
static void cancel_with_status(grpc_call* c, grpc_status_code status,
|
283
|
-
const char* description);
|
284
|
-
static void cancel_with_error(grpc_call* c, grpc_error_handle error);
|
285
|
-
static void destroy_call(void* call_stack, grpc_error_handle error);
|
286
|
-
static void receiving_slice_ready(void* bctlp, grpc_error_handle error);
|
287
|
-
static void set_final_status(grpc_call* call, grpc_error_handle error);
|
288
|
-
static void process_data_after_md(batch_control* bctl);
|
289
|
-
static void post_batch_completion(batch_control* bctl);
|
290
|
-
|
291
|
-
static void add_init_error(grpc_error_handle* composite,
|
292
|
-
grpc_error_handle new_err) {
|
293
|
-
if (new_err == GRPC_ERROR_NONE) return;
|
294
|
-
if (*composite == GRPC_ERROR_NONE) {
|
295
|
-
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Call creation failed");
|
428
|
+
Call::ParentCall* Call::GetOrCreateParentCall() {
|
429
|
+
ParentCall* p = parent_call_.load(std::memory_order_acquire);
|
430
|
+
if (p == nullptr) {
|
431
|
+
p = arena_->New<ParentCall>();
|
432
|
+
ParentCall* expected = nullptr;
|
433
|
+
if (!parent_call_.compare_exchange_strong(expected, p,
|
434
|
+
std::memory_order_release,
|
435
|
+
std::memory_order_relaxed)) {
|
436
|
+
p->~ParentCall();
|
437
|
+
p = expected;
|
438
|
+
}
|
296
439
|
}
|
297
|
-
|
440
|
+
return p;
|
298
441
|
}
|
299
442
|
|
300
|
-
|
301
|
-
|
302
|
-
return call->arena->Alloc(size);
|
443
|
+
Call::ParentCall* Call::parent_call() {
|
444
|
+
return parent_call_.load(std::memory_order_acquire);
|
303
445
|
}
|
304
446
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
447
|
+
absl::Status Call::InitParent(Call* parent, uint32_t propagation_mask) {
|
448
|
+
child_ = arena()->New<ChildCall>(parent);
|
449
|
+
|
450
|
+
parent->InternalRef("child");
|
451
|
+
GPR_ASSERT(is_client_);
|
452
|
+
GPR_ASSERT(!parent->is_client_);
|
453
|
+
|
454
|
+
if (propagation_mask & GRPC_PROPAGATE_DEADLINE) {
|
455
|
+
send_deadline_ = std::min(send_deadline_, parent->send_deadline_);
|
456
|
+
}
|
457
|
+
/* for now GRPC_PROPAGATE_TRACING_CONTEXT *MUST* be passed with
|
458
|
+
* GRPC_PROPAGATE_STATS_CONTEXT */
|
459
|
+
/* TODO(ctiller): This should change to use the appropriate census start_op
|
460
|
+
* call. */
|
461
|
+
if (propagation_mask & GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT) {
|
462
|
+
if (0 == (propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT)) {
|
463
|
+
return absl::UnknownError(
|
464
|
+
"Census tracing propagation requested without Census context "
|
465
|
+
"propagation");
|
316
466
|
}
|
467
|
+
ContextSet(GRPC_CONTEXT_TRACING, parent->ContextGet(GRPC_CONTEXT_TRACING),
|
468
|
+
nullptr);
|
469
|
+
} else if (propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT) {
|
470
|
+
return absl::UnknownError(
|
471
|
+
"Census context propagation requested without Census tracing "
|
472
|
+
"propagation");
|
317
473
|
}
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
return reinterpret_cast<parent_call*>(
|
323
|
-
gpr_atm_acq_load(&call->parent_call_atm));
|
474
|
+
if (propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
|
475
|
+
cancellation_is_inherited_ = true;
|
476
|
+
}
|
477
|
+
return absl::OkStatus();
|
324
478
|
}
|
325
479
|
|
326
|
-
|
327
|
-
|
480
|
+
void Call::PublishToParent(Call* parent) {
|
481
|
+
ChildCall* cc = child_;
|
482
|
+
ParentCall* pc = parent->GetOrCreateParentCall();
|
483
|
+
MutexLock lock(&pc->child_list_mu);
|
484
|
+
if (pc->first_child == nullptr) {
|
485
|
+
pc->first_child = this;
|
486
|
+
cc->sibling_next = cc->sibling_prev = this;
|
487
|
+
} else {
|
488
|
+
cc->sibling_next = pc->first_child;
|
489
|
+
cc->sibling_prev = pc->first_child->child_->sibling_prev;
|
490
|
+
cc->sibling_next->child_->sibling_prev =
|
491
|
+
cc->sibling_prev->child_->sibling_next = this;
|
492
|
+
}
|
493
|
+
if (parent->Completed()) {
|
494
|
+
CancelWithError(GRPC_ERROR_CANCELLED);
|
495
|
+
}
|
328
496
|
}
|
329
497
|
|
330
|
-
grpc_error_handle
|
331
|
-
|
498
|
+
grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
|
499
|
+
grpc_call** out_call) {
|
332
500
|
GPR_TIMER_SCOPE("grpc_call_create", 0);
|
333
501
|
|
334
502
|
GRPC_CHANNEL_INTERNAL_REF(args->channel, "call");
|
335
503
|
|
336
|
-
|
337
|
-
|
504
|
+
auto add_init_error = [](grpc_error_handle* composite,
|
505
|
+
grpc_error_handle new_err) {
|
506
|
+
if (new_err == GRPC_ERROR_NONE) return;
|
507
|
+
if (*composite == GRPC_ERROR_NONE) {
|
508
|
+
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Call creation failed");
|
509
|
+
}
|
510
|
+
*composite = grpc_error_add_child(*composite, new_err);
|
511
|
+
};
|
512
|
+
|
513
|
+
Arena* arena;
|
514
|
+
FilterStackCall* call;
|
338
515
|
grpc_error_handle error = GRPC_ERROR_NONE;
|
339
516
|
grpc_channel_stack* channel_stack =
|
340
517
|
grpc_channel_get_channel_stack(args->channel);
|
341
518
|
size_t initial_size = grpc_channel_get_call_size_estimate(args->channel);
|
342
519
|
GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
|
343
|
-
size_t call_and_stack_size =
|
344
|
-
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)) +
|
345
|
-
channel_stack->call_stack_size;
|
346
520
|
size_t call_alloc_size =
|
347
|
-
|
521
|
+
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(FilterStackCall)) +
|
522
|
+
channel_stack->call_stack_size;
|
348
523
|
|
349
|
-
std::pair<
|
350
|
-
|
351
|
-
&*args->channel->allocator);
|
524
|
+
std::pair<Arena*, void*> arena_with_call = Arena::CreateWithAlloc(
|
525
|
+
initial_size, call_alloc_size, &*args->channel->allocator);
|
352
526
|
arena = arena_with_call.first;
|
353
|
-
call = new (arena_with_call.second)
|
354
|
-
|
527
|
+
call = new (arena_with_call.second) FilterStackCall(arena, *args);
|
528
|
+
GPR_DEBUG_ASSERT(FromC(call->c_ptr()) == call);
|
529
|
+
GPR_DEBUG_ASSERT(FromCallStack(call->call_stack()) == call);
|
530
|
+
*out_call = call->c_ptr();
|
355
531
|
grpc_slice path = grpc_empty_slice();
|
356
|
-
if (call->is_client) {
|
357
|
-
call->
|
358
|
-
call->
|
359
|
-
call->
|
532
|
+
if (call->is_client()) {
|
533
|
+
call->final_op_.client.status_details = nullptr;
|
534
|
+
call->final_op_.client.status = nullptr;
|
535
|
+
call->final_op_.client.error_string = nullptr;
|
360
536
|
GRPC_STATS_INC_CLIENT_CALLS_CREATED();
|
361
537
|
path = grpc_slice_ref_internal(args->path->c_slice());
|
362
|
-
call->
|
363
|
-
|
538
|
+
call->send_initial_metadata_.Set(HttpPathMetadata(),
|
539
|
+
std::move(*args->path));
|
364
540
|
if (args->authority.has_value()) {
|
365
|
-
call->
|
366
|
-
|
541
|
+
call->send_initial_metadata_.Set(HttpAuthorityMetadata(),
|
542
|
+
std::move(*args->authority));
|
367
543
|
}
|
368
544
|
} else {
|
369
545
|
GRPC_STATS_INC_SERVER_CALLS_CREATED();
|
370
|
-
call->
|
371
|
-
call->
|
546
|
+
call->final_op_.server.cancelled = nullptr;
|
547
|
+
call->final_op_.server.core_server = args->server;
|
372
548
|
}
|
373
549
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
call->child = new (reinterpret_cast<char*>(arena_with_call.second) +
|
379
|
-
call_and_stack_size) child_call(args->parent);
|
380
|
-
|
381
|
-
GRPC_CALL_INTERNAL_REF(args->parent, "child");
|
382
|
-
GPR_ASSERT(call->is_client);
|
383
|
-
GPR_ASSERT(!args->parent->is_client);
|
384
|
-
|
385
|
-
if (args->propagation_mask & GRPC_PROPAGATE_DEADLINE) {
|
386
|
-
send_deadline = std::min(send_deadline, args->parent->send_deadline);
|
387
|
-
}
|
388
|
-
/* for now GRPC_PROPAGATE_TRACING_CONTEXT *MUST* be passed with
|
389
|
-
* GRPC_PROPAGATE_STATS_CONTEXT */
|
390
|
-
/* TODO(ctiller): This should change to use the appropriate census start_op
|
391
|
-
* call. */
|
392
|
-
if (args->propagation_mask & GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT) {
|
393
|
-
if (0 == (args->propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT)) {
|
394
|
-
add_init_error(&error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
395
|
-
"Census tracing propagation requested "
|
396
|
-
"without Census context propagation"));
|
397
|
-
}
|
398
|
-
grpc_call_context_set(call, GRPC_CONTEXT_TRACING,
|
399
|
-
args->parent->context[GRPC_CONTEXT_TRACING].value,
|
400
|
-
nullptr);
|
401
|
-
} else if (args->propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT) {
|
402
|
-
add_init_error(&error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
403
|
-
"Census context propagation requested "
|
404
|
-
"without Census tracing propagation"));
|
405
|
-
}
|
406
|
-
if (args->propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
|
407
|
-
call->cancellation_is_inherited = true;
|
408
|
-
if (gpr_atm_acq_load(&args->parent->received_final_op_atm)) {
|
409
|
-
immediately_cancel = true;
|
410
|
-
}
|
411
|
-
}
|
550
|
+
Call* parent = Call::FromC(args->parent);
|
551
|
+
if (parent != nullptr) {
|
552
|
+
add_init_error(&error, absl_status_to_grpc_error(call->InitParent(
|
553
|
+
parent, args->propagation_mask)));
|
412
554
|
}
|
413
|
-
call->send_deadline = send_deadline;
|
414
555
|
/* initial refcount dropped by grpc_call_unref */
|
415
|
-
grpc_call_element_args call_args = {
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
call->arena,
|
422
|
-
&call->call_combiner};
|
423
|
-
add_init_error(&error, grpc_call_stack_init(channel_stack, 1, destroy_call,
|
556
|
+
grpc_call_element_args call_args = {
|
557
|
+
call->call_stack(), args->server_transport_data,
|
558
|
+
call->context_, path,
|
559
|
+
call->start_time_, call->send_deadline(),
|
560
|
+
call->arena(), &call->call_combiner_};
|
561
|
+
add_init_error(&error, grpc_call_stack_init(channel_stack, 1, DestroyCall,
|
424
562
|
call, &call_args));
|
425
563
|
// Publish this call to parent only after the call stack has been initialized.
|
426
|
-
if (
|
427
|
-
|
428
|
-
parent_call* pc = get_or_create_parent_call(args->parent);
|
429
|
-
gpr_mu_lock(&pc->child_list_mu);
|
430
|
-
if (pc->first_child == nullptr) {
|
431
|
-
pc->first_child = call;
|
432
|
-
cc->sibling_next = cc->sibling_prev = call;
|
433
|
-
} else {
|
434
|
-
cc->sibling_next = pc->first_child;
|
435
|
-
cc->sibling_prev = pc->first_child->child->sibling_prev;
|
436
|
-
cc->sibling_next->child->sibling_prev =
|
437
|
-
cc->sibling_prev->child->sibling_next = call;
|
438
|
-
}
|
439
|
-
gpr_mu_unlock(&pc->child_list_mu);
|
564
|
+
if (parent != nullptr) {
|
565
|
+
call->PublishToParent(parent);
|
440
566
|
}
|
441
567
|
|
442
568
|
if (error != GRPC_ERROR_NONE) {
|
443
|
-
|
444
|
-
}
|
445
|
-
if (immediately_cancel) {
|
446
|
-
cancel_with_error(call, GRPC_ERROR_CANCELLED);
|
569
|
+
call->CancelWithError(GRPC_ERROR_REF(error));
|
447
570
|
}
|
448
571
|
if (args->cq != nullptr) {
|
449
572
|
GPR_ASSERT(args->pollset_set_alternative == nullptr &&
|
450
573
|
"Only one of 'cq' and 'pollset_set_alternative' should be "
|
451
574
|
"non-nullptr.");
|
452
575
|
GRPC_CQ_INTERNAL_REF(args->cq, "bind");
|
453
|
-
call->
|
576
|
+
call->pollent_ =
|
454
577
|
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(args->cq));
|
455
578
|
}
|
456
579
|
if (args->pollset_set_alternative != nullptr) {
|
457
|
-
call->
|
580
|
+
call->pollent_ = grpc_polling_entity_create_from_pollset_set(
|
458
581
|
args->pollset_set_alternative);
|
459
582
|
}
|
460
|
-
if (!grpc_polling_entity_is_empty(&call->
|
461
|
-
grpc_call_stack_set_pollset_or_pollset_set(
|
462
|
-
&call->
|
583
|
+
if (!grpc_polling_entity_is_empty(&call->pollent_)) {
|
584
|
+
grpc_call_stack_set_pollset_or_pollset_set(call->call_stack(),
|
585
|
+
&call->pollent_);
|
463
586
|
}
|
464
587
|
|
465
|
-
if (call->is_client) {
|
466
|
-
|
467
|
-
grpc_channel_get_channelz_node(call->
|
588
|
+
if (call->is_client()) {
|
589
|
+
channelz::ChannelNode* channelz_channel =
|
590
|
+
grpc_channel_get_channelz_node(call->channel_);
|
468
591
|
if (channelz_channel != nullptr) {
|
469
592
|
channelz_channel->RecordCallStarted();
|
470
593
|
}
|
471
|
-
} else if (call->
|
472
|
-
|
473
|
-
call->
|
594
|
+
} else if (call->final_op_.server.core_server != nullptr) {
|
595
|
+
channelz::ServerNode* channelz_node =
|
596
|
+
call->final_op_.server.core_server->channelz_node();
|
474
597
|
if (channelz_node != nullptr) {
|
475
598
|
channelz_node->RecordCallStarted();
|
476
599
|
}
|
@@ -481,266 +604,211 @@ grpc_error_handle grpc_call_create(grpc_call_create_args* args,
|
|
481
604
|
return error;
|
482
605
|
}
|
483
606
|
|
484
|
-
void
|
485
|
-
grpc_completion_queue* cq) {
|
607
|
+
void FilterStackCall::SetCompletionQueue(grpc_completion_queue* cq) {
|
486
608
|
GPR_ASSERT(cq);
|
487
609
|
|
488
|
-
if (grpc_polling_entity_pollset_set(&
|
610
|
+
if (grpc_polling_entity_pollset_set(&pollent_) != nullptr) {
|
489
611
|
gpr_log(GPR_ERROR, "A pollset_set is already registered for this call.");
|
490
612
|
abort();
|
491
613
|
}
|
492
|
-
|
614
|
+
cq_ = cq;
|
493
615
|
GRPC_CQ_INTERNAL_REF(cq, "bind");
|
494
|
-
|
495
|
-
grpc_call_stack_set_pollset_or_pollset_set(
|
496
|
-
&call->pollent);
|
497
|
-
}
|
498
|
-
|
499
|
-
#ifndef NDEBUG
|
500
|
-
#define REF_REASON reason
|
501
|
-
#define REF_ARG , const char* reason
|
502
|
-
#else
|
503
|
-
#define REF_REASON ""
|
504
|
-
#define REF_ARG
|
505
|
-
#endif
|
506
|
-
void grpc_call_internal_ref(grpc_call* c REF_ARG) {
|
507
|
-
GRPC_CALL_STACK_REF(CALL_STACK_FROM_CALL(c), REF_REASON);
|
508
|
-
}
|
509
|
-
void grpc_call_internal_unref(grpc_call* c REF_ARG) {
|
510
|
-
GRPC_CALL_STACK_UNREF(CALL_STACK_FROM_CALL(c), REF_REASON);
|
616
|
+
pollent_ = grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq));
|
617
|
+
grpc_call_stack_set_pollset_or_pollset_set(call_stack(), &pollent_);
|
511
618
|
}
|
512
619
|
|
513
|
-
|
514
|
-
|
515
|
-
grpc_channel* channel = c->
|
516
|
-
|
517
|
-
c->~
|
620
|
+
void FilterStackCall::ReleaseCall(void* call, grpc_error_handle /*error*/) {
|
621
|
+
auto* c = static_cast<FilterStackCall*>(call);
|
622
|
+
grpc_channel* channel = c->channel_;
|
623
|
+
Arena* arena = c->arena();
|
624
|
+
c->~FilterStackCall();
|
518
625
|
grpc_channel_update_call_size_estimate(channel, arena->Destroy());
|
519
626
|
GRPC_CHANNEL_INTERNAL_UNREF(channel, "call");
|
520
627
|
}
|
521
628
|
|
522
|
-
|
629
|
+
void FilterStackCall::DestroyCall(void* call, grpc_error_handle /*error*/) {
|
523
630
|
GPR_TIMER_SCOPE("destroy_call", 0);
|
524
|
-
|
525
|
-
c->
|
526
|
-
c->
|
527
|
-
c->
|
528
|
-
|
631
|
+
auto* c = static_cast<FilterStackCall*>(call);
|
632
|
+
c->recv_initial_metadata_.Clear();
|
633
|
+
c->recv_trailing_metadata_.Clear();
|
634
|
+
c->receiving_stream_.reset();
|
635
|
+
ParentCall* pc = c->parent_call();
|
529
636
|
if (pc != nullptr) {
|
530
|
-
pc->~
|
637
|
+
pc->~ParentCall();
|
531
638
|
}
|
532
|
-
if (c->
|
533
|
-
GRPC_CQ_INTERNAL_UNREF(c->
|
639
|
+
if (c->cq_) {
|
640
|
+
GRPC_CQ_INTERNAL_UNREF(c->cq_, "bind");
|
534
641
|
}
|
535
642
|
|
536
|
-
grpc_error_handle status_error = c->
|
537
|
-
grpc_error_get_status(status_error, c->send_deadline,
|
538
|
-
&c->
|
539
|
-
&(c->
|
540
|
-
c->
|
541
|
-
c->
|
542
|
-
gpr_cycle_counter_sub(gpr_get_cycle_counter(), c->
|
543
|
-
grpc_call_stack_destroy(
|
544
|
-
GRPC_CLOSURE_INIT(&c->
|
643
|
+
grpc_error_handle status_error = c->status_error_.get();
|
644
|
+
grpc_error_get_status(status_error, c->send_deadline(),
|
645
|
+
&c->final_info_.final_status, nullptr, nullptr,
|
646
|
+
&(c->final_info_.error_string));
|
647
|
+
c->status_error_.set(GRPC_ERROR_NONE);
|
648
|
+
c->final_info_.stats.latency =
|
649
|
+
gpr_cycle_counter_sub(gpr_get_cycle_counter(), c->start_time_);
|
650
|
+
grpc_call_stack_destroy(c->call_stack(), &c->final_info_,
|
651
|
+
GRPC_CLOSURE_INIT(&c->release_call_, ReleaseCall, c,
|
545
652
|
grpc_schedule_on_exec_ctx));
|
546
653
|
}
|
547
654
|
|
548
|
-
void
|
549
|
-
|
550
|
-
|
551
|
-
if (GPR_LIKELY(!c->ext_ref.Unref())) return;
|
552
|
-
|
553
|
-
GPR_TIMER_SCOPE("grpc_call_unref", 0);
|
655
|
+
void Call::MaybeUnpublishFromParent() {
|
656
|
+
ChildCall* cc = child_;
|
657
|
+
if (cc == nullptr) return;
|
554
658
|
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (c));
|
560
|
-
|
561
|
-
if (cc) {
|
562
|
-
parent_call* pc = get_parent_call(cc->parent);
|
563
|
-
gpr_mu_lock(&pc->child_list_mu);
|
564
|
-
if (c == pc->first_child) {
|
659
|
+
ParentCall* pc = cc->parent->parent_call();
|
660
|
+
{
|
661
|
+
MutexLock lock(&pc->child_list_mu);
|
662
|
+
if (this == pc->first_child) {
|
565
663
|
pc->first_child = cc->sibling_next;
|
566
|
-
if (
|
664
|
+
if (this == pc->first_child) {
|
567
665
|
pc->first_child = nullptr;
|
568
666
|
}
|
569
667
|
}
|
570
|
-
cc->sibling_prev->
|
571
|
-
cc->sibling_next->
|
572
|
-
gpr_mu_unlock(&pc->child_list_mu);
|
573
|
-
GRPC_CALL_INTERNAL_UNREF(cc->parent, "child");
|
668
|
+
cc->sibling_prev->child_->sibling_next = cc->sibling_next;
|
669
|
+
cc->sibling_next->child_->sibling_prev = cc->sibling_prev;
|
574
670
|
}
|
671
|
+
cc->parent->InternalUnref("child");
|
672
|
+
}
|
673
|
+
|
674
|
+
void FilterStackCall::ExternalUnref() {
|
675
|
+
if (GPR_LIKELY(!ext_ref_.Unref())) return;
|
676
|
+
|
677
|
+
GPR_TIMER_SCOPE("grpc_call_unref", 0);
|
678
|
+
|
679
|
+
ApplicationCallbackExecCtx callback_exec_ctx;
|
680
|
+
ExecCtx exec_ctx;
|
681
|
+
|
682
|
+
GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (this));
|
575
683
|
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
684
|
+
MaybeUnpublishFromParent();
|
685
|
+
|
686
|
+
GPR_ASSERT(!destroy_called_);
|
687
|
+
destroy_called_ = true;
|
688
|
+
bool cancel = gpr_atm_acq_load(&any_ops_sent_atm_) != 0 &&
|
689
|
+
gpr_atm_acq_load(&received_final_op_atm_) == 0;
|
580
690
|
if (cancel) {
|
581
|
-
|
691
|
+
CancelWithError(GRPC_ERROR_CANCELLED);
|
582
692
|
} else {
|
583
693
|
// Unset the call combiner cancellation closure. This has the
|
584
694
|
// effect of scheduling the previously set cancellation closure, if
|
585
695
|
// any, so that it can release any internal references it may be
|
586
696
|
// holding to the call stack.
|
587
|
-
|
697
|
+
call_combiner_.SetNotifyOnCancel(nullptr);
|
588
698
|
}
|
589
|
-
|
590
|
-
}
|
591
|
-
|
592
|
-
grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
|
593
|
-
GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
|
594
|
-
GPR_ASSERT(!reserved);
|
595
|
-
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
596
|
-
grpc_core::ExecCtx exec_ctx;
|
597
|
-
cancel_with_error(call, GRPC_ERROR_CANCELLED);
|
598
|
-
return GRPC_CALL_OK;
|
699
|
+
InternalUnref("destroy");
|
599
700
|
}
|
600
701
|
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
static_cast<grpc_transport_stream_op_batch*>(arg);
|
608
|
-
grpc_call* call = static_cast<grpc_call*>(batch->handler_private.extra_arg);
|
609
|
-
grpc_call_element* elem = CALL_ELEM_FROM_CALL(call, 0);
|
610
|
-
GRPC_CALL_LOG_OP(GPR_INFO, elem, batch);
|
611
|
-
elem->filter->start_transport_stream_op_batch(elem, batch);
|
702
|
+
char* FilterStackCall::GetPeer() {
|
703
|
+
char* peer_string = reinterpret_cast<char*>(gpr_atm_acq_load(&peer_string_));
|
704
|
+
if (peer_string != nullptr) return gpr_strdup(peer_string);
|
705
|
+
peer_string = grpc_channel_get_target(channel_);
|
706
|
+
if (peer_string != nullptr) return peer_string;
|
707
|
+
return gpr_strdup("unknown");
|
612
708
|
}
|
613
709
|
|
614
710
|
// start_batch_closure points to a caller-allocated closure to be used
|
615
711
|
// for entering the call combiner.
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
712
|
+
void FilterStackCall::ExecuteBatch(grpc_transport_stream_op_batch* batch,
|
713
|
+
grpc_closure* start_batch_closure) {
|
714
|
+
// This is called via the call combiner to start sending a batch down
|
715
|
+
// the filter stack.
|
716
|
+
auto execute_batch_in_call_combiner = [](void* arg, grpc_error_handle) {
|
717
|
+
GPR_TIMER_SCOPE("execute_batch_in_call_combiner", 0);
|
718
|
+
grpc_transport_stream_op_batch* batch =
|
719
|
+
static_cast<grpc_transport_stream_op_batch*>(arg);
|
720
|
+
auto* call =
|
721
|
+
static_cast<FilterStackCall*>(batch->handler_private.extra_arg);
|
722
|
+
grpc_call_element* elem = call->call_elem(0);
|
723
|
+
GRPC_CALL_LOG_OP(GPR_INFO, elem, batch);
|
724
|
+
elem->filter->start_transport_stream_op_batch(elem, batch);
|
725
|
+
};
|
726
|
+
batch->handler_private.extra_arg = this;
|
620
727
|
GRPC_CLOSURE_INIT(start_batch_closure, execute_batch_in_call_combiner, batch,
|
621
728
|
grpc_schedule_on_exec_ctx);
|
622
|
-
GRPC_CALL_COMBINER_START(
|
729
|
+
GRPC_CALL_COMBINER_START(call_combiner(), start_batch_closure,
|
623
730
|
GRPC_ERROR_NONE, "executing batch");
|
624
731
|
}
|
625
732
|
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
if (peer_string != nullptr) return gpr_strdup(peer_string);
|
630
|
-
peer_string = grpc_channel_get_target(call->channel);
|
631
|
-
if (peer_string != nullptr) return peer_string;
|
632
|
-
return gpr_strdup("unknown");
|
633
|
-
}
|
634
|
-
|
635
|
-
grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element) {
|
636
|
-
return CALL_FROM_TOP_ELEM(surface_element);
|
637
|
-
}
|
638
|
-
|
639
|
-
/*******************************************************************************
|
640
|
-
* CANCELLATION
|
641
|
-
*/
|
642
|
-
|
643
|
-
grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
|
644
|
-
grpc_status_code status,
|
645
|
-
const char* description,
|
646
|
-
void* reserved) {
|
647
|
-
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
648
|
-
grpc_core::ExecCtx exec_ctx;
|
649
|
-
GRPC_API_TRACE(
|
650
|
-
"grpc_call_cancel_with_status("
|
651
|
-
"c=%p, status=%d, description=%s, reserved=%p)",
|
652
|
-
4, (c, (int)status, description, reserved));
|
653
|
-
GPR_ASSERT(reserved == nullptr);
|
654
|
-
cancel_with_status(c, status, description);
|
655
|
-
return GRPC_CALL_OK;
|
656
|
-
}
|
657
|
-
|
658
|
-
struct cancel_state {
|
659
|
-
grpc_call* call;
|
733
|
+
namespace {
|
734
|
+
struct CancelState {
|
735
|
+
FilterStackCall* call;
|
660
736
|
grpc_closure start_batch;
|
661
737
|
grpc_closure finish_batch;
|
662
738
|
};
|
739
|
+
} // namespace
|
740
|
+
|
663
741
|
// The on_complete callback used when sending a cancel_stream batch down
|
664
742
|
// the filter stack. Yields the call combiner when the batch is done.
|
665
743
|
static void done_termination(void* arg, grpc_error_handle /*error*/) {
|
666
|
-
|
667
|
-
GRPC_CALL_COMBINER_STOP(
|
744
|
+
CancelState* state = static_cast<CancelState*>(arg);
|
745
|
+
GRPC_CALL_COMBINER_STOP(state->call->call_combiner(),
|
668
746
|
"on_complete for cancel_stream op");
|
669
|
-
|
670
|
-
|
747
|
+
state->call->InternalUnref("termination");
|
748
|
+
delete state;
|
671
749
|
}
|
672
750
|
|
673
|
-
|
674
|
-
if (!gpr_atm_rel_cas(&
|
751
|
+
void FilterStackCall::CancelWithError(grpc_error_handle error) {
|
752
|
+
if (!gpr_atm_rel_cas(&cancelled_with_error_, 0, 1)) {
|
675
753
|
GRPC_ERROR_UNREF(error);
|
676
754
|
return;
|
677
755
|
}
|
678
|
-
|
756
|
+
InternalRef("termination");
|
679
757
|
// Inform the call combiner of the cancellation, so that it can cancel
|
680
758
|
// any in-flight asynchronous actions that may be holding the call
|
681
759
|
// combiner. This ensures that the cancel_stream batch can be sent
|
682
760
|
// down the filter stack in a timely manner.
|
683
|
-
|
684
|
-
|
685
|
-
state->call =
|
761
|
+
call_combiner_.Cancel(GRPC_ERROR_REF(error));
|
762
|
+
CancelState* state = new CancelState;
|
763
|
+
state->call = this;
|
686
764
|
GRPC_CLOSURE_INIT(&state->finish_batch, done_termination, state,
|
687
765
|
grpc_schedule_on_exec_ctx);
|
688
766
|
grpc_transport_stream_op_batch* op =
|
689
767
|
grpc_make_transport_stream_op(&state->finish_batch);
|
690
768
|
op->cancel_stream = true;
|
691
769
|
op->payload->cancel_stream.cancel_error = error;
|
692
|
-
|
770
|
+
ExecuteBatch(op, &state->start_batch);
|
693
771
|
}
|
694
772
|
|
695
|
-
void
|
696
|
-
cancel_with_error(call, GRPC_ERROR_CANCELLED);
|
697
|
-
}
|
698
|
-
|
699
|
-
static grpc_error_handle error_from_status(grpc_status_code status,
|
700
|
-
const char* description) {
|
773
|
+
void Call::CancelWithStatus(grpc_status_code status, const char* description) {
|
701
774
|
// copying 'description' is needed to ensure the grpc_call_cancel_with_status
|
702
775
|
// guarantee that can be short-lived.
|
703
|
-
|
776
|
+
CancelWithError(grpc_error_set_int(
|
704
777
|
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_COPIED_STRING(description),
|
705
778
|
GRPC_ERROR_STR_GRPC_MESSAGE, description),
|
706
|
-
GRPC_ERROR_INT_GRPC_STATUS, status);
|
707
|
-
}
|
708
|
-
|
709
|
-
static void cancel_with_status(grpc_call* c, grpc_status_code status,
|
710
|
-
const char* description) {
|
711
|
-
cancel_with_error(c, error_from_status(status, description));
|
779
|
+
GRPC_ERROR_INT_GRPC_STATUS, status));
|
712
780
|
}
|
713
781
|
|
714
|
-
|
782
|
+
void FilterStackCall::SetFinalStatus(grpc_error_handle error) {
|
715
783
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_call_error_trace)) {
|
716
|
-
gpr_log(GPR_DEBUG, "set_final_status %s",
|
784
|
+
gpr_log(GPR_DEBUG, "set_final_status %s", is_client() ? "CLI" : "SVR");
|
717
785
|
gpr_log(GPR_DEBUG, "%s", grpc_error_std_string(error).c_str());
|
718
786
|
}
|
719
|
-
if (
|
787
|
+
if (is_client()) {
|
720
788
|
std::string status_details;
|
721
|
-
grpc_error_get_status(error,
|
722
|
-
|
723
|
-
|
724
|
-
*
|
789
|
+
grpc_error_get_status(error, send_deadline(), final_op_.client.status,
|
790
|
+
&status_details, nullptr,
|
791
|
+
final_op_.client.error_string);
|
792
|
+
*final_op_.client.status_details =
|
725
793
|
grpc_slice_from_cpp_string(std::move(status_details));
|
726
|
-
|
794
|
+
status_error_.set(error);
|
727
795
|
GRPC_ERROR_UNREF(error);
|
728
|
-
|
729
|
-
grpc_channel_get_channelz_node(
|
796
|
+
channelz::ChannelNode* channelz_channel =
|
797
|
+
grpc_channel_get_channelz_node(channel_);
|
730
798
|
if (channelz_channel != nullptr) {
|
731
|
-
if (*
|
799
|
+
if (*final_op_.client.status != GRPC_STATUS_OK) {
|
732
800
|
channelz_channel->RecordCallFailed();
|
733
801
|
} else {
|
734
802
|
channelz_channel->RecordCallSucceeded();
|
735
803
|
}
|
736
804
|
}
|
737
805
|
} else {
|
738
|
-
*
|
739
|
-
error != GRPC_ERROR_NONE || !
|
740
|
-
|
741
|
-
|
806
|
+
*final_op_.server.cancelled =
|
807
|
+
error != GRPC_ERROR_NONE || !sent_server_trailing_metadata_;
|
808
|
+
channelz::ServerNode* channelz_node =
|
809
|
+
final_op_.server.core_server->channelz_node();
|
742
810
|
if (channelz_node != nullptr) {
|
743
|
-
if (*
|
811
|
+
if (*final_op_.server.cancelled || !status_error_.ok()) {
|
744
812
|
channelz_node->RecordCallFailed();
|
745
813
|
} else {
|
746
814
|
channelz_node->RecordCallSucceeded();
|
@@ -750,58 +818,40 @@ static void set_final_status(grpc_call* call, grpc_error_handle error) {
|
|
750
818
|
}
|
751
819
|
}
|
752
820
|
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
return call->incoming_compression_algorithm;
|
760
|
-
}
|
761
|
-
|
762
|
-
uint32_t grpc_call_test_only_get_message_flags(grpc_call* call) {
|
763
|
-
uint32_t flags;
|
764
|
-
flags = call->test_only_last_message_flags;
|
765
|
-
return flags;
|
766
|
-
}
|
767
|
-
|
768
|
-
uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call) {
|
769
|
-
return call->encodings_accepted_by_peer.ToLegacyBitmask();
|
770
|
-
}
|
771
|
-
|
772
|
-
static int prepare_application_metadata(grpc_call* call, int count,
|
773
|
-
grpc_metadata* metadata,
|
774
|
-
int is_trailing) {
|
775
|
-
int i;
|
776
|
-
grpc_metadata_batch* batch = is_trailing ? &call->send_trailing_metadata
|
777
|
-
: &call->send_initial_metadata;
|
778
|
-
for (i = 0; i < count; i++) {
|
821
|
+
bool FilterStackCall::PrepareApplicationMetadata(size_t count,
|
822
|
+
grpc_metadata* metadata,
|
823
|
+
bool is_trailing) {
|
824
|
+
grpc_metadata_batch* batch =
|
825
|
+
is_trailing ? &send_trailing_metadata_ : &send_initial_metadata_;
|
826
|
+
for (size_t i = 0; i < count; i++) {
|
779
827
|
grpc_metadata* md = &metadata[i];
|
780
828
|
if (!GRPC_LOG_IF_ERROR("validate_metadata",
|
781
829
|
grpc_validate_header_key_is_legal(md->key))) {
|
782
|
-
return
|
830
|
+
return false;
|
783
831
|
} else if (!grpc_is_binary_header_internal(md->key) &&
|
784
832
|
!GRPC_LOG_IF_ERROR(
|
785
833
|
"validate_metadata",
|
786
834
|
grpc_validate_header_nonbin_value_is_legal(md->value))) {
|
787
|
-
return
|
835
|
+
return false;
|
788
836
|
} else if (GRPC_SLICE_LENGTH(md->value) >= UINT32_MAX) {
|
789
837
|
// HTTP2 hpack encoding has a maximum limit.
|
790
|
-
return
|
838
|
+
return false;
|
839
|
+
} else if (grpc_slice_str_cmp(md->key, "content-length") == 0) {
|
840
|
+
// Filter "content-length metadata"
|
841
|
+
continue;
|
791
842
|
}
|
792
|
-
batch->Append(
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
return 1;
|
843
|
+
batch->Append(StringViewFromSlice(md->key),
|
844
|
+
Slice(grpc_slice_ref_internal(md->value)),
|
845
|
+
[md](absl::string_view error, const Slice& value) {
|
846
|
+
gpr_log(GPR_DEBUG, "Append error: %s",
|
847
|
+
absl::StrCat("key=", StringViewFromSlice(md->key),
|
848
|
+
" error=", error,
|
849
|
+
" value=", value.as_string_view())
|
850
|
+
.c_str());
|
851
|
+
});
|
852
|
+
}
|
853
|
+
|
854
|
+
return true;
|
805
855
|
}
|
806
856
|
|
807
857
|
namespace {
|
@@ -809,7 +859,7 @@ class PublishToAppEncoder {
|
|
809
859
|
public:
|
810
860
|
explicit PublishToAppEncoder(grpc_metadata_array* dest) : dest_(dest) {}
|
811
861
|
|
812
|
-
void Encode(const
|
862
|
+
void Encode(const Slice& key, const Slice& value) {
|
813
863
|
Append(key.c_slice(), value.c_slice());
|
814
864
|
}
|
815
865
|
|
@@ -819,36 +869,34 @@ class PublishToAppEncoder {
|
|
819
869
|
template <typename Which>
|
820
870
|
void Encode(Which, const typename Which::ValueType&) {}
|
821
871
|
|
822
|
-
void Encode(
|
823
|
-
Append(
|
872
|
+
void Encode(UserAgentMetadata, const Slice& slice) {
|
873
|
+
Append(UserAgentMetadata::key(), slice);
|
824
874
|
}
|
825
875
|
|
826
|
-
void Encode(
|
827
|
-
Append(
|
876
|
+
void Encode(HostMetadata, const Slice& slice) {
|
877
|
+
Append(HostMetadata::key(), slice);
|
828
878
|
}
|
829
879
|
|
830
|
-
void Encode(
|
831
|
-
Append(
|
880
|
+
void Encode(GrpcPreviousRpcAttemptsMetadata, uint32_t count) {
|
881
|
+
Append(GrpcPreviousRpcAttemptsMetadata::key(), count);
|
832
882
|
}
|
833
883
|
|
834
|
-
void Encode(
|
835
|
-
|
836
|
-
Append(grpc_core::GrpcRetryPushbackMsMetadata::key(), count.millis());
|
884
|
+
void Encode(GrpcRetryPushbackMsMetadata, Duration count) {
|
885
|
+
Append(GrpcRetryPushbackMsMetadata::key(), count.millis());
|
837
886
|
}
|
838
887
|
|
839
|
-
void Encode(
|
840
|
-
Append(
|
888
|
+
void Encode(LbTokenMetadata, const Slice& slice) {
|
889
|
+
Append(LbTokenMetadata::key(), slice);
|
841
890
|
}
|
842
891
|
|
843
892
|
private:
|
844
893
|
void Append(absl::string_view key, int64_t value) {
|
845
|
-
Append(
|
846
|
-
|
894
|
+
Append(StaticSlice::FromStaticString(key).c_slice(),
|
895
|
+
Slice::FromInt64(value).c_slice());
|
847
896
|
}
|
848
897
|
|
849
|
-
void Append(absl::string_view key, const
|
850
|
-
Append(
|
851
|
-
value.c_slice());
|
898
|
+
void Append(absl::string_view key, const Slice& value) {
|
899
|
+
Append(StaticSlice::FromStaticString(key).c_slice(), value.c_slice());
|
852
900
|
}
|
853
901
|
|
854
902
|
void Append(grpc_slice key, grpc_slice value) {
|
@@ -861,14 +909,14 @@ class PublishToAppEncoder {
|
|
861
909
|
};
|
862
910
|
} // namespace
|
863
911
|
|
864
|
-
|
865
|
-
|
912
|
+
void FilterStackCall::PublishAppMetadata(grpc_metadata_batch* b,
|
913
|
+
bool is_trailing) {
|
866
914
|
if (b->count() == 0) return;
|
867
|
-
if (!
|
868
|
-
if (is_trailing &&
|
915
|
+
if (!is_client() && is_trailing) return;
|
916
|
+
if (is_trailing && buffered_metadata_[1] == nullptr) return;
|
869
917
|
GPR_TIMER_SCOPE("publish_app_metadata", 0);
|
870
918
|
grpc_metadata_array* dest;
|
871
|
-
dest =
|
919
|
+
dest = buffered_metadata_[is_trailing];
|
872
920
|
if (dest->count + b->count() > dest->capacity) {
|
873
921
|
dest->capacity =
|
874
922
|
std::max(dest->capacity + b->count(), dest->capacity * 3 / 2);
|
@@ -879,68 +927,57 @@ static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
|
|
879
927
|
b->Encode(&encoder);
|
880
928
|
}
|
881
929
|
|
882
|
-
|
883
|
-
|
884
|
-
b->Take(
|
885
|
-
|
886
|
-
b->Take(
|
887
|
-
.value_or(
|
888
|
-
|
930
|
+
void FilterStackCall::RecvInitialFilter(grpc_metadata_batch* b) {
|
931
|
+
incoming_compression_algorithm_ =
|
932
|
+
b->Take(GrpcEncodingMetadata()).value_or(GRPC_COMPRESS_NONE);
|
933
|
+
encodings_accepted_by_peer_ =
|
934
|
+
b->Take(GrpcAcceptEncodingMetadata())
|
935
|
+
.value_or(CompressionAlgorithmSet{GRPC_COMPRESS_NONE});
|
936
|
+
PublishAppMetadata(b, false);
|
889
937
|
}
|
890
938
|
|
891
|
-
|
892
|
-
|
893
|
-
grpc_call* call = static_cast<grpc_call*>(args);
|
939
|
+
void FilterStackCall::RecvTrailingFilter(grpc_metadata_batch* b,
|
940
|
+
grpc_error_handle batch_error) {
|
894
941
|
if (batch_error != GRPC_ERROR_NONE) {
|
895
|
-
|
942
|
+
SetFinalStatus(batch_error);
|
896
943
|
} else {
|
897
944
|
absl::optional<grpc_status_code> grpc_status =
|
898
|
-
b->Take(
|
945
|
+
b->Take(GrpcStatusMetadata());
|
899
946
|
if (grpc_status.has_value()) {
|
900
947
|
grpc_status_code status_code = *grpc_status;
|
901
948
|
grpc_error_handle error = GRPC_ERROR_NONE;
|
902
949
|
if (status_code != GRPC_STATUS_OK) {
|
903
|
-
char* peer =
|
950
|
+
char* peer = GetPeer();
|
904
951
|
error = grpc_error_set_int(
|
905
952
|
GRPC_ERROR_CREATE_FROM_CPP_STRING(
|
906
953
|
absl::StrCat("Error received from peer ", peer)),
|
907
954
|
GRPC_ERROR_INT_GRPC_STATUS, static_cast<intptr_t>(status_code));
|
908
955
|
gpr_free(peer);
|
909
956
|
}
|
910
|
-
auto grpc_message = b->Take(
|
957
|
+
auto grpc_message = b->Take(GrpcMessageMetadata());
|
911
958
|
if (grpc_message.has_value()) {
|
912
959
|
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE,
|
913
960
|
grpc_message->as_string_view());
|
914
961
|
} else if (error != GRPC_ERROR_NONE) {
|
915
962
|
error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, "");
|
916
963
|
}
|
917
|
-
|
964
|
+
SetFinalStatus(GRPC_ERROR_REF(error));
|
918
965
|
GRPC_ERROR_UNREF(error);
|
919
|
-
} else if (!
|
920
|
-
|
966
|
+
} else if (!is_client()) {
|
967
|
+
SetFinalStatus(GRPC_ERROR_NONE);
|
921
968
|
} else {
|
922
969
|
gpr_log(GPR_DEBUG,
|
923
970
|
"Received trailing metadata with no error and no status");
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNKNOWN));
|
971
|
+
SetFinalStatus(grpc_error_set_int(
|
972
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No status received"),
|
973
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNKNOWN));
|
928
974
|
}
|
929
975
|
}
|
930
|
-
|
931
|
-
}
|
932
|
-
|
933
|
-
grpc_core::Arena* grpc_call_get_arena(grpc_call* call) { return call->arena; }
|
934
|
-
|
935
|
-
grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
|
936
|
-
return CALL_STACK_FROM_CALL(call);
|
976
|
+
PublishAppMetadata(b, true);
|
937
977
|
}
|
938
978
|
|
939
|
-
|
940
|
-
|
941
|
-
*/
|
942
|
-
|
943
|
-
static bool are_write_flags_valid(uint32_t flags) {
|
979
|
+
namespace {
|
980
|
+
bool AreWriteFlagsValid(uint32_t flags) {
|
944
981
|
/* check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set */
|
945
982
|
const uint32_t allowed_write_positions =
|
946
983
|
(GRPC_WRITE_USED_MASK | GRPC_WRITE_INTERNAL_USED_MASK);
|
@@ -948,16 +985,13 @@ static bool are_write_flags_valid(uint32_t flags) {
|
|
948
985
|
return !(flags & invalid_positions);
|
949
986
|
}
|
950
987
|
|
951
|
-
|
988
|
+
bool AreInitialMetadataFlagsValid(uint32_t flags) {
|
952
989
|
/* check that only bits in GRPC_WRITE_(INTERNAL?)_USED_MASK are set */
|
953
990
|
uint32_t invalid_positions = ~GRPC_INITIAL_METADATA_USED_MASK;
|
954
|
-
if (!is_client) {
|
955
|
-
invalid_positions |= GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
|
956
|
-
}
|
957
991
|
return !(flags & invalid_positions);
|
958
992
|
}
|
959
993
|
|
960
|
-
|
994
|
+
size_t BatchSlotForOp(grpc_op_type type) {
|
961
995
|
switch (type) {
|
962
996
|
case GRPC_OP_SEND_INITIAL_METADATA:
|
963
997
|
return 0;
|
@@ -976,137 +1010,135 @@ static size_t batch_slot_for_op(grpc_op_type type) {
|
|
976
1010
|
}
|
977
1011
|
GPR_UNREACHABLE_CODE(return 123456789);
|
978
1012
|
}
|
1013
|
+
} // namespace
|
979
1014
|
|
980
|
-
|
981
|
-
|
982
|
-
size_t slot_idx =
|
983
|
-
|
984
|
-
|
1015
|
+
FilterStackCall::BatchControl* FilterStackCall::ReuseOrAllocateBatchControl(
|
1016
|
+
const grpc_op* ops) {
|
1017
|
+
size_t slot_idx = BatchSlotForOp(ops[0].op);
|
1018
|
+
BatchControl** pslot = &active_batches_[slot_idx];
|
1019
|
+
BatchControl* bctl;
|
985
1020
|
if (*pslot != nullptr) {
|
986
1021
|
bctl = *pslot;
|
987
|
-
if (bctl->
|
1022
|
+
if (bctl->call_ != nullptr) {
|
988
1023
|
return nullptr;
|
989
1024
|
}
|
990
|
-
bctl->~
|
991
|
-
bctl->
|
992
|
-
new (&bctl->
|
1025
|
+
bctl->~BatchControl();
|
1026
|
+
bctl->op_ = {};
|
1027
|
+
new (&bctl->batch_error_) AtomicError();
|
993
1028
|
} else {
|
994
|
-
bctl =
|
1029
|
+
bctl = arena()->New<BatchControl>();
|
995
1030
|
*pslot = bctl;
|
996
1031
|
}
|
997
|
-
bctl->
|
998
|
-
bctl->
|
1032
|
+
bctl->call_ = this;
|
1033
|
+
bctl->op_.payload = &stream_op_payload_;
|
999
1034
|
return bctl;
|
1000
1035
|
}
|
1001
1036
|
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1037
|
+
void Call::PropagateCancellationToChildren() {
|
1038
|
+
ParentCall* pc = parent_call();
|
1039
|
+
if (pc != nullptr) {
|
1040
|
+
Call* child;
|
1041
|
+
MutexLock lock(&pc->child_list_mu);
|
1042
|
+
child = pc->first_child;
|
1043
|
+
if (child != nullptr) {
|
1044
|
+
do {
|
1045
|
+
Call* next_child_call = child->child_->sibling_next;
|
1046
|
+
if (child->cancellation_is_inherited_) {
|
1047
|
+
child->InternalRef("propagate_cancel");
|
1048
|
+
child->CancelWithError(GRPC_ERROR_CANCELLED);
|
1049
|
+
child->InternalUnref("propagate_cancel");
|
1050
|
+
}
|
1051
|
+
child = next_child_call;
|
1052
|
+
} while (child != pc->first_child);
|
1053
|
+
}
|
1054
|
+
}
|
1012
1055
|
}
|
1013
1056
|
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
grpc_error_handle error = GRPC_ERROR_REF(bctl->batch_error.get());
|
1057
|
+
void FilterStackCall::BatchControl::PostCompletion() {
|
1058
|
+
FilterStackCall* call = call_;
|
1059
|
+
grpc_error_handle error = GRPC_ERROR_REF(batch_error_.get());
|
1018
1060
|
|
1019
|
-
if (
|
1020
|
-
call->
|
1061
|
+
if (op_.send_initial_metadata) {
|
1062
|
+
call->send_initial_metadata_.Clear();
|
1021
1063
|
}
|
1022
|
-
if (
|
1023
|
-
if (
|
1064
|
+
if (op_.send_message) {
|
1065
|
+
if (op_.payload->send_message.stream_write_closed &&
|
1024
1066
|
error == GRPC_ERROR_NONE) {
|
1025
1067
|
error = grpc_error_add_child(
|
1026
1068
|
error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1027
1069
|
"Attempt to send message after stream was closed."));
|
1028
1070
|
}
|
1029
|
-
call->
|
1071
|
+
call->sending_message_ = false;
|
1030
1072
|
}
|
1031
|
-
if (
|
1032
|
-
call->
|
1073
|
+
if (op_.send_trailing_metadata) {
|
1074
|
+
call->send_trailing_metadata_.Clear();
|
1033
1075
|
}
|
1034
|
-
if (
|
1076
|
+
if (op_.recv_trailing_metadata) {
|
1035
1077
|
/* propagate cancellation to any interested children */
|
1036
|
-
gpr_atm_rel_store(&call->
|
1037
|
-
|
1038
|
-
if (pc != nullptr) {
|
1039
|
-
grpc_call* child;
|
1040
|
-
gpr_mu_lock(&pc->child_list_mu);
|
1041
|
-
child = pc->first_child;
|
1042
|
-
if (child != nullptr) {
|
1043
|
-
do {
|
1044
|
-
next_child_call = child->child->sibling_next;
|
1045
|
-
if (child->cancellation_is_inherited) {
|
1046
|
-
GRPC_CALL_INTERNAL_REF(child, "propagate_cancel");
|
1047
|
-
cancel_with_error(child, GRPC_ERROR_CANCELLED);
|
1048
|
-
GRPC_CALL_INTERNAL_UNREF(child, "propagate_cancel");
|
1049
|
-
}
|
1050
|
-
child = next_child_call;
|
1051
|
-
} while (child != pc->first_child);
|
1052
|
-
}
|
1053
|
-
gpr_mu_unlock(&pc->child_list_mu);
|
1054
|
-
}
|
1078
|
+
gpr_atm_rel_store(&call->received_final_op_atm_, 1);
|
1079
|
+
call->PropagateCancellationToChildren();
|
1055
1080
|
GRPC_ERROR_UNREF(error);
|
1056
1081
|
error = GRPC_ERROR_NONE;
|
1057
1082
|
}
|
1058
|
-
if (error != GRPC_ERROR_NONE &&
|
1059
|
-
*call->
|
1060
|
-
grpc_byte_buffer_destroy(*call->
|
1061
|
-
*call->
|
1083
|
+
if (error != GRPC_ERROR_NONE && op_.recv_message &&
|
1084
|
+
*call->receiving_buffer_ != nullptr) {
|
1085
|
+
grpc_byte_buffer_destroy(*call->receiving_buffer_);
|
1086
|
+
*call->receiving_buffer_ = nullptr;
|
1062
1087
|
}
|
1063
|
-
|
1088
|
+
batch_error_.set(GRPC_ERROR_NONE);
|
1064
1089
|
|
1065
|
-
if (
|
1090
|
+
if (completion_data_.notify_tag.is_closure) {
|
1066
1091
|
/* unrefs error */
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
GRPC_CALL_INTERNAL_UNREF(call, "completion");
|
1092
|
+
call_ = nullptr;
|
1093
|
+
Closure::Run(DEBUG_LOCATION,
|
1094
|
+
static_cast<grpc_closure*>(completion_data_.notify_tag.tag),
|
1095
|
+
error);
|
1096
|
+
call->InternalUnref("completion");
|
1073
1097
|
} else {
|
1074
1098
|
/* unrefs error */
|
1075
|
-
grpc_cq_end_op(
|
1076
|
-
|
1077
|
-
|
1099
|
+
grpc_cq_end_op(
|
1100
|
+
call->cq_, completion_data_.notify_tag.tag, error,
|
1101
|
+
[](void* user_data, grpc_cq_completion* /*storage*/) {
|
1102
|
+
BatchControl* bctl = static_cast<BatchControl*>(user_data);
|
1103
|
+
Call* call = bctl->call_;
|
1104
|
+
bctl->call_ = nullptr;
|
1105
|
+
call->InternalUnref("completion");
|
1106
|
+
},
|
1107
|
+
this, &completion_data_.cq_completion);
|
1078
1108
|
}
|
1079
1109
|
}
|
1080
1110
|
|
1081
|
-
|
1082
|
-
if (GPR_UNLIKELY(
|
1083
|
-
|
1111
|
+
void FilterStackCall::BatchControl::FinishStep() {
|
1112
|
+
if (GPR_UNLIKELY(completed_batch_step())) {
|
1113
|
+
PostCompletion();
|
1084
1114
|
}
|
1085
1115
|
}
|
1086
1116
|
|
1087
|
-
|
1117
|
+
void FilterStackCall::BatchControl::ContinueReceivingSlices() {
|
1088
1118
|
grpc_error_handle error;
|
1089
|
-
|
1119
|
+
FilterStackCall* call = call_;
|
1090
1120
|
for (;;) {
|
1091
|
-
size_t remaining = call->
|
1092
|
-
(*call->
|
1121
|
+
size_t remaining = call->receiving_stream_->length() -
|
1122
|
+
(*call->receiving_buffer_)->data.raw.slice_buffer.length;
|
1093
1123
|
if (remaining == 0) {
|
1094
|
-
call->
|
1095
|
-
call->
|
1096
|
-
|
1124
|
+
call->receiving_message_ = false;
|
1125
|
+
call->receiving_stream_.reset();
|
1126
|
+
FinishStep();
|
1097
1127
|
return;
|
1098
1128
|
}
|
1099
|
-
if (call->
|
1100
|
-
|
1129
|
+
if (call->receiving_stream_->Next(remaining,
|
1130
|
+
&call->receiving_slice_ready_)) {
|
1131
|
+
error = call->receiving_stream_->Pull(&call->receiving_slice_);
|
1101
1132
|
if (error == GRPC_ERROR_NONE) {
|
1102
|
-
grpc_slice_buffer_add(
|
1103
|
-
|
1133
|
+
grpc_slice_buffer_add(
|
1134
|
+
&(*call->receiving_buffer_)->data.raw.slice_buffer,
|
1135
|
+
call->receiving_slice_);
|
1104
1136
|
} else {
|
1105
|
-
call->
|
1106
|
-
grpc_byte_buffer_destroy(*call->
|
1107
|
-
*call->
|
1108
|
-
call->
|
1109
|
-
|
1137
|
+
call->receiving_stream_.reset();
|
1138
|
+
grpc_byte_buffer_destroy(*call->receiving_buffer_);
|
1139
|
+
*call->receiving_buffer_ = nullptr;
|
1140
|
+
call->receiving_message_ = false;
|
1141
|
+
FinishStep();
|
1110
1142
|
GRPC_ERROR_UNREF(error);
|
1111
1143
|
return;
|
1112
1144
|
}
|
@@ -1116,18 +1148,18 @@ static void continue_receiving_slices(batch_control* bctl) {
|
|
1116
1148
|
}
|
1117
1149
|
}
|
1118
1150
|
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1151
|
+
void FilterStackCall::BatchControl::ReceivingSliceReady(
|
1152
|
+
grpc_error_handle error) {
|
1153
|
+
FilterStackCall* call = call_;
|
1122
1154
|
bool release_error = false;
|
1123
1155
|
|
1124
1156
|
if (error == GRPC_ERROR_NONE) {
|
1125
1157
|
grpc_slice slice;
|
1126
|
-
error = call->
|
1158
|
+
error = call->receiving_stream_->Pull(&slice);
|
1127
1159
|
if (error == GRPC_ERROR_NONE) {
|
1128
|
-
grpc_slice_buffer_add(&(*call->
|
1160
|
+
grpc_slice_buffer_add(&(*call->receiving_buffer_)->data.raw.slice_buffer,
|
1129
1161
|
slice);
|
1130
|
-
|
1162
|
+
ContinueReceivingSlices();
|
1131
1163
|
} else {
|
1132
1164
|
/* Error returned by ByteStream::Pull() needs to be released manually */
|
1133
1165
|
release_error = true;
|
@@ -1138,142 +1170,133 @@ static void receiving_slice_ready(void* bctlp, grpc_error_handle error) {
|
|
1138
1170
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures)) {
|
1139
1171
|
GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error));
|
1140
1172
|
}
|
1141
|
-
call->
|
1142
|
-
grpc_byte_buffer_destroy(*call->
|
1143
|
-
*call->
|
1144
|
-
call->
|
1145
|
-
|
1173
|
+
call->receiving_stream_.reset();
|
1174
|
+
grpc_byte_buffer_destroy(*call->receiving_buffer_);
|
1175
|
+
*call->receiving_buffer_ = nullptr;
|
1176
|
+
call->receiving_message_ = false;
|
1177
|
+
FinishStep();
|
1146
1178
|
if (release_error) {
|
1147
1179
|
GRPC_ERROR_UNREF(error);
|
1148
1180
|
}
|
1149
1181
|
}
|
1150
1182
|
}
|
1151
1183
|
|
1152
|
-
|
1153
|
-
|
1154
|
-
if (call->
|
1155
|
-
*call->
|
1156
|
-
call->
|
1157
|
-
|
1184
|
+
void FilterStackCall::BatchControl::ProcessDataAfterMetadata() {
|
1185
|
+
FilterStackCall* call = call_;
|
1186
|
+
if (call->receiving_stream_ == nullptr) {
|
1187
|
+
*call->receiving_buffer_ = nullptr;
|
1188
|
+
call->receiving_message_ = false;
|
1189
|
+
FinishStep();
|
1158
1190
|
} else {
|
1159
|
-
call->
|
1160
|
-
if ((call->
|
1161
|
-
(call->
|
1162
|
-
*call->
|
1163
|
-
nullptr, 0, call->
|
1191
|
+
call->test_only_last_message_flags_ = call->receiving_stream_->flags();
|
1192
|
+
if ((call->receiving_stream_->flags() & GRPC_WRITE_INTERNAL_COMPRESS) &&
|
1193
|
+
(call->incoming_compression_algorithm_ != GRPC_COMPRESS_NONE)) {
|
1194
|
+
*call->receiving_buffer_ = grpc_raw_compressed_byte_buffer_create(
|
1195
|
+
nullptr, 0, call->incoming_compression_algorithm_);
|
1164
1196
|
} else {
|
1165
|
-
*call->
|
1197
|
+
*call->receiving_buffer_ = grpc_raw_byte_buffer_create(nullptr, 0);
|
1166
1198
|
}
|
1167
|
-
GRPC_CLOSURE_INIT(
|
1168
|
-
|
1169
|
-
|
1199
|
+
GRPC_CLOSURE_INIT(
|
1200
|
+
&call->receiving_slice_ready_,
|
1201
|
+
[](void* bctl, grpc_error_handle error) {
|
1202
|
+
static_cast<BatchControl*>(bctl)->ReceivingSliceReady(error);
|
1203
|
+
},
|
1204
|
+
this, grpc_schedule_on_exec_ctx);
|
1205
|
+
ContinueReceivingSlices();
|
1170
1206
|
}
|
1171
1207
|
}
|
1172
1208
|
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1209
|
+
void FilterStackCall::BatchControl::ReceivingStreamReady(
|
1210
|
+
grpc_error_handle error) {
|
1211
|
+
FilterStackCall* call = call_;
|
1176
1212
|
if (error != GRPC_ERROR_NONE) {
|
1177
|
-
call->
|
1178
|
-
if (
|
1179
|
-
|
1213
|
+
call->receiving_stream_.reset();
|
1214
|
+
if (batch_error_.ok()) {
|
1215
|
+
batch_error_.set(error);
|
1180
1216
|
}
|
1181
|
-
|
1217
|
+
call->CancelWithError(GRPC_ERROR_REF(error));
|
1182
1218
|
}
|
1183
|
-
/* If recv_state is
|
1219
|
+
/* If recv_state is kRecvNone, we will save the batch_control
|
1184
1220
|
* object with rel_cas, and will not use it after the cas. Its corresponding
|
1185
1221
|
* acq_load is in receiving_initial_metadata_ready() */
|
1186
|
-
if (error != GRPC_ERROR_NONE || call->
|
1187
|
-
!gpr_atm_rel_cas(&call->
|
1188
|
-
reinterpret_cast<gpr_atm>(
|
1189
|
-
|
1222
|
+
if (error != GRPC_ERROR_NONE || call->receiving_stream_ == nullptr ||
|
1223
|
+
!gpr_atm_rel_cas(&call->recv_state_, kRecvNone,
|
1224
|
+
reinterpret_cast<gpr_atm>(this))) {
|
1225
|
+
ProcessDataAfterMetadata();
|
1190
1226
|
}
|
1191
1227
|
}
|
1192
1228
|
|
1193
|
-
|
1194
|
-
|
1195
|
-
// before processing the received message.
|
1196
|
-
static void receiving_stream_ready_in_call_combiner(void* bctlp,
|
1197
|
-
grpc_error_handle error) {
|
1198
|
-
batch_control* bctl = static_cast<batch_control*>(bctlp);
|
1199
|
-
grpc_call* call = bctl->call;
|
1200
|
-
GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_message_ready");
|
1201
|
-
receiving_stream_ready(bctlp, error);
|
1202
|
-
}
|
1203
|
-
|
1204
|
-
static void GPR_ATTRIBUTE_NOINLINE handle_compression_algorithm_disabled(
|
1205
|
-
grpc_call* call, grpc_compression_algorithm compression_algorithm) {
|
1229
|
+
void FilterStackCall::HandleCompressionAlgorithmDisabled(
|
1230
|
+
grpc_compression_algorithm compression_algorithm) {
|
1206
1231
|
const char* algo_name = nullptr;
|
1207
1232
|
grpc_compression_algorithm_name(compression_algorithm, &algo_name);
|
1208
1233
|
std::string error_msg =
|
1209
1234
|
absl::StrFormat("Compression algorithm '%s' is disabled.", algo_name);
|
1210
1235
|
gpr_log(GPR_ERROR, "%s", error_msg.c_str());
|
1211
|
-
|
1236
|
+
CancelWithStatus(GRPC_STATUS_UNIMPLEMENTED, error_msg.c_str());
|
1212
1237
|
}
|
1213
1238
|
|
1214
|
-
|
1215
|
-
|
1239
|
+
void FilterStackCall::HandleCompressionAlgorithmNotAccepted(
|
1240
|
+
grpc_compression_algorithm compression_algorithm) {
|
1216
1241
|
const char* algo_name = nullptr;
|
1217
1242
|
grpc_compression_algorithm_name(compression_algorithm, &algo_name);
|
1218
1243
|
gpr_log(GPR_ERROR,
|
1219
1244
|
"Compression algorithm ('%s') not present in the "
|
1220
1245
|
"accepted encodings (%s)",
|
1221
|
-
algo_name,
|
1246
|
+
algo_name, encodings_accepted_by_peer_.ToString().c_str());
|
1222
1247
|
}
|
1223
1248
|
|
1224
|
-
|
1225
|
-
|
1249
|
+
void FilterStackCall::BatchControl::ValidateFilteredMetadata() {
|
1250
|
+
FilterStackCall* call = call_;
|
1226
1251
|
|
1227
1252
|
const grpc_compression_options compression_options =
|
1228
|
-
grpc_channel_compression_options(call->
|
1253
|
+
grpc_channel_compression_options(call->channel_);
|
1229
1254
|
const grpc_compression_algorithm compression_algorithm =
|
1230
|
-
call->
|
1231
|
-
if (GPR_UNLIKELY(!
|
1255
|
+
call->incoming_compression_algorithm_;
|
1256
|
+
if (GPR_UNLIKELY(!CompressionAlgorithmSet::FromUint32(
|
1232
1257
|
compression_options.enabled_algorithms_bitset)
|
1233
1258
|
.IsSet(compression_algorithm))) {
|
1234
1259
|
/* check if algorithm is supported by current channel config */
|
1235
|
-
|
1260
|
+
call->HandleCompressionAlgorithmDisabled(compression_algorithm);
|
1236
1261
|
}
|
1237
1262
|
/* GRPC_COMPRESS_NONE is always set. */
|
1238
|
-
GPR_DEBUG_ASSERT(call->
|
1263
|
+
GPR_DEBUG_ASSERT(call->encodings_accepted_by_peer_.IsSet(GRPC_COMPRESS_NONE));
|
1239
1264
|
if (GPR_UNLIKELY(
|
1240
|
-
!call->
|
1265
|
+
!call->encodings_accepted_by_peer_.IsSet(compression_algorithm))) {
|
1241
1266
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
|
1242
|
-
|
1267
|
+
call->HandleCompressionAlgorithmNotAccepted(compression_algorithm);
|
1243
1268
|
}
|
1244
1269
|
}
|
1245
1270
|
}
|
1246
1271
|
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
grpc_call* call = bctl->call;
|
1272
|
+
void FilterStackCall::BatchControl::ReceivingInitialMetadataReady(
|
1273
|
+
grpc_error_handle error) {
|
1274
|
+
FilterStackCall* call = call_;
|
1251
1275
|
|
1252
|
-
GRPC_CALL_COMBINER_STOP(
|
1276
|
+
GRPC_CALL_COMBINER_STOP(call->call_combiner(), "recv_initial_metadata_ready");
|
1253
1277
|
|
1254
1278
|
if (error == GRPC_ERROR_NONE) {
|
1255
|
-
grpc_metadata_batch* md = &call->
|
1256
|
-
|
1279
|
+
grpc_metadata_batch* md = &call->recv_initial_metadata_;
|
1280
|
+
call->RecvInitialFilter(md);
|
1257
1281
|
|
1258
1282
|
/* TODO(ctiller): this could be moved into recv_initial_filter now */
|
1259
1283
|
GPR_TIMER_SCOPE("validate_filtered_metadata", 0);
|
1260
|
-
|
1284
|
+
ValidateFilteredMetadata();
|
1261
1285
|
|
1262
|
-
absl::optional<
|
1263
|
-
|
1264
|
-
|
1265
|
-
call->send_deadline = *deadline;
|
1286
|
+
absl::optional<Timestamp> deadline = md->get(GrpcTimeoutMetadata());
|
1287
|
+
if (deadline.has_value() && !call->is_client()) {
|
1288
|
+
call_->set_send_deadline(*deadline);
|
1266
1289
|
}
|
1267
1290
|
} else {
|
1268
|
-
if (
|
1269
|
-
|
1291
|
+
if (batch_error_.ok()) {
|
1292
|
+
batch_error_.set(error);
|
1270
1293
|
}
|
1271
|
-
|
1294
|
+
call->CancelWithError(GRPC_ERROR_REF(error));
|
1272
1295
|
}
|
1273
1296
|
|
1274
1297
|
grpc_closure* saved_rsr_closure = nullptr;
|
1275
1298
|
while (true) {
|
1276
|
-
gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->
|
1299
|
+
gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state_);
|
1277
1300
|
/* Should only receive initial metadata once */
|
1278
1301
|
GPR_ASSERT(rsr_bctlp != 1);
|
1279
1302
|
if (rsr_bctlp == 0) {
|
@@ -1282,62 +1305,57 @@ static void receiving_initial_metadata_ready(void* bctlp,
|
|
1282
1305
|
* no_barrier_cas is used, as this function won't access the batch_control
|
1283
1306
|
* object saved by receiving_stream_ready() if the initial metadata is
|
1284
1307
|
* received first. */
|
1285
|
-
if (gpr_atm_no_barrier_cas(&call->
|
1286
|
-
|
1308
|
+
if (gpr_atm_no_barrier_cas(&call->recv_state_, kRecvNone,
|
1309
|
+
kRecvInitialMetadataFirst)) {
|
1287
1310
|
break;
|
1288
1311
|
}
|
1289
1312
|
} else {
|
1290
1313
|
/* Already received messages */
|
1291
|
-
saved_rsr_closure =
|
1292
|
-
|
1293
|
-
|
1314
|
+
saved_rsr_closure = GRPC_CLOSURE_CREATE(
|
1315
|
+
[](void* bctl, grpc_error_handle error) {
|
1316
|
+
static_cast<BatchControl*>(bctl)->ReceivingStreamReady(error);
|
1317
|
+
},
|
1318
|
+
reinterpret_cast<BatchControl*>(rsr_bctlp),
|
1319
|
+
grpc_schedule_on_exec_ctx);
|
1294
1320
|
/* No need to modify recv_state */
|
1295
1321
|
break;
|
1296
1322
|
}
|
1297
1323
|
}
|
1298
1324
|
if (saved_rsr_closure != nullptr) {
|
1299
|
-
|
1300
|
-
GRPC_ERROR_REF(error));
|
1325
|
+
Closure::Run(DEBUG_LOCATION, saved_rsr_closure, GRPC_ERROR_REF(error));
|
1301
1326
|
}
|
1302
1327
|
|
1303
|
-
|
1328
|
+
FinishStep();
|
1304
1329
|
}
|
1305
1330
|
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
finish_batch_step(bctl);
|
1331
|
+
void FilterStackCall::BatchControl::ReceivingTrailingMetadataReady(
|
1332
|
+
grpc_error_handle error) {
|
1333
|
+
GRPC_CALL_COMBINER_STOP(call_->call_combiner(),
|
1334
|
+
"recv_trailing_metadata_ready");
|
1335
|
+
grpc_metadata_batch* md = &call_->recv_trailing_metadata_;
|
1336
|
+
call_->RecvTrailingFilter(md, GRPC_ERROR_REF(error));
|
1337
|
+
FinishStep();
|
1314
1338
|
}
|
1315
1339
|
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
if (bctl->batch_error.ok()) {
|
1321
|
-
bctl->batch_error.set(error);
|
1340
|
+
void FilterStackCall::BatchControl::FinishBatch(grpc_error_handle error) {
|
1341
|
+
GRPC_CALL_COMBINER_STOP(call_->call_combiner(), "on_complete");
|
1342
|
+
if (batch_error_.ok()) {
|
1343
|
+
batch_error_.set(error);
|
1322
1344
|
}
|
1323
1345
|
if (error != GRPC_ERROR_NONE) {
|
1324
|
-
|
1346
|
+
call_->CancelWithError(GRPC_ERROR_REF(error));
|
1325
1347
|
}
|
1326
|
-
|
1327
|
-
}
|
1328
|
-
|
1329
|
-
static void free_no_op_completion(void* /*p*/, grpc_cq_completion* completion) {
|
1330
|
-
gpr_free(completion);
|
1348
|
+
FinishStep();
|
1331
1349
|
}
|
1332
1350
|
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1351
|
+
grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
|
1352
|
+
void* notify_tag,
|
1353
|
+
bool is_notify_tag_closure) {
|
1336
1354
|
GPR_TIMER_SCOPE("call_start_batch", 0);
|
1337
1355
|
|
1338
1356
|
size_t i;
|
1339
1357
|
const grpc_op* op;
|
1340
|
-
|
1358
|
+
BatchControl* bctl;
|
1341
1359
|
bool has_send_ops = false;
|
1342
1360
|
int num_recv_ops = 0;
|
1343
1361
|
grpc_call_error error = GRPC_CALL_OK;
|
@@ -1356,30 +1374,31 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1356
1374
|
|
1357
1375
|
if (nops == 0) {
|
1358
1376
|
if (!is_notify_tag_closure) {
|
1359
|
-
GPR_ASSERT(grpc_cq_begin_op(
|
1360
|
-
grpc_cq_end_op(
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1377
|
+
GPR_ASSERT(grpc_cq_begin_op(cq_, notify_tag));
|
1378
|
+
grpc_cq_end_op(
|
1379
|
+
cq_, notify_tag, GRPC_ERROR_NONE,
|
1380
|
+
[](void*, grpc_cq_completion* completion) { gpr_free(completion); },
|
1381
|
+
nullptr,
|
1382
|
+
static_cast<grpc_cq_completion*>(
|
1383
|
+
gpr_malloc(sizeof(grpc_cq_completion))));
|
1364
1384
|
} else {
|
1365
|
-
|
1366
|
-
|
1367
|
-
GRPC_ERROR_NONE);
|
1385
|
+
Closure::Run(DEBUG_LOCATION, static_cast<grpc_closure*>(notify_tag),
|
1386
|
+
GRPC_ERROR_NONE);
|
1368
1387
|
}
|
1369
1388
|
error = GRPC_CALL_OK;
|
1370
1389
|
goto done;
|
1371
1390
|
}
|
1372
1391
|
|
1373
|
-
bctl =
|
1392
|
+
bctl = ReuseOrAllocateBatchControl(ops);
|
1374
1393
|
if (bctl == nullptr) {
|
1375
1394
|
return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1376
1395
|
}
|
1377
|
-
bctl->
|
1378
|
-
bctl->
|
1396
|
+
bctl->completion_data_.notify_tag.tag = notify_tag;
|
1397
|
+
bctl->completion_data_.notify_tag.is_closure =
|
1379
1398
|
static_cast<uint8_t>(is_notify_tag_closure != 0);
|
1380
1399
|
|
1381
|
-
stream_op = &bctl->
|
1382
|
-
stream_op_payload = &
|
1400
|
+
stream_op = &bctl->op_;
|
1401
|
+
stream_op_payload = &stream_op_payload_;
|
1383
1402
|
|
1384
1403
|
/* rewrite batch ops into a transport op */
|
1385
1404
|
for (i = 0; i < nops; i++) {
|
@@ -1391,11 +1410,11 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1391
1410
|
switch (op->op) {
|
1392
1411
|
case GRPC_OP_SEND_INITIAL_METADATA: {
|
1393
1412
|
/* Flag validation: currently allow no flags */
|
1394
|
-
if (!
|
1413
|
+
if (!AreInitialMetadataFlagsValid(op->flags)) {
|
1395
1414
|
error = GRPC_CALL_ERROR_INVALID_FLAGS;
|
1396
1415
|
goto done_with_error;
|
1397
1416
|
}
|
1398
|
-
if (
|
1417
|
+
if (sent_initial_metadata_) {
|
1399
1418
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1400
1419
|
goto done_with_error;
|
1401
1420
|
}
|
@@ -1413,56 +1432,52 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1413
1432
|
level_set = true;
|
1414
1433
|
} else {
|
1415
1434
|
const grpc_compression_options copts =
|
1416
|
-
grpc_channel_compression_options(
|
1435
|
+
grpc_channel_compression_options(channel_);
|
1417
1436
|
if (copts.default_level.is_set) {
|
1418
1437
|
level_set = true;
|
1419
1438
|
effective_compression_level = copts.default_level.level;
|
1420
1439
|
}
|
1421
1440
|
}
|
1422
1441
|
// Currently, only server side supports compression level setting.
|
1423
|
-
if (level_set && !
|
1442
|
+
if (level_set && !is_client()) {
|
1424
1443
|
const grpc_compression_algorithm calgo =
|
1425
|
-
|
1444
|
+
encodings_accepted_by_peer_.CompressionAlgorithmForLevel(
|
1426
1445
|
effective_compression_level);
|
1427
1446
|
// The following metadata will be checked and removed by the message
|
1428
1447
|
// compression filter. It will be used as the call's compression
|
1429
1448
|
// algorithm.
|
1430
|
-
|
1431
|
-
grpc_core::GrpcInternalEncodingRequest(), calgo);
|
1449
|
+
send_initial_metadata_.Set(GrpcInternalEncodingRequest(), calgo);
|
1432
1450
|
}
|
1433
1451
|
if (op->data.send_initial_metadata.count > INT_MAX) {
|
1434
1452
|
error = GRPC_CALL_ERROR_INVALID_METADATA;
|
1435
1453
|
goto done_with_error;
|
1436
1454
|
}
|
1437
1455
|
stream_op->send_initial_metadata = true;
|
1438
|
-
|
1439
|
-
if (!
|
1440
|
-
|
1441
|
-
|
1456
|
+
sent_initial_metadata_ = true;
|
1457
|
+
if (!PrepareApplicationMetadata(op->data.send_initial_metadata.count,
|
1458
|
+
op->data.send_initial_metadata.metadata,
|
1459
|
+
false)) {
|
1442
1460
|
error = GRPC_CALL_ERROR_INVALID_METADATA;
|
1443
1461
|
goto done_with_error;
|
1444
1462
|
}
|
1445
1463
|
// Ignore any te metadata key value pairs specified.
|
1446
|
-
|
1464
|
+
send_initial_metadata_.Remove(TeMetadata());
|
1447
1465
|
/* TODO(ctiller): just make these the same variable? */
|
1448
|
-
if (
|
1449
|
-
|
1450
|
-
call->send_initial_metadata.Set(grpc_core::GrpcTimeoutMetadata(),
|
1451
|
-
call->send_deadline);
|
1466
|
+
if (is_client() && send_deadline() != Timestamp::InfFuture()) {
|
1467
|
+
send_initial_metadata_.Set(GrpcTimeoutMetadata(), send_deadline());
|
1452
1468
|
}
|
1453
1469
|
stream_op_payload->send_initial_metadata.send_initial_metadata =
|
1454
|
-
&
|
1470
|
+
&send_initial_metadata_;
|
1455
1471
|
stream_op_payload->send_initial_metadata.send_initial_metadata_flags =
|
1456
1472
|
op->flags;
|
1457
|
-
if (
|
1458
|
-
stream_op_payload->send_initial_metadata.peer_string =
|
1459
|
-
&call->peer_string;
|
1473
|
+
if (is_client()) {
|
1474
|
+
stream_op_payload->send_initial_metadata.peer_string = &peer_string_;
|
1460
1475
|
}
|
1461
1476
|
has_send_ops = true;
|
1462
1477
|
break;
|
1463
1478
|
}
|
1464
1479
|
case GRPC_OP_SEND_MESSAGE: {
|
1465
|
-
if (!
|
1480
|
+
if (!AreWriteFlagsValid(op->flags)) {
|
1466
1481
|
error = GRPC_CALL_ERROR_INVALID_FLAGS;
|
1467
1482
|
goto done_with_error;
|
1468
1483
|
}
|
@@ -1470,7 +1485,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1470
1485
|
error = GRPC_CALL_ERROR_INVALID_MESSAGE;
|
1471
1486
|
goto done_with_error;
|
1472
1487
|
}
|
1473
|
-
if (
|
1488
|
+
if (sending_message_) {
|
1474
1489
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1475
1490
|
goto done_with_error;
|
1476
1491
|
}
|
@@ -1483,11 +1498,11 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1483
1498
|
flags |= GRPC_WRITE_INTERNAL_COMPRESS;
|
1484
1499
|
}
|
1485
1500
|
stream_op->send_message = true;
|
1486
|
-
|
1487
|
-
|
1501
|
+
sending_message_ = true;
|
1502
|
+
sending_stream_.Init(
|
1488
1503
|
&op->data.send_message.send_message->data.raw.slice_buffer, flags);
|
1489
1504
|
stream_op_payload->send_message.send_message.reset(
|
1490
|
-
|
1505
|
+
sending_stream_.get());
|
1491
1506
|
has_send_ops = true;
|
1492
1507
|
break;
|
1493
1508
|
}
|
@@ -1497,18 +1512,18 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1497
1512
|
error = GRPC_CALL_ERROR_INVALID_FLAGS;
|
1498
1513
|
goto done_with_error;
|
1499
1514
|
}
|
1500
|
-
if (!
|
1515
|
+
if (!is_client()) {
|
1501
1516
|
error = GRPC_CALL_ERROR_NOT_ON_SERVER;
|
1502
1517
|
goto done_with_error;
|
1503
1518
|
}
|
1504
|
-
if (
|
1519
|
+
if (sent_final_op_) {
|
1505
1520
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1506
1521
|
goto done_with_error;
|
1507
1522
|
}
|
1508
1523
|
stream_op->send_trailing_metadata = true;
|
1509
|
-
|
1524
|
+
sent_final_op_ = true;
|
1510
1525
|
stream_op_payload->send_trailing_metadata.send_trailing_metadata =
|
1511
|
-
&
|
1526
|
+
&send_trailing_metadata_;
|
1512
1527
|
has_send_ops = true;
|
1513
1528
|
break;
|
1514
1529
|
}
|
@@ -1518,11 +1533,11 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1518
1533
|
error = GRPC_CALL_ERROR_INVALID_FLAGS;
|
1519
1534
|
goto done_with_error;
|
1520
1535
|
}
|
1521
|
-
if (
|
1536
|
+
if (is_client()) {
|
1522
1537
|
error = GRPC_CALL_ERROR_NOT_ON_CLIENT;
|
1523
1538
|
goto done_with_error;
|
1524
1539
|
}
|
1525
|
-
if (
|
1540
|
+
if (sent_final_op_) {
|
1526
1541
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1527
1542
|
goto done_with_error;
|
1528
1543
|
}
|
@@ -1532,13 +1547,11 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1532
1547
|
goto done_with_error;
|
1533
1548
|
}
|
1534
1549
|
stream_op->send_trailing_metadata = true;
|
1535
|
-
|
1550
|
+
sent_final_op_ = true;
|
1536
1551
|
|
1537
|
-
if (!
|
1538
|
-
|
1539
|
-
|
1540
|
-
op->data.send_status_from_server.trailing_metadata_count),
|
1541
|
-
op->data.send_status_from_server.trailing_metadata, 1)) {
|
1552
|
+
if (!PrepareApplicationMetadata(
|
1553
|
+
op->data.send_status_from_server.trailing_metadata_count,
|
1554
|
+
op->data.send_status_from_server.trailing_metadata, true)) {
|
1542
1555
|
error = GRPC_CALL_ERROR_INVALID_METADATA;
|
1543
1556
|
goto done_with_error;
|
1544
1557
|
}
|
@@ -1553,31 +1566,30 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1553
1566
|
static_cast<intptr_t>(
|
1554
1567
|
op->data.send_status_from_server.status));
|
1555
1568
|
if (op->data.send_status_from_server.status_details != nullptr) {
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1569
|
+
send_trailing_metadata_.Set(
|
1570
|
+
GrpcMessageMetadata(),
|
1571
|
+
Slice(grpc_slice_copy(
|
1559
1572
|
*op->data.send_status_from_server.status_details)));
|
1560
1573
|
if (status_error != GRPC_ERROR_NONE) {
|
1561
1574
|
status_error = grpc_error_set_str(
|
1562
1575
|
status_error, GRPC_ERROR_STR_GRPC_MESSAGE,
|
1563
|
-
|
1576
|
+
StringViewFromSlice(
|
1564
1577
|
*op->data.send_status_from_server.status_details));
|
1565
1578
|
}
|
1566
1579
|
}
|
1567
1580
|
|
1568
|
-
|
1581
|
+
status_error_.set(status_error);
|
1569
1582
|
GRPC_ERROR_UNREF(status_error);
|
1570
1583
|
|
1571
|
-
|
1572
|
-
|
1573
|
-
op->data.send_status_from_server.status);
|
1584
|
+
send_trailing_metadata_.Set(GrpcStatusMetadata(),
|
1585
|
+
op->data.send_status_from_server.status);
|
1574
1586
|
|
1575
1587
|
// Ignore any te metadata key value pairs specified.
|
1576
|
-
|
1588
|
+
send_trailing_metadata_.Remove(TeMetadata());
|
1577
1589
|
stream_op_payload->send_trailing_metadata.send_trailing_metadata =
|
1578
|
-
&
|
1590
|
+
&send_trailing_metadata_;
|
1579
1591
|
stream_op_payload->send_trailing_metadata.sent =
|
1580
|
-
&
|
1592
|
+
&sent_server_trailing_metadata_;
|
1581
1593
|
has_send_ops = true;
|
1582
1594
|
break;
|
1583
1595
|
}
|
@@ -1587,27 +1599,30 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1587
1599
|
error = GRPC_CALL_ERROR_INVALID_FLAGS;
|
1588
1600
|
goto done_with_error;
|
1589
1601
|
}
|
1590
|
-
if (
|
1602
|
+
if (received_initial_metadata_) {
|
1591
1603
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1592
1604
|
goto done_with_error;
|
1593
1605
|
}
|
1594
|
-
|
1595
|
-
|
1606
|
+
received_initial_metadata_ = true;
|
1607
|
+
buffered_metadata_[0] =
|
1596
1608
|
op->data.recv_initial_metadata.recv_initial_metadata;
|
1597
|
-
GRPC_CLOSURE_INIT(
|
1598
|
-
|
1599
|
-
|
1609
|
+
GRPC_CLOSURE_INIT(
|
1610
|
+
&receiving_initial_metadata_ready_,
|
1611
|
+
[](void* bctl, grpc_error_handle error) {
|
1612
|
+
static_cast<BatchControl*>(bctl)->ReceivingInitialMetadataReady(
|
1613
|
+
error);
|
1614
|
+
},
|
1615
|
+
bctl, grpc_schedule_on_exec_ctx);
|
1600
1616
|
stream_op->recv_initial_metadata = true;
|
1601
1617
|
stream_op_payload->recv_initial_metadata.recv_initial_metadata =
|
1602
|
-
&
|
1618
|
+
&recv_initial_metadata_;
|
1603
1619
|
stream_op_payload->recv_initial_metadata.recv_initial_metadata_ready =
|
1604
|
-
&
|
1605
|
-
if (
|
1620
|
+
&receiving_initial_metadata_ready_;
|
1621
|
+
if (is_client()) {
|
1606
1622
|
stream_op_payload->recv_initial_metadata.trailing_metadata_available =
|
1607
|
-
&
|
1623
|
+
&is_trailers_only_;
|
1608
1624
|
} else {
|
1609
|
-
stream_op_payload->recv_initial_metadata.peer_string =
|
1610
|
-
&call->peer_string;
|
1625
|
+
stream_op_payload->recv_initial_metadata.peer_string = &peer_string_;
|
1611
1626
|
}
|
1612
1627
|
++num_recv_ops;
|
1613
1628
|
break;
|
@@ -1618,21 +1633,30 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1618
1633
|
error = GRPC_CALL_ERROR_INVALID_FLAGS;
|
1619
1634
|
goto done_with_error;
|
1620
1635
|
}
|
1621
|
-
if (
|
1636
|
+
if (receiving_message_) {
|
1622
1637
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1623
1638
|
goto done_with_error;
|
1624
1639
|
}
|
1625
|
-
|
1640
|
+
receiving_message_ = true;
|
1626
1641
|
stream_op->recv_message = true;
|
1627
|
-
|
1628
|
-
stream_op_payload->recv_message.recv_message = &
|
1642
|
+
receiving_buffer_ = op->data.recv_message.recv_message;
|
1643
|
+
stream_op_payload->recv_message.recv_message = &receiving_stream_;
|
1629
1644
|
stream_op_payload->recv_message.call_failed_before_recv_message =
|
1630
|
-
&
|
1631
|
-
GRPC_CLOSURE_INIT(
|
1632
|
-
|
1633
|
-
|
1645
|
+
&call_failed_before_recv_message_;
|
1646
|
+
GRPC_CLOSURE_INIT(
|
1647
|
+
&receiving_stream_ready_,
|
1648
|
+
[](void* bctlp, grpc_error_handle error) {
|
1649
|
+
auto* bctl = static_cast<BatchControl*>(bctlp);
|
1650
|
+
auto* call = bctl->call_;
|
1651
|
+
// Yields the call combiner before processing the received
|
1652
|
+
// message.
|
1653
|
+
GRPC_CALL_COMBINER_STOP(call->call_combiner(),
|
1654
|
+
"recv_message_ready");
|
1655
|
+
bctl->ReceivingStreamReady(error);
|
1656
|
+
},
|
1657
|
+
bctl, grpc_schedule_on_exec_ctx);
|
1634
1658
|
stream_op_payload->recv_message.recv_message_ready =
|
1635
|
-
&
|
1659
|
+
&receiving_stream_ready_;
|
1636
1660
|
++num_recv_ops;
|
1637
1661
|
break;
|
1638
1662
|
}
|
@@ -1642,32 +1666,36 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1642
1666
|
error = GRPC_CALL_ERROR_INVALID_FLAGS;
|
1643
1667
|
goto done_with_error;
|
1644
1668
|
}
|
1645
|
-
if (!
|
1669
|
+
if (!is_client()) {
|
1646
1670
|
error = GRPC_CALL_ERROR_NOT_ON_SERVER;
|
1647
1671
|
goto done_with_error;
|
1648
1672
|
}
|
1649
|
-
if (
|
1673
|
+
if (requested_final_op_) {
|
1650
1674
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1651
1675
|
goto done_with_error;
|
1652
1676
|
}
|
1653
|
-
|
1654
|
-
|
1677
|
+
requested_final_op_ = true;
|
1678
|
+
buffered_metadata_[1] =
|
1655
1679
|
op->data.recv_status_on_client.trailing_metadata;
|
1656
|
-
|
1657
|
-
|
1680
|
+
final_op_.client.status = op->data.recv_status_on_client.status;
|
1681
|
+
final_op_.client.status_details =
|
1658
1682
|
op->data.recv_status_on_client.status_details;
|
1659
|
-
|
1683
|
+
final_op_.client.error_string =
|
1660
1684
|
op->data.recv_status_on_client.error_string;
|
1661
1685
|
stream_op->recv_trailing_metadata = true;
|
1662
1686
|
stream_op_payload->recv_trailing_metadata.recv_trailing_metadata =
|
1663
|
-
&
|
1687
|
+
&recv_trailing_metadata_;
|
1664
1688
|
stream_op_payload->recv_trailing_metadata.collect_stats =
|
1665
|
-
&
|
1666
|
-
GRPC_CLOSURE_INIT(
|
1667
|
-
|
1668
|
-
|
1689
|
+
&final_info_.stats.transport_stream_stats;
|
1690
|
+
GRPC_CLOSURE_INIT(
|
1691
|
+
&receiving_trailing_metadata_ready_,
|
1692
|
+
[](void* bctl, grpc_error_handle error) {
|
1693
|
+
static_cast<BatchControl*>(bctl)->ReceivingTrailingMetadataReady(
|
1694
|
+
error);
|
1695
|
+
},
|
1696
|
+
bctl, grpc_schedule_on_exec_ctx);
|
1669
1697
|
stream_op_payload->recv_trailing_metadata.recv_trailing_metadata_ready =
|
1670
|
-
&
|
1698
|
+
&receiving_trailing_metadata_ready_;
|
1671
1699
|
++num_recv_ops;
|
1672
1700
|
break;
|
1673
1701
|
}
|
@@ -1677,47 +1705,54 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1677
1705
|
error = GRPC_CALL_ERROR_INVALID_FLAGS;
|
1678
1706
|
goto done_with_error;
|
1679
1707
|
}
|
1680
|
-
if (
|
1708
|
+
if (is_client()) {
|
1681
1709
|
error = GRPC_CALL_ERROR_NOT_ON_CLIENT;
|
1682
1710
|
goto done_with_error;
|
1683
1711
|
}
|
1684
|
-
if (
|
1712
|
+
if (requested_final_op_) {
|
1685
1713
|
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
|
1686
1714
|
goto done_with_error;
|
1687
1715
|
}
|
1688
|
-
|
1689
|
-
|
1690
|
-
op->data.recv_close_on_server.cancelled;
|
1716
|
+
requested_final_op_ = true;
|
1717
|
+
final_op_.server.cancelled = op->data.recv_close_on_server.cancelled;
|
1691
1718
|
stream_op->recv_trailing_metadata = true;
|
1692
1719
|
stream_op_payload->recv_trailing_metadata.recv_trailing_metadata =
|
1693
|
-
&
|
1720
|
+
&recv_trailing_metadata_;
|
1694
1721
|
stream_op_payload->recv_trailing_metadata.collect_stats =
|
1695
|
-
&
|
1696
|
-
GRPC_CLOSURE_INIT(
|
1697
|
-
|
1698
|
-
|
1722
|
+
&final_info_.stats.transport_stream_stats;
|
1723
|
+
GRPC_CLOSURE_INIT(
|
1724
|
+
&receiving_trailing_metadata_ready_,
|
1725
|
+
[](void* bctl, grpc_error_handle error) {
|
1726
|
+
static_cast<BatchControl*>(bctl)->ReceivingTrailingMetadataReady(
|
1727
|
+
error);
|
1728
|
+
},
|
1729
|
+
bctl, grpc_schedule_on_exec_ctx);
|
1699
1730
|
stream_op_payload->recv_trailing_metadata.recv_trailing_metadata_ready =
|
1700
|
-
&
|
1731
|
+
&receiving_trailing_metadata_ready_;
|
1701
1732
|
++num_recv_ops;
|
1702
1733
|
break;
|
1703
1734
|
}
|
1704
1735
|
}
|
1705
1736
|
}
|
1706
1737
|
|
1707
|
-
|
1738
|
+
InternalRef("completion");
|
1708
1739
|
if (!is_notify_tag_closure) {
|
1709
|
-
GPR_ASSERT(grpc_cq_begin_op(
|
1740
|
+
GPR_ASSERT(grpc_cq_begin_op(cq_, notify_tag));
|
1710
1741
|
}
|
1711
1742
|
bctl->set_num_steps_to_complete((has_send_ops ? 1 : 0) + num_recv_ops);
|
1712
1743
|
|
1713
1744
|
if (has_send_ops) {
|
1714
|
-
GRPC_CLOSURE_INIT(
|
1715
|
-
|
1716
|
-
|
1745
|
+
GRPC_CLOSURE_INIT(
|
1746
|
+
&bctl->finish_batch_,
|
1747
|
+
[](void* bctl, grpc_error_handle error) {
|
1748
|
+
static_cast<BatchControl*>(bctl)->FinishBatch(error);
|
1749
|
+
},
|
1750
|
+
bctl, grpc_schedule_on_exec_ctx);
|
1751
|
+
stream_op->on_complete = &bctl->finish_batch_;
|
1717
1752
|
}
|
1718
1753
|
|
1719
|
-
gpr_atm_rel_store(&
|
1720
|
-
|
1754
|
+
gpr_atm_rel_store(&any_ops_sent_atm_, 1);
|
1755
|
+
ExecuteBatch(stream_op, &bctl->start_batch_);
|
1721
1756
|
|
1722
1757
|
done:
|
1723
1758
|
return error;
|
@@ -1725,87 +1760,172 @@ done:
|
|
1725
1760
|
done_with_error:
|
1726
1761
|
/* reverse any mutations that occurred */
|
1727
1762
|
if (stream_op->send_initial_metadata) {
|
1728
|
-
|
1729
|
-
|
1763
|
+
sent_initial_metadata_ = false;
|
1764
|
+
send_initial_metadata_.Clear();
|
1730
1765
|
}
|
1731
1766
|
if (stream_op->send_message) {
|
1732
|
-
|
1767
|
+
sending_message_ = false;
|
1733
1768
|
// No need to invoke call->sending_stream->Orphan() explicitly.
|
1734
1769
|
// stream_op_payload->send_message.send_message.reset() calls Deletor
|
1735
1770
|
// of call->sending_stream which in-turn invokes the Orphan() method.
|
1736
1771
|
stream_op_payload->send_message.send_message.reset();
|
1737
1772
|
}
|
1738
1773
|
if (stream_op->send_trailing_metadata) {
|
1739
|
-
|
1740
|
-
|
1774
|
+
sent_final_op_ = false;
|
1775
|
+
send_trailing_metadata_.Clear();
|
1741
1776
|
}
|
1742
1777
|
if (stream_op->recv_initial_metadata) {
|
1743
|
-
|
1778
|
+
received_initial_metadata_ = false;
|
1744
1779
|
}
|
1745
1780
|
if (stream_op->recv_message) {
|
1746
|
-
|
1781
|
+
receiving_message_ = false;
|
1747
1782
|
}
|
1748
1783
|
if (stream_op->recv_trailing_metadata) {
|
1749
|
-
|
1784
|
+
requested_final_op_ = false;
|
1750
1785
|
}
|
1751
1786
|
goto done;
|
1752
1787
|
}
|
1753
1788
|
|
1789
|
+
void FilterStackCall::ContextSet(grpc_context_index elem, void* value,
|
1790
|
+
void (*destroy)(void*)) {
|
1791
|
+
if (context_[elem].destroy) {
|
1792
|
+
context_[elem].destroy(context_[elem].value);
|
1793
|
+
}
|
1794
|
+
context_[elem].value = value;
|
1795
|
+
context_[elem].destroy = destroy;
|
1796
|
+
}
|
1797
|
+
|
1798
|
+
} // namespace grpc_core
|
1799
|
+
|
1800
|
+
void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
|
1801
|
+
grpc_core::ExecCtx exec_ctx;
|
1802
|
+
return grpc_core::Call::FromC(call)->arena()->Alloc(size);
|
1803
|
+
}
|
1804
|
+
|
1805
|
+
size_t grpc_call_get_initial_size_estimate() {
|
1806
|
+
return grpc_core::FilterStackCall::InitialSizeEstimate();
|
1807
|
+
}
|
1808
|
+
|
1809
|
+
grpc_error_handle grpc_call_create(grpc_call_create_args* args,
|
1810
|
+
grpc_call** out_call) {
|
1811
|
+
return grpc_core::FilterStackCall::Create(args, out_call);
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
void grpc_call_set_completion_queue(grpc_call* call,
|
1815
|
+
grpc_completion_queue* cq) {
|
1816
|
+
grpc_core::Call::FromC(call)->SetCompletionQueue(cq);
|
1817
|
+
}
|
1818
|
+
|
1819
|
+
void grpc_call_ref(grpc_call* c) { grpc_core::Call::FromC(c)->ExternalRef(); }
|
1820
|
+
|
1821
|
+
void grpc_call_unref(grpc_call* c) {
|
1822
|
+
grpc_core::Call::FromC(c)->ExternalUnref();
|
1823
|
+
}
|
1824
|
+
|
1825
|
+
char* grpc_call_get_peer(grpc_call* call) {
|
1826
|
+
return grpc_core::Call::FromC(call)->GetPeer();
|
1827
|
+
}
|
1828
|
+
|
1829
|
+
grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element) {
|
1830
|
+
return grpc_core::FilterStackCall::FromTopElem(surface_element)->c_ptr();
|
1831
|
+
}
|
1832
|
+
|
1833
|
+
grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
|
1834
|
+
GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
|
1835
|
+
GPR_ASSERT(reserved == nullptr);
|
1836
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
1837
|
+
grpc_core::ExecCtx exec_ctx;
|
1838
|
+
grpc_core::Call::FromC(call)->CancelWithError(GRPC_ERROR_CANCELLED);
|
1839
|
+
return GRPC_CALL_OK;
|
1840
|
+
}
|
1841
|
+
|
1842
|
+
grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
|
1843
|
+
grpc_status_code status,
|
1844
|
+
const char* description,
|
1845
|
+
void* reserved) {
|
1846
|
+
GRPC_API_TRACE(
|
1847
|
+
"grpc_call_cancel_with_status("
|
1848
|
+
"c=%p, status=%d, description=%s, reserved=%p)",
|
1849
|
+
4, (c, (int)status, description, reserved));
|
1850
|
+
GPR_ASSERT(reserved == nullptr);
|
1851
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
1852
|
+
grpc_core::ExecCtx exec_ctx;
|
1853
|
+
grpc_core::Call::FromC(c)->CancelWithStatus(status, description);
|
1854
|
+
return GRPC_CALL_OK;
|
1855
|
+
}
|
1856
|
+
|
1857
|
+
void grpc_call_cancel_internal(grpc_call* call) {
|
1858
|
+
grpc_core::Call::FromC(call)->CancelWithError(GRPC_ERROR_CANCELLED);
|
1859
|
+
}
|
1860
|
+
|
1861
|
+
grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
|
1862
|
+
grpc_call* call) {
|
1863
|
+
return grpc_core::Call::FromC(call)->test_only_compression_algorithm();
|
1864
|
+
}
|
1865
|
+
|
1866
|
+
uint32_t grpc_call_test_only_get_message_flags(grpc_call* call) {
|
1867
|
+
return grpc_core::Call::FromC(call)->test_only_message_flags();
|
1868
|
+
}
|
1869
|
+
|
1870
|
+
uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call) {
|
1871
|
+
return grpc_core::Call::FromC(call)->test_only_encodings_accepted_by_peer();
|
1872
|
+
}
|
1873
|
+
|
1874
|
+
grpc_core::Arena* grpc_call_get_arena(grpc_call* call) {
|
1875
|
+
return grpc_core::Call::FromC(call)->arena();
|
1876
|
+
}
|
1877
|
+
|
1878
|
+
grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
|
1879
|
+
return grpc_core::Call::FromC(call)->call_stack();
|
1880
|
+
}
|
1881
|
+
|
1754
1882
|
grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
|
1755
1883
|
size_t nops, void* tag, void* reserved) {
|
1756
|
-
grpc_call_error err;
|
1757
|
-
|
1758
1884
|
GRPC_API_TRACE(
|
1759
1885
|
"grpc_call_start_batch(call=%p, ops=%p, nops=%lu, tag=%p, "
|
1760
1886
|
"reserved=%p)",
|
1761
1887
|
5, (call, ops, (unsigned long)nops, tag, reserved));
|
1762
1888
|
|
1763
1889
|
if (reserved != nullptr) {
|
1764
|
-
|
1890
|
+
return GRPC_CALL_ERROR;
|
1765
1891
|
} else {
|
1766
1892
|
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
1767
1893
|
grpc_core::ExecCtx exec_ctx;
|
1768
|
-
|
1894
|
+
return grpc_core::Call::FromC(call)->StartBatch(ops, nops, tag, false);
|
1769
1895
|
}
|
1770
|
-
|
1771
|
-
return err;
|
1772
1896
|
}
|
1773
1897
|
|
1774
1898
|
grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call,
|
1775
1899
|
const grpc_op* ops,
|
1776
1900
|
size_t nops,
|
1777
1901
|
grpc_closure* closure) {
|
1778
|
-
return
|
1902
|
+
return grpc_core::Call::FromC(call)->StartBatch(ops, nops, closure, true);
|
1779
1903
|
}
|
1780
1904
|
|
1781
1905
|
void grpc_call_context_set(grpc_call* call, grpc_context_index elem,
|
1782
1906
|
void* value, void (*destroy)(void* value)) {
|
1783
|
-
|
1784
|
-
call->context[elem].destroy(call->context[elem].value);
|
1785
|
-
}
|
1786
|
-
call->context[elem].value = value;
|
1787
|
-
call->context[elem].destroy = destroy;
|
1907
|
+
return grpc_core::Call::FromC(call)->ContextSet(elem, value, destroy);
|
1788
1908
|
}
|
1789
1909
|
|
1790
1910
|
void* grpc_call_context_get(grpc_call* call, grpc_context_index elem) {
|
1791
|
-
return call->
|
1911
|
+
return grpc_core::Call::FromC(call)->ContextGet(elem);
|
1792
1912
|
}
|
1793
1913
|
|
1794
|
-
uint8_t grpc_call_is_client(grpc_call* call) {
|
1914
|
+
uint8_t grpc_call_is_client(grpc_call* call) {
|
1915
|
+
return grpc_core::Call::FromC(call)->is_client();
|
1916
|
+
}
|
1795
1917
|
|
1796
1918
|
grpc_compression_algorithm grpc_call_compression_for_level(
|
1797
1919
|
grpc_call* call, grpc_compression_level level) {
|
1798
|
-
return call->
|
1920
|
+
return grpc_core::Call::FromC(call)->compression_for_level(level);
|
1799
1921
|
}
|
1800
1922
|
|
1801
1923
|
bool grpc_call_is_trailers_only(const grpc_call* call) {
|
1802
|
-
|
1803
|
-
GPR_DEBUG_ASSERT(!result || call->recv_initial_metadata.empty());
|
1804
|
-
return result;
|
1924
|
+
return grpc_core::Call::FromC(call)->is_trailers_only();
|
1805
1925
|
}
|
1806
1926
|
|
1807
1927
|
int grpc_call_failed_before_recv_message(const grpc_call* c) {
|
1808
|
-
return c->
|
1928
|
+
return grpc_core::Call::FromC(c)->failed_before_recv_message();
|
1809
1929
|
}
|
1810
1930
|
|
1811
1931
|
const char* grpc_call_error_to_string(grpc_call_error error) {
|