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
@@ -29,7 +29,9 @@
|
|
29
29
|
|
30
30
|
#include "src/core/lib/gpr/alloc.h"
|
31
31
|
#include "src/core/lib/gpr/string.h"
|
32
|
+
#include "src/core/lib/gprpp/memory.h"
|
32
33
|
#include "src/core/lib/iomgr/executor.h"
|
34
|
+
#include "src/core/lib/iomgr/iomgr.h"
|
33
35
|
#include "src/core/lib/slice/slice_internal.h"
|
34
36
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
35
37
|
#include "src/core/lib/transport/transport_impl.h"
|
@@ -37,71 +39,39 @@
|
|
37
39
|
grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount(false,
|
38
40
|
"stream_refcount");
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
void grpc_stream_destroy(grpc_stream_refcount* refcount) {
|
43
|
+
if (!grpc_iomgr_is_any_background_poller_thread() &&
|
44
|
+
(grpc_core::ExecCtx::Get()->flags() &
|
45
|
+
GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP)) {
|
46
|
+
/* Ick.
|
47
|
+
The thread we're running on MAY be owned (indirectly) by a call-stack.
|
48
|
+
If that's the case, destroying the call-stack MAY try to destroy the
|
49
|
+
thread, which is a tangled mess that we just don't want to ever have to
|
50
|
+
cope with.
|
51
|
+
Throw this over to the executor (on a core-owned thread) and process it
|
52
|
+
there. */
|
53
|
+
refcount->destroy.scheduler =
|
54
|
+
grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT);
|
47
55
|
}
|
48
|
-
|
49
|
-
void grpc_stream_ref(grpc_stream_refcount* refcount) {
|
50
|
-
#endif
|
51
|
-
gpr_ref_non_zero(&refcount->refs);
|
56
|
+
GRPC_CLOSURE_SCHED(&refcount->destroy, GRPC_ERROR_NONE);
|
52
57
|
}
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
if (grpc_trace_stream_refcount.enabled()) {
|
57
|
-
gpr_atm val = gpr_atm_no_barrier_load(&refcount->refs.count);
|
58
|
-
gpr_log(GPR_DEBUG, "%s %p:%p UNREF %" PRIdPTR "->%" PRIdPTR " %s",
|
59
|
-
refcount->object_type, refcount, refcount->destroy.cb_arg, val,
|
60
|
-
val - 1, reason);
|
61
|
-
}
|
62
|
-
#else
|
63
|
-
void grpc_stream_unref(grpc_stream_refcount* refcount) {
|
64
|
-
#endif
|
65
|
-
if (gpr_unref(&refcount->refs)) {
|
66
|
-
if (grpc_core::ExecCtx::Get()->flags() &
|
67
|
-
GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP) {
|
68
|
-
/* Ick.
|
69
|
-
The thread we're running on MAY be owned (indirectly) by a call-stack.
|
70
|
-
If that's the case, destroying the call-stack MAY try to destroy the
|
71
|
-
thread, which is a tangled mess that we just don't want to ever have to
|
72
|
-
cope with.
|
73
|
-
Throw this over to the executor (on a core-owned thread) and process it
|
74
|
-
there. */
|
75
|
-
refcount->destroy.scheduler =
|
76
|
-
grpc_executor_scheduler(GRPC_EXECUTOR_SHORT);
|
77
|
-
}
|
78
|
-
GRPC_CLOSURE_SCHED(&refcount->destroy, GRPC_ERROR_NONE);
|
79
|
-
}
|
59
|
+
void slice_stream_destroy(void* arg) {
|
60
|
+
grpc_stream_destroy(static_cast<grpc_stream_refcount*>(arg));
|
80
61
|
}
|
81
62
|
|
82
63
|
#define STREAM_REF_FROM_SLICE_REF(p) \
|
83
64
|
((grpc_stream_refcount*)(((uint8_t*)p) - \
|
84
65
|
offsetof(grpc_stream_refcount, slice_refcount)))
|
85
66
|
|
86
|
-
|
87
|
-
|
88
|
-
grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(p), "slice");
|
89
|
-
#else
|
90
|
-
grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(p));
|
91
|
-
#endif
|
92
|
-
}
|
93
|
-
|
94
|
-
static void slice_stream_unref(void* p) {
|
67
|
+
grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
|
68
|
+
void* buffer, size_t length) {
|
95
69
|
#ifndef NDEBUG
|
96
|
-
|
70
|
+
grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(&refcount->slice_refcount),
|
71
|
+
"slice");
|
97
72
|
#else
|
98
|
-
|
73
|
+
grpc_stream_ref(STREAM_REF_FROM_SLICE_REF(&refcount->slice_refcount));
|
99
74
|
#endif
|
100
|
-
}
|
101
|
-
|
102
|
-
grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
|
103
|
-
void* buffer, size_t length) {
|
104
|
-
slice_stream_ref(&refcount->slice_refcount);
|
105
75
|
grpc_slice res;
|
106
76
|
res.refcount = &refcount->slice_refcount;
|
107
77
|
res.data.refcounted.bytes = static_cast<uint8_t*>(buffer);
|
@@ -109,13 +79,6 @@ grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
|
|
109
79
|
return res;
|
110
80
|
}
|
111
81
|
|
112
|
-
static const grpc_slice_refcount_vtable stream_ref_slice_vtable = {
|
113
|
-
slice_stream_ref, /* ref */
|
114
|
-
slice_stream_unref, /* unref */
|
115
|
-
grpc_slice_default_eq_impl, /* eq */
|
116
|
-
grpc_slice_default_hash_impl /* hash */
|
117
|
-
};
|
118
|
-
|
119
82
|
#ifndef NDEBUG
|
120
83
|
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
121
84
|
grpc_iomgr_cb_func cb, void* cb_arg,
|
@@ -125,10 +88,12 @@ void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
|
125
88
|
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
126
89
|
grpc_iomgr_cb_func cb, void* cb_arg) {
|
127
90
|
#endif
|
128
|
-
gpr_ref_init(&refcount->refs, initial_refs);
|
129
91
|
GRPC_CLOSURE_INIT(&refcount->destroy, cb, cb_arg, grpc_schedule_on_exec_ctx);
|
130
|
-
|
131
|
-
refcount->
|
92
|
+
|
93
|
+
new (&refcount->refs) grpc_core::RefCount(1, &grpc_trace_stream_refcount);
|
94
|
+
new (&refcount->slice_refcount) grpc_slice_refcount(
|
95
|
+
grpc_slice_refcount::Type::REGULAR, &refcount->refs, slice_stream_destroy,
|
96
|
+
refcount, &refcount->slice_refcount);
|
132
97
|
}
|
133
98
|
|
134
99
|
static void move64(uint64_t* from, uint64_t* to) {
|
@@ -159,7 +124,8 @@ void grpc_transport_destroy(grpc_transport* transport) {
|
|
159
124
|
|
160
125
|
int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream,
|
161
126
|
grpc_stream_refcount* refcount,
|
162
|
-
const void* server_data,
|
127
|
+
const void* server_data,
|
128
|
+
grpc_core::Arena* arena) {
|
163
129
|
return transport->vtable->init_stream(transport, stream, refcount,
|
164
130
|
server_data, arena);
|
165
131
|
}
|
@@ -209,7 +175,7 @@ grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport) {
|
|
209
175
|
// it's grpc_transport_stream_op_batch_finish_with_failure
|
210
176
|
void grpc_transport_stream_op_batch_finish_with_failure(
|
211
177
|
grpc_transport_stream_op_batch* batch, grpc_error* error,
|
212
|
-
|
178
|
+
grpc_core::CallCombiner* call_combiner) {
|
213
179
|
if (batch->send_message) {
|
214
180
|
batch->payload->send_message.send_message.reset();
|
215
181
|
}
|
@@ -241,25 +207,26 @@ void grpc_transport_stream_op_batch_finish_with_failure(
|
|
241
207
|
GRPC_ERROR_UNREF(error);
|
242
208
|
}
|
243
209
|
|
244
|
-
|
210
|
+
struct made_transport_op {
|
245
211
|
grpc_closure outer_on_complete;
|
246
|
-
grpc_closure* inner_on_complete;
|
212
|
+
grpc_closure* inner_on_complete = nullptr;
|
247
213
|
grpc_transport_op op;
|
248
|
-
|
214
|
+
made_transport_op() {
|
215
|
+
memset(&outer_on_complete, 0, sizeof(outer_on_complete));
|
216
|
+
}
|
217
|
+
};
|
249
218
|
|
250
219
|
static void destroy_made_transport_op(void* arg, grpc_error* error) {
|
251
220
|
made_transport_op* op = static_cast<made_transport_op*>(arg);
|
252
221
|
GRPC_CLOSURE_SCHED(op->inner_on_complete, GRPC_ERROR_REF(error));
|
253
|
-
|
222
|
+
grpc_core::Delete<made_transport_op>(op);
|
254
223
|
}
|
255
224
|
|
256
225
|
grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) {
|
257
|
-
made_transport_op* op =
|
258
|
-
static_cast<made_transport_op*>(gpr_malloc(sizeof(*op)));
|
226
|
+
made_transport_op* op = grpc_core::New<made_transport_op>();
|
259
227
|
GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op,
|
260
228
|
grpc_schedule_on_exec_ctx);
|
261
229
|
op->inner_on_complete = on_complete;
|
262
|
-
memset(&op->op, 0, sizeof(op->op));
|
263
230
|
op->op.on_consumed = &op->outer_on_complete;
|
264
231
|
return &op->op;
|
265
232
|
}
|
@@ -24,12 +24,13 @@
|
|
24
24
|
#include <stddef.h>
|
25
25
|
|
26
26
|
#include "src/core/lib/channel/context.h"
|
27
|
-
#include "src/core/lib/
|
27
|
+
#include "src/core/lib/gprpp/arena.h"
|
28
28
|
#include "src/core/lib/iomgr/call_combiner.h"
|
29
29
|
#include "src/core/lib/iomgr/endpoint.h"
|
30
30
|
#include "src/core/lib/iomgr/polling_entity.h"
|
31
31
|
#include "src/core/lib/iomgr/pollset.h"
|
32
32
|
#include "src/core/lib/iomgr/pollset_set.h"
|
33
|
+
#include "src/core/lib/slice/slice_internal.h"
|
33
34
|
#include "src/core/lib/transport/byte_stream.h"
|
34
35
|
#include "src/core/lib/transport/metadata_batch.h"
|
35
36
|
|
@@ -51,7 +52,7 @@ typedef struct grpc_stream grpc_stream;
|
|
51
52
|
extern grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount;
|
52
53
|
|
53
54
|
typedef struct grpc_stream_refcount {
|
54
|
-
|
55
|
+
grpc_core::RefCount refs;
|
55
56
|
grpc_closure destroy;
|
56
57
|
#ifndef NDEBUG
|
57
58
|
const char* object_type;
|
@@ -63,19 +64,51 @@ typedef struct grpc_stream_refcount {
|
|
63
64
|
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
64
65
|
grpc_iomgr_cb_func cb, void* cb_arg,
|
65
66
|
const char* object_type);
|
66
|
-
void grpc_stream_ref(grpc_stream_refcount* refcount, const char* reason);
|
67
|
-
void grpc_stream_unref(grpc_stream_refcount* refcount, const char* reason);
|
68
67
|
#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \
|
69
68
|
grpc_stream_ref_init(rc, ir, cb, cb_arg, objtype)
|
70
69
|
#else
|
71
70
|
void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs,
|
72
71
|
grpc_iomgr_cb_func cb, void* cb_arg);
|
73
|
-
void grpc_stream_ref(grpc_stream_refcount* refcount);
|
74
|
-
void grpc_stream_unref(grpc_stream_refcount* refcount);
|
75
72
|
#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \
|
76
73
|
grpc_stream_ref_init(rc, ir, cb, cb_arg)
|
77
74
|
#endif
|
78
75
|
|
76
|
+
#ifndef NDEBUG
|
77
|
+
inline void grpc_stream_ref(grpc_stream_refcount* refcount,
|
78
|
+
const char* reason) {
|
79
|
+
if (grpc_trace_stream_refcount.enabled()) {
|
80
|
+
gpr_log(GPR_DEBUG, "%s %p:%p REF %s", refcount->object_type, refcount,
|
81
|
+
refcount->destroy.cb_arg, reason);
|
82
|
+
}
|
83
|
+
refcount->refs.RefNonZero(DEBUG_LOCATION, reason);
|
84
|
+
}
|
85
|
+
#else
|
86
|
+
inline void grpc_stream_ref(grpc_stream_refcount* refcount) {
|
87
|
+
refcount->refs.RefNonZero();
|
88
|
+
}
|
89
|
+
#endif
|
90
|
+
|
91
|
+
void grpc_stream_destroy(grpc_stream_refcount* refcount);
|
92
|
+
|
93
|
+
#ifndef NDEBUG
|
94
|
+
inline void grpc_stream_unref(grpc_stream_refcount* refcount,
|
95
|
+
const char* reason) {
|
96
|
+
if (grpc_trace_stream_refcount.enabled()) {
|
97
|
+
gpr_log(GPR_DEBUG, "%s %p:%p UNREF %s", refcount->object_type, refcount,
|
98
|
+
refcount->destroy.cb_arg, reason);
|
99
|
+
}
|
100
|
+
if (GPR_UNLIKELY(refcount->refs.Unref(DEBUG_LOCATION, reason))) {
|
101
|
+
grpc_stream_destroy(refcount);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
#else
|
105
|
+
inline void grpc_stream_unref(grpc_stream_refcount* refcount) {
|
106
|
+
if (GPR_UNLIKELY(refcount->refs.Unref())) {
|
107
|
+
grpc_stream_destroy(refcount);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
#endif
|
111
|
+
|
79
112
|
/* Wrap a buffer that is owned by some stream object into a slice that shares
|
80
113
|
the same refcount */
|
81
114
|
grpc_slice grpc_slice_from_stream_owned_buffer(grpc_stream_refcount* refcount,
|
@@ -111,10 +144,11 @@ void grpc_transport_move_stats(grpc_transport_stream_stats* from,
|
|
111
144
|
// currently handling the batch). Once a filter or transport passes control
|
112
145
|
// of the batch to the next handler, it cannot depend on the contents of
|
113
146
|
// this struct anymore, because the next handler may reuse it.
|
114
|
-
|
115
|
-
void* extra_arg;
|
147
|
+
struct grpc_handler_private_op_data {
|
148
|
+
void* extra_arg = nullptr;
|
116
149
|
grpc_closure closure;
|
117
|
-
|
150
|
+
grpc_handler_private_op_data() { memset(&closure, 0, sizeof(closure)); }
|
151
|
+
};
|
118
152
|
|
119
153
|
typedef struct grpc_transport_stream_op_batch_payload
|
120
154
|
grpc_transport_stream_op_batch_payload;
|
@@ -272,40 +306,40 @@ struct grpc_transport_stream_op_batch_payload {
|
|
272
306
|
/** Transport op: a set of operations to perform on a transport as a whole */
|
273
307
|
typedef struct grpc_transport_op {
|
274
308
|
/** Called when processing of this op is done. */
|
275
|
-
grpc_closure* on_consumed;
|
309
|
+
grpc_closure* on_consumed = nullptr;
|
276
310
|
/** connectivity monitoring - set connectivity_state to NULL to unsubscribe */
|
277
|
-
grpc_closure* on_connectivity_state_change;
|
278
|
-
grpc_connectivity_state* connectivity_state;
|
311
|
+
grpc_closure* on_connectivity_state_change = nullptr;
|
312
|
+
grpc_connectivity_state* connectivity_state = nullptr;
|
279
313
|
/** should the transport be disconnected
|
280
314
|
* Error contract: the transport that gets this op must cause
|
281
315
|
* disconnect_with_error to be unref'ed after processing it */
|
282
|
-
grpc_error* disconnect_with_error;
|
316
|
+
grpc_error* disconnect_with_error = nullptr;
|
283
317
|
/** what should the goaway contain?
|
284
318
|
* Error contract: the transport that gets this op must cause
|
285
319
|
* goaway_error to be unref'ed after processing it */
|
286
|
-
grpc_error* goaway_error;
|
320
|
+
grpc_error* goaway_error = nullptr;
|
287
321
|
/** set the callback for accepting new streams;
|
288
322
|
this is a permanent callback, unlike the other one-shot closures.
|
289
323
|
If true, the callback is set to set_accept_stream_fn, with its
|
290
324
|
user_data argument set to set_accept_stream_user_data */
|
291
|
-
bool set_accept_stream;
|
325
|
+
bool set_accept_stream = false;
|
292
326
|
void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport,
|
293
|
-
const void* server_data);
|
294
|
-
void* set_accept_stream_user_data;
|
327
|
+
const void* server_data) = nullptr;
|
328
|
+
void* set_accept_stream_user_data = nullptr;
|
295
329
|
/** add this transport to a pollset */
|
296
|
-
grpc_pollset* bind_pollset;
|
330
|
+
grpc_pollset* bind_pollset = nullptr;
|
297
331
|
/** add this transport to a pollset_set */
|
298
|
-
grpc_pollset_set* bind_pollset_set;
|
332
|
+
grpc_pollset_set* bind_pollset_set = nullptr;
|
299
333
|
/** send a ping, if either on_initiate or on_ack is not NULL */
|
300
334
|
struct {
|
301
335
|
/** Ping may be delayed by the transport, on_initiate callback will be
|
302
336
|
called when the ping is actually being sent. */
|
303
|
-
grpc_closure* on_initiate;
|
337
|
+
grpc_closure* on_initiate = nullptr;
|
304
338
|
/** Called when the ping ack is received */
|
305
|
-
grpc_closure* on_ack;
|
339
|
+
grpc_closure* on_ack = nullptr;
|
306
340
|
} send_ping;
|
307
341
|
// If true, will reset the channel's connection backoff.
|
308
|
-
bool reset_connect_backoff;
|
342
|
+
bool reset_connect_backoff = false;
|
309
343
|
|
310
344
|
/***************************************************************************
|
311
345
|
* remaining fields are initialized and used at the discretion of the
|
@@ -330,7 +364,8 @@ size_t grpc_transport_stream_size(grpc_transport* transport);
|
|
330
364
|
supplied from the accept_stream callback function */
|
331
365
|
int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream,
|
332
366
|
grpc_stream_refcount* refcount,
|
333
|
-
const void* server_data,
|
367
|
+
const void* server_data,
|
368
|
+
grpc_core::Arena* arena);
|
334
369
|
|
335
370
|
void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream,
|
336
371
|
grpc_polling_entity* pollent);
|
@@ -351,7 +386,7 @@ void grpc_transport_destroy_stream(grpc_transport* transport,
|
|
351
386
|
|
352
387
|
void grpc_transport_stream_op_batch_finish_with_failure(
|
353
388
|
grpc_transport_stream_op_batch* op, grpc_error* error,
|
354
|
-
|
389
|
+
grpc_core::CallCombiner* call_combiner);
|
355
390
|
|
356
391
|
char* grpc_transport_stream_op_batch_string(grpc_transport_stream_op_batch* op);
|
357
392
|
char* grpc_transport_op_string(grpc_transport_op* op);
|
@@ -34,7 +34,7 @@ typedef struct grpc_transport_vtable {
|
|
34
34
|
/* implementation of grpc_transport_init_stream */
|
35
35
|
int (*init_stream)(grpc_transport* self, grpc_stream* stream,
|
36
36
|
grpc_stream_refcount* refcount, const void* server_data,
|
37
|
-
|
37
|
+
grpc_core::Arena* arena);
|
38
38
|
|
39
39
|
/* implementation of grpc_transport_set_pollset */
|
40
40
|
void (*set_pollset)(grpc_transport* self, grpc_stream* stream,
|
@@ -363,7 +363,7 @@ static tsi_result handshaker_client_next(alts_handshaker_client* c,
|
|
363
363
|
alts_grpc_handshaker_client* client =
|
364
364
|
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
365
365
|
grpc_slice_unref_internal(client->recv_bytes);
|
366
|
-
client->recv_bytes =
|
366
|
+
client->recv_bytes = grpc_slice_ref_internal(*bytes_received);
|
367
367
|
grpc_byte_buffer* buffer = get_serialized_next(bytes_received);
|
368
368
|
if (buffer == nullptr) {
|
369
369
|
gpr_log(GPR_ERROR, "get_serialized_next() failed");
|
@@ -406,7 +406,7 @@ static const alts_handshaker_client_vtable vtable = {
|
|
406
406
|
alts_handshaker_client* alts_grpc_handshaker_client_create(
|
407
407
|
alts_tsi_handshaker* handshaker, grpc_channel* channel,
|
408
408
|
const char* handshaker_service_url, grpc_pollset_set* interested_parties,
|
409
|
-
grpc_alts_credentials_options* options, grpc_slice target_name,
|
409
|
+
grpc_alts_credentials_options* options, const grpc_slice& target_name,
|
410
410
|
grpc_iomgr_cb_func grpc_cb, tsi_handshaker_on_next_done_cb cb,
|
411
411
|
void* user_data, alts_handshaker_client_vtable* vtable_for_testing,
|
412
412
|
bool is_client) {
|
@@ -487,7 +487,7 @@ void alts_handshaker_client_set_recv_bytes_for_testing(
|
|
487
487
|
GPR_ASSERT(c != nullptr);
|
488
488
|
alts_grpc_handshaker_client* client =
|
489
489
|
reinterpret_cast<alts_grpc_handshaker_client*>(c);
|
490
|
-
client->recv_bytes =
|
490
|
+
client->recv_bytes = grpc_slice_ref_internal(*recv_bytes);
|
491
491
|
}
|
492
492
|
|
493
493
|
void alts_handshaker_client_set_fields_for_testing(
|
@@ -138,7 +138,7 @@ void alts_handshaker_client_destroy(alts_handshaker_client* client);
|
|
138
138
|
alts_handshaker_client* alts_grpc_handshaker_client_create(
|
139
139
|
alts_tsi_handshaker* handshaker, grpc_channel* channel,
|
140
140
|
const char* handshaker_service_url, grpc_pollset_set* interested_parties,
|
141
|
-
grpc_alts_credentials_options* options, grpc_slice target_name,
|
141
|
+
grpc_alts_credentials_options* options, const grpc_slice& target_name,
|
142
142
|
grpc_iomgr_cb_func grpc_cb, tsi_handshaker_on_next_done_cb cb,
|
143
143
|
void* user_data, alts_handshaker_client_vtable* vtable_for_testing,
|
144
144
|
bool is_client);
|
@@ -48,7 +48,7 @@ alts_shared_resource_dedicated* grpc_alts_get_shared_resource_dedicated(void);
|
|
48
48
|
|
49
49
|
/**
|
50
50
|
* This method destroys the alts_shared_resource_dedicated object
|
51
|
-
* shared by all TSI handshakes. The
|
51
|
+
* shared by all TSI handshakes. The application is responsible for
|
52
52
|
* invoking the API before calling grpc_shutdown().
|
53
53
|
*/
|
54
54
|
void grpc_alts_shared_resource_dedicated_shutdown();
|
@@ -106,15 +106,16 @@ bool grpc_gcp_rpc_protocol_versions_encode(
|
|
106
106
|
}
|
107
107
|
|
108
108
|
bool grpc_gcp_rpc_protocol_versions_decode(
|
109
|
-
grpc_slice slice, grpc_gcp_rpc_protocol_versions* versions) {
|
109
|
+
const grpc_slice& slice, grpc_gcp_rpc_protocol_versions* versions) {
|
110
110
|
if (versions == nullptr) {
|
111
111
|
gpr_log(GPR_ERROR,
|
112
112
|
"version is nullptr in "
|
113
113
|
"grpc_gcp_rpc_protocol_versions_decode().");
|
114
114
|
return false;
|
115
115
|
}
|
116
|
-
pb_istream_t stream =
|
117
|
-
|
116
|
+
pb_istream_t stream =
|
117
|
+
pb_istream_from_buffer(const_cast<uint8_t*>(GRPC_SLICE_START_PTR(slice)),
|
118
|
+
GRPC_SLICE_LENGTH(slice));
|
118
119
|
if (!pb_decode(&stream, grpc_gcp_RpcProtocolVersions_fields, versions)) {
|
119
120
|
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream));
|
120
121
|
return false;
|
@@ -112,7 +112,7 @@ bool grpc_gcp_rpc_protocol_versions_encode(
|
|
112
112
|
* The method returns true on success and false otherwise.
|
113
113
|
*/
|
114
114
|
bool grpc_gcp_rpc_protocol_versions_decode(
|
115
|
-
grpc_slice slice, grpc_gcp_rpc_protocol_versions* versions);
|
115
|
+
const grpc_slice& slice, grpc_gcp_rpc_protocol_versions* versions);
|
116
116
|
|
117
117
|
/**
|
118
118
|
* This method performs a deep copy operation on rpc protocol versions
|
@@ -105,7 +105,7 @@ static bool read_frame_size(const grpc_slice_buffer* sb,
|
|
105
105
|
* Creates an alts_grpc_record_protocol object, given key, key size, and flags
|
106
106
|
* to indicate whether the record_protocol object uses the rekeying AEAD,
|
107
107
|
* whether the object is for client or server, whether the object is for
|
108
|
-
* integrity-only or privacy-integrity mode, and whether the object is
|
108
|
+
* integrity-only or privacy-integrity mode, and whether the object is used
|
109
109
|
* for protect or unprotect.
|
110
110
|
*/
|
111
111
|
static tsi_result create_alts_grpc_record_protocol(
|
@@ -585,7 +585,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
|
|
585
585
|
if (next_message_to_send > TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
|
586
586
|
next_message_to_send = TSI_FAKE_HANDSHAKE_MESSAGE_MAX;
|
587
587
|
}
|
588
|
-
if (tsi_tracing_enabled
|
588
|
+
if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
589
589
|
gpr_log(GPR_INFO, "%s prepared %s.",
|
590
590
|
impl->is_client ? "Client" : "Server",
|
591
591
|
tsi_fake_handshake_message_to_string(impl->next_message_to_send));
|
@@ -597,7 +597,7 @@ static tsi_result fake_handshaker_get_bytes_to_send_to_peer(
|
|
597
597
|
if (!impl->is_client &&
|
598
598
|
impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
|
599
599
|
/* We're done. */
|
600
|
-
if (tsi_tracing_enabled
|
600
|
+
if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
601
601
|
gpr_log(GPR_INFO, "Server is done.");
|
602
602
|
}
|
603
603
|
impl->result = TSI_OK;
|
@@ -636,7 +636,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
|
|
636
636
|
tsi_fake_handshake_message_to_string(received_msg),
|
637
637
|
tsi_fake_handshake_message_to_string(expected_msg));
|
638
638
|
}
|
639
|
-
if (tsi_tracing_enabled
|
639
|
+
if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
640
640
|
gpr_log(GPR_INFO, "%s received %s.", impl->is_client ? "Client" : "Server",
|
641
641
|
tsi_fake_handshake_message_to_string(received_msg));
|
642
642
|
}
|
@@ -644,7 +644,7 @@ static tsi_result fake_handshaker_process_bytes_from_peer(
|
|
644
644
|
impl->needs_incoming_message = 0;
|
645
645
|
if (impl->next_message_to_send == TSI_FAKE_HANDSHAKE_MESSAGE_MAX) {
|
646
646
|
/* We're done. */
|
647
|
-
if (tsi_tracing_enabled
|
647
|
+
if (GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
648
648
|
gpr_log(GPR_INFO, "%s is done.", impl->is_client ? "Client" : "Server");
|
649
649
|
}
|
650
650
|
impl->result = TSI_OK;
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
#include <grpc/support/port_platform.h>
|
20
20
|
|
21
|
-
#include "src/core/lib/gprpp/
|
21
|
+
#include "src/core/lib/gprpp/sync.h"
|
22
22
|
#include "src/core/lib/slice/slice_internal.h"
|
23
23
|
#include "src/core/tsi/ssl/session_cache/ssl_session.h"
|
24
24
|
#include "src/core/tsi/ssl/session_cache/ssl_session_cache.h"
|
@@ -213,7 +213,7 @@ static const char* ssl_error_string(int error) {
|
|
213
213
|
/* TODO(jboeuf): Remove when we are past the debugging phase with this code. */
|
214
214
|
static void ssl_log_where_info(const SSL* ssl, int where, int flag,
|
215
215
|
const char* msg) {
|
216
|
-
if ((where & flag) && tsi_tracing_enabled
|
216
|
+
if ((where & flag) && GRPC_TRACE_FLAG_ENABLED(tsi_tracing_enabled)) {
|
217
217
|
gpr_log(GPR_INFO, "%20.20s - %30.30s - %5.10s", msg,
|
218
218
|
SSL_state_string_long(ssl), SSL_state_string(ssl));
|
219
219
|
}
|
@@ -619,15 +619,19 @@ static tsi_result x509_store_load_certs(X509_STORE* cert_store,
|
|
619
619
|
sk_X509_NAME_push(*root_names, root_name);
|
620
620
|
root_name = nullptr;
|
621
621
|
}
|
622
|
+
ERR_clear_error();
|
622
623
|
if (!X509_STORE_add_cert(cert_store, root)) {
|
623
|
-
|
624
|
-
|
625
|
-
|
624
|
+
unsigned long error = ERR_get_error();
|
625
|
+
if (ERR_GET_LIB(error) != ERR_LIB_X509 ||
|
626
|
+
ERR_GET_REASON(error) != X509_R_CERT_ALREADY_IN_HASH_TABLE) {
|
627
|
+
gpr_log(GPR_ERROR, "Could not add root certificate to ssl context.");
|
628
|
+
result = TSI_INTERNAL_ERROR;
|
629
|
+
break;
|
630
|
+
}
|
626
631
|
}
|
627
632
|
X509_free(root);
|
628
633
|
num_roots++;
|
629
634
|
}
|
630
|
-
|
631
635
|
if (num_roots == 0) {
|
632
636
|
gpr_log(GPR_ERROR, "Could not load any root certificate.");
|
633
637
|
result = TSI_INVALID_ARGUMENT;
|
@@ -651,6 +655,8 @@ static tsi_result ssl_ctx_load_verification_certs(SSL_CTX* context,
|
|
651
655
|
STACK_OF(X509_NAME) *
|
652
656
|
*root_name) {
|
653
657
|
X509_STORE* cert_store = SSL_CTX_get_cert_store(context);
|
658
|
+
X509_STORE_set_flags(cert_store,
|
659
|
+
X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_TRUSTED_FIRST);
|
654
660
|
return x509_store_load_certs(cert_store, pem_roots, pem_roots_size,
|
655
661
|
root_name);
|
656
662
|
}
|
@@ -1011,7 +1017,6 @@ static void tsi_ssl_handshaker_factory_init(
|
|
1011
1017
|
}
|
1012
1018
|
|
1013
1019
|
/* --- tsi_handshaker_result methods implementation. ---*/
|
1014
|
-
|
1015
1020
|
static tsi_result ssl_handshaker_result_extract_peer(
|
1016
1021
|
const tsi_handshaker_result* self, tsi_peer* peer) {
|
1017
1022
|
tsi_result result = TSI_OK;
|
@@ -1019,6 +1024,7 @@ static tsi_result ssl_handshaker_result_extract_peer(
|
|
1019
1024
|
unsigned int alpn_selected_len;
|
1020
1025
|
const tsi_ssl_handshaker_result* impl =
|
1021
1026
|
reinterpret_cast<const tsi_ssl_handshaker_result*>(self);
|
1027
|
+
// TODO(yihuazhang): Return a full certificate chain as a peer property.
|
1022
1028
|
X509* peer_cert = SSL_get_peer_certificate(impl->ssl);
|
1023
1029
|
if (peer_cert != nullptr) {
|
1024
1030
|
result = peer_from_x509(peer_cert, 1, peer);
|
@@ -1060,7 +1066,6 @@ static tsi_result ssl_handshaker_result_extract_peer(
|
|
1060
1066
|
&peer->properties[peer->property_count]);
|
1061
1067
|
if (result != TSI_OK) return result;
|
1062
1068
|
peer->property_count++;
|
1063
|
-
|
1064
1069
|
return result;
|
1065
1070
|
}
|
1066
1071
|
|
@@ -1394,7 +1399,6 @@ static tsi_result create_tsi_ssl_handshaker(SSL_CTX* ctx, int is_client,
|
|
1394
1399
|
static_cast<unsigned char*>(gpr_zalloc(impl->outgoing_bytes_buffer_size));
|
1395
1400
|
impl->base.vtable = &handshaker_vtable;
|
1396
1401
|
impl->factory_ref = tsi_ssl_handshaker_factory_ref(factory);
|
1397
|
-
|
1398
1402
|
*handshaker = &impl->base;
|
1399
1403
|
return TSI_OK;
|
1400
1404
|
}
|
@@ -1628,7 +1632,6 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
|
|
1628
1632
|
const char** alpn_protocols, uint16_t num_alpn_protocols,
|
1629
1633
|
tsi_ssl_client_handshaker_factory** factory) {
|
1630
1634
|
tsi_ssl_client_handshaker_options options;
|
1631
|
-
memset(&options, 0, sizeof(options));
|
1632
1635
|
options.pem_key_cert_pair = pem_key_cert_pair;
|
1633
1636
|
options.pem_root_certs = pem_root_certs;
|
1634
1637
|
options.cipher_suites = cipher_suites;
|
@@ -1758,7 +1761,6 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
|
|
1758
1761
|
const char* cipher_suites, const char** alpn_protocols,
|
1759
1762
|
uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory** factory) {
|
1760
1763
|
tsi_ssl_server_handshaker_options options;
|
1761
|
-
memset(&options, 0, sizeof(options));
|
1762
1764
|
options.pem_key_cert_pairs = pem_key_cert_pairs;
|
1763
1765
|
options.num_key_cert_pairs = num_key_cert_pairs;
|
1764
1766
|
options.pem_client_root_certs = pem_client_root_certs;
|
@@ -111,7 +111,7 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
|
|
111
111
|
const char** alpn_protocols, uint16_t num_alpn_protocols,
|
112
112
|
tsi_ssl_client_handshaker_factory** factory);
|
113
113
|
|
114
|
-
|
114
|
+
struct tsi_ssl_client_handshaker_options {
|
115
115
|
/* pem_key_cert_pair is a pointer to the object containing client's private
|
116
116
|
key and certificate chain. This parameter can be NULL if the client does
|
117
117
|
not have such a key/cert pair. */
|
@@ -140,7 +140,16 @@ typedef struct {
|
|
140
140
|
size_t num_alpn_protocols;
|
141
141
|
/* ssl_session_cache is a cache for reusable client-side sessions. */
|
142
142
|
tsi_ssl_session_cache* session_cache;
|
143
|
-
|
143
|
+
|
144
|
+
tsi_ssl_client_handshaker_options()
|
145
|
+
: pem_key_cert_pair(nullptr),
|
146
|
+
pem_root_certs(nullptr),
|
147
|
+
root_store(nullptr),
|
148
|
+
cipher_suites(nullptr),
|
149
|
+
alpn_protocols(nullptr),
|
150
|
+
num_alpn_protocols(0),
|
151
|
+
session_cache(nullptr) {}
|
152
|
+
};
|
144
153
|
|
145
154
|
/* Creates a client handshaker factory.
|
146
155
|
- options is the options used to create a factory.
|
@@ -221,7 +230,7 @@ tsi_result tsi_create_ssl_server_handshaker_factory_ex(
|
|
221
230
|
const char* cipher_suites, const char** alpn_protocols,
|
222
231
|
uint16_t num_alpn_protocols, tsi_ssl_server_handshaker_factory** factory);
|
223
232
|
|
224
|
-
|
233
|
+
struct tsi_ssl_server_handshaker_options {
|
225
234
|
/* pem_key_cert_pairs is an array private key / certificate chains of the
|
226
235
|
server. */
|
227
236
|
const tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs;
|
@@ -255,7 +264,18 @@ typedef struct {
|
|
255
264
|
const char* session_ticket_key;
|
256
265
|
/* session_ticket_key_size is a size of session ticket encryption key. */
|
257
266
|
size_t session_ticket_key_size;
|
258
|
-
|
267
|
+
|
268
|
+
tsi_ssl_server_handshaker_options()
|
269
|
+
: pem_key_cert_pairs(nullptr),
|
270
|
+
num_key_cert_pairs(0),
|
271
|
+
pem_client_root_certs(nullptr),
|
272
|
+
client_certificate_request(TSI_DONT_REQUEST_CLIENT_CERTIFICATE),
|
273
|
+
cipher_suites(nullptr),
|
274
|
+
alpn_protocols(nullptr),
|
275
|
+
num_alpn_protocols(0),
|
276
|
+
session_ticket_key(nullptr),
|
277
|
+
session_ticket_key_size(0) {}
|
278
|
+
};
|
259
279
|
|
260
280
|
/* Creates a server handshaker factory.
|
261
281
|
- options is the options used to create a factory.
|