grpc 1.73.0 → 1.74.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +38 -17
- data/include/grpc/create_channel_from_endpoint.h +54 -0
- data/include/grpc/credentials.h +11 -5
- data/include/grpc/event_engine/event_engine.h +74 -17
- data/include/grpc/grpc_posix.h +20 -1
- data/include/grpc/impl/channel_arg_names.h +2 -4
- data/include/grpc/module.modulemap +1 -0
- data/include/grpc/support/json.h +24 -0
- data/src/core/call/interception_chain.h +7 -11
- data/src/core/channelz/channel_trace.cc +213 -115
- data/src/core/channelz/channel_trace.h +380 -86
- data/src/core/channelz/channelz.cc +270 -181
- data/src/core/channelz/channelz.h +168 -55
- data/src/core/channelz/channelz_registry.cc +2 -1
- data/src/core/channelz/channelz_registry.h +24 -0
- data/src/core/channelz/property_list.cc +357 -0
- data/src/core/channelz/property_list.h +202 -0
- data/src/core/channelz/ztrace_collector.h +3 -2
- data/src/core/client_channel/backup_poller.cc +17 -2
- data/src/core/client_channel/client_channel.cc +17 -28
- data/src/core/client_channel/client_channel_filter.cc +19 -29
- data/src/core/client_channel/config_selector.h +8 -2
- data/src/core/client_channel/dynamic_filters.cc +5 -6
- data/src/core/client_channel/dynamic_filters.h +1 -1
- data/src/core/client_channel/global_subchannel_pool.cc +4 -1
- data/src/core/client_channel/retry_filter.cc +21 -27
- data/src/core/client_channel/retry_filter.h +10 -7
- data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -5
- data/src/core/client_channel/retry_filter_legacy_call_data.h +1 -1
- data/src/core/client_channel/retry_interceptor.cc +30 -44
- data/src/core/client_channel/retry_interceptor.h +18 -17
- data/src/core/client_channel/retry_throttle.cc +46 -61
- data/src/core/client_channel/retry_throttle.h +17 -39
- data/src/core/client_channel/subchannel.cc +43 -19
- data/src/core/client_channel/subchannel.h +8 -0
- data/src/core/config/config_vars.cc +2 -0
- data/src/core/config/core_configuration.cc +1 -0
- data/src/core/config/core_configuration.h +11 -0
- data/src/core/credentials/call/call_creds_registry.h +125 -0
- data/src/core/credentials/call/call_creds_registry_init.cc +91 -0
- data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +6 -48
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +86 -0
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.h +74 -0
- data/src/core/credentials/call/jwt_util.cc +70 -0
- data/src/core/credentials/call/jwt_util.h +32 -0
- data/src/core/credentials/transport/channel_creds_registry_init.cc +1 -1
- data/src/core/credentials/transport/google_default/google_default_credentials.cc +72 -4
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +0 -1
- data/src/core/credentials/transport/tls/load_system_roots_supported.cc +1 -0
- data/src/core/credentials/transport/xds/xds_credentials.cc +0 -3
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +8 -8
- data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +16 -16
- data/src/core/ext/filters/http/client_authority_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/compression_filter.h +25 -22
- data/src/core/ext/filters/http/server/http_server_filter.h +12 -11
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +120 -35
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +162 -115
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +0 -3
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +1239 -3514
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1008 -1486
- data/src/core/ext/transport/chttp2/transport/flow_control.h +22 -17
- data/src/core/ext/transport/chttp2/transport/frame.cc +10 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +7 -8
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +4 -5
- data/src/core/ext/transport/chttp2/transport/header_assembler.h +299 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +11 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +12 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +1017 -0
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +593 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +19 -22
- data/{third_party/abseil-cpp/absl/strings/cord_buffer.cc → src/core/ext/transport/chttp2/transport/http2_stats_collector.cc} +14 -14
- data/src/core/ext/transport/chttp2/transport/http2_stats_collector.h +33 -0
- data/src/core/ext/transport/chttp2/transport/http2_status.h +6 -1
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +43 -0
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +65 -0
- data/src/core/ext/transport/chttp2/transport/http2_ztrace_collector.h +0 -29
- data/src/core/ext/transport/chttp2/transport/internal.h +18 -8
- data/src/core/ext/transport/chttp2/transport/keepalive.cc +105 -0
- data/src/core/ext/transport/chttp2/transport/keepalive.h +138 -0
- data/src/core/ext/transport/chttp2/transport/message_assembler.h +185 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -4
- data/src/core/ext/transport/chttp2/transport/ping_callbacks.h +19 -0
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +151 -0
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +180 -0
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +5 -9
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +11 -0
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +39 -1
- data/src/core/ext/transport/chttp2/transport/transport_common.cc +19 -0
- data/src/core/ext/transport/chttp2/transport/transport_common.h +27 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +37 -11
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb.h +571 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb_minitable.c +120 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/channelz.upb_minitable.h +36 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb.h +1272 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb_minitable.c +312 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/promise.upb_minitable.h +50 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +984 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +226 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +44 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/promise.upbdefs.c +175 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/promise.upbdefs.h +82 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +135 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +67 -0
- data/src/core/filter/auth/auth_filters.h +0 -25
- data/src/core/filter/auth/client_auth_filter.cc +0 -118
- data/src/core/filter/filter_args.h +9 -23
- data/src/core/handshaker/handshaker.cc +23 -14
- data/src/core/handshaker/handshaker.h +3 -0
- data/src/core/handshaker/http_connect/http_connect_handshaker.cc +3 -1
- data/src/core/handshaker/security/legacy_secure_endpoint.cc +6 -5
- data/src/core/handshaker/security/secure_endpoint.cc +70 -25
- data/src/core/handshaker/security/security_handshaker.cc +4 -1
- data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +7 -1
- data/src/core/lib/channel/channel_args.cc +15 -0
- data/src/core/lib/channel/channel_args.h +3 -0
- data/src/core/lib/channel/channel_stack.cc +22 -23
- data/src/core/lib/channel/channel_stack.h +9 -7
- data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -1
- data/src/core/lib/channel/channel_stack_builder_impl.h +2 -7
- data/src/core/lib/channel/promise_based_filter.h +5 -5
- data/src/core/lib/debug/trace_impl.h +0 -1
- data/src/core/lib/event_engine/ares_resolver.cc +165 -46
- data/src/core/lib/event_engine/ares_resolver.h +48 -2
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +3 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +1 -4
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +2 -6
- data/src/core/lib/event_engine/endpoint_channel_arg_wrapper.cc +40 -0
- data/src/core/lib/event_engine/endpoint_channel_arg_wrapper.h +60 -0
- data/src/core/lib/event_engine/event_engine.cc +7 -0
- data/src/core/lib/event_engine/extensions/channelz.h +10 -6
- data/src/core/lib/event_engine/grpc_polled_fd.h +5 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +130 -162
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +11 -15
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +75 -117
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -9
- data/src/core/lib/event_engine/posix_engine/event_poller.h +18 -15
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +0 -18
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.cc +124 -0
- data/src/core/lib/event_engine/posix_engine/file_descriptor_collection.h +243 -0
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +29 -19
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.cc +6 -2
- data/src/core/lib/event_engine/posix_engine/internal_errqueue.h +6 -1
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +145 -92
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +9 -19
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +333 -116
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +61 -18
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +45 -37
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +6 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +32 -142
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h +6 -5
- data/src/core/lib/event_engine/posix_engine/posix_interface.h +211 -0
- data/src/core/lib/event_engine/posix_engine/posix_interface_posix.cc +1083 -0
- data/src/core/lib/event_engine/posix_engine/posix_interface_windows.cc +281 -0
- data/src/core/lib/event_engine/posix_engine/posix_write_event_sink.cc +154 -0
- data/src/core/lib/event_engine/posix_engine/posix_write_event_sink.h +174 -0
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -719
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +10 -170
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +33 -22
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +13 -11
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +117 -151
- data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +26 -94
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc +26 -25
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h +6 -2
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc +36 -62
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h +6 -2
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h +7 -6
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.cc +12 -6
- data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h +3 -1
- data/src/core/lib/event_engine/shim.cc +9 -0
- data/src/core/lib/event_engine/shim.h +3 -0
- data/src/core/lib/event_engine/thread_pool/thread_pool.h +7 -3
- data/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +0 -17
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +4 -2
- data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +3 -2
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +4 -0
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.h +4 -0
- data/src/core/lib/event_engine/windows/windows_endpoint.h +2 -6
- data/src/core/lib/event_engine/windows/windows_engine.cc +0 -1
- data/src/core/lib/event_engine/windows/windows_engine.h +1 -3
- data/src/core/lib/event_engine/windows/windows_listener.cc +14 -2
- data/src/core/lib/experiments/experiments.cc +45 -93
- data/src/core/lib/experiments/experiments.h +21 -51
- data/src/core/lib/iomgr/endpoint.cc +4 -3
- data/src/core/lib/iomgr/endpoint.h +7 -4
- data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +7 -2
- data/src/core/lib/iomgr/ev_poll_posix.cc +7 -2
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +4 -6
- data/src/core/lib/iomgr/tcp_posix.cc +12 -6
- data/src/core/lib/iomgr/tcp_windows.cc +3 -2
- data/src/core/lib/promise/activity.h +1 -0
- data/src/core/lib/promise/arena_promise.h +23 -7
- data/src/core/lib/promise/detail/promise_factory.h +10 -0
- data/src/core/lib/promise/detail/promise_like.h +118 -11
- data/src/core/lib/promise/detail/promise_variant.h +50 -0
- data/src/core/lib/promise/detail/seq_state.h +687 -548
- data/src/core/lib/promise/if.h +20 -0
- data/src/core/lib/promise/inter_activity_latch.h +147 -0
- data/src/core/lib/promise/inter_activity_mutex.h +547 -0
- data/src/core/lib/promise/loop.h +65 -3
- data/src/core/lib/promise/map.h +24 -0
- data/src/core/lib/promise/match_promise.h +103 -0
- data/src/core/lib/promise/mpsc.cc +425 -0
- data/src/core/lib/promise/mpsc.h +490 -0
- data/src/core/lib/promise/party.cc +50 -1
- data/src/core/lib/promise/party.h +66 -1
- data/src/core/lib/promise/race.h +31 -0
- data/src/core/lib/promise/seq.h +4 -1
- data/src/core/lib/promise/status_flag.h +7 -0
- data/src/core/lib/promise/try_seq.h +4 -1
- data/src/core/lib/promise/wait_set.cc +28 -0
- data/src/core/lib/promise/wait_set.h +86 -0
- data/src/core/lib/resource_quota/arena.h +19 -0
- data/src/core/lib/slice/slice.h +5 -0
- data/src/core/lib/surface/channel_create.cc +88 -13
- data/src/core/lib/surface/channel_create.h +4 -0
- data/src/core/lib/surface/channel_init.cc +164 -47
- data/src/core/lib/surface/channel_init.h +64 -1
- data/src/core/lib/surface/filter_stack_call.cc +18 -9
- data/src/core/lib/surface/init.cc +6 -15
- data/src/core/lib/surface/legacy_channel.cc +3 -5
- data/src/core/lib/surface/legacy_channel.h +3 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.cc +110 -0
- data/src/core/lib/transport/promise_endpoint.h +307 -0
- data/src/core/load_balancing/child_policy_handler.cc +2 -4
- data/src/core/load_balancing/delegating_helper.h +2 -3
- data/src/core/load_balancing/health_check_client.cc +1 -5
- data/src/core/load_balancing/lb_policy.h +1 -3
- data/src/core/load_balancing/oob_backend_metric.cc +1 -5
- data/src/core/load_balancing/pick_first/pick_first.cc +3 -0
- data/src/core/load_balancing/xds/cds.cc +10 -1
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +2 -0
- data/src/core/resolver/xds/xds_config.cc +6 -3
- data/src/core/resolver/xds/xds_config.h +9 -4
- data/src/core/resolver/xds/xds_dependency_manager.cc +21 -6
- data/src/core/resolver/xds/xds_dependency_manager.h +2 -1
- data/src/core/resolver/xds/xds_resolver.cc +31 -11
- data/src/core/server/server.cc +83 -12
- data/src/core/server/server.h +21 -2
- data/src/core/server/xds_server_config_fetcher.cc +63 -25
- data/src/core/service_config/service_config.h +1 -1
- data/src/core/service_config/service_config_impl.h +1 -1
- data/src/core/telemetry/context_list_entry.cc +38 -0
- data/src/core/telemetry/context_list_entry.h +42 -12
- data/src/core/telemetry/stats_data.cc +233 -207
- data/src/core/telemetry/stats_data.h +250 -153
- data/src/core/telemetry/tcp_tracer.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +11 -3
- data/src/core/tsi/fake_transport_security.cc +17 -0
- data/src/core/tsi/ssl_transport_security.cc +2 -0
- data/src/core/tsi/transport_security_grpc.cc +8 -0
- data/src/core/tsi/transport_security_grpc.h +15 -0
- data/src/core/util/backoff.cc +1 -5
- data/src/core/util/backoff.h +1 -0
- data/src/core/util/down_cast.h +1 -1
- data/src/core/util/function_signature.h +15 -1
- data/src/core/util/http_client/httpcli.cc +12 -5
- data/src/core/util/http_client/httpcli.h +4 -1
- data/src/core/util/latent_see.h +8 -5
- data/src/core/util/log.cc +4 -0
- data/src/core/util/memory_usage.h +268 -0
- data/src/core/util/per_cpu.cc +2 -0
- data/src/core/util/per_cpu.h +7 -0
- data/src/core/util/shared_bit_gen.h +20 -0
- data/src/core/util/single_set_ptr.h +2 -2
- data/src/core/util/upb_utils.h +42 -0
- data/src/core/util/uri.cc +3 -2
- data/src/core/util/useful.h +53 -2
- data/src/core/util/wait_for_single_owner.cc +31 -0
- data/src/core/util/wait_for_single_owner.h +24 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc.h +5 -0
- data/src/core/xds/grpc/xds_client_grpc.cc +6 -2
- data/src/core/xds/grpc/xds_common_types_parser.cc +138 -50
- data/src/core/xds/grpc/xds_common_types_parser.h +12 -0
- data/src/core/xds/grpc/xds_http_filter.h +7 -0
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +22 -0
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -0
- data/src/core/xds/grpc/xds_route_config_parser.cc +15 -38
- data/src/core/xds/grpc/xds_server_grpc.cc +63 -13
- data/src/core/xds/grpc/xds_server_grpc.h +10 -2
- data/src/core/xds/grpc/xds_server_grpc_interface.h +4 -0
- data/src/core/xds/grpc/xds_transport_grpc.cc +18 -0
- data/src/core/xds/xds_client/xds_bootstrap.h +2 -0
- data/src/core/xds/xds_client/xds_client.cc +26 -5
- data/src/ruby/ext/grpc/extconf.rb +2 -0
- data/src/ruby/ext/grpc/rb_call.c +1 -8
- data/src/ruby/ext/grpc/rb_channel.c +70 -557
- data/src/ruby/ext/grpc/rb_channel.h +0 -3
- data/src/ruby/ext/grpc/rb_completion_queue.c +26 -14
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -7
- data/src/ruby/ext/grpc/rb_grpc.c +9 -5
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/ext/grpc/rb_loader.c +0 -4
- data/src/ruby/ext/grpc/rb_server.c +31 -50
- data/src/ruby/lib/grpc/generic/client_stub.rb +4 -4
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/core_spec.rb +22 -0
- data/src/ruby/spec/generic/active_call_spec.rb +1 -1
- data/third_party/abseil-cpp/absl/algorithm/container.h +2 -19
- data/third_party/abseil-cpp/absl/base/attributes.h +76 -7
- data/third_party/abseil-cpp/absl/base/call_once.h +11 -12
- data/third_party/abseil-cpp/absl/base/config.h +20 -129
- data/third_party/abseil-cpp/absl/base/{internal/fast_type_id.h → fast_type_id.h} +11 -16
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +0 -5
- data/third_party/abseil-cpp/absl/base/internal/cycleclock_config.h +7 -7
- data/third_party/abseil-cpp/absl/base/internal/endian.h +34 -38
- data/third_party/abseil-cpp/absl/base/internal/iterator_traits.h +71 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +6 -5
- data/third_party/abseil-cpp/absl/base/internal/{nullability_impl.h → nullability_deprecated.h} +45 -8
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +0 -9
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +3 -13
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +6 -6
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +8 -3
- data/third_party/abseil-cpp/absl/base/no_destructor.h +11 -32
- data/third_party/abseil-cpp/absl/base/nullability.h +84 -72
- data/third_party/abseil-cpp/absl/base/options.h +3 -80
- data/third_party/abseil-cpp/absl/base/policy_checks.h +7 -7
- data/third_party/abseil-cpp/absl/cleanup/cleanup.h +1 -3
- data/third_party/abseil-cpp/absl/cleanup/internal/cleanup.h +3 -4
- data/third_party/abseil-cpp/absl/container/btree_map.h +4 -2
- data/third_party/abseil-cpp/absl/container/btree_set.h +4 -2
- data/third_party/abseil-cpp/absl/container/fixed_array.h +7 -14
- data/third_party/abseil-cpp/absl/container/flat_hash_map.h +5 -0
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +6 -1
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +8 -5
- data/third_party/abseil-cpp/absl/container/internal/btree.h +132 -29
- data/third_party/abseil-cpp/absl/container/internal/btree_container.h +175 -71
- data/third_party/abseil-cpp/absl/container/internal/common.h +43 -0
- data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -2
- data/third_party/abseil-cpp/absl/container/internal/container_memory.h +9 -10
- data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +1 -8
- data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +0 -4
- data/third_party/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +527 -0
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +20 -4
- data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +31 -12
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +2 -7
- data/third_party/abseil-cpp/absl/container/internal/layout.h +26 -42
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +199 -68
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +1354 -183
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +881 -1424
- data/third_party/abseil-cpp/absl/container/internal/raw_hash_set_resize_impl.h +80 -0
- data/third_party/abseil-cpp/absl/crc/crc32c.cc +0 -4
- data/third_party/abseil-cpp/absl/crc/crc32c.h +7 -5
- data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +0 -22
- data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +45 -74
- data/third_party/abseil-cpp/absl/debugging/internal/addresses.h +57 -0
- data/third_party/abseil-cpp/absl/debugging/internal/decode_rust_punycode.cc +1 -1
- data/third_party/abseil-cpp/absl/debugging/internal/decode_rust_punycode.h +5 -5
- data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +8 -35
- data/third_party/abseil-cpp/absl/debugging/internal/demangle_rust.cc +16 -16
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +40 -37
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +16 -7
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +14 -5
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +10 -4
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +27 -16
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +13 -4
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +4 -3
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +15 -28
- data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +19 -9
- data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +144 -27
- data/third_party/abseil-cpp/absl/debugging/stacktrace.h +73 -5
- data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +19 -9
- data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +3 -2
- data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +25 -6
- data/third_party/abseil-cpp/absl/flags/commandlineflag.h +2 -2
- data/third_party/abseil-cpp/absl/flags/flag.h +4 -3
- data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.h +2 -2
- data/third_party/abseil-cpp/absl/flags/internal/flag.cc +2 -1
- data/third_party/abseil-cpp/absl/flags/internal/flag.h +7 -6
- data/third_party/abseil-cpp/absl/flags/internal/registry.h +4 -3
- data/third_party/abseil-cpp/absl/flags/reflection.cc +2 -3
- data/third_party/abseil-cpp/absl/functional/any_invocable.h +8 -10
- data/third_party/abseil-cpp/absl/functional/function_ref.h +2 -9
- data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +110 -226
- data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +10 -12
- data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +2 -5
- data/third_party/abseil-cpp/absl/hash/hash.h +18 -0
- data/third_party/abseil-cpp/absl/hash/internal/hash.cc +1 -5
- data/third_party/abseil-cpp/absl/hash/internal/hash.h +86 -61
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +25 -68
- data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.h +2 -6
- data/third_party/abseil-cpp/absl/hash/internal/weakly_mixed_integer.h +38 -0
- data/third_party/abseil-cpp/absl/log/check.h +2 -1
- data/third_party/abseil-cpp/absl/log/globals.h +4 -5
- data/third_party/abseil-cpp/absl/log/internal/append_truncated.h +28 -0
- data/third_party/abseil-cpp/absl/log/internal/check_op.cc +22 -22
- data/third_party/abseil-cpp/absl/log/internal/check_op.h +65 -62
- data/third_party/abseil-cpp/absl/log/internal/conditions.cc +5 -3
- data/third_party/abseil-cpp/absl/log/internal/conditions.h +7 -2
- data/third_party/abseil-cpp/absl/log/internal/log_message.cc +85 -43
- data/third_party/abseil-cpp/absl/log/internal/log_message.h +84 -59
- data/third_party/abseil-cpp/absl/log/internal/nullstream.h +1 -0
- data/third_party/abseil-cpp/absl/log/internal/proto.cc +3 -2
- data/third_party/abseil-cpp/absl/log/internal/proto.h +3 -3
- data/third_party/abseil-cpp/absl/log/internal/strip.h +4 -12
- data/third_party/abseil-cpp/absl/log/internal/vlog_config.h +8 -6
- data/third_party/abseil-cpp/absl/log/internal/voidify.h +10 -4
- data/third_party/abseil-cpp/absl/log/log.h +48 -35
- data/third_party/abseil-cpp/absl/log/log_sink_registry.h +2 -2
- data/third_party/abseil-cpp/absl/meta/type_traits.h +46 -175
- data/third_party/abseil-cpp/absl/numeric/bits.h +68 -2
- data/third_party/abseil-cpp/absl/numeric/int128.cc +0 -52
- data/third_party/abseil-cpp/absl/numeric/internal/bits.h +7 -3
- data/third_party/abseil-cpp/absl/profiling/internal/exponential_biased.cc +1 -1
- data/third_party/abseil-cpp/absl/random/bit_gen_ref.h +10 -11
- data/third_party/abseil-cpp/absl/random/distributions.h +6 -8
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +1 -1
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +5 -6
- data/third_party/abseil-cpp/absl/random/internal/{pool_urbg.cc → entropy_pool.cc} +22 -90
- data/third_party/abseil-cpp/absl/random/internal/entropy_pool.h +35 -0
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +5 -6
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +1 -1
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +20 -12
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +5 -5
- data/third_party/abseil-cpp/absl/random/random.h +88 -53
- data/third_party/abseil-cpp/absl/random/seed_sequences.cc +6 -2
- data/third_party/abseil-cpp/absl/status/internal/status_internal.cc +3 -4
- data/third_party/abseil-cpp/absl/status/internal/status_internal.h +3 -4
- data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +4 -3
- data/third_party/abseil-cpp/absl/status/status.cc +4 -8
- data/third_party/abseil-cpp/absl/status/status.h +8 -8
- data/third_party/abseil-cpp/absl/status/status_payload_printer.h +2 -2
- data/third_party/abseil-cpp/absl/status/statusor.cc +2 -2
- data/third_party/abseil-cpp/absl/status/statusor.h +6 -6
- data/third_party/abseil-cpp/absl/strings/ascii.cc +9 -9
- data/third_party/abseil-cpp/absl/strings/ascii.h +18 -18
- data/third_party/abseil-cpp/absl/strings/charconv.cc +21 -22
- data/third_party/abseil-cpp/absl/strings/charconv.h +5 -5
- data/third_party/abseil-cpp/absl/strings/cord.cc +54 -58
- data/third_party/abseil-cpp/absl/strings/cord.h +94 -83
- data/third_party/abseil-cpp/absl/strings/cord_analysis.cc +11 -11
- data/third_party/abseil-cpp/absl/strings/cord_analysis.h +3 -3
- data/third_party/abseil-cpp/absl/strings/escaping.cc +130 -149
- data/third_party/abseil-cpp/absl/strings/escaping.h +9 -10
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
- data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +6 -8
- data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +0 -4
- data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +0 -4
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +7 -63
- data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +1 -11
- data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +0 -22
- data/third_party/abseil-cpp/absl/strings/internal/str_format/output.cc +5 -3
- data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +4 -2
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +3 -3
- data/third_party/abseil-cpp/absl/strings/internal/string_constant.h +0 -5
- data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +96 -1
- data/third_party/abseil-cpp/absl/strings/internal/utf8.h +15 -1
- data/third_party/abseil-cpp/absl/strings/numbers.cc +53 -32
- data/third_party/abseil-cpp/absl/strings/numbers.h +87 -58
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +6 -7
- data/third_party/abseil-cpp/absl/strings/str_cat.h +32 -32
- data/third_party/abseil-cpp/absl/strings/str_format.h +18 -18
- data/third_party/abseil-cpp/absl/strings/str_replace.cc +3 -3
- data/third_party/abseil-cpp/absl/strings/str_replace.h +6 -6
- data/third_party/abseil-cpp/absl/strings/string_view.cc +4 -9
- data/third_party/abseil-cpp/absl/strings/string_view.h +27 -32
- data/third_party/abseil-cpp/absl/strings/strip.h +4 -4
- data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -4
- data/third_party/abseil-cpp/absl/strings/substitute.h +66 -64
- data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc +0 -5
- data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc +0 -4
- data/third_party/abseil-cpp/absl/synchronization/mutex.cc +1 -1
- data/third_party/abseil-cpp/absl/synchronization/mutex.h +97 -69
- data/third_party/abseil-cpp/absl/synchronization/notification.h +1 -1
- data/third_party/abseil-cpp/absl/time/civil_time.cc +1 -0
- data/third_party/abseil-cpp/absl/time/duration.cc +12 -7
- data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +1 -1
- data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +90 -111
- data/third_party/abseil-cpp/absl/time/time.h +20 -15
- data/third_party/abseil-cpp/absl/types/optional.h +7 -747
- data/third_party/abseil-cpp/absl/types/span.h +13 -11
- data/third_party/abseil-cpp/absl/types/variant.h +5 -784
- data/third_party/abseil-cpp/absl/utility/utility.h +10 -185
- metadata +72 -20
- data/src/core/lib/event_engine/forkable.cc +0 -105
- data/src/core/lib/event_engine/forkable.h +0 -67
- data/src/core/lib/iomgr/python_util.h +0 -46
- data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +0 -108
- data/third_party/abseil-cpp/absl/base/internal/invoke.h +0 -241
- data/third_party/abseil-cpp/absl/log/log_entry.cc +0 -41
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +0 -131
- data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +0 -66
- data/third_party/abseil-cpp/absl/types/bad_optional_access.h +0 -78
- data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +0 -82
- data/third_party/abseil-cpp/absl/types/bad_variant_access.h +0 -82
- data/third_party/abseil-cpp/absl/types/internal/optional.h +0 -352
- data/third_party/abseil-cpp/absl/types/internal/variant.h +0 -1622
@@ -59,126 +59,26 @@ static VALUE grpc_rb_cChannel = Qnil;
|
|
59
59
|
/* Used during the conversion of a hash to channel args during channel setup */
|
60
60
|
static VALUE grpc_rb_cChannelArgs;
|
61
61
|
|
62
|
-
typedef struct bg_watched_channel {
|
63
|
-
grpc_channel* channel;
|
64
|
-
// these fields must only be accessed under global_connection_polling_mu
|
65
|
-
struct bg_watched_channel* next;
|
66
|
-
int channel_destroyed;
|
67
|
-
int refcount;
|
68
|
-
} bg_watched_channel;
|
69
|
-
|
70
62
|
/* grpc_rb_channel wraps a grpc_channel. */
|
71
63
|
typedef struct grpc_rb_channel {
|
72
|
-
VALUE credentials;
|
73
|
-
grpc_channel_args args;
|
74
|
-
/* The actual channel (protected in a wrapper to tell when it's safe to
|
75
|
-
* destroy) */
|
76
|
-
bg_watched_channel* bg_wrapped;
|
77
|
-
} grpc_rb_channel;
|
78
|
-
|
79
|
-
typedef enum { CONTINUOUS_WATCH, WATCH_STATE_API } watch_state_op_type;
|
80
|
-
|
81
|
-
typedef struct watch_state_op {
|
82
|
-
watch_state_op_type op_type;
|
83
|
-
// from event.success
|
84
|
-
union {
|
85
|
-
struct {
|
86
|
-
int success;
|
87
|
-
// has been called back due to a cq next call
|
88
|
-
int called_back;
|
89
|
-
} api_callback_args;
|
90
|
-
struct {
|
91
|
-
bg_watched_channel* bg;
|
92
|
-
} continuous_watch_callback_args;
|
93
|
-
} op;
|
94
|
-
} watch_state_op;
|
95
|
-
|
96
|
-
static bg_watched_channel* bg_watched_channel_list_head = NULL;
|
97
|
-
|
98
|
-
static void grpc_rb_channel_try_register_connection_polling(
|
99
|
-
bg_watched_channel* bg);
|
100
|
-
static void* channel_init_try_register_connection_polling_without_gil(
|
101
|
-
void* arg);
|
102
|
-
|
103
|
-
typedef struct channel_init_try_register_stack {
|
104
64
|
grpc_channel* channel;
|
105
|
-
|
106
|
-
}
|
107
|
-
|
108
|
-
static grpc_completion_queue* g_channel_polling_cq;
|
109
|
-
static gpr_mu global_connection_polling_mu;
|
110
|
-
static gpr_cv global_connection_polling_cv;
|
111
|
-
static int g_abort_channel_polling = 0;
|
112
|
-
static gpr_once g_once_init = GPR_ONCE_INIT;
|
113
|
-
static VALUE g_channel_polling_thread = Qnil;
|
114
|
-
|
115
|
-
static int bg_watched_channel_list_lookup(bg_watched_channel* bg);
|
116
|
-
static bg_watched_channel* bg_watched_channel_list_create_and_add(
|
117
|
-
grpc_channel* channel);
|
118
|
-
static void bg_watched_channel_list_free_and_remove(bg_watched_channel* bg);
|
119
|
-
static void run_poll_channels_loop_unblocking_func(void* arg);
|
120
|
-
static void* run_poll_channels_loop_unblocking_func_wrapper(void* arg);
|
121
|
-
|
122
|
-
// Needs to be called under global_connection_polling_mu
|
123
|
-
static void grpc_rb_channel_watch_connection_state_op_complete(
|
124
|
-
watch_state_op* op, int success) {
|
125
|
-
GRPC_RUBY_ASSERT(!op->op.api_callback_args.called_back);
|
126
|
-
op->op.api_callback_args.called_back = 1;
|
127
|
-
op->op.api_callback_args.success = success;
|
128
|
-
// wake up the watch API call that's waiting on this op
|
129
|
-
gpr_cv_broadcast(&global_connection_polling_cv);
|
130
|
-
}
|
131
|
-
|
132
|
-
/* Avoids destroying a channel twice. */
|
133
|
-
static void grpc_rb_channel_safe_destroy(bg_watched_channel* bg) {
|
134
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
135
|
-
GRPC_RUBY_ASSERT(bg_watched_channel_list_lookup(bg));
|
136
|
-
if (!bg->channel_destroyed) {
|
137
|
-
grpc_channel_destroy(bg->channel);
|
138
|
-
bg->channel_destroyed = 1;
|
139
|
-
}
|
140
|
-
bg->refcount--;
|
141
|
-
if (bg->refcount == 0) {
|
142
|
-
bg_watched_channel_list_free_and_remove(bg);
|
143
|
-
}
|
144
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
145
|
-
}
|
146
|
-
|
147
|
-
static void* channel_safe_destroy_without_gil(void* arg) {
|
148
|
-
grpc_rb_channel_safe_destroy((bg_watched_channel*)arg);
|
149
|
-
return NULL;
|
150
|
-
}
|
65
|
+
VALUE mark;
|
66
|
+
} grpc_rb_channel;
|
151
67
|
|
152
|
-
static void
|
153
|
-
grpc_rb_channel* ch = NULL;
|
68
|
+
static void grpc_rb_channel_free(void* p) {
|
154
69
|
if (p == NULL) {
|
155
70
|
return;
|
156
71
|
};
|
157
|
-
|
158
|
-
if (
|
159
|
-
|
160
|
-
|
161
|
-
* and we can count on this thread to not be interrupted or
|
162
|
-
* yield the gil. */
|
163
|
-
grpc_rb_channel_safe_destroy(ch->bg_wrapped);
|
164
|
-
grpc_rb_channel_args_destroy(&ch->args);
|
72
|
+
grpc_rb_channel* wrapper = (grpc_rb_channel*)p;
|
73
|
+
if (wrapper->channel != NULL) {
|
74
|
+
grpc_channel_destroy(wrapper->channel);
|
75
|
+
wrapper->channel = NULL;
|
165
76
|
}
|
166
77
|
xfree(p);
|
167
78
|
}
|
168
79
|
|
169
|
-
/* Destroys Channel instances. */
|
170
|
-
static void grpc_rb_channel_free(void* p) { grpc_rb_channel_free_internal(p); }
|
171
|
-
|
172
|
-
/* Protects the mark object from GC */
|
173
80
|
static void grpc_rb_channel_mark(void* p) {
|
174
|
-
grpc_rb_channel*
|
175
|
-
if (p == NULL) {
|
176
|
-
return;
|
177
|
-
}
|
178
|
-
channel = (grpc_rb_channel*)p;
|
179
|
-
if (channel->credentials != Qnil) {
|
180
|
-
rb_gc_mark(channel->credentials);
|
181
|
-
}
|
81
|
+
rb_gc_mark(((grpc_rb_channel*)p)->mark);
|
182
82
|
}
|
183
83
|
|
184
84
|
static rb_data_type_t grpc_channel_data_type = {"grpc_channel",
|
@@ -197,9 +97,8 @@ static rb_data_type_t grpc_channel_data_type = {"grpc_channel",
|
|
197
97
|
static VALUE grpc_rb_channel_alloc(VALUE cls) {
|
198
98
|
grpc_ruby_init();
|
199
99
|
grpc_rb_channel* wrapper = ALLOC(grpc_rb_channel);
|
200
|
-
wrapper->
|
201
|
-
wrapper->
|
202
|
-
MEMZERO(&wrapper->args, grpc_channel_args, 1);
|
100
|
+
wrapper->channel = NULL;
|
101
|
+
wrapper->mark = Qnil;
|
203
102
|
return TypedData_Wrap_Struct(cls, &grpc_channel_data_type, wrapper);
|
204
103
|
}
|
205
104
|
|
@@ -212,53 +111,46 @@ static VALUE grpc_rb_channel_alloc(VALUE cls) {
|
|
212
111
|
|
213
112
|
Creates channel instances. */
|
214
113
|
static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
|
215
|
-
VALUE
|
216
|
-
VALUE
|
114
|
+
VALUE rb_channel_args = Qnil;
|
115
|
+
VALUE rb_credentials = Qnil;
|
217
116
|
VALUE target = Qnil;
|
218
117
|
grpc_rb_channel* wrapper = NULL;
|
219
|
-
grpc_channel* ch = NULL;
|
220
|
-
grpc_channel_credentials* creds = NULL;
|
221
118
|
char* target_chars = NULL;
|
222
|
-
channel_init_try_register_stack stack;
|
223
|
-
|
224
119
|
grpc_ruby_fork_guard();
|
225
120
|
/* "3" == 3 mandatory args */
|
226
|
-
rb_scan_args(argc, argv, "3", &target, &
|
227
|
-
|
121
|
+
rb_scan_args(argc, argv, "3", &target, &rb_channel_args, &rb_credentials);
|
228
122
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
229
123
|
target_chars = StringValueCStr(target);
|
230
|
-
|
231
|
-
|
232
|
-
|
124
|
+
grpc_channel_args channel_args;
|
125
|
+
memset(&channel_args, 0, sizeof(channel_args));
|
126
|
+
grpc_rb_hash_convert_to_channel_args(rb_channel_args, &channel_args);
|
127
|
+
if (TYPE(rb_credentials) == T_SYMBOL) {
|
128
|
+
if (id_insecure_channel != SYM2ID(rb_credentials)) {
|
233
129
|
rb_raise(rb_eTypeError,
|
234
130
|
"bad creds symbol, want :this_channel_is_insecure");
|
235
131
|
return Qnil;
|
236
132
|
}
|
237
133
|
grpc_channel_credentials* insecure_creds =
|
238
134
|
grpc_insecure_credentials_create();
|
239
|
-
|
135
|
+
wrapper->channel =
|
136
|
+
grpc_channel_create(target_chars, insecure_creds, &channel_args);
|
240
137
|
grpc_channel_credentials_release(insecure_creds);
|
241
138
|
} else {
|
242
|
-
|
243
|
-
if (grpc_rb_is_channel_credentials(
|
244
|
-
creds = grpc_rb_get_wrapped_channel_credentials(
|
245
|
-
} else if (grpc_rb_is_xds_channel_credentials(
|
246
|
-
creds = grpc_rb_get_wrapped_xds_channel_credentials(
|
139
|
+
grpc_channel_credentials* creds;
|
140
|
+
if (grpc_rb_is_channel_credentials(rb_credentials)) {
|
141
|
+
creds = grpc_rb_get_wrapped_channel_credentials(rb_credentials);
|
142
|
+
} else if (grpc_rb_is_xds_channel_credentials(rb_credentials)) {
|
143
|
+
creds = grpc_rb_get_wrapped_xds_channel_credentials(rb_credentials);
|
247
144
|
} else {
|
248
145
|
rb_raise(rb_eTypeError,
|
249
146
|
"bad creds, want ChannelCredentials or XdsChannelCredentials");
|
250
147
|
return Qnil;
|
251
148
|
}
|
252
|
-
|
149
|
+
wrapper->channel = grpc_channel_create(target_chars, creds, &channel_args);
|
150
|
+
wrapper->mark = rb_credentials;
|
253
151
|
}
|
254
|
-
|
255
|
-
|
256
|
-
stack.channel = ch;
|
257
|
-
stack.wrapper = wrapper;
|
258
|
-
rb_thread_call_without_gvl(
|
259
|
-
channel_init_try_register_connection_polling_without_gil, &stack, NULL,
|
260
|
-
NULL);
|
261
|
-
if (ch == NULL) {
|
152
|
+
grpc_rb_channel_args_destroy(&channel_args);
|
153
|
+
if (wrapper->channel == NULL) {
|
262
154
|
rb_raise(rb_eRuntimeError, "could not create an rpc channel to target:%s",
|
263
155
|
target_chars);
|
264
156
|
return Qnil;
|
@@ -268,27 +160,6 @@ static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
|
|
268
160
|
return self;
|
269
161
|
}
|
270
162
|
|
271
|
-
typedef struct get_state_stack {
|
272
|
-
bg_watched_channel* bg;
|
273
|
-
int try_to_connect;
|
274
|
-
int out;
|
275
|
-
} get_state_stack;
|
276
|
-
|
277
|
-
static void* get_state_without_gil(void* arg) {
|
278
|
-
get_state_stack* stack = (get_state_stack*)arg;
|
279
|
-
|
280
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
281
|
-
if (stack->bg->channel_destroyed) {
|
282
|
-
stack->out = GRPC_CHANNEL_SHUTDOWN;
|
283
|
-
} else {
|
284
|
-
stack->out = grpc_channel_check_connectivity_state(stack->bg->channel,
|
285
|
-
stack->try_to_connect);
|
286
|
-
}
|
287
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
288
|
-
|
289
|
-
return NULL;
|
290
|
-
}
|
291
|
-
|
292
163
|
/*
|
293
164
|
call-seq:
|
294
165
|
ch.connectivity_state -> state
|
@@ -302,68 +173,17 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE* argv,
|
|
302
173
|
VALUE self) {
|
303
174
|
VALUE try_to_connect_param = Qfalse;
|
304
175
|
grpc_rb_channel* wrapper = NULL;
|
305
|
-
get_state_stack stack;
|
306
|
-
|
307
176
|
/* "01" == 0 mandatory args, 1 (try_to_connect) is optional */
|
308
177
|
rb_scan_args(argc, argv, "01", &try_to_connect_param);
|
309
|
-
|
310
178
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
311
|
-
if (wrapper->
|
179
|
+
if (wrapper->channel == NULL) {
|
312
180
|
rb_raise(rb_eRuntimeError, "closed!");
|
313
181
|
return Qnil;
|
314
182
|
}
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
return LONG2NUM(stack.out);
|
321
|
-
}
|
322
|
-
|
323
|
-
typedef struct watch_state_stack {
|
324
|
-
bg_watched_channel* bg_wrapped;
|
325
|
-
gpr_timespec deadline;
|
326
|
-
int last_state;
|
327
|
-
} watch_state_stack;
|
328
|
-
|
329
|
-
static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
|
330
|
-
watch_state_stack* stack = (watch_state_stack*)arg;
|
331
|
-
watch_state_op* op = NULL;
|
332
|
-
void* success = (void*)0;
|
333
|
-
|
334
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
335
|
-
// it's unsafe to do a "watch" after "channel polling abort" because the cq
|
336
|
-
// has been shut down.
|
337
|
-
if (g_abort_channel_polling || stack->bg_wrapped->channel_destroyed) {
|
338
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
339
|
-
return (void*)0;
|
340
|
-
}
|
341
|
-
op = gpr_zalloc(sizeof(watch_state_op));
|
342
|
-
op->op_type = WATCH_STATE_API;
|
343
|
-
grpc_channel_watch_connectivity_state(stack->bg_wrapped->channel,
|
344
|
-
stack->last_state, stack->deadline,
|
345
|
-
g_channel_polling_cq, op);
|
346
|
-
|
347
|
-
while (!op->op.api_callback_args.called_back) {
|
348
|
-
gpr_cv_wait(&global_connection_polling_cv, &global_connection_polling_mu,
|
349
|
-
gpr_inf_future(GPR_CLOCK_REALTIME));
|
350
|
-
}
|
351
|
-
if (op->op.api_callback_args.success) {
|
352
|
-
success = (void*)1;
|
353
|
-
}
|
354
|
-
gpr_free(op);
|
355
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
356
|
-
|
357
|
-
return success;
|
358
|
-
}
|
359
|
-
static void wait_for_watch_state_op_complete_unblocking_func(void* arg) {
|
360
|
-
bg_watched_channel* bg = (bg_watched_channel*)arg;
|
361
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
362
|
-
if (!bg->channel_destroyed) {
|
363
|
-
grpc_channel_destroy(bg->channel);
|
364
|
-
bg->channel_destroyed = 1;
|
365
|
-
}
|
366
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
183
|
+
bool try_to_connect = RTEST(try_to_connect_param) ? true : false;
|
184
|
+
int state =
|
185
|
+
grpc_channel_check_connectivity_state(wrapper->channel, try_to_connect);
|
186
|
+
return LONG2NUM(state);
|
367
187
|
}
|
368
188
|
|
369
189
|
/* Wait until the channel's connectivity state becomes different from
|
@@ -375,79 +195,46 @@ static void wait_for_watch_state_op_complete_unblocking_func(void* arg) {
|
|
375
195
|
* */
|
376
196
|
static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
|
377
197
|
VALUE last_state,
|
378
|
-
VALUE
|
198
|
+
VALUE rb_deadline) {
|
379
199
|
grpc_rb_channel* wrapper = NULL;
|
380
|
-
watch_state_stack stack;
|
381
|
-
void* op_success = 0;
|
382
|
-
|
383
200
|
grpc_ruby_fork_guard();
|
384
201
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
385
|
-
|
386
|
-
if (wrapper->bg_wrapped == NULL) {
|
202
|
+
if (wrapper->channel == NULL) {
|
387
203
|
rb_raise(rb_eRuntimeError, "closed!");
|
388
204
|
return Qnil;
|
389
205
|
}
|
390
|
-
|
391
206
|
if (!FIXNUM_P(last_state)) {
|
392
207
|
rb_raise(
|
393
208
|
rb_eTypeError,
|
394
209
|
"bad type for last_state. want a GRPC::Core::ChannelState constant");
|
395
210
|
return Qnil;
|
396
211
|
}
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
if (
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
grpc_channel* channel;
|
424
|
-
if (wrapper->credentials == Qnil) {
|
425
|
-
grpc_channel_credentials* insecure_creds =
|
426
|
-
grpc_insecure_credentials_create();
|
427
|
-
channel = grpc_channel_create(target_str, insecure_creds, &wrapper->args);
|
428
|
-
grpc_channel_credentials_release(insecure_creds);
|
429
|
-
} else {
|
430
|
-
grpc_channel_credentials* creds;
|
431
|
-
if (grpc_rb_is_channel_credentials(wrapper->credentials)) {
|
432
|
-
creds = grpc_rb_get_wrapped_channel_credentials(wrapper->credentials);
|
433
|
-
} else if (grpc_rb_is_xds_channel_credentials(wrapper->credentials)) {
|
434
|
-
creds =
|
435
|
-
grpc_rb_get_wrapped_xds_channel_credentials(wrapper->credentials);
|
436
|
-
} else {
|
437
|
-
rb_raise(rb_eTypeError,
|
438
|
-
"failed to re-create channel after fork: bad creds, want "
|
439
|
-
"ChannelCredentials or XdsChannelCredentials");
|
440
|
-
return;
|
441
|
-
}
|
442
|
-
channel = grpc_channel_create(target_str, creds, &wrapper->args);
|
443
|
-
}
|
444
|
-
// re-register with channel polling thread
|
445
|
-
channel_init_try_register_stack stack;
|
446
|
-
stack.channel = channel;
|
447
|
-
stack.wrapper = wrapper;
|
448
|
-
rb_thread_call_without_gvl(
|
449
|
-
channel_init_try_register_connection_polling_without_gil, &stack, NULL,
|
450
|
-
NULL);
|
212
|
+
const void* tag = &wrapper;
|
213
|
+
gpr_timespec deadline = grpc_rb_time_timeval(rb_deadline, 0);
|
214
|
+
grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(NULL);
|
215
|
+
grpc_channel_watch_connectivity_state(wrapper->channel, NUM2LONG(last_state),
|
216
|
+
deadline, cq, tag);
|
217
|
+
grpc_event event =
|
218
|
+
rb_completion_queue_pluck(cq, tag, gpr_inf_future(GPR_CLOCK_REALTIME),
|
219
|
+
"grpc_channel_watch_connectivity_state");
|
220
|
+
// TODO(apolcyn): this CQ would leak if the thread were killed
|
221
|
+
// while polling queue_pluck, e.g. with Thread#kill. One fix may be
|
222
|
+
// to make this CQ owned by the channel object. Another fix could be to
|
223
|
+
// busy-poll watch_connectivity_state with a short deadline, without
|
224
|
+
// the GIL, rather than just polling CQ pluck, and destroy the CQ
|
225
|
+
// before exitting the no-GIL block.
|
226
|
+
grpc_completion_queue_shutdown(cq);
|
227
|
+
grpc_rb_completion_queue_destroy(cq);
|
228
|
+
if (event.type == GRPC_OP_COMPLETE) {
|
229
|
+
return Qtrue;
|
230
|
+
} else if (event.type == GRPC_QUEUE_TIMEOUT) {
|
231
|
+
return Qfalse;
|
232
|
+
} else {
|
233
|
+
grpc_absl_log_int(
|
234
|
+
GPR_ERROR,
|
235
|
+
"GRPC_RUBY: unexpected grpc_channel_watch_connectivity_state result:",
|
236
|
+
event.type);
|
237
|
+
return Qfalse;
|
451
238
|
}
|
452
239
|
}
|
453
240
|
|
@@ -466,7 +253,6 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
|
|
466
253
|
grpc_slice host_slice;
|
467
254
|
grpc_slice* host_slice_ptr = NULL;
|
468
255
|
char* tmp_str = NULL;
|
469
|
-
|
470
256
|
grpc_ruby_fork_guard();
|
471
257
|
if (host != Qnil) {
|
472
258
|
host_slice =
|
@@ -479,40 +265,29 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
|
|
479
265
|
if (parent != Qnil) {
|
480
266
|
parent_call = grpc_rb_get_wrapped_call(parent);
|
481
267
|
}
|
482
|
-
|
483
268
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
484
|
-
if (wrapper->
|
269
|
+
if (wrapper->channel == NULL) {
|
485
270
|
rb_raise(rb_eRuntimeError, "closed!");
|
486
271
|
return Qnil;
|
487
272
|
}
|
488
|
-
// TODO(apolcyn): only do this check if fork support is enabled
|
489
|
-
rb_mutex_lock(rb_ivar_get(self, id_channel_recreation_mu));
|
490
|
-
grpc_rb_channel_maybe_recreate_channel_after_fork(
|
491
|
-
wrapper, rb_ivar_get(self, id_target));
|
492
|
-
rb_mutex_unlock(rb_ivar_get(self, id_channel_recreation_mu));
|
493
|
-
|
494
273
|
cq = grpc_completion_queue_create_for_pluck(NULL);
|
495
274
|
method_slice =
|
496
275
|
grpc_slice_from_copied_buffer(RSTRING_PTR(method), RSTRING_LEN(method));
|
497
|
-
call = grpc_channel_create_call(wrapper->
|
498
|
-
|
276
|
+
call = grpc_channel_create_call(wrapper->channel, parent_call, flags, cq,
|
277
|
+
method_slice, host_slice_ptr,
|
499
278
|
grpc_rb_time_timeval(deadline,
|
500
279
|
/* absolute time */ 0),
|
501
280
|
NULL);
|
502
|
-
|
503
281
|
if (call == NULL) {
|
504
282
|
tmp_str = grpc_slice_to_c_string(method_slice);
|
505
283
|
rb_raise(rb_eRuntimeError, "cannot create call with method %s", tmp_str);
|
506
284
|
return Qnil;
|
507
285
|
}
|
508
|
-
|
509
286
|
grpc_slice_unref(method_slice);
|
510
287
|
if (host_slice_ptr != NULL) {
|
511
288
|
grpc_slice_unref(host_slice);
|
512
289
|
}
|
513
|
-
|
514
290
|
res = grpc_rb_wrap_call(call, cq);
|
515
|
-
|
516
291
|
/* Make this channel an instance attribute of the call so that it is not GCed
|
517
292
|
* before the call. */
|
518
293
|
rb_ivar_set(res, id_channel, self);
|
@@ -524,14 +299,11 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
|
|
524
299
|
* this */
|
525
300
|
static VALUE grpc_rb_channel_destroy(VALUE self) {
|
526
301
|
grpc_rb_channel* wrapper = NULL;
|
527
|
-
|
528
302
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
529
|
-
if (wrapper->
|
530
|
-
|
531
|
-
|
532
|
-
wrapper->bg_wrapped = NULL;
|
303
|
+
if (wrapper->channel != NULL) {
|
304
|
+
grpc_channel_destroy(wrapper->channel);
|
305
|
+
wrapper->channel = NULL;
|
533
306
|
}
|
534
|
-
|
535
307
|
return Qnil;
|
536
308
|
}
|
537
309
|
|
@@ -540,271 +312,13 @@ static VALUE grpc_rb_channel_get_target(VALUE self) {
|
|
540
312
|
grpc_rb_channel* wrapper = NULL;
|
541
313
|
VALUE res = Qnil;
|
542
314
|
char* target = NULL;
|
543
|
-
|
544
315
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
545
|
-
target = grpc_channel_get_target(wrapper->
|
316
|
+
target = grpc_channel_get_target(wrapper->channel);
|
546
317
|
res = rb_str_new2(target);
|
547
318
|
gpr_free(target);
|
548
|
-
|
549
319
|
return res;
|
550
320
|
}
|
551
321
|
|
552
|
-
/* Needs to be called under global_connection_polling_mu */
|
553
|
-
static int bg_watched_channel_list_lookup(bg_watched_channel* target) {
|
554
|
-
bg_watched_channel* cur = bg_watched_channel_list_head;
|
555
|
-
|
556
|
-
while (cur != NULL) {
|
557
|
-
if (cur == target) {
|
558
|
-
return 1;
|
559
|
-
}
|
560
|
-
cur = cur->next;
|
561
|
-
}
|
562
|
-
|
563
|
-
return 0;
|
564
|
-
}
|
565
|
-
|
566
|
-
/* Needs to be called under global_connection_polling_mu */
|
567
|
-
static bg_watched_channel* bg_watched_channel_list_create_and_add(
|
568
|
-
grpc_channel* channel) {
|
569
|
-
bg_watched_channel* watched = gpr_zalloc(sizeof(bg_watched_channel));
|
570
|
-
|
571
|
-
watched->channel = channel;
|
572
|
-
watched->next = bg_watched_channel_list_head;
|
573
|
-
watched->refcount = 1;
|
574
|
-
bg_watched_channel_list_head = watched;
|
575
|
-
return watched;
|
576
|
-
}
|
577
|
-
|
578
|
-
/* Needs to be called under global_connection_polling_mu */
|
579
|
-
static void bg_watched_channel_list_free_and_remove(
|
580
|
-
bg_watched_channel* target) {
|
581
|
-
bg_watched_channel* bg = NULL;
|
582
|
-
|
583
|
-
GRPC_RUBY_ASSERT(bg_watched_channel_list_lookup(target));
|
584
|
-
GRPC_RUBY_ASSERT(target->channel_destroyed && target->refcount == 0);
|
585
|
-
if (bg_watched_channel_list_head == target) {
|
586
|
-
bg_watched_channel_list_head = target->next;
|
587
|
-
gpr_free(target);
|
588
|
-
return;
|
589
|
-
}
|
590
|
-
bg = bg_watched_channel_list_head;
|
591
|
-
while (bg != NULL && bg->next != NULL) {
|
592
|
-
if (bg->next == target) {
|
593
|
-
bg->next = bg->next->next;
|
594
|
-
gpr_free(target);
|
595
|
-
return;
|
596
|
-
}
|
597
|
-
bg = bg->next;
|
598
|
-
}
|
599
|
-
GRPC_RUBY_ASSERT(0);
|
600
|
-
}
|
601
|
-
|
602
|
-
/* Initialize a grpc_rb_channel's "protected grpc_channel" and try to push
|
603
|
-
* it onto the background thread for constant watches. */
|
604
|
-
static void* channel_init_try_register_connection_polling_without_gil(
|
605
|
-
void* arg) {
|
606
|
-
channel_init_try_register_stack* stack =
|
607
|
-
(channel_init_try_register_stack*)arg;
|
608
|
-
|
609
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
610
|
-
stack->wrapper->bg_wrapped =
|
611
|
-
bg_watched_channel_list_create_and_add(stack->channel);
|
612
|
-
grpc_rb_channel_try_register_connection_polling(stack->wrapper->bg_wrapped);
|
613
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
614
|
-
return NULL;
|
615
|
-
}
|
616
|
-
|
617
|
-
// Needs to be called under global_connection_poolling_mu
|
618
|
-
static void grpc_rb_channel_try_register_connection_polling(
|
619
|
-
bg_watched_channel* bg) {
|
620
|
-
grpc_connectivity_state conn_state;
|
621
|
-
watch_state_op* op = NULL;
|
622
|
-
if (bg->refcount == 0) {
|
623
|
-
GRPC_RUBY_ASSERT(bg->channel_destroyed);
|
624
|
-
bg_watched_channel_list_free_and_remove(bg);
|
625
|
-
return;
|
626
|
-
}
|
627
|
-
GRPC_RUBY_ASSERT(bg->refcount == 1);
|
628
|
-
if (bg->channel_destroyed || g_abort_channel_polling) {
|
629
|
-
return;
|
630
|
-
}
|
631
|
-
conn_state = grpc_channel_check_connectivity_state(bg->channel, 0);
|
632
|
-
if (conn_state == GRPC_CHANNEL_SHUTDOWN) {
|
633
|
-
return;
|
634
|
-
}
|
635
|
-
GRPC_RUBY_ASSERT(bg_watched_channel_list_lookup(bg));
|
636
|
-
// prevent bg from being free'd by GC while background thread is watching it
|
637
|
-
bg->refcount++;
|
638
|
-
op = gpr_zalloc(sizeof(watch_state_op));
|
639
|
-
op->op_type = CONTINUOUS_WATCH;
|
640
|
-
op->op.continuous_watch_callback_args.bg = bg;
|
641
|
-
grpc_channel_watch_connectivity_state(bg->channel, conn_state,
|
642
|
-
gpr_inf_future(GPR_CLOCK_REALTIME),
|
643
|
-
g_channel_polling_cq, op);
|
644
|
-
}
|
645
|
-
|
646
|
-
// Note this loop breaks out with a single call of
|
647
|
-
// "run_poll_channels_loop_no_gil".
|
648
|
-
// This assumes that a ruby call the unblocking func
|
649
|
-
// indicates process shutdown.
|
650
|
-
// In the worst case, this stops polling channel connectivity
|
651
|
-
// early and falls back to current behavior.
|
652
|
-
static void* run_poll_channels_loop_no_gil(void* arg) {
|
653
|
-
grpc_event event;
|
654
|
-
watch_state_op* op = NULL;
|
655
|
-
bg_watched_channel* bg = NULL;
|
656
|
-
(void)arg;
|
657
|
-
grpc_absl_log(GPR_DEBUG, "GRPC_RUBY: run_poll_channels_loop_no_gil - begin");
|
658
|
-
|
659
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
660
|
-
gpr_cv_broadcast(&global_connection_polling_cv);
|
661
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
662
|
-
|
663
|
-
for (;;) {
|
664
|
-
event = grpc_completion_queue_next(
|
665
|
-
g_channel_polling_cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
|
666
|
-
if (event.type == GRPC_QUEUE_SHUTDOWN) {
|
667
|
-
break;
|
668
|
-
}
|
669
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
670
|
-
if (event.type == GRPC_OP_COMPLETE) {
|
671
|
-
op = (watch_state_op*)event.tag;
|
672
|
-
if (op->op_type == CONTINUOUS_WATCH) {
|
673
|
-
bg = (bg_watched_channel*)op->op.continuous_watch_callback_args.bg;
|
674
|
-
bg->refcount--;
|
675
|
-
grpc_rb_channel_try_register_connection_polling(bg);
|
676
|
-
gpr_free(op);
|
677
|
-
} else if (op->op_type == WATCH_STATE_API) {
|
678
|
-
grpc_rb_channel_watch_connection_state_op_complete(
|
679
|
-
(watch_state_op*)event.tag, event.success);
|
680
|
-
} else {
|
681
|
-
GRPC_RUBY_ASSERT(0);
|
682
|
-
}
|
683
|
-
}
|
684
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
685
|
-
}
|
686
|
-
grpc_completion_queue_destroy(g_channel_polling_cq);
|
687
|
-
grpc_absl_log(
|
688
|
-
GPR_DEBUG,
|
689
|
-
"GRPC_RUBY: run_poll_channels_loop_no_gil - exit connection polling "
|
690
|
-
"loop");
|
691
|
-
return NULL;
|
692
|
-
}
|
693
|
-
|
694
|
-
static void run_poll_channels_loop_unblocking_func(void* arg) {
|
695
|
-
run_poll_channels_loop_unblocking_func_wrapper(arg);
|
696
|
-
}
|
697
|
-
|
698
|
-
// Notify the channel polling loop to cleanup and shutdown.
|
699
|
-
static void* run_poll_channels_loop_unblocking_func_wrapper(void* arg) {
|
700
|
-
bg_watched_channel* bg = NULL;
|
701
|
-
(void)arg;
|
702
|
-
|
703
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
704
|
-
grpc_absl_log(
|
705
|
-
GPR_DEBUG,
|
706
|
-
"GRPC_RUBY: run_poll_channels_loop_unblocking_func - begin aborting "
|
707
|
-
"connection polling");
|
708
|
-
// early out after first time through
|
709
|
-
if (g_abort_channel_polling) {
|
710
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
711
|
-
return NULL;
|
712
|
-
}
|
713
|
-
g_abort_channel_polling = 1;
|
714
|
-
|
715
|
-
// force pending watches to end by switching to shutdown state
|
716
|
-
bg = bg_watched_channel_list_head;
|
717
|
-
while (bg != NULL) {
|
718
|
-
if (!bg->channel_destroyed) {
|
719
|
-
grpc_channel_destroy(bg->channel);
|
720
|
-
bg->channel_destroyed = 1;
|
721
|
-
}
|
722
|
-
bg = bg->next;
|
723
|
-
}
|
724
|
-
|
725
|
-
grpc_absl_log_int(
|
726
|
-
GPR_DEBUG,
|
727
|
-
"GRPC_RUBY: cq shutdown on global polling cq. pid: ", getpid());
|
728
|
-
grpc_completion_queue_shutdown(g_channel_polling_cq);
|
729
|
-
gpr_cv_broadcast(&global_connection_polling_cv);
|
730
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
731
|
-
grpc_absl_log(
|
732
|
-
GPR_DEBUG,
|
733
|
-
"GRPC_RUBY: run_poll_channels_loop_unblocking_func - end aborting "
|
734
|
-
"connection polling");
|
735
|
-
return NULL;
|
736
|
-
}
|
737
|
-
|
738
|
-
// Poll channel connectivity states in background thread without the GIL.
|
739
|
-
static VALUE run_poll_channels_loop(void* arg) {
|
740
|
-
(void)arg;
|
741
|
-
grpc_absl_log(
|
742
|
-
GPR_DEBUG,
|
743
|
-
"GRPC_RUBY: run_poll_channels_loop - create connection polling thread");
|
744
|
-
rb_thread_call_without_gvl(run_poll_channels_loop_no_gil, NULL,
|
745
|
-
run_poll_channels_loop_unblocking_func, NULL);
|
746
|
-
return Qnil;
|
747
|
-
}
|
748
|
-
|
749
|
-
static void* set_abort_channel_polling_without_gil(void* arg) {
|
750
|
-
(void)arg;
|
751
|
-
gpr_mu_lock(&global_connection_polling_mu);
|
752
|
-
g_abort_channel_polling = 1;
|
753
|
-
gpr_cv_broadcast(&global_connection_polling_cv);
|
754
|
-
gpr_mu_unlock(&global_connection_polling_mu);
|
755
|
-
return NULL;
|
756
|
-
}
|
757
|
-
|
758
|
-
static void do_basic_init() {
|
759
|
-
gpr_mu_init(&global_connection_polling_mu);
|
760
|
-
gpr_cv_init(&global_connection_polling_cv);
|
761
|
-
}
|
762
|
-
|
763
|
-
/* Temporary fix for
|
764
|
-
* https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues/899.
|
765
|
-
* Transports in idle channels can get destroyed. Normally c-core re-connects,
|
766
|
-
* but in grpc-ruby core never gets a thread until an RPC is made, because ruby
|
767
|
-
* only calls c-core's "completion_queu_pluck" API.
|
768
|
-
* This uses a global background thread that calls
|
769
|
-
* "completion_queue_next" on registered "watch_channel_connectivity_state"
|
770
|
-
* calls - so that c-core can reconnect if needed, when there aren't any RPC's.
|
771
|
-
* TODO(apolcyn) remove this when core handles new RPCs on dead connections.
|
772
|
-
*/
|
773
|
-
void grpc_rb_channel_polling_thread_start() {
|
774
|
-
gpr_once_init(&g_once_init, do_basic_init);
|
775
|
-
GRPC_RUBY_ASSERT(!RTEST(g_channel_polling_thread));
|
776
|
-
GRPC_RUBY_ASSERT(!g_abort_channel_polling);
|
777
|
-
GRPC_RUBY_ASSERT(g_channel_polling_cq == NULL);
|
778
|
-
|
779
|
-
g_channel_polling_cq = grpc_completion_queue_create_for_next(NULL);
|
780
|
-
g_channel_polling_thread = rb_thread_create(run_poll_channels_loop, NULL);
|
781
|
-
|
782
|
-
if (!RTEST(g_channel_polling_thread)) {
|
783
|
-
grpc_absl_log(GPR_ERROR,
|
784
|
-
"GRPC_RUBY: failed to spawn channel polling thread");
|
785
|
-
rb_thread_call_without_gvl(set_abort_channel_polling_without_gil, NULL,
|
786
|
-
NULL, NULL);
|
787
|
-
return;
|
788
|
-
}
|
789
|
-
}
|
790
|
-
|
791
|
-
void grpc_rb_channel_polling_thread_stop() {
|
792
|
-
if (!RTEST(g_channel_polling_thread)) {
|
793
|
-
grpc_absl_log(
|
794
|
-
GPR_ERROR,
|
795
|
-
"GRPC_RUBY: channel polling thread stop: thread was not started");
|
796
|
-
return;
|
797
|
-
}
|
798
|
-
rb_thread_call_without_gvl(run_poll_channels_loop_unblocking_func_wrapper,
|
799
|
-
NULL, NULL, NULL);
|
800
|
-
rb_funcall(g_channel_polling_thread, rb_intern("join"), 0);
|
801
|
-
// state associated with the channel polling thread is destroyed, reset so
|
802
|
-
// we can start again later
|
803
|
-
g_channel_polling_thread = Qnil;
|
804
|
-
g_abort_channel_polling = false;
|
805
|
-
g_channel_polling_cq = NULL;
|
806
|
-
}
|
807
|
-
|
808
322
|
static void Init_grpc_propagate_masks() {
|
809
323
|
/* Constants representing call propagation masks in grpc.h */
|
810
324
|
VALUE grpc_rb_mPropagateMasks =
|
@@ -838,7 +352,6 @@ static void Init_grpc_connectivity_states() {
|
|
838
352
|
}
|
839
353
|
|
840
354
|
void Init_grpc_channel() {
|
841
|
-
rb_global_variable(&g_channel_polling_thread);
|
842
355
|
grpc_rb_cChannelArgs = rb_define_class("TmpChannelArgs", rb_cObject);
|
843
356
|
rb_undef_alloc_func(grpc_rb_cChannelArgs);
|
844
357
|
grpc_rb_cChannel =
|
@@ -883,5 +396,5 @@ void Init_grpc_channel() {
|
|
883
396
|
grpc_channel* grpc_rb_get_wrapped_channel(VALUE v) {
|
884
397
|
grpc_rb_channel* wrapper = NULL;
|
885
398
|
TypedData_Get_Struct(v, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
886
|
-
return wrapper->
|
399
|
+
return wrapper->channel;
|
887
400
|
}
|