grpc 1.18.0 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +4731 -7404
- data/etc/roots.pem +146 -0
- data/include/grpc/grpc.h +11 -6
- data/include/grpc/grpc_security.h +297 -4
- data/include/grpc/grpc_security_constants.h +1 -1
- data/include/grpc/impl/codegen/byte_buffer.h +13 -0
- data/include/grpc/impl/codegen/gpr_types.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +30 -7
- data/include/grpc/impl/codegen/port_platform.h +88 -7
- data/include/grpc/impl/codegen/slice.h +2 -22
- data/include/grpc/impl/codegen/status.h +2 -1
- data/include/grpc/impl/codegen/sync_posix.h +18 -0
- data/include/grpc/slice.h +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +21 -16
- data/src/core/ext/filters/client_channel/backup_poller.h +8 -2
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +3 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +2435 -1557
- data/src/core/ext/filters/client_channel/client_channel.h +2 -10
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +6 -89
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +8 -33
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +22 -34
- data/src/core/ext/filters/client_channel/client_channel_factory.h +19 -38
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +9 -11
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +179 -0
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +59 -55
- data/src/core/ext/filters/client_channel/health/health_check_client.h +20 -9
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +146 -157
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +29 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +844 -859
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +2 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +14 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +16 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +185 -312
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +143 -375
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +192 -245
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +1554 -955
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +0 -43
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +14 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy.cc +115 -22
- data/src/core/ext/filters/client_channel/lb_policy.h +260 -129
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +5 -2
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +107 -4
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -3
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +56 -0
- data/src/core/ext/filters/client_channel/parse_address.cc +24 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +121 -122
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +84 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +179 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +24 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +111 -47
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +7 -13
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +39 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +0 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +2 -64
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
- data/src/core/{lib/iomgr/network_status_tracker.cc → ext/filters/client_channel/resolver/dns/dns_resolver_selection.h} +8 -15
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +36 -82
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +111 -72
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +13 -8
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +28 -63
- data/src/core/ext/filters/client_channel/resolver.cc +54 -1
- data/src/core/ext/filters/client_channel/resolver.h +52 -23
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -1
- data/src/core/ext/filters/client_channel/resolver_registry.cc +5 -2
- data/src/core/ext/filters/client_channel/resolver_registry.h +5 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +368 -241
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +58 -76
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +543 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +139 -0
- data/src/core/ext/filters/client_channel/server_address.cc +4 -54
- data/src/core/ext/filters/client_channel/server_address.h +1 -13
- data/src/core/ext/filters/client_channel/service_config.cc +329 -0
- data/src/core/ext/filters/client_channel/service_config.h +205 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +803 -838
- data/src/core/ext/filters/client_channel/subchannel.h +295 -128
- data/src/core/ext/filters/client_channel/subchannel_interface.h +113 -0
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +94 -0
- data/src/core/ext/filters/deadline/deadline_filter.cc +3 -4
- data/src/core/ext/filters/deadline/deadline_filter.h +3 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +7 -5
- data/src/core/ext/filters/http/client/http_client_filter.h +1 -1
- data/src/core/ext/filters/http/client_authority_filter.cc +6 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -3
- data/src/core/ext/filters/http/server/http_server_filter.cc +18 -12
- data/src/core/ext/filters/max_age/max_age_filter.cc +5 -2
- data/src/core/ext/filters/message_size/message_size_filter.cc +119 -77
- data/src/core/ext/filters/message_size/message_size_filter.h +33 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.h +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -12
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +45 -47
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +134 -143
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +68 -21
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +4 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +9 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +156 -94
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +33 -37
- data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +8 -6
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -4
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +74 -55
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +33 -11
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -2
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +7 -14
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -1
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +9 -5
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +9 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +43 -30
- data/src/core/ext/transport/chttp2/transport/parsing.cc +52 -70
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +70 -33
- data/src/core/ext/transport/inproc/inproc_transport.cc +26 -18
- data/src/core/lib/channel/channel_args.cc +2 -101
- data/src/core/lib/channel/channel_args.h +3 -37
- data/src/core/lib/channel/channel_stack.h +10 -6
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channel_trace.h +4 -4
- data/src/core/lib/channel/channelz.cc +168 -38
- data/src/core/lib/channel/channelz.h +40 -44
- data/src/core/lib/channel/channelz_registry.cc +75 -107
- data/src/core/lib/channel/channelz_registry.h +10 -28
- data/src/core/lib/channel/connected_channel.cc +2 -2
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/channel/handshaker.cc +151 -218
- data/src/core/lib/channel/handshaker.h +110 -101
- data/src/core/lib/channel/handshaker_factory.h +11 -19
- data/src/core/lib/channel/handshaker_registry.cc +67 -51
- data/src/core/lib/channel/handshaker_registry.h +21 -16
- data/src/core/lib/compression/algorithm_metadata.h +3 -3
- data/src/core/lib/compression/compression.cc +14 -9
- data/src/core/lib/compression/compression_args.cc +127 -0
- data/src/core/lib/compression/compression_args.h +55 -0
- data/src/core/lib/compression/compression_internal.cc +16 -12
- data/src/core/lib/compression/compression_internal.h +1 -1
- data/src/core/lib/compression/stream_compression.cc +3 -2
- data/src/core/lib/compression/stream_compression.h +2 -2
- data/src/core/lib/compression/stream_compression_gzip.cc +9 -9
- data/src/core/lib/debug/trace.cc +13 -7
- data/src/core/lib/debug/trace.h +14 -1
- data/src/core/lib/gpr/arena.h +13 -9
- data/src/core/lib/gpr/cpu_posix.cc +5 -3
- data/src/core/lib/gpr/env.h +3 -6
- data/src/core/lib/gpr/env_linux.cc +6 -1
- data/src/core/lib/gpr/env_posix.cc +5 -0
- data/src/core/lib/gpr/env_windows.cc +7 -5
- data/src/core/lib/gpr/log.cc +9 -13
- data/src/core/lib/gpr/log_posix.cc +2 -1
- data/src/core/lib/gpr/string.cc +20 -7
- data/src/core/lib/gpr/string.h +10 -3
- data/src/core/lib/gpr/sync_posix.cc +65 -4
- data/src/core/lib/gpr/time.cc +8 -0
- data/src/core/lib/gpr/time_posix.cc +21 -2
- data/src/core/lib/gprpp/arena.cc +103 -0
- data/src/core/lib/gprpp/arena.h +121 -0
- data/src/core/lib/gprpp/atomic.h +75 -5
- data/src/core/lib/gprpp/fork.cc +13 -32
- data/src/core/lib/gprpp/fork.h +5 -1
- data/src/core/lib/gprpp/global_config.h +96 -0
- data/src/core/lib/gprpp/global_config_custom.h +29 -0
- data/src/core/lib/gprpp/global_config_env.cc +135 -0
- data/src/core/lib/gprpp/global_config_env.h +131 -0
- data/src/core/lib/gprpp/global_config_generic.h +44 -0
- data/src/core/lib/gprpp/inlined_vector.h +8 -0
- data/src/core/lib/gprpp/map.h +436 -0
- data/src/core/lib/gprpp/memory.h +2 -2
- data/src/core/lib/gprpp/optional.h +48 -0
- data/src/core/lib/gprpp/orphanable.h +6 -5
- data/src/core/lib/gprpp/{mutex_lock.h → pair.h} +15 -19
- data/src/core/lib/gprpp/ref_counted.h +36 -17
- data/src/core/lib/gprpp/sync.h +126 -0
- data/src/core/lib/gprpp/thd.h +42 -7
- data/src/core/lib/gprpp/thd_posix.cc +31 -13
- data/src/core/lib/gprpp/thd_windows.cc +47 -34
- data/src/core/lib/http/httpcli.cc +6 -5
- data/src/core/lib/http/httpcli_security_connector.cc +13 -15
- data/src/core/lib/http/parser.cc +3 -2
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/buffer_list.cc +182 -24
- data/src/core/lib/iomgr/buffer_list.h +72 -10
- data/src/core/lib/iomgr/call_combiner.cc +84 -90
- data/src/core/lib/iomgr/call_combiner.h +75 -82
- data/src/core/lib/iomgr/cfstream_handle.cc +203 -0
- data/src/core/lib/iomgr/cfstream_handle.h +86 -0
- data/src/core/lib/iomgr/combiner.cc +11 -3
- data/src/core/lib/iomgr/combiner.h +1 -1
- data/src/core/lib/iomgr/endpoint.cc +2 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +375 -0
- data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/error.cc +21 -17
- data/src/core/lib/iomgr/error.h +36 -6
- data/src/core/lib/iomgr/error_cfstream.cc +52 -0
- data/src/core/lib/iomgr/error_cfstream.h +31 -0
- data/src/core/lib/iomgr/error_internal.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +44 -28
- data/src/core/lib/iomgr/ev_epollex_linux.cc +173 -194
- data/src/core/lib/iomgr/ev_poll_posix.cc +16 -487
- data/src/core/lib/iomgr/ev_posix.cc +29 -19
- data/src/core/lib/iomgr/ev_posix.h +19 -3
- data/src/core/lib/iomgr/ev_windows.cc +2 -2
- data/src/core/lib/iomgr/exec_ctx.cc +1 -0
- data/src/core/lib/iomgr/exec_ctx.h +137 -8
- data/src/core/lib/iomgr/executor.cc +147 -95
- data/src/core/lib/iomgr/executor.h +55 -49
- data/src/core/lib/iomgr/fork_posix.cc +6 -5
- data/src/core/lib/{gprpp/atomic_with_std.h → iomgr/grpc_if_nametoindex.h} +8 -13
- data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
- data/src/core/lib/iomgr/{network_status_tracker.h → grpc_if_nametoindex_unsupported.cc} +15 -9
- data/src/core/lib/iomgr/internal_errqueue.cc +3 -5
- data/src/core/lib/iomgr/internal_errqueue.h +105 -3
- data/src/core/lib/iomgr/iomgr.cc +20 -13
- data/src/core/lib/iomgr/iomgr.h +15 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +17 -3
- data/src/core/lib/iomgr/iomgr_custom.h +2 -0
- data/src/core/lib/iomgr/iomgr_internal.cc +10 -0
- data/src/core/lib/iomgr/iomgr_internal.h +12 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +19 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +93 -0
- data/src/core/lib/iomgr/iomgr_windows.cc +18 -2
- data/src/core/lib/iomgr/lockfree_event.cc +4 -4
- data/src/core/lib/iomgr/port.h +35 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +4 -3
- data/src/core/lib/iomgr/resolve_address_windows.cc +2 -1
- data/src/core/lib/iomgr/resource_quota.cc +40 -37
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +6 -2
- data/src/core/lib/iomgr/socket_windows.cc +19 -0
- data/src/core/lib/iomgr/socket_windows.h +8 -0
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +216 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_client_windows.cc +7 -5
- data/src/core/lib/iomgr/tcp_custom.cc +10 -14
- data/src/core/lib/iomgr/tcp_posix.cc +256 -140
- data/src/core/lib/iomgr/tcp_server.cc +5 -0
- data/src/core/lib/iomgr/tcp_server.h +24 -0
- data/src/core/lib/iomgr/tcp_server_custom.cc +14 -12
- data/src/core/lib/iomgr/tcp_server_posix.cc +86 -12
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +13 -11
- data/src/core/lib/iomgr/tcp_uv.cc +5 -7
- data/src/core/lib/iomgr/tcp_windows.cc +8 -14
- data/src/core/lib/iomgr/timer.h +2 -1
- data/src/core/lib/iomgr/timer_generic.cc +16 -16
- data/src/core/lib/iomgr/timer_manager.cc +20 -11
- data/src/core/lib/iomgr/udp_server.cc +8 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -19
- data/src/core/lib/json/json.cc +1 -4
- data/src/core/lib/profiling/basic_timers.cc +10 -4
- data/src/core/lib/security/context/security_context.cc +6 -7
- data/src/core/lib/security/context/security_context.h +3 -4
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
- data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
- data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -0
- data/src/core/lib/security/credentials/credentials.h +9 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -3
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +2 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +10 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +3 -3
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +9 -8
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +192 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +210 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +129 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.h +62 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +10 -8
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -12
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +7 -5
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +10 -8
- data/src/core/lib/security/security_connector/security_connector.cc +0 -1
- data/src/core/lib/security/security_connector/security_connector.h +3 -3
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +39 -38
- data/src/core/lib/security/security_connector/ssl_utils.cc +164 -26
- data/src/core/lib/security/security_connector/ssl_utils.h +70 -1
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +426 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +122 -0
- data/src/core/lib/security/transport/auth_filters.h +5 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +55 -50
- data/src/core/lib/security/transport/secure_endpoint.cc +6 -6
- data/src/core/lib/security/transport/security_handshaker.cc +271 -303
- data/src/core/lib/security/transport/security_handshaker.h +11 -2
- data/src/core/lib/security/transport/server_auth_filter.cc +3 -3
- data/src/core/lib/slice/b64.h +2 -2
- data/src/core/lib/slice/percent_encoding.cc +3 -3
- data/src/core/lib/slice/percent_encoding.h +3 -3
- data/src/core/lib/slice/slice.cc +174 -122
- data/src/core/lib/slice/slice_buffer.cc +54 -21
- data/src/core/lib/slice/slice_hash_table.h +4 -4
- data/src/core/lib/slice/slice_intern.cc +49 -107
- data/src/core/lib/slice/slice_internal.h +264 -3
- data/src/core/lib/slice/slice_string_helpers.cc +10 -1
- data/src/core/lib/slice/slice_string_helpers.h +3 -1
- data/src/core/lib/slice/slice_utils.h +50 -0
- data/src/core/lib/slice/slice_weak_hash_table.h +6 -6
- data/src/core/lib/surface/api_trace.h +1 -1
- data/src/core/lib/surface/byte_buffer_reader.cc +17 -0
- data/src/core/lib/surface/call.cc +67 -46
- data/src/core/lib/surface/call.h +7 -2
- data/src/core/lib/surface/call_details.cc +0 -1
- data/src/core/lib/surface/channel.cc +89 -97
- data/src/core/lib/surface/channel.h +60 -6
- data/src/core/lib/surface/channel_init.h +5 -0
- data/src/core/lib/surface/completion_queue.cc +221 -216
- data/src/core/lib/surface/completion_queue.h +2 -1
- data/src/core/lib/surface/init.cc +82 -33
- data/src/core/lib/surface/init.h +1 -0
- data/src/core/lib/surface/init_secure.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +5 -7
- data/src/core/lib/surface/server.cc +42 -47
- data/src/core/lib/surface/validate_metadata.cc +14 -8
- data/src/core/lib/surface/validate_metadata.h +13 -2
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/bdp_estimator.cc +3 -3
- data/src/core/lib/transport/bdp_estimator.h +2 -2
- data/src/core/lib/transport/connectivity_state.cc +10 -40
- data/src/core/lib/transport/connectivity_state.h +0 -8
- data/src/core/lib/transport/error_utils.cc +12 -0
- data/src/core/lib/transport/metadata.cc +258 -267
- data/src/core/lib/transport/metadata.h +227 -16
- data/src/core/lib/transport/metadata_batch.cc +1 -1
- data/src/core/lib/transport/metadata_batch.h +1 -1
- data/src/core/lib/transport/static_metadata.cc +477 -399
- data/src/core/lib/transport/static_metadata.h +273 -182
- data/src/core/lib/transport/status_metadata.cc +3 -3
- data/src/core/lib/transport/timeout_encoding.cc +1 -1
- data/src/core/lib/transport/timeout_encoding.h +1 -1
- data/src/core/lib/transport/transport.cc +39 -72
- data/src/core/lib/transport/transport.h +59 -24
- data/src/core/lib/transport/transport_impl.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_shared_resource.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +4 -3
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -1
- data/src/core/tsi/fake_transport_security.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +12 -10
- data/src/core/tsi/ssl_transport_security.h +24 -4
- data/src/ruby/bin/math_pb.rb +18 -16
- data/src/ruby/ext/grpc/extconf.rb +12 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +8 -5
- data/src/ruby/ext/grpc/rb_channel.c +14 -10
- data/src/ruby/ext/grpc/rb_channel_credentials.c +8 -4
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -7
- data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc.c +23 -24
- data/src/ruby/ext/grpc/rb_grpc.h +4 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +24 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +36 -0
- data/src/ruby/ext/grpc/rb_server.c +8 -4
- data/src/ruby/lib/grpc/errors.rb +22 -3
- data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +13 -10
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +18 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +3 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +58 -56
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -0
- data/src/ruby/spec/errors_spec.rb +141 -0
- data/third_party/cares/cares/ares.h +12 -0
- data/third_party/cares/cares/ares_create_query.c +5 -1
- data/third_party/cares/cares/ares_data.c +74 -73
- data/third_party/cares/cares/ares_destroy.c +6 -1
- data/third_party/cares/cares/ares_gethostbyaddr.c +5 -5
- data/third_party/cares/cares/ares_gethostbyname.c +15 -4
- data/third_party/cares/cares/ares_getnameinfo.c +11 -0
- data/third_party/cares/cares/ares_init.c +274 -173
- data/third_party/cares/cares/ares_library_init.c +21 -3
- data/third_party/cares/cares/ares_options.c +6 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +7 -6
- data/third_party/cares/cares/ares_parse_ptr_reply.c +4 -2
- data/third_party/cares/cares/ares_platform.c +7 -0
- data/third_party/cares/cares/ares_private.h +19 -11
- data/third_party/cares/cares/ares_process.c +27 -2
- data/third_party/cares/cares/ares_rules.h +1 -1
- data/third_party/cares/cares/ares_search.c +7 -0
- data/third_party/cares/cares/ares_send.c +6 -0
- data/third_party/cares/cares/ares_strsplit.c +174 -0
- data/third_party/cares/cares/ares_strsplit.h +43 -0
- data/third_party/cares/cares/ares_version.h +4 -4
- data/third_party/cares/cares/config-win32.h +1 -1
- data/third_party/cares/cares/inet_ntop.c +2 -3
- data/third_party/cares/config_darwin/ares_config.h +3 -0
- data/third_party/cares/config_freebsd/ares_config.h +3 -0
- data/third_party/cares/config_linux/ares_config.h +3 -0
- data/third_party/cares/config_openbsd/ares_config.h +3 -0
- metadata +83 -48
- data/src/core/ext/filters/client_channel/request_routing.cc +0 -936
- data/src/core/ext/filters/client_channel/request_routing.h +0 -177
- data/src/core/ext/filters/client_channel/subchannel_index.cc +0 -248
- data/src/core/ext/filters/client_channel/subchannel_index.h +0 -76
- data/src/core/lib/channel/handshaker_factory.cc +0 -42
- data/src/core/lib/gpr/arena.cc +0 -192
- data/src/core/lib/gprpp/atomic_with_atm.h +0 -57
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +0 -107
- data/src/core/lib/iomgr/wakeup_fd_cv.h +0 -69
- data/src/core/lib/transport/service_config.cc +0 -106
- data/src/core/lib/transport/service_config.h +0 -249
@@ -0,0 +1,50 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2019 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#ifndef GRPC_CORE_LIB_SLICE_SLICE_UTILS_H
|
20
|
+
#define GRPC_CORE_LIB_SLICE_SLICE_UTILS_H
|
21
|
+
|
22
|
+
#include <grpc/support/port_platform.h>
|
23
|
+
|
24
|
+
#include <grpc/slice.h>
|
25
|
+
|
26
|
+
// When we compare two slices, and we know the latter is not inlined, we can
|
27
|
+
// short circuit our comparison operator. We specifically use differs()
|
28
|
+
// semantics instead of equals() semantics due to more favourable code
|
29
|
+
// generation when using differs(). Specifically, we may use the output of
|
30
|
+
// grpc_slice_differs_refcounted for control flow. If we use differs()
|
31
|
+
// semantics, we end with a tailcall to memcmp(). If we use equals() semantics,
|
32
|
+
// we need to invert the result that memcmp provides us, which costs several
|
33
|
+
// instructions to do so. If we're using the result for control flow (i.e.
|
34
|
+
// branching based on the output) then we're just performing the extra
|
35
|
+
// operations to invert the result pointlessly. Concretely, we save 6 ops on
|
36
|
+
// x86-64/clang with differs().
|
37
|
+
int grpc_slice_differs_refcounted(const grpc_slice& a,
|
38
|
+
const grpc_slice& b_not_inline);
|
39
|
+
// When we compare two slices, and we *know* that one of them is static or
|
40
|
+
// interned, we can short circuit our slice equality function. The second slice
|
41
|
+
// here must be static or interned; slice a can be any slice, inlined or not.
|
42
|
+
inline bool grpc_slice_eq_static_interned(const grpc_slice& a,
|
43
|
+
const grpc_slice& b_static_interned) {
|
44
|
+
if (a.refcount == b_static_interned.refcount) {
|
45
|
+
return true;
|
46
|
+
}
|
47
|
+
return !grpc_slice_differs_refcounted(a, b_static_interned);
|
48
|
+
}
|
49
|
+
|
50
|
+
#endif /* GRPC_CORE_LIB_SLICE_SLICE_UTILS_H */
|
@@ -46,16 +46,16 @@ class SliceWeakHashTable : public RefCounted<SliceWeakHashTable<T, Size>> {
|
|
46
46
|
|
47
47
|
/// Add a mapping from \a key to \a value, taking ownership of \a key. This
|
48
48
|
/// operation will always succeed. It may discard older entries.
|
49
|
-
void Add(grpc_slice key, T value) {
|
50
|
-
const size_t idx =
|
49
|
+
void Add(const grpc_slice& key, T value) {
|
50
|
+
const size_t idx = grpc_slice_hash_internal(key) % Size;
|
51
51
|
entries_[idx].Set(key, std::move(value));
|
52
52
|
return;
|
53
53
|
}
|
54
54
|
|
55
55
|
/// Returns the value from the table associated with / \a key or null if not
|
56
56
|
/// found.
|
57
|
-
const T* Get(const grpc_slice key) const {
|
58
|
-
const size_t idx =
|
57
|
+
const T* Get(const grpc_slice& key) const {
|
58
|
+
const size_t idx = grpc_slice_hash_internal(key) % Size;
|
59
59
|
const auto& entry = entries_[idx];
|
60
60
|
return grpc_slice_eq(entry.key(), key) ? entry.value() : nullptr;
|
61
61
|
}
|
@@ -79,7 +79,7 @@ class SliceWeakHashTable : public RefCounted<SliceWeakHashTable<T, Size>> {
|
|
79
79
|
~Entry() {
|
80
80
|
if (is_set_) grpc_slice_unref_internal(key_);
|
81
81
|
}
|
82
|
-
grpc_slice key() const { return key_; }
|
82
|
+
const grpc_slice& key() const { return key_; }
|
83
83
|
|
84
84
|
/// Return the entry's value, or null if unset.
|
85
85
|
const T* value() const {
|
@@ -88,7 +88,7 @@ class SliceWeakHashTable : public RefCounted<SliceWeakHashTable<T, Size>> {
|
|
88
88
|
}
|
89
89
|
|
90
90
|
/// Set the \a key and \a value (which is moved) for the entry.
|
91
|
-
void Set(grpc_slice key, T&& value) {
|
91
|
+
void Set(const grpc_slice& key, T&& value) {
|
92
92
|
if (is_set_) grpc_slice_unref_internal(key_);
|
93
93
|
key_ = key;
|
94
94
|
value_ = std::move(value);
|
@@ -45,7 +45,7 @@ extern grpc_core::TraceFlag grpc_api_trace;
|
|
45
45
|
/* Due to the limitations of C89's preprocessor, the arity of the var-arg list
|
46
46
|
'nargs' must be specified. */
|
47
47
|
#define GRPC_API_TRACE(fmt, nargs, args) \
|
48
|
-
if (grpc_api_trace
|
48
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \
|
49
49
|
gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \
|
50
50
|
}
|
51
51
|
|
@@ -91,6 +91,23 @@ void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader) {
|
|
91
91
|
}
|
92
92
|
}
|
93
93
|
|
94
|
+
int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader,
|
95
|
+
grpc_slice** slice) {
|
96
|
+
switch (reader->buffer_in->type) {
|
97
|
+
case GRPC_BB_RAW: {
|
98
|
+
grpc_slice_buffer* slice_buffer;
|
99
|
+
slice_buffer = &reader->buffer_out->data.raw.slice_buffer;
|
100
|
+
if (reader->current.index < slice_buffer->count) {
|
101
|
+
*slice = &slice_buffer->slices[reader->current.index];
|
102
|
+
reader->current.index += 1;
|
103
|
+
return 1;
|
104
|
+
}
|
105
|
+
break;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
return 0;
|
109
|
+
}
|
110
|
+
|
94
111
|
int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
|
95
112
|
grpc_slice* slice) {
|
96
113
|
switch (reader->buffer_in->type) {
|
@@ -35,14 +35,15 @@
|
|
35
35
|
#include "src/core/lib/compression/algorithm_metadata.h"
|
36
36
|
#include "src/core/lib/debug/stats.h"
|
37
37
|
#include "src/core/lib/gpr/alloc.h"
|
38
|
-
#include "src/core/lib/gpr/arena.h"
|
39
38
|
#include "src/core/lib/gpr/string.h"
|
40
39
|
#include "src/core/lib/gpr/useful.h"
|
40
|
+
#include "src/core/lib/gprpp/arena.h"
|
41
41
|
#include "src/core/lib/gprpp/manual_constructor.h"
|
42
|
+
#include "src/core/lib/gprpp/ref_counted.h"
|
42
43
|
#include "src/core/lib/iomgr/timer.h"
|
43
44
|
#include "src/core/lib/profiling/timers.h"
|
44
|
-
#include "src/core/lib/slice/slice_internal.h"
|
45
45
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
46
|
+
#include "src/core/lib/slice/slice_utils.h"
|
46
47
|
#include "src/core/lib/surface/api_trace.h"
|
47
48
|
#include "src/core/lib/surface/call.h"
|
48
49
|
#include "src/core/lib/surface/call_test_only.h"
|
@@ -73,7 +74,7 @@
|
|
73
74
|
#define ESTIMATED_MDELEM_COUNT 16
|
74
75
|
|
75
76
|
struct batch_control {
|
76
|
-
batch_control()
|
77
|
+
batch_control() = default;
|
77
78
|
|
78
79
|
grpc_call* call = nullptr;
|
79
80
|
grpc_transport_stream_op_batch op;
|
@@ -98,8 +99,14 @@ struct batch_control {
|
|
98
99
|
} completion_data;
|
99
100
|
grpc_closure start_batch;
|
100
101
|
grpc_closure finish_batch;
|
101
|
-
|
102
|
+
grpc_core::Atomic<intptr_t> steps_to_complete;
|
102
103
|
gpr_atm batch_error = reinterpret_cast<gpr_atm>(GRPC_ERROR_NONE);
|
104
|
+
void set_num_steps_to_complete(uintptr_t steps) {
|
105
|
+
steps_to_complete.Store(steps, grpc_core::MemoryOrder::RELEASE);
|
106
|
+
}
|
107
|
+
bool completed_batch_step() {
|
108
|
+
return steps_to_complete.FetchSub(1, grpc_core::MemoryOrder::ACQ_REL) == 1;
|
109
|
+
}
|
103
110
|
};
|
104
111
|
|
105
112
|
struct parent_call {
|
@@ -124,14 +131,12 @@ struct child_call {
|
|
124
131
|
#define RECV_INITIAL_METADATA_FIRST ((gpr_atm)1)
|
125
132
|
|
126
133
|
struct grpc_call {
|
127
|
-
grpc_call(
|
134
|
+
grpc_call(grpc_core::Arena* arena, const grpc_call_create_args& args)
|
128
135
|
: arena(arena),
|
129
136
|
cq(args.cq),
|
130
137
|
channel(args.channel),
|
131
138
|
is_client(args.server_transport_data == nullptr),
|
132
139
|
stream_op_payload(context) {
|
133
|
-
gpr_ref_init(&ext_ref, 1);
|
134
|
-
grpc_call_combiner_init(&call_combiner);
|
135
140
|
for (int i = 0; i < 2; i++) {
|
136
141
|
for (int j = 0; j < 2; j++) {
|
137
142
|
metadata_batch[i][j].deadline = GRPC_MILLIS_INF_FUTURE;
|
@@ -141,12 +146,11 @@ struct grpc_call {
|
|
141
146
|
|
142
147
|
~grpc_call() {
|
143
148
|
gpr_free(static_cast<void*>(const_cast<char*>(final_info.error_string)));
|
144
|
-
grpc_call_combiner_destroy(&call_combiner);
|
145
149
|
}
|
146
150
|
|
147
|
-
|
148
|
-
|
149
|
-
|
151
|
+
grpc_core::RefCount ext_ref;
|
152
|
+
grpc_core::Arena* arena;
|
153
|
+
grpc_core::CallCombiner call_combiner;
|
150
154
|
grpc_completion_queue* cq;
|
151
155
|
grpc_polling_entity pollent;
|
152
156
|
grpc_channel* channel;
|
@@ -292,13 +296,13 @@ static void add_init_error(grpc_error** composite, grpc_error* new_err) {
|
|
292
296
|
}
|
293
297
|
|
294
298
|
void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
|
295
|
-
return
|
299
|
+
return call->arena->Alloc(size);
|
296
300
|
}
|
297
301
|
|
298
302
|
static parent_call* get_or_create_parent_call(grpc_call* call) {
|
299
303
|
parent_call* p = (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
|
300
304
|
if (p == nullptr) {
|
301
|
-
p =
|
305
|
+
p = call->arena->New<parent_call>();
|
302
306
|
if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm) nullptr,
|
303
307
|
(gpr_atm)p)) {
|
304
308
|
p->~parent_call();
|
@@ -323,16 +327,23 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
|
323
327
|
|
324
328
|
GRPC_CHANNEL_INTERNAL_REF(args->channel, "call");
|
325
329
|
|
330
|
+
grpc_core::Arena* arena;
|
331
|
+
grpc_call* call;
|
326
332
|
grpc_error* error = GRPC_ERROR_NONE;
|
327
333
|
grpc_channel_stack* channel_stack =
|
328
334
|
grpc_channel_get_channel_stack(args->channel);
|
329
|
-
grpc_call* call;
|
330
335
|
size_t initial_size = grpc_channel_get_call_size_estimate(args->channel);
|
331
336
|
GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
337
|
+
size_t call_and_stack_size =
|
338
|
+
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_call)) +
|
339
|
+
channel_stack->call_stack_size;
|
340
|
+
size_t call_alloc_size =
|
341
|
+
call_and_stack_size + (args->parent ? sizeof(child_call) : 0);
|
342
|
+
|
343
|
+
std::pair<grpc_core::Arena*, void*> arena_with_call =
|
344
|
+
grpc_core::Arena::CreateWithAlloc(initial_size, call_alloc_size);
|
345
|
+
arena = arena_with_call.first;
|
346
|
+
call = new (arena_with_call.second) grpc_call(arena, *args);
|
336
347
|
*out_call = call;
|
337
348
|
grpc_slice path = grpc_empty_slice();
|
338
349
|
if (call->is_client) {
|
@@ -344,8 +355,8 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
|
344
355
|
MAX_SEND_EXTRA_METADATA_COUNT);
|
345
356
|
for (size_t i = 0; i < args->add_initial_metadata_count; i++) {
|
346
357
|
call->send_extra_metadata[i].md = args->add_initial_metadata[i];
|
347
|
-
if (
|
348
|
-
|
358
|
+
if (grpc_slice_eq_static_interned(
|
359
|
+
GRPC_MDKEY(args->add_initial_metadata[i]), GRPC_MDSTR_PATH)) {
|
349
360
|
path = grpc_slice_ref_internal(
|
350
361
|
GRPC_MDVALUE(args->add_initial_metadata[i]));
|
351
362
|
}
|
@@ -364,8 +375,8 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
|
|
364
375
|
bool immediately_cancel = false;
|
365
376
|
|
366
377
|
if (args->parent != nullptr) {
|
367
|
-
call->child = new (
|
368
|
-
|
378
|
+
call->child = new (reinterpret_cast<char*>(arena_with_call.second) +
|
379
|
+
call_and_stack_size) child_call(args->parent);
|
369
380
|
|
370
381
|
GRPC_CALL_INTERNAL_REF(args->parent, "child");
|
371
382
|
GPR_ASSERT(call->is_client);
|
@@ -502,9 +513,9 @@ void grpc_call_internal_unref(grpc_call* c REF_ARG) {
|
|
502
513
|
static void release_call(void* call, grpc_error* error) {
|
503
514
|
grpc_call* c = static_cast<grpc_call*>(call);
|
504
515
|
grpc_channel* channel = c->channel;
|
505
|
-
|
516
|
+
grpc_core::Arena* arena = c->arena;
|
506
517
|
c->~grpc_call();
|
507
|
-
grpc_channel_update_call_size_estimate(channel,
|
518
|
+
grpc_channel_update_call_size_estimate(channel, arena->Destroy());
|
508
519
|
GRPC_CHANNEL_INTERNAL_UNREF(channel, "call");
|
509
520
|
}
|
510
521
|
|
@@ -548,14 +559,15 @@ static void destroy_call(void* call, grpc_error* error) {
|
|
548
559
|
grpc_schedule_on_exec_ctx));
|
549
560
|
}
|
550
561
|
|
551
|
-
void grpc_call_ref(grpc_call* c) {
|
562
|
+
void grpc_call_ref(grpc_call* c) { c->ext_ref.Ref(); }
|
552
563
|
|
553
564
|
void grpc_call_unref(grpc_call* c) {
|
554
|
-
if (!
|
565
|
+
if (GPR_LIKELY(!c->ext_ref.Unref())) return;
|
555
566
|
|
556
567
|
GPR_TIMER_SCOPE("grpc_call_unref", 0);
|
557
568
|
|
558
569
|
child_call* cc = c->child;
|
570
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
559
571
|
grpc_core::ExecCtx exec_ctx;
|
560
572
|
|
561
573
|
GRPC_API_TRACE("grpc_call_unref(c=%p)", 1, (c));
|
@@ -588,7 +600,7 @@ void grpc_call_unref(grpc_call* c) {
|
|
588
600
|
// holding to the call stack. Also flush the closures on exec_ctx so that
|
589
601
|
// filters that schedule cancel notification closures on exec_ctx do not
|
590
602
|
// need to take a ref of the call stack to guarantee closure liveness.
|
591
|
-
|
603
|
+
c->call_combiner.SetNotifyOnCancel(nullptr);
|
592
604
|
grpc_core::ExecCtx::Get()->Flush();
|
593
605
|
}
|
594
606
|
GRPC_CALL_INTERNAL_UNREF(c, "destroy");
|
@@ -597,6 +609,7 @@ void grpc_call_unref(grpc_call* c) {
|
|
597
609
|
grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
|
598
610
|
GRPC_API_TRACE("grpc_call_cancel(call=%p, reserved=%p)", 2, (call, reserved));
|
599
611
|
GPR_ASSERT(!reserved);
|
612
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
600
613
|
grpc_core::ExecCtx exec_ctx;
|
601
614
|
cancel_with_error(call, GRPC_ERROR_CANCELLED);
|
602
615
|
return GRPC_CALL_OK;
|
@@ -646,6 +659,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
|
|
646
659
|
grpc_status_code status,
|
647
660
|
const char* description,
|
648
661
|
void* reserved) {
|
662
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
649
663
|
grpc_core::ExecCtx exec_ctx;
|
650
664
|
GRPC_API_TRACE(
|
651
665
|
"grpc_call_cancel_with_status("
|
@@ -682,7 +696,7 @@ static void cancel_with_error(grpc_call* c, grpc_error* error) {
|
|
682
696
|
// any in-flight asynchronous actions that may be holding the call
|
683
697
|
// combiner. This ensures that the cancel_stream batch can be sent
|
684
698
|
// down the filter stack in a timely manner.
|
685
|
-
|
699
|
+
c->call_combiner.Cancel(GRPC_ERROR_REF(error));
|
686
700
|
cancel_state* state = static_cast<cancel_state*>(gpr_malloc(sizeof(*state)));
|
687
701
|
state->call = c;
|
688
702
|
GRPC_CLOSURE_INIT(&state->finish_batch, done_termination, state,
|
@@ -715,7 +729,7 @@ static void cancel_with_status(grpc_call* c, grpc_status_code status,
|
|
715
729
|
}
|
716
730
|
|
717
731
|
static void set_final_status(grpc_call* call, grpc_error* error) {
|
718
|
-
if (grpc_call_error_trace
|
732
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_call_error_trace)) {
|
719
733
|
gpr_log(GPR_DEBUG, "set_final_status %s", call->is_client ? "CLI" : "SVR");
|
720
734
|
gpr_log(GPR_DEBUG, "%s", grpc_error_string(error));
|
721
735
|
}
|
@@ -891,7 +905,7 @@ static int prepare_application_metadata(grpc_call* call, int count,
|
|
891
905
|
if (!GRPC_LOG_IF_ERROR("validate_metadata",
|
892
906
|
grpc_validate_header_key_is_legal(md->key))) {
|
893
907
|
break;
|
894
|
-
} else if (!
|
908
|
+
} else if (!grpc_is_binary_header_internal(md->key) &&
|
895
909
|
!GRPC_LOG_IF_ERROR(
|
896
910
|
"validate_metadata",
|
897
911
|
grpc_validate_header_nonbin_value_is_legal(md->value))) {
|
@@ -1032,9 +1046,14 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b,
|
|
1032
1046
|
grpc_get_status_code_from_metadata(b->idx.named.grpc_status->md);
|
1033
1047
|
grpc_error* error = GRPC_ERROR_NONE;
|
1034
1048
|
if (status_code != GRPC_STATUS_OK) {
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1049
|
+
char* peer_msg = nullptr;
|
1050
|
+
char* peer = grpc_call_get_peer(call);
|
1051
|
+
gpr_asprintf(&peer_msg, "Error received from peer %s", peer);
|
1052
|
+
error = grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(peer_msg),
|
1053
|
+
GRPC_ERROR_INT_GRPC_STATUS,
|
1054
|
+
static_cast<intptr_t>(status_code));
|
1055
|
+
gpr_free(peer);
|
1056
|
+
gpr_free(peer_msg);
|
1038
1057
|
}
|
1039
1058
|
if (b->idx.named.grpc_message != nullptr) {
|
1040
1059
|
error = grpc_error_set_str(
|
@@ -1061,7 +1080,7 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b,
|
|
1061
1080
|
publish_app_metadata(call, b, true);
|
1062
1081
|
}
|
1063
1082
|
|
1064
|
-
|
1083
|
+
grpc_core::Arena* grpc_call_get_arena(grpc_call* call) { return call->arena; }
|
1065
1084
|
|
1066
1085
|
grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
|
1067
1086
|
return CALL_STACK_FROM_CALL(call);
|
@@ -1122,8 +1141,7 @@ static batch_control* reuse_or_allocate_batch_control(grpc_call* call,
|
|
1122
1141
|
bctl->~batch_control();
|
1123
1142
|
bctl->op = {};
|
1124
1143
|
} else {
|
1125
|
-
bctl =
|
1126
|
-
batch_control();
|
1144
|
+
bctl = call->arena->New<batch_control>();
|
1127
1145
|
*pslot = bctl;
|
1128
1146
|
}
|
1129
1147
|
bctl->call = call;
|
@@ -1213,7 +1231,7 @@ static void post_batch_completion(batch_control* bctl) {
|
|
1213
1231
|
}
|
1214
1232
|
|
1215
1233
|
static void finish_batch_step(batch_control* bctl) {
|
1216
|
-
if (
|
1234
|
+
if (GPR_UNLIKELY(bctl->completed_batch_step())) {
|
1217
1235
|
post_batch_completion(bctl);
|
1218
1236
|
}
|
1219
1237
|
}
|
@@ -1268,7 +1286,7 @@ static void receiving_slice_ready(void* bctlp, grpc_error* error) {
|
|
1268
1286
|
}
|
1269
1287
|
|
1270
1288
|
if (error != GRPC_ERROR_NONE) {
|
1271
|
-
if (grpc_trace_operation_failures
|
1289
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures)) {
|
1272
1290
|
GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error));
|
1273
1291
|
}
|
1274
1292
|
call->receiving_stream.reset();
|
@@ -1392,7 +1410,7 @@ static void validate_filtered_metadata(batch_control* bctl) {
|
|
1392
1410
|
|
1393
1411
|
GPR_ASSERT(call->encodings_accepted_by_peer != 0);
|
1394
1412
|
if (!GPR_BITGET(call->encodings_accepted_by_peer, compression_algorithm)) {
|
1395
|
-
if (grpc_compression_trace
|
1413
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_compression_trace)) {
|
1396
1414
|
const char* algo_name = nullptr;
|
1397
1415
|
grpc_compression_algorithm_name(compression_algorithm, &algo_name);
|
1398
1416
|
gpr_log(GPR_ERROR,
|
@@ -1551,7 +1569,10 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1551
1569
|
goto done_with_error;
|
1552
1570
|
}
|
1553
1571
|
/* process compression level */
|
1554
|
-
|
1572
|
+
grpc_metadata& compression_md = call->compression_md;
|
1573
|
+
compression_md.key = grpc_empty_slice();
|
1574
|
+
compression_md.value = grpc_empty_slice();
|
1575
|
+
compression_md.flags = 0;
|
1555
1576
|
size_t additional_metadata_count = 0;
|
1556
1577
|
grpc_compression_level effective_compression_level =
|
1557
1578
|
GRPC_COMPRESS_LEVEL_NONE;
|
@@ -1574,8 +1595,8 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1574
1595
|
call, effective_compression_level);
|
1575
1596
|
/* the following will be picked up by the compress filter and used
|
1576
1597
|
* as the call's compression algorithm. */
|
1577
|
-
|
1578
|
-
|
1598
|
+
compression_md.key = GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST;
|
1599
|
+
compression_md.value = grpc_compression_algorithm_slice(calgo);
|
1579
1600
|
additional_metadata_count++;
|
1580
1601
|
}
|
1581
1602
|
|
@@ -1589,8 +1610,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1589
1610
|
if (!prepare_application_metadata(
|
1590
1611
|
call, static_cast<int>(op->data.send_initial_metadata.count),
|
1591
1612
|
op->data.send_initial_metadata.metadata, 0, call->is_client,
|
1592
|
-
&
|
1593
|
-
static_cast<int>(additional_metadata_count))) {
|
1613
|
+
&compression_md, static_cast<int>(additional_metadata_count))) {
|
1594
1614
|
error = GRPC_CALL_ERROR_INVALID_METADATA;
|
1595
1615
|
goto done_with_error;
|
1596
1616
|
}
|
@@ -1852,7 +1872,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1852
1872
|
if (!is_notify_tag_closure) {
|
1853
1873
|
GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag));
|
1854
1874
|
}
|
1855
|
-
|
1875
|
+
bctl->set_num_steps_to_complete((has_send_ops ? 1 : 0) + num_recv_ops);
|
1856
1876
|
|
1857
1877
|
if (has_send_ops) {
|
1858
1878
|
GRPC_CLOSURE_INIT(&bctl->finish_batch, finish_batch, bctl,
|
@@ -1894,7 +1914,6 @@ done_with_error:
|
|
1894
1914
|
|
1895
1915
|
grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
|
1896
1916
|
size_t nops, void* tag, void* reserved) {
|
1897
|
-
grpc_core::ExecCtx exec_ctx;
|
1898
1917
|
grpc_call_error err;
|
1899
1918
|
|
1900
1919
|
GRPC_API_TRACE(
|
@@ -1905,6 +1924,8 @@ grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
|
|
1905
1924
|
if (reserved != nullptr) {
|
1906
1925
|
err = GRPC_CALL_ERROR;
|
1907
1926
|
} else {
|
1927
|
+
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
|
1928
|
+
grpc_core::ExecCtx exec_ctx;
|
1908
1929
|
err = call_start_batch(call, ops, nops, tag, 0);
|
1909
1930
|
}
|
1910
1931
|
|
data/src/core/lib/surface/call.h
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
|
24
24
|
#include "src/core/lib/channel/channel_stack.h"
|
25
25
|
#include "src/core/lib/channel/context.h"
|
26
|
+
#include "src/core/lib/gprpp/arena.h"
|
26
27
|
#include "src/core/lib/surface/api_trace.h"
|
27
28
|
|
28
29
|
#include <grpc/grpc.h>
|
@@ -72,7 +73,7 @@ void grpc_call_internal_unref(grpc_call* call);
|
|
72
73
|
#define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call)
|
73
74
|
#endif
|
74
75
|
|
75
|
-
|
76
|
+
grpc_core::Arena* grpc_call_get_arena(grpc_call* call);
|
76
77
|
|
77
78
|
grpc_call_stack* grpc_call_get_call_stack(grpc_call* call);
|
78
79
|
|
@@ -101,7 +102,11 @@ void grpc_call_context_set(grpc_call* call, grpc_context_index elem,
|
|
101
102
|
void* grpc_call_context_get(grpc_call* call, grpc_context_index elem);
|
102
103
|
|
103
104
|
#define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \
|
104
|
-
|
105
|
+
do { \
|
106
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \
|
107
|
+
grpc_call_log_batch(sev, call, ops, nops, tag); \
|
108
|
+
} \
|
109
|
+
} while (0)
|
105
110
|
|
106
111
|
uint8_t grpc_call_is_client(grpc_call* call);
|
107
112
|
|