grpc 1.56.2 → 1.57.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +29 -22
- data/include/grpc/event_engine/event_engine.h +22 -32
- data/include/grpc/impl/grpc_types.h +3 -0
- data/include/grpc/support/port_platform.h +29 -23
- data/src/core/ext/filters/client_channel/client_channel.cc +44 -8
- data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +5 -0
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +21 -52
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +19 -7
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +25 -35
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +78 -132
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +2 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +38 -15
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client.h +3 -5
- data/src/core/ext/filters/client_channel/lb_policy/health_check_client_internal.h +22 -6
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric_internal.h +2 -0
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +97 -71
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +2 -16
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +56 -11
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.h +25 -0
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -32
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +4 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +20 -79
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +31 -19
- data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +7 -41
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +3 -67
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +8 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +31 -74
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +7 -51
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +16 -87
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +16 -50
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +12 -74
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -4
- data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +69 -59
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +7 -2
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +1 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +25 -13
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +366 -311
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +17 -1
- data/src/core/ext/filters/client_channel/retry_filter.cc +39 -2498
- data/src/core/ext/filters/client_channel/retry_filter.h +91 -1
- data/src/core/ext/filters/client_channel/retry_filter_legacy_call_data.cc +2052 -0
- data/src/core/ext/filters/client_channel/retry_filter_legacy_call_data.h +442 -0
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +38 -58
- data/src/core/ext/filters/client_channel/subchannel.h +3 -3
- data/src/core/ext/filters/client_channel/subchannel_interface_internal.h +3 -0
- data/src/core/ext/filters/rbac/rbac_filter.cc +40 -111
- data/src/core/ext/filters/rbac/rbac_filter.h +12 -30
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +162 -86
- data/src/core/ext/filters/stateful_session/stateful_session_filter.h +0 -6
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +7 -4
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +131 -186
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +6569 -174
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +2278 -441
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +9 -8
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +3 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +8 -4
- data/src/core/ext/transport/chttp2/transport/parsing.cc +15 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +2 -3
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +27 -6
- data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +143 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +2 -9
- data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +0 -39
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +13 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +35 -6
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +17 -13
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +85 -20
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +26 -7
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +45 -3
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.c +4 -3
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/metrics_service.upb.h +21 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +30 -6
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +180 -0
- data/src/core/ext/upb-generated/envoy/data/accesslog/v3/accesslog.upb.c +558 -0
- data/src/core/ext/upb-generated/envoy/data/accesslog/v3/accesslog.upb.h +2710 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +30 -11
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +53 -24
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +30 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +110 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +41 -15
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +150 -27
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.c +1 -0
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/pick_first/v3/pick_first.upb.c +47 -0
- data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/pick_first/v3/pick_first.upb.h +93 -0
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +88 -76
- data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +11 -12
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +0 -5
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +162 -160
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +129 -118
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +141 -135
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/metrics_service.upbdefs.c +19 -12
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +38 -30
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/data/accesslog/v3/accesslog.upbdefs.c +402 -0
- data/src/core/ext/upbdefs-generated/envoy/data/accesslog/v3/accesslog.upbdefs.h +111 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +80 -74
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +63 -47
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +315 -293
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +29 -29
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +33 -30
- data/src/core/ext/xds/xds_bootstrap_grpc.h +5 -13
- data/src/core/ext/xds/xds_client_grpc.cc +11 -6
- data/src/core/ext/xds/xds_client_grpc.h +16 -2
- data/src/core/ext/xds/xds_client_stats.h +10 -0
- data/src/core/ext/xds/xds_cluster.cc +26 -16
- data/src/core/ext/xds/xds_endpoint.cc +4 -7
- data/src/core/ext/xds/xds_health_status.cc +0 -17
- data/src/core/ext/xds/xds_health_status.h +5 -25
- data/src/core/ext/xds/xds_lb_policy_registry.cc +39 -0
- data/src/core/ext/xds/xds_route_config.cc +4 -0
- data/src/core/ext/xds/xds_transport_grpc.cc +1 -3
- data/src/core/lib/address_utils/parse_address.cc +63 -1
- data/src/core/lib/address_utils/parse_address.h +8 -0
- data/src/core/lib/address_utils/sockaddr_utils.cc +46 -1
- data/src/core/lib/address_utils/sockaddr_utils.h +2 -2
- data/src/core/lib/channel/channel_args.cc +21 -10
- data/src/core/lib/channel/channel_args.h +3 -0
- data/src/core/lib/channel/connected_channel.cc +4 -1
- data/src/core/lib/channel/promise_based_filter.h +1 -0
- data/src/core/lib/debug/trace.cc +1 -4
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +2 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +1 -1
- data/src/core/lib/event_engine/event_engine.cc +0 -12
- data/src/core/lib/event_engine/forkable.cc +47 -42
- data/src/core/lib/event_engine/handle_containers.h +0 -4
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +4 -6
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -6
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +25 -11
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +3 -1
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +2 -1
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +8 -12
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +37 -27
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +2 -0
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +4 -2
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +42 -2
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +6 -0
- data/src/core/lib/event_engine/posix_engine/timer.h +10 -37
- data/src/core/lib/event_engine/tcp_socket_utils.cc +67 -7
- data/src/core/lib/event_engine/tcp_socket_utils.h +3 -0
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +90 -37
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +32 -12
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.cc +12 -21
- data/src/core/lib/event_engine/thready_event_engine/thready_event_engine.h +8 -12
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +55 -54
- data/src/core/lib/event_engine/windows/windows_endpoint.h +15 -12
- data/src/core/lib/event_engine/windows/windows_engine.cc +2 -1
- data/src/core/lib/event_engine/windows/windows_engine.h +8 -12
- data/src/core/lib/experiments/config.cc +60 -22
- data/src/core/lib/experiments/config.h +20 -8
- data/src/core/lib/experiments/experiments.cc +278 -0
- data/src/core/lib/experiments/experiments.h +59 -1
- data/src/core/lib/gprpp/dual_ref_counted.h +9 -9
- data/src/core/lib/gprpp/fork.cc +8 -9
- data/src/core/lib/gprpp/fork.h +6 -5
- data/src/core/lib/gprpp/if_list.h +4530 -0
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/ref_counted.h +6 -6
- data/src/core/lib/gprpp/sorted_pack.h +3 -12
- data/src/core/lib/gprpp/status_helper.h +16 -15
- data/src/core/lib/gprpp/time.h +12 -0
- data/src/core/lib/gprpp/type_list.h +32 -0
- data/src/core/lib/http/httpcli.h +6 -9
- data/src/core/lib/iomgr/error.cc +32 -2
- data/src/core/lib/iomgr/error.h +9 -10
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +5 -7
- data/src/core/lib/iomgr/ev_poll_posix.cc +6 -5
- data/src/core/lib/iomgr/exec_ctx.h +11 -0
- data/src/core/lib/iomgr/pollset.h +4 -5
- data/src/core/lib/iomgr/port.h +10 -0
- data/src/core/lib/iomgr/resolve_address.cc +13 -1
- data/src/core/lib/iomgr/resolve_address.h +17 -3
- data/src/core/lib/iomgr/sockaddr_posix.h +7 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +29 -0
- data/src/core/lib/iomgr/socket_utils_posix.cc +2 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +6 -0
- data/src/core/lib/iomgr/tcp_client_posix.cc +4 -1
- data/src/core/lib/iomgr/tcp_posix.cc +21 -4
- data/src/core/lib/iomgr/tcp_server_posix.cc +3 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +5 -2
- data/src/core/lib/iomgr/tcp_windows.cc +1 -3
- data/src/core/lib/iomgr/vsock.cc +59 -0
- data/src/core/lib/iomgr/vsock.h +38 -0
- data/src/core/lib/iomgr/wakeup_fd_posix.h +3 -6
- data/src/core/lib/load_balancing/delegating_helper.h +115 -0
- data/src/core/lib/load_balancing/lb_policy.h +20 -0
- data/src/core/lib/load_balancing/subchannel_interface.h +6 -0
- data/src/core/lib/promise/party.h +1 -1
- data/src/core/lib/resolver/resolver_factory.h +3 -2
- data/src/core/lib/resolver/server_address.cc +9 -94
- data/src/core/lib/resolver/server_address.h +10 -64
- data/src/core/lib/resource_quota/memory_quota.h +1 -1
- data/src/core/lib/security/credentials/channel_creds_registry.h +51 -27
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +169 -9
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +1 -1
- data/src/core/lib/security/credentials/composite/composite_credentials.h +3 -1
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +40 -1
- data/src/core/lib/security/credentials/external/external_account_credentials.h +6 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +30 -38
- data/src/core/lib/security/credentials/fake/fake_credentials.h +28 -0
- data/src/core/lib/security/credentials/tls/tls_credentials.cc +1 -1
- data/src/core/lib/security/credentials/tls/tls_credentials.h +3 -1
- data/src/core/lib/service_config/service_config_call_data.h +5 -0
- data/src/core/lib/slice/slice.h +16 -0
- data/src/core/lib/surface/call.cc +31 -29
- data/src/core/lib/surface/server.h +2 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/metadata_batch.cc +7 -7
- data/src/core/lib/transport/metadata_batch.h +86 -48
- data/src/core/lib/transport/parsed_metadata.h +34 -20
- data/src/core/lib/transport/simple_slice_based_metadata.h +9 -2
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +4 -6
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -2
- data/src/core/tsi/ssl_transport_security.cc +28 -7
- data/src/ruby/bin/math_pb.rb +24 -18
- data/src/ruby/ext/grpc/extconf.rb +19 -18
- data/src/ruby/ext/grpc/rb_call.c +62 -39
- data/src/ruby/ext/grpc/rb_call_credentials.c +0 -1
- data/src/ruby/ext/grpc/rb_channel.c +126 -49
- data/src/ruby/ext/grpc/rb_channel.h +1 -0
- data/src/ruby/ext/grpc/rb_channel_args.c +16 -2
- data/src/ruby/ext/grpc/rb_channel_args.h +4 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +0 -1
- data/src/ruby/ext/grpc/rb_compression_options.c +0 -1
- data/src/ruby/ext/grpc/rb_event_thread.c +22 -6
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -0
- data/src/ruby/ext/grpc/rb_grpc.c +192 -30
- data/src/ruby/ext/grpc/rb_grpc.h +8 -2
- data/src/ruby/ext/grpc/rb_server.c +62 -45
- data/src/ruby/ext/grpc/rb_server_credentials.c +0 -1
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +0 -1
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +0 -1
- data/src/ruby/lib/grpc/generic/bidi_call.rb +2 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +24 -13
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +24 -3
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +25 -111
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +25 -2
- data/third_party/boringssl-with-bazel/err_data.c +552 -552
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +34 -1
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +4 -1
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +7 -8
- data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +8 -8
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +19 -1
- data/third_party/boringssl-with-bazel/src/crypto/chacha/internal.h +8 -1
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +28 -185
- data/third_party/boringssl-with-bazel/src/crypto/conf/conf_def.h +3 -7
- data/third_party/boringssl-with-bazel/src/crypto/conf/internal.h +8 -0
- data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +49 -46
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_64_adx.c +18 -0
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519_tables.h +2809 -7417
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +27 -5
- data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +20 -0
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +110 -72
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_derive.c +4 -3
- data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +15 -14
- data/third_party/boringssl-with-bazel/src/crypto/err/err.c +13 -10
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +35 -12
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/evp/p_ec_asn1.c +3 -7
- data/third_party/boringssl-with-bazel/src/crypto/evp/pbkdf.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/evp/print.c +7 -6
- data/third_party/boringssl-with-bazel/src/crypto/ex_data.c +34 -72
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +12 -5
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd.c +5 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +12 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +17 -18
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery_inv.c +51 -15
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/rsaz_exp.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/delocate.h +5 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/builtin_curves.h +277 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +180 -404
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +24 -57
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +17 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +33 -71
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +18 -17
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +5 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.c +15 -18
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +9 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +24 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +11 -27
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +8 -8
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +4 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +9 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hkdf/hkdf.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +40 -26
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +21 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +38 -19
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +2 -29
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +55 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +33 -52
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +3 -8
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +198 -79
- data/third_party/boringssl-with-bazel/src/crypto/kyber/kyber.c +5 -4
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +7 -8
- data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +19 -23
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/p5_pbev2.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +8 -5
- data/third_party/boringssl-with-bazel/src/crypto/pool/internal.h +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +7 -6
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/forkunsafe.c +6 -12
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/getentropy.c +48 -0
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/{fuchsia.c → ios.c} +8 -8
- data/third_party/boringssl-with-bazel/src/crypto/{refcount_no_threads.c → rand_extra/trusty.c} +15 -19
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +41 -19
- data/third_party/boringssl-with-bazel/src/crypto/{refcount_c11.c → refcount.c} +11 -17
- data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +147 -72
- data/third_party/boringssl-with-bazel/src/crypto/thread_none.c +0 -8
- data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +6 -35
- data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +5 -26
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +14 -18
- data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +54 -143
- data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +7 -13
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +2 -4
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +8 -12
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +19 -20
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +11 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +5 -5
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +7 -7
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +2 -3
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +4 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +4 -119
- data/third_party/boringssl-with-bazel/src/include/openssl/asm_base.h +207 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +5 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +2 -116
- data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +0 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +6 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +5 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +0 -21
- data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +21 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ec_key.h +19 -6
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +11 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +13 -14
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +0 -61
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +127 -81
- data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +224 -209
- data/third_party/boringssl-with-bazel/src/include/openssl/target.h +154 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/thread.h +1 -29
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +4 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +3 -2
- data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +9 -65
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +20 -20
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +4 -11
- data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +24 -18
- data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +37 -30
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +125 -26
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +2 -3
- data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64_adx.h +691 -0
- data/third_party/upb/upb/collections/map.c +3 -3
- metadata +27 -12
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.cc +0 -42
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.h +0 -64
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +0 -177
- data/src/core/ext/transport/chttp2/transport/stream_map.h +0 -68
- data/third_party/boringssl-with-bazel/src/crypto/refcount_win.c +0 -89
data/src/ruby/ext/grpc/rb_call.c
CHANGED
@@ -801,6 +801,56 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) {
|
|
801
801
|
return result;
|
802
802
|
}
|
803
803
|
|
804
|
+
struct call_run_batch_args {
|
805
|
+
grpc_rb_call* call;
|
806
|
+
unsigned write_flag;
|
807
|
+
VALUE ops_hash;
|
808
|
+
run_batch_stack* st;
|
809
|
+
};
|
810
|
+
|
811
|
+
static VALUE grpc_rb_call_run_batch_try(VALUE value_args) {
|
812
|
+
grpc_rb_fork_unsafe_begin();
|
813
|
+
struct call_run_batch_args* args = (struct call_run_batch_args*)value_args;
|
814
|
+
void* tag = (void*)&args->st;
|
815
|
+
|
816
|
+
grpc_event ev;
|
817
|
+
grpc_call_error err;
|
818
|
+
|
819
|
+
args->st = gpr_malloc(sizeof(run_batch_stack));
|
820
|
+
grpc_run_batch_stack_init(args->st, args->write_flag);
|
821
|
+
grpc_run_batch_stack_fill_ops(args->st, args->ops_hash);
|
822
|
+
|
823
|
+
/* call grpc_call_start_batch, then wait for it to complete using
|
824
|
+
* pluck_event */
|
825
|
+
err = grpc_call_start_batch(args->call->wrapped, args->st->ops,
|
826
|
+
args->st->op_num, tag, NULL);
|
827
|
+
if (err != GRPC_CALL_OK) {
|
828
|
+
rb_raise(grpc_rb_eCallError,
|
829
|
+
"grpc_call_start_batch failed with %s (code=%d)",
|
830
|
+
grpc_call_error_detail_of(err), err);
|
831
|
+
}
|
832
|
+
ev = rb_completion_queue_pluck(args->call->queue, tag,
|
833
|
+
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
|
834
|
+
if (!ev.success) {
|
835
|
+
rb_raise(grpc_rb_eCallError, "call#run_batch failed somehow");
|
836
|
+
}
|
837
|
+
/* Build and return the BatchResult struct result,
|
838
|
+
if there is an error, it's reflected in the status */
|
839
|
+
return grpc_run_batch_stack_build_result(args->st);
|
840
|
+
}
|
841
|
+
|
842
|
+
static VALUE grpc_rb_call_run_batch_ensure(VALUE value_args) {
|
843
|
+
grpc_rb_fork_unsafe_end();
|
844
|
+
struct call_run_batch_args* args = (struct call_run_batch_args*)value_args;
|
845
|
+
|
846
|
+
if (args->st) {
|
847
|
+
grpc_run_batch_stack_cleanup(args->st);
|
848
|
+
gpr_free(args->st);
|
849
|
+
}
|
850
|
+
|
851
|
+
return Qnil;
|
852
|
+
}
|
853
|
+
|
804
854
|
/* call-seq:
|
805
855
|
ops = {
|
806
856
|
GRPC::Core::CallOps::SEND_INITIAL_METADATA => <op_value>,
|
@@ -819,56 +869,29 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) {
|
|
819
869
|
Only one operation of each type can be active at once in any given
|
820
870
|
batch */
|
821
871
|
static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
|
822
|
-
run_batch_stack* st = NULL;
|
823
|
-
grpc_rb_call* call = NULL;
|
824
|
-
grpc_event ev;
|
825
|
-
grpc_call_error err;
|
826
|
-
VALUE result = Qnil;
|
827
|
-
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
|
828
|
-
unsigned write_flag = 0;
|
829
|
-
void* tag = (void*)&st;
|
830
|
-
|
831
872
|
grpc_ruby_fork_guard();
|
832
873
|
if (RTYPEDDATA_DATA(self) == NULL) {
|
833
874
|
rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
|
834
|
-
return Qnil;
|
835
875
|
}
|
876
|
+
|
877
|
+
grpc_rb_call* call = NULL;
|
836
878
|
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
|
837
879
|
|
838
880
|
/* Validate the ops args, adding them to a ruby array */
|
839
881
|
if (TYPE(ops_hash) != T_HASH) {
|
840
882
|
rb_raise(rb_eTypeError, "call#run_batch: ops hash should be a hash");
|
841
|
-
return Qnil;
|
842
883
|
}
|
843
|
-
if (rb_write_flag != Qnil) {
|
844
|
-
write_flag = NUM2UINT(rb_write_flag);
|
845
|
-
}
|
846
|
-
st = gpr_malloc(sizeof(run_batch_stack));
|
847
|
-
grpc_run_batch_stack_init(st, write_flag);
|
848
|
-
grpc_run_batch_stack_fill_ops(st, ops_hash);
|
849
884
|
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
}
|
861
|
-
ev = rb_completion_queue_pluck(call->queue, tag,
|
862
|
-
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
|
863
|
-
if (!ev.success) {
|
864
|
-
rb_raise(grpc_rb_eCallError, "call#run_batch failed somehow");
|
865
|
-
}
|
866
|
-
/* Build and return the BatchResult struct result,
|
867
|
-
if there is an error, it's reflected in the status */
|
868
|
-
result = grpc_run_batch_stack_build_result(st);
|
869
|
-
grpc_run_batch_stack_cleanup(st);
|
870
|
-
gpr_free(st);
|
871
|
-
return result;
|
885
|
+
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
|
886
|
+
|
887
|
+
struct call_run_batch_args args = {
|
888
|
+
.call = call,
|
889
|
+
.write_flag = rb_write_flag == Qnil ? 0 : NUM2UINT(rb_write_flag),
|
890
|
+
.ops_hash = ops_hash,
|
891
|
+
.st = NULL};
|
892
|
+
|
893
|
+
return rb_ensure(grpc_rb_call_run_batch_try, (VALUE)&args,
|
894
|
+
grpc_rb_call_run_batch_ensure, (VALUE)&args);
|
872
895
|
}
|
873
896
|
|
874
897
|
static void Init_grpc_write_flags() {
|
@@ -193,7 +193,6 @@ static void grpc_rb_call_credentials_free_internal(void* p) {
|
|
193
193
|
/* Destroys the credentials instances. */
|
194
194
|
static void grpc_rb_call_credentials_free(void* p) {
|
195
195
|
grpc_rb_call_credentials_free_internal(p);
|
196
|
-
grpc_ruby_shutdown();
|
197
196
|
}
|
198
197
|
|
199
198
|
/* Protects the mark object from GC */
|
@@ -47,6 +47,9 @@ static ID id_channel;
|
|
47
47
|
* GCed before the channel */
|
48
48
|
static ID id_target;
|
49
49
|
|
50
|
+
/* hidden ivar that synchronizes post-fork channel re-creation */
|
51
|
+
static ID id_channel_recreation_mu;
|
52
|
+
|
50
53
|
/* id_insecure_channel is used to indicate that a channel is insecure */
|
51
54
|
static VALUE id_insecure_channel;
|
52
55
|
|
@@ -67,7 +70,7 @@ typedef struct bg_watched_channel {
|
|
67
70
|
/* grpc_rb_channel wraps a grpc_channel. */
|
68
71
|
typedef struct grpc_rb_channel {
|
69
72
|
VALUE credentials;
|
70
|
-
|
73
|
+
grpc_channel_args args;
|
71
74
|
/* The actual channel (protected in a wrapper to tell when it's safe to
|
72
75
|
* destroy) */
|
73
76
|
bg_watched_channel* bg_wrapped;
|
@@ -104,11 +107,13 @@ typedef struct channel_init_try_register_stack {
|
|
104
107
|
grpc_rb_channel* wrapper;
|
105
108
|
} channel_init_try_register_stack;
|
106
109
|
|
107
|
-
static grpc_completion_queue*
|
110
|
+
static grpc_completion_queue* g_channel_polling_cq;
|
108
111
|
static gpr_mu global_connection_polling_mu;
|
109
112
|
static gpr_cv global_connection_polling_cv;
|
110
|
-
static int
|
111
|
-
static int
|
113
|
+
static int g_abort_channel_polling = 0;
|
114
|
+
static int g_channel_polling_thread_started = 0;
|
115
|
+
static gpr_once g_once_init = GPR_ONCE_INIT;
|
116
|
+
static VALUE g_channel_polling_thread = Qnil;
|
112
117
|
|
113
118
|
static int bg_watched_channel_list_lookup(bg_watched_channel* bg);
|
114
119
|
static bg_watched_channel* bg_watched_channel_list_create_and_add(
|
@@ -158,16 +163,13 @@ static void grpc_rb_channel_free_internal(void* p) {
|
|
158
163
|
* and we can count on this thread to not be interrupted or
|
159
164
|
* yield the gil. */
|
160
165
|
grpc_rb_channel_safe_destroy(ch->bg_wrapped);
|
161
|
-
ch->
|
166
|
+
grpc_rb_channel_args_destroy(&ch->args);
|
162
167
|
}
|
163
168
|
xfree(p);
|
164
169
|
}
|
165
170
|
|
166
171
|
/* Destroys Channel instances. */
|
167
|
-
static void grpc_rb_channel_free(void* p) {
|
168
|
-
grpc_rb_channel_free_internal(p);
|
169
|
-
grpc_ruby_shutdown();
|
170
|
-
}
|
172
|
+
static void grpc_rb_channel_free(void* p) { grpc_rb_channel_free_internal(p); }
|
171
173
|
|
172
174
|
/* Protects the mark object from GC */
|
173
175
|
static void grpc_rb_channel_mark(void* p) {
|
@@ -199,6 +201,7 @@ static VALUE grpc_rb_channel_alloc(VALUE cls) {
|
|
199
201
|
grpc_rb_channel* wrapper = ALLOC(grpc_rb_channel);
|
200
202
|
wrapper->bg_wrapped = NULL;
|
201
203
|
wrapper->credentials = Qnil;
|
204
|
+
MEMZERO(&wrapper->args, grpc_channel_args, 1);
|
202
205
|
return TypedData_Wrap_Struct(cls, &grpc_channel_data_type, wrapper);
|
203
206
|
}
|
204
207
|
|
@@ -218,24 +221,21 @@ static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
|
|
218
221
|
grpc_channel* ch = NULL;
|
219
222
|
grpc_channel_credentials* creds = NULL;
|
220
223
|
char* target_chars = NULL;
|
221
|
-
grpc_channel_args args;
|
222
224
|
channel_init_try_register_stack stack;
|
223
|
-
int stop_waiting_for_thread_start = 0;
|
224
|
-
MEMZERO(&args, grpc_channel_args, 1);
|
225
225
|
|
226
226
|
grpc_ruby_fork_guard();
|
227
|
+
int stop_waiting_for_thread_start = 0;
|
227
228
|
rb_thread_call_without_gvl(
|
228
229
|
wait_until_channel_polling_thread_started_no_gil,
|
229
230
|
&stop_waiting_for_thread_start,
|
230
231
|
wait_until_channel_polling_thread_started_unblocking_func,
|
231
232
|
&stop_waiting_for_thread_start);
|
232
|
-
|
233
233
|
/* "3" == 3 mandatory args */
|
234
234
|
rb_scan_args(argc, argv, "3", &target, &channel_args, &credentials);
|
235
235
|
|
236
236
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
237
237
|
target_chars = StringValueCStr(target);
|
238
|
-
grpc_rb_hash_convert_to_channel_args(channel_args, &args);
|
238
|
+
grpc_rb_hash_convert_to_channel_args(channel_args, &wrapper->args);
|
239
239
|
if (TYPE(credentials) == T_SYMBOL) {
|
240
240
|
if (id_insecure_channel != SYM2ID(credentials)) {
|
241
241
|
rb_raise(rb_eTypeError,
|
@@ -244,7 +244,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
|
|
244
244
|
}
|
245
245
|
grpc_channel_credentials* insecure_creds =
|
246
246
|
grpc_insecure_credentials_create();
|
247
|
-
ch = grpc_channel_create(target_chars, insecure_creds, &args);
|
247
|
+
ch = grpc_channel_create(target_chars, insecure_creds, &wrapper->args);
|
248
248
|
grpc_channel_credentials_release(insecure_creds);
|
249
249
|
} else {
|
250
250
|
wrapper->credentials = credentials;
|
@@ -257,7 +257,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
|
|
257
257
|
"bad creds, want ChannelCredentials or XdsChannelCredentials");
|
258
258
|
return Qnil;
|
259
259
|
}
|
260
|
-
ch = grpc_channel_create(target_chars, creds, &args);
|
260
|
+
ch = grpc_channel_create(target_chars, creds, &wrapper->args);
|
261
261
|
}
|
262
262
|
|
263
263
|
GPR_ASSERT(ch);
|
@@ -266,16 +266,13 @@ static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
|
|
266
266
|
rb_thread_call_without_gvl(
|
267
267
|
channel_init_try_register_connection_polling_without_gil, &stack, NULL,
|
268
268
|
NULL);
|
269
|
-
|
270
|
-
if (args.args != NULL) {
|
271
|
-
xfree(args.args); /* Allocated by grpc_rb_hash_convert_to_channel_args */
|
272
|
-
}
|
273
269
|
if (ch == NULL) {
|
274
270
|
rb_raise(rb_eRuntimeError, "could not create an rpc channel to target:%s",
|
275
271
|
target_chars);
|
276
272
|
return Qnil;
|
277
273
|
}
|
278
274
|
rb_ivar_set(self, id_target, target);
|
275
|
+
rb_ivar_set(self, id_channel_recreation_mu, rb_mutex_new());
|
279
276
|
return self;
|
280
277
|
}
|
281
278
|
|
@@ -289,7 +286,7 @@ static void* get_state_without_gil(void* arg) {
|
|
289
286
|
get_state_stack* stack = (get_state_stack*)arg;
|
290
287
|
|
291
288
|
gpr_mu_lock(&global_connection_polling_mu);
|
292
|
-
GPR_ASSERT(
|
289
|
+
GPR_ASSERT(g_abort_channel_polling || g_channel_polling_thread_started);
|
293
290
|
if (stack->bg->channel_destroyed) {
|
294
291
|
stack->out = GRPC_CHANNEL_SHUTDOWN;
|
295
292
|
} else {
|
@@ -346,7 +343,7 @@ static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
|
|
346
343
|
gpr_mu_lock(&global_connection_polling_mu);
|
347
344
|
// it's unsafe to do a "watch" after "channel polling abort" because the cq
|
348
345
|
// has been shut down.
|
349
|
-
if (
|
346
|
+
if (g_abort_channel_polling || stack->bg_wrapped->channel_destroyed) {
|
350
347
|
gpr_mu_unlock(&global_connection_polling_mu);
|
351
348
|
return (void*)0;
|
352
349
|
}
|
@@ -354,7 +351,7 @@ static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
|
|
354
351
|
op->op_type = WATCH_STATE_API;
|
355
352
|
grpc_channel_watch_connectivity_state(stack->bg_wrapped->channel,
|
356
353
|
stack->last_state, stack->deadline,
|
357
|
-
|
354
|
+
g_channel_polling_cq, op);
|
358
355
|
|
359
356
|
while (!op->op.api_callback_args.called_back) {
|
360
357
|
gpr_cv_wait(&global_connection_polling_cv, &global_connection_polling_mu,
|
@@ -418,6 +415,58 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
|
|
418
415
|
return op_success ? Qtrue : Qfalse;
|
419
416
|
}
|
420
417
|
|
418
|
+
static void grpc_rb_channel_maybe_recreate_channel_after_fork(
|
419
|
+
grpc_rb_channel* wrapper, VALUE target) {
|
420
|
+
// TODO(apolcyn): maybe check if fork support is enabled here.
|
421
|
+
// The only way we can get bg->channel_destroyed without bg itself being
|
422
|
+
// NULL is if we destroyed the channel during GRPC::prefork.
|
423
|
+
bg_watched_channel* bg = wrapper->bg_wrapped;
|
424
|
+
if (bg->channel_destroyed) {
|
425
|
+
// There must be one ref at this point, held by the ruby-level channel
|
426
|
+
// object.
|
427
|
+
GPR_ASSERT(bg->refcount == 1);
|
428
|
+
// Wait for channel polling thread to re-initialize
|
429
|
+
int stop_waiting_for_thread_start = 0;
|
430
|
+
rb_thread_call_without_gvl(
|
431
|
+
wait_until_channel_polling_thread_started_no_gil,
|
432
|
+
&stop_waiting_for_thread_start,
|
433
|
+
wait_until_channel_polling_thread_started_unblocking_func,
|
434
|
+
&stop_waiting_for_thread_start);
|
435
|
+
rb_thread_call_without_gvl(channel_safe_destroy_without_gil, bg, NULL,
|
436
|
+
NULL);
|
437
|
+
// re-create C-core channel
|
438
|
+
const char* target_str = StringValueCStr(target);
|
439
|
+
grpc_channel* channel;
|
440
|
+
if (wrapper->credentials == Qnil) {
|
441
|
+
grpc_channel_credentials* insecure_creds =
|
442
|
+
grpc_insecure_credentials_create();
|
443
|
+
channel = grpc_channel_create(target_str, insecure_creds, &wrapper->args);
|
444
|
+
grpc_channel_credentials_release(insecure_creds);
|
445
|
+
} else {
|
446
|
+
grpc_channel_credentials* creds;
|
447
|
+
if (grpc_rb_is_channel_credentials(wrapper->credentials)) {
|
448
|
+
creds = grpc_rb_get_wrapped_channel_credentials(wrapper->credentials);
|
449
|
+
} else if (grpc_rb_is_xds_channel_credentials(wrapper->credentials)) {
|
450
|
+
creds =
|
451
|
+
grpc_rb_get_wrapped_xds_channel_credentials(wrapper->credentials);
|
452
|
+
} else {
|
453
|
+
rb_raise(rb_eTypeError,
|
454
|
+
"failed to re-create channel after fork: bad creds, want "
|
455
|
+
"ChannelCredentials or XdsChannelCredentials");
|
456
|
+
return;
|
457
|
+
}
|
458
|
+
channel = grpc_channel_create(target_str, creds, &wrapper->args);
|
459
|
+
}
|
460
|
+
// re-register with channel polling thread
|
461
|
+
channel_init_try_register_stack stack;
|
462
|
+
stack.channel = channel;
|
463
|
+
stack.wrapper = wrapper;
|
464
|
+
rb_thread_call_without_gvl(
|
465
|
+
channel_init_try_register_connection_polling_without_gil, &stack, NULL,
|
466
|
+
NULL);
|
467
|
+
}
|
468
|
+
}
|
469
|
+
|
421
470
|
/* Create a call given a grpc_channel, in order to call method. The request
|
422
471
|
is not sent until grpc_call_invoke is called. */
|
423
472
|
static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
|
@@ -452,6 +501,11 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
|
|
452
501
|
rb_raise(rb_eRuntimeError, "closed!");
|
453
502
|
return Qnil;
|
454
503
|
}
|
504
|
+
// TODO(apolcyn): only do this check if fork support is enabled
|
505
|
+
rb_mutex_lock(rb_ivar_get(self, id_channel_recreation_mu));
|
506
|
+
grpc_rb_channel_maybe_recreate_channel_after_fork(
|
507
|
+
wrapper, rb_ivar_get(self, id_target));
|
508
|
+
rb_mutex_unlock(rb_ivar_get(self, id_channel_recreation_mu));
|
455
509
|
|
456
510
|
cq = grpc_completion_queue_create_for_pluck(NULL);
|
457
511
|
method_slice =
|
@@ -582,7 +636,7 @@ static void grpc_rb_channel_try_register_connection_polling(
|
|
582
636
|
grpc_connectivity_state conn_state;
|
583
637
|
watch_state_op* op = NULL;
|
584
638
|
|
585
|
-
GPR_ASSERT(
|
639
|
+
GPR_ASSERT(g_channel_polling_thread_started || g_abort_channel_polling);
|
586
640
|
|
587
641
|
if (bg->refcount == 0) {
|
588
642
|
GPR_ASSERT(bg->channel_destroyed);
|
@@ -590,7 +644,7 @@ static void grpc_rb_channel_try_register_connection_polling(
|
|
590
644
|
return;
|
591
645
|
}
|
592
646
|
GPR_ASSERT(bg->refcount == 1);
|
593
|
-
if (bg->channel_destroyed ||
|
647
|
+
if (bg->channel_destroyed || g_abort_channel_polling) {
|
594
648
|
return;
|
595
649
|
}
|
596
650
|
|
@@ -607,7 +661,7 @@ static void grpc_rb_channel_try_register_connection_polling(
|
|
607
661
|
op->op.continuous_watch_callback_args.bg = bg;
|
608
662
|
grpc_channel_watch_connectivity_state(bg->channel, conn_state,
|
609
663
|
gpr_inf_future(GPR_CLOCK_REALTIME),
|
610
|
-
|
664
|
+
g_channel_polling_cq, op);
|
611
665
|
}
|
612
666
|
|
613
667
|
// Note this loop breaks out with a single call of
|
@@ -624,14 +678,15 @@ static void* run_poll_channels_loop_no_gil(void* arg) {
|
|
624
678
|
gpr_log(GPR_DEBUG, "GRPC_RUBY: run_poll_channels_loop_no_gil - begin");
|
625
679
|
|
626
680
|
gpr_mu_lock(&global_connection_polling_mu);
|
627
|
-
GPR_ASSERT(!
|
628
|
-
|
681
|
+
GPR_ASSERT(!g_abort_channel_polling);
|
682
|
+
GPR_ASSERT(!g_channel_polling_thread_started);
|
683
|
+
g_channel_polling_thread_started = 1;
|
629
684
|
gpr_cv_broadcast(&global_connection_polling_cv);
|
630
685
|
gpr_mu_unlock(&global_connection_polling_mu);
|
631
686
|
|
632
687
|
for (;;) {
|
633
688
|
event = grpc_completion_queue_next(
|
634
|
-
|
689
|
+
g_channel_polling_cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
|
635
690
|
if (event.type == GRPC_QUEUE_SHUTDOWN) {
|
636
691
|
break;
|
637
692
|
}
|
@@ -652,7 +707,7 @@ static void* run_poll_channels_loop_no_gil(void* arg) {
|
|
652
707
|
}
|
653
708
|
gpr_mu_unlock(&global_connection_polling_mu);
|
654
709
|
}
|
655
|
-
grpc_completion_queue_destroy(
|
710
|
+
grpc_completion_queue_destroy(g_channel_polling_cq);
|
656
711
|
gpr_log(GPR_DEBUG,
|
657
712
|
"GRPC_RUBY: run_poll_channels_loop_no_gil - exit connection polling "
|
658
713
|
"loop");
|
@@ -669,11 +724,11 @@ static void run_poll_channels_loop_unblocking_func(void* arg) {
|
|
669
724
|
"GRPC_RUBY: run_poll_channels_loop_unblocking_func - begin aborting "
|
670
725
|
"connection polling");
|
671
726
|
// early out after first time through
|
672
|
-
if (
|
727
|
+
if (g_abort_channel_polling) {
|
673
728
|
gpr_mu_unlock(&global_connection_polling_mu);
|
674
729
|
return;
|
675
730
|
}
|
676
|
-
|
731
|
+
g_abort_channel_polling = 1;
|
677
732
|
|
678
733
|
// force pending watches to end by switching to shutdown state
|
679
734
|
bg = bg_watched_channel_list_head;
|
@@ -685,7 +740,9 @@ static void run_poll_channels_loop_unblocking_func(void* arg) {
|
|
685
740
|
bg = bg->next;
|
686
741
|
}
|
687
742
|
|
688
|
-
|
743
|
+
gpr_log(GPR_DEBUG, "GRPC_RUBY: cq shutdown on global polling cq. pid: %d",
|
744
|
+
getpid());
|
745
|
+
grpc_completion_queue_shutdown(g_channel_polling_cq);
|
689
746
|
gpr_cv_broadcast(&global_connection_polling_cv);
|
690
747
|
gpr_mu_unlock(&global_connection_polling_mu);
|
691
748
|
gpr_log(GPR_DEBUG,
|
@@ -699,10 +756,8 @@ static VALUE run_poll_channels_loop(VALUE arg) {
|
|
699
756
|
gpr_log(
|
700
757
|
GPR_DEBUG,
|
701
758
|
"GRPC_RUBY: run_poll_channels_loop - create connection polling thread");
|
702
|
-
grpc_ruby_init();
|
703
759
|
rb_thread_call_without_gvl(run_poll_channels_loop_no_gil, NULL,
|
704
760
|
run_poll_channels_loop_unblocking_func, NULL);
|
705
|
-
grpc_ruby_shutdown();
|
706
761
|
return Qnil;
|
707
762
|
}
|
708
763
|
|
@@ -710,7 +765,7 @@ static void* wait_until_channel_polling_thread_started_no_gil(void* arg) {
|
|
710
765
|
int* stop_waiting = (int*)arg;
|
711
766
|
gpr_log(GPR_DEBUG, "GRPC_RUBY: wait for channel polling thread to start");
|
712
767
|
gpr_mu_lock(&global_connection_polling_mu);
|
713
|
-
while (!
|
768
|
+
while (!g_channel_polling_thread_started && !g_abort_channel_polling &&
|
714
769
|
!*stop_waiting) {
|
715
770
|
gpr_cv_wait(&global_connection_polling_cv, &global_connection_polling_mu,
|
716
771
|
gpr_inf_future(GPR_CLOCK_REALTIME));
|
@@ -734,12 +789,17 @@ static void wait_until_channel_polling_thread_started_unblocking_func(
|
|
734
789
|
static void* set_abort_channel_polling_without_gil(void* arg) {
|
735
790
|
(void)arg;
|
736
791
|
gpr_mu_lock(&global_connection_polling_mu);
|
737
|
-
|
792
|
+
g_abort_channel_polling = 1;
|
738
793
|
gpr_cv_broadcast(&global_connection_polling_cv);
|
739
794
|
gpr_mu_unlock(&global_connection_polling_mu);
|
740
795
|
return NULL;
|
741
796
|
}
|
742
797
|
|
798
|
+
static void do_basic_init() {
|
799
|
+
gpr_mu_init(&global_connection_polling_mu);
|
800
|
+
gpr_cv_init(&global_connection_polling_cv);
|
801
|
+
}
|
802
|
+
|
743
803
|
/* Temporary fix for
|
744
804
|
* https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues/899.
|
745
805
|
* Transports in idle channels can get destroyed. Normally c-core re-connects,
|
@@ -751,23 +811,38 @@ static void* set_abort_channel_polling_without_gil(void* arg) {
|
|
751
811
|
* TODO(apolcyn) remove this when core handles new RPCs on dead connections.
|
752
812
|
*/
|
753
813
|
void grpc_rb_channel_polling_thread_start() {
|
754
|
-
|
814
|
+
gpr_once_init(&g_once_init, do_basic_init);
|
815
|
+
GPR_ASSERT(!RTEST(g_channel_polling_thread));
|
816
|
+
GPR_ASSERT(!g_abort_channel_polling);
|
817
|
+
GPR_ASSERT(!g_channel_polling_thread_started);
|
818
|
+
GPR_ASSERT(g_channel_polling_cq == NULL);
|
755
819
|
|
756
|
-
|
757
|
-
|
758
|
-
GPR_ASSERT(channel_polling_cq == NULL);
|
820
|
+
g_channel_polling_cq = grpc_completion_queue_create_for_next(NULL);
|
821
|
+
g_channel_polling_thread = rb_thread_create(run_poll_channels_loop, NULL);
|
759
822
|
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
channel_polling_cq = grpc_completion_queue_create_for_next(NULL);
|
764
|
-
background_thread = rb_thread_create(run_poll_channels_loop, NULL);
|
765
|
-
|
766
|
-
if (!RTEST(background_thread)) {
|
767
|
-
gpr_log(GPR_DEBUG, "GRPC_RUBY: failed to spawn channel polling thread");
|
823
|
+
if (!RTEST(g_channel_polling_thread)) {
|
824
|
+
gpr_log(GPR_ERROR, "GRPC_RUBY: failed to spawn channel polling thread");
|
768
825
|
rb_thread_call_without_gvl(set_abort_channel_polling_without_gil, NULL,
|
769
826
|
NULL, NULL);
|
827
|
+
return;
|
828
|
+
}
|
829
|
+
}
|
830
|
+
|
831
|
+
void grpc_rb_channel_polling_thread_stop() {
|
832
|
+
if (!RTEST(g_channel_polling_thread)) {
|
833
|
+
gpr_log(GPR_ERROR,
|
834
|
+
"GRPC_RUBY: channel polling thread stop: thread was not started");
|
835
|
+
return;
|
770
836
|
}
|
837
|
+
rb_thread_call_without_gvl(run_poll_channels_loop_unblocking_func, NULL, NULL,
|
838
|
+
NULL);
|
839
|
+
rb_funcall(g_channel_polling_thread, rb_intern("join"), 0);
|
840
|
+
// state associated with the channel polling thread is destroyed, reset so
|
841
|
+
// we can start again later
|
842
|
+
g_channel_polling_thread = Qnil;
|
843
|
+
g_abort_channel_polling = false;
|
844
|
+
g_channel_polling_thread_started = false;
|
845
|
+
g_channel_polling_cq = NULL;
|
771
846
|
}
|
772
847
|
|
773
848
|
static void Init_grpc_propagate_masks() {
|
@@ -803,6 +878,7 @@ static void Init_grpc_connectivity_states() {
|
|
803
878
|
}
|
804
879
|
|
805
880
|
void Init_grpc_channel() {
|
881
|
+
rb_global_variable(&g_channel_polling_thread);
|
806
882
|
grpc_rb_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject);
|
807
883
|
rb_undef_alloc_func(grpc_rb_cChannelArgs);
|
808
884
|
grpc_rb_cChannel =
|
@@ -829,6 +905,7 @@ void Init_grpc_channel() {
|
|
829
905
|
|
830
906
|
id_channel = rb_intern("__channel");
|
831
907
|
id_target = rb_intern("__target");
|
908
|
+
id_channel_recreation_mu = rb_intern("__channel_recreation_mu");
|
832
909
|
rb_define_const(grpc_rb_cChannel, "SSL_TARGET",
|
833
910
|
ID2SYM(rb_intern(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)));
|
834
911
|
rb_define_const(grpc_rb_cChannel, "ENABLE_CENSUS",
|
@@ -24,6 +24,7 @@
|
|
24
24
|
#include "rb_grpc_imports.generated.h"
|
25
25
|
|
26
26
|
#include <grpc/grpc.h>
|
27
|
+
#include <grpc/support/log.h>
|
27
28
|
|
28
29
|
static rb_data_type_t grpc_rb_channel_args_data_type = {
|
29
30
|
"grpc_channel_args",
|
@@ -73,13 +74,14 @@ static int grpc_rb_channel_create_in_process_add_args_hash_cb(VALUE key,
|
|
73
74
|
case T_SYMBOL:
|
74
75
|
args->args[args->num_args - 1].type = GRPC_ARG_STRING;
|
75
76
|
args->args[args->num_args - 1].value.string =
|
76
|
-
(
|
77
|
+
strdup(rb_id2name(SYM2ID(val)));
|
77
78
|
--args->num_args;
|
78
79
|
return ST_CONTINUE;
|
79
80
|
|
80
81
|
case T_STRING:
|
81
82
|
args->args[args->num_args - 1].type = GRPC_ARG_STRING;
|
82
|
-
args->args[args->num_args - 1].value.string =
|
83
|
+
args->args[args->num_args - 1].value.string =
|
84
|
+
strdup(StringValueCStr(val));
|
83
85
|
--args->num_args;
|
84
86
|
return ST_CONTINUE;
|
85
87
|
|
@@ -154,3 +156,15 @@ void grpc_rb_hash_convert_to_channel_args(VALUE src_hash,
|
|
154
156
|
rb_jump_tag(status);
|
155
157
|
}
|
156
158
|
}
|
159
|
+
|
160
|
+
void grpc_rb_channel_args_destroy(grpc_channel_args* args) {
|
161
|
+
GPR_ASSERT(args != NULL);
|
162
|
+
if (args->args == NULL) return;
|
163
|
+
for (int i = 0; i < args->num_args; i++) {
|
164
|
+
if (args->args[i].type == GRPC_ARG_STRING) {
|
165
|
+
// we own string pointers, which were created with strdup
|
166
|
+
free(args->args[i].value.string);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
xfree(args->args);
|
170
|
+
}
|
@@ -35,4 +35,8 @@
|
|
35
35
|
void grpc_rb_hash_convert_to_channel_args(VALUE src_hash,
|
36
36
|
grpc_channel_args* dst);
|
37
37
|
|
38
|
+
/* Destroys inner fields of args (does not deallocate the args pointer itself)
|
39
|
+
*/
|
40
|
+
void grpc_rb_channel_args_destroy(grpc_channel_args* args);
|
41
|
+
|
38
42
|
#endif /* GRPC_RB_CHANNEL_ARGS_H_ */
|
@@ -63,7 +63,6 @@ static void grpc_rb_channel_credentials_free_internal(void* p) {
|
|
63
63
|
/* Destroys the credentials instances. */
|
64
64
|
static void grpc_rb_channel_credentials_free(void* p) {
|
65
65
|
grpc_rb_channel_credentials_free_internal(p);
|
66
|
-
grpc_ruby_shutdown();
|
67
66
|
}
|
68
67
|
|
69
68
|
/* Protects the mark object from GC */
|
@@ -70,7 +70,6 @@ static void grpc_rb_compression_options_free_internal(void* p) {
|
|
70
70
|
* wrapped grpc compression options. */
|
71
71
|
static void grpc_rb_compression_options_free(void* p) {
|
72
72
|
grpc_rb_compression_options_free_internal(p);
|
73
|
-
grpc_ruby_shutdown();
|
74
73
|
}
|
75
74
|
|
76
75
|
/* Ruby recognized data type for the CompressionOptions class. */
|
@@ -51,6 +51,8 @@ typedef struct grpc_rb_event_queue {
|
|
51
51
|
} grpc_rb_event_queue;
|
52
52
|
|
53
53
|
static grpc_rb_event_queue event_queue;
|
54
|
+
static VALUE g_event_thread = Qnil;
|
55
|
+
static bool g_one_time_init_done = false;
|
54
56
|
|
55
57
|
void grpc_rb_event_queue_enqueue(void (*callback)(void*), void* argument) {
|
56
58
|
grpc_rb_event* event = gpr_malloc(sizeof(grpc_rb_event));
|
@@ -117,7 +119,6 @@ static void grpc_rb_event_unblocking_func(void* arg) {
|
|
117
119
|
static VALUE grpc_rb_event_thread(VALUE arg) {
|
118
120
|
grpc_rb_event* event;
|
119
121
|
(void)arg;
|
120
|
-
grpc_ruby_init();
|
121
122
|
while (true) {
|
122
123
|
event = (grpc_rb_event*)rb_thread_call_without_gvl(
|
123
124
|
grpc_rb_wait_for_event_no_gil, NULL, grpc_rb_event_unblocking_func,
|
@@ -131,15 +132,30 @@ static VALUE grpc_rb_event_thread(VALUE arg) {
|
|
131
132
|
}
|
132
133
|
}
|
133
134
|
grpc_rb_event_queue_destroy();
|
134
|
-
grpc_ruby_shutdown();
|
135
135
|
return Qnil;
|
136
136
|
}
|
137
137
|
|
138
138
|
void grpc_rb_event_queue_thread_start() {
|
139
|
-
|
139
|
+
if (!g_one_time_init_done) {
|
140
|
+
g_one_time_init_done = true;
|
141
|
+
gpr_mu_init(&event_queue.mu);
|
142
|
+
gpr_cv_init(&event_queue.cv);
|
143
|
+
rb_global_variable(&g_event_thread);
|
144
|
+
event_queue.head = event_queue.tail = NULL;
|
145
|
+
}
|
140
146
|
event_queue.abort = false;
|
141
|
-
|
142
|
-
|
147
|
+
GPR_ASSERT(!RTEST(g_event_thread));
|
148
|
+
g_event_thread = rb_thread_create(grpc_rb_event_thread, NULL);
|
149
|
+
}
|
143
150
|
|
144
|
-
|
151
|
+
void grpc_rb_event_queue_thread_stop() {
|
152
|
+
GPR_ASSERT(g_one_time_init_done);
|
153
|
+
if (!RTEST(g_event_thread)) {
|
154
|
+
gpr_log(GPR_ERROR,
|
155
|
+
"GRPC_RUBY: call credentials thread stop: thread not running");
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
rb_thread_call_without_gvl(grpc_rb_event_unblocking_func, NULL, NULL, NULL);
|
159
|
+
rb_funcall(g_event_thread, rb_intern("join"), 0);
|
160
|
+
g_event_thread = Qnil;
|
145
161
|
}
|