wearefair-grpc 1.3.1.pre.a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +1 -0
- data/Makefile +19484 -0
- data/etc/roots.pem +5288 -0
- data/include/grpc/byte_buffer.h +102 -0
- data/include/grpc/byte_buffer_reader.h +39 -0
- data/include/grpc/census.h +484 -0
- data/include/grpc/compression.h +85 -0
- data/include/grpc/grpc.h +509 -0
- data/include/grpc/grpc_cronet.h +51 -0
- data/include/grpc/grpc_posix.h +81 -0
- data/include/grpc/grpc_security.h +390 -0
- data/include/grpc/grpc_security_constants.h +114 -0
- data/include/grpc/impl/codegen/atm.h +100 -0
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +97 -0
- data/include/grpc/impl/codegen/atm_gcc_sync.h +97 -0
- data/include/grpc/impl/codegen/atm_windows.h +140 -0
- data/include/grpc/impl/codegen/byte_buffer_reader.h +57 -0
- data/include/grpc/impl/codegen/compression_types.h +122 -0
- data/include/grpc/impl/codegen/connectivity_state.h +61 -0
- data/include/grpc/impl/codegen/exec_ctx_fwd.h +41 -0
- data/include/grpc/impl/codegen/gpr_slice.h +84 -0
- data/include/grpc/impl/codegen/gpr_types.h +75 -0
- data/include/grpc/impl/codegen/grpc_types.h +550 -0
- data/include/grpc/impl/codegen/port_platform.h +421 -0
- data/include/grpc/impl/codegen/propagation_bits.h +67 -0
- data/include/grpc/impl/codegen/slice.h +157 -0
- data/include/grpc/impl/codegen/status.h +163 -0
- data/include/grpc/impl/codegen/sync.h +75 -0
- data/include/grpc/impl/codegen/sync_generic.h +55 -0
- data/include/grpc/impl/codegen/sync_posix.h +47 -0
- data/include/grpc/impl/codegen/sync_windows.h +49 -0
- data/include/grpc/load_reporting.h +63 -0
- data/include/grpc/module.modulemap +13 -0
- data/include/grpc/slice.h +168 -0
- data/include/grpc/slice_buffer.h +94 -0
- data/include/grpc/status.h +39 -0
- data/include/grpc/support/alloc.h +82 -0
- data/include/grpc/support/atm.h +39 -0
- data/include/grpc/support/atm_gcc_atomic.h +39 -0
- data/include/grpc/support/atm_gcc_sync.h +39 -0
- data/include/grpc/support/atm_windows.h +39 -0
- data/include/grpc/support/avl.h +97 -0
- data/include/grpc/support/cmdline.h +103 -0
- data/include/grpc/support/cpu.h +59 -0
- data/include/grpc/support/histogram.h +79 -0
- data/include/grpc/support/host_port.h +66 -0
- data/include/grpc/support/log.h +118 -0
- data/include/grpc/support/log_windows.h +53 -0
- data/include/grpc/support/port_platform.h +39 -0
- data/include/grpc/support/string_util.h +64 -0
- data/include/grpc/support/subprocess.h +59 -0
- data/include/grpc/support/sync.h +295 -0
- data/include/grpc/support/sync_generic.h +39 -0
- data/include/grpc/support/sync_posix.h +39 -0
- data/include/grpc/support/sync_windows.h +39 -0
- data/include/grpc/support/thd.h +91 -0
- data/include/grpc/support/time.h +105 -0
- data/include/grpc/support/tls.h +77 -0
- data/include/grpc/support/tls_gcc.h +100 -0
- data/include/grpc/support/tls_msvc.h +56 -0
- data/include/grpc/support/tls_pthread.h +60 -0
- data/include/grpc/support/useful.h +80 -0
- data/src/boringssl/err_data.c +1270 -0
- data/src/core/ext/census/aggregation.h +66 -0
- data/src/core/ext/census/base_resources.c +71 -0
- data/src/core/ext/census/base_resources.h +39 -0
- data/src/core/ext/census/census_interface.h +76 -0
- data/src/core/ext/census/census_rpc_stats.h +101 -0
- data/src/core/ext/census/context.c +509 -0
- data/src/core/ext/census/gen/census.pb.c +176 -0
- data/src/core/ext/census/gen/census.pb.h +295 -0
- data/src/core/ext/census/gen/trace_context.pb.c +54 -0
- data/src/core/ext/census/gen/trace_context.pb.h +93 -0
- data/src/core/ext/census/grpc_context.c +53 -0
- data/src/core/ext/census/grpc_filter.c +213 -0
- data/src/core/ext/census/grpc_filter.h +44 -0
- data/src/core/ext/census/grpc_plugin.c +85 -0
- data/src/core/ext/census/initialize.c +66 -0
- data/src/core/ext/census/mlog.c +600 -0
- data/src/core/ext/census/mlog.h +95 -0
- data/src/core/ext/census/operation.c +63 -0
- data/src/core/ext/census/placeholders.c +64 -0
- data/src/core/ext/census/resource.c +312 -0
- data/src/core/ext/census/resource.h +63 -0
- data/src/core/ext/census/rpc_metric_id.h +51 -0
- data/src/core/ext/census/trace_context.c +86 -0
- data/src/core/ext/census/trace_context.h +71 -0
- data/src/core/ext/census/trace_label.h +61 -0
- data/src/core/ext/census/trace_propagation.h +63 -0
- data/src/core/ext/census/trace_status.h +45 -0
- data/src/core/ext/census/trace_string.h +50 -0
- data/src/core/ext/census/tracing.c +71 -0
- data/src/core/ext/census/tracing.h +124 -0
- data/src/core/ext/filters/client_channel/channel_connectivity.c +226 -0
- data/src/core/ext/filters/client_channel/client_channel.c +1410 -0
- data/src/core/ext/filters/client_channel/client_channel.h +64 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.c +87 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.h +92 -0
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +106 -0
- data/src/core/ext/filters/client_channel/connector.c +55 -0
- data/src/core/ext/filters/client_channel/connector.h +88 -0
- data/src/core/ext/filters/client_channel/http_connect_handshaker.c +389 -0
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +49 -0
- data/src/core/ext/filters/client_channel/http_proxy.c +125 -0
- data/src/core/ext/filters/client_channel/http_proxy.h +39 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +1419 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +44 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +57 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c +107 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +249 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +105 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +88 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +158 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +476 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +795 -0
- data/src/core/ext/filters/client_channel/lb_policy.c +167 -0
- data/src/core/ext/filters/client_channel/lb_policy.h +209 -0
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +163 -0
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +134 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.c +85 -0
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +55 -0
- data/src/core/ext/filters/client_channel/parse_address.c +170 -0
- data/src/core/ext/filters/client_channel/parse_address.h +54 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.c +63 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.h +89 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +139 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +59 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +325 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +234 -0
- data/src/core/ext/filters/client_channel/resolver.c +88 -0
- data/src/core/ext/filters/client_channel/resolver.h +101 -0
- data/src/core/ext/filters/client_channel/resolver_factory.c +56 -0
- data/src/core/ext/filters/client_channel/resolver_factory.h +85 -0
- data/src/core/ext/filters/client_channel/resolver_registry.c +174 -0
- data/src/core/ext/filters/client_channel/resolver_registry.h +84 -0
- data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
- data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
- data/src/core/ext/filters/client_channel/subchannel.c +835 -0
- data/src/core/ext/filters/client_channel/subchannel.h +203 -0
- data/src/core/ext/filters/client_channel/subchannel_index.c +262 -0
- data/src/core/ext/filters/client_channel/subchannel_index.h +77 -0
- data/src/core/ext/filters/client_channel/uri_parser.c +315 -0
- data/src/core/ext/filters/client_channel/uri_parser.h +65 -0
- data/src/core/ext/filters/load_reporting/load_reporting.c +106 -0
- data/src/core/ext/filters/load_reporting/load_reporting.h +73 -0
- data/src/core/ext/filters/load_reporting/load_reporting_filter.c +218 -0
- data/src/core/ext/filters/load_reporting/load_reporting_filter.h +42 -0
- data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
- data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.c +56 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.h +49 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +221 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +41 -0
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +121 -0
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +239 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +304 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +47 -0
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +59 -0
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +90 -0
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +101 -0
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +236 -0
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +67 -0
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +241 -0
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +54 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +43 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +2847 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +53 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +61 -0
- data/src/core/ext/transport/chttp2/transport/frame_data.c +287 -0
- data/src/core/ext/transport/chttp2/transport/frame_data.h +104 -0
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +198 -0
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +78 -0
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +145 -0
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +59 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +125 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +58 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +239 -0
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +76 -0
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +134 -0
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +57 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +661 -0
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +107 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +1734 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +129 -0
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +383 -0
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +112 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
- data/src/core/ext/transport/chttp2/transport/huffsyms.c +105 -0
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +48 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +88 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +63 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +852 -0
- data/src/core/ext/transport/chttp2/transport/parsing.c +825 -0
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +194 -0
- data/src/core/ext/transport/chttp2/transport/stream_map.c +176 -0
- data/src/core/ext/transport/chttp2/transport/stream_map.h +83 -0
- data/src/core/ext/transport/chttp2/transport/varint.c +65 -0
- data/src/core/ext/transport/chttp2/transport/varint.h +75 -0
- data/src/core/ext/transport/chttp2/transport/writing.c +429 -0
- data/src/core/lib/channel/channel_args.c +355 -0
- data/src/core/lib/channel/channel_args.h +126 -0
- data/src/core/lib/channel/channel_stack.c +291 -0
- data/src/core/lib/channel/channel_stack.h +319 -0
- data/src/core/lib/channel/channel_stack_builder.c +284 -0
- data/src/core/lib/channel/channel_stack_builder.h +170 -0
- data/src/core/lib/channel/compress_filter.c +353 -0
- data/src/core/lib/channel/compress_filter.h +67 -0
- data/src/core/lib/channel/connected_channel.c +188 -0
- data/src/core/lib/channel/connected_channel.h +48 -0
- data/src/core/lib/channel/context.h +64 -0
- data/src/core/lib/channel/deadline_filter.c +348 -0
- data/src/core/lib/channel/deadline_filter.h +102 -0
- data/src/core/lib/channel/handshaker.c +281 -0
- data/src/core/lib/channel/handshaker.h +182 -0
- data/src/core/lib/channel/handshaker_factory.c +54 -0
- data/src/core/lib/channel/handshaker_factory.h +66 -0
- data/src/core/lib/channel/handshaker_registry.c +113 -0
- data/src/core/lib/channel/handshaker_registry.h +63 -0
- data/src/core/lib/channel/http_client_filter.c +601 -0
- data/src/core/lib/channel/http_client_filter.h +47 -0
- data/src/core/lib/channel/http_server_filter.c +445 -0
- data/src/core/lib/channel/http_server_filter.h +42 -0
- data/src/core/lib/channel/message_size_filter.c +270 -0
- data/src/core/lib/channel/message_size_filter.h +39 -0
- data/src/core/lib/compression/algorithm_metadata.h +53 -0
- data/src/core/lib/compression/compression.c +198 -0
- data/src/core/lib/compression/message_compress.c +204 -0
- data/src/core/lib/compression/message_compress.h +54 -0
- data/src/core/lib/debug/trace.c +140 -0
- data/src/core/lib/debug/trace.h +43 -0
- data/src/core/lib/http/format_request.c +135 -0
- data/src/core/lib/http/format_request.h +47 -0
- data/src/core/lib/http/httpcli.c +336 -0
- data/src/core/lib/http/httpcli.h +141 -0
- data/src/core/lib/http/httpcli_security_connector.c +199 -0
- data/src/core/lib/http/parser.c +379 -0
- data/src/core/lib/http/parser.h +126 -0
- data/src/core/lib/iomgr/closure.c +168 -0
- data/src/core/lib/iomgr/closure.h +153 -0
- data/src/core/lib/iomgr/combiner.c +460 -0
- data/src/core/lib/iomgr/combiner.h +83 -0
- data/src/core/lib/iomgr/endpoint.c +78 -0
- data/src/core/lib/iomgr/endpoint.h +117 -0
- data/src/core/lib/iomgr/endpoint_pair.h +47 -0
- data/src/core/lib/iomgr/endpoint_pair_posix.c +87 -0
- data/src/core/lib/iomgr/endpoint_pair_uv.c +53 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.c +101 -0
- data/src/core/lib/iomgr/error.c +793 -0
- data/src/core/lib/iomgr/error.h +218 -0
- data/src/core/lib/iomgr/error_internal.h +75 -0
- data/src/core/lib/iomgr/ev_epoll_linux.c +1965 -0
- data/src/core/lib/iomgr/ev_epoll_linux.h +48 -0
- data/src/core/lib/iomgr/ev_poll_posix.c +1593 -0
- data/src/core/lib/iomgr/ev_poll_posix.h +42 -0
- data/src/core/lib/iomgr/ev_posix.c +287 -0
- data/src/core/lib/iomgr/ev_posix.h +189 -0
- data/src/core/lib/iomgr/exec_ctx.c +117 -0
- data/src/core/lib/iomgr/exec_ctx.h +117 -0
- data/src/core/lib/iomgr/executor.c +170 -0
- data/src/core/lib/iomgr/executor.h +51 -0
- data/src/core/lib/iomgr/iocp_windows.c +168 -0
- data/src/core/lib/iomgr/iocp_windows.h +55 -0
- data/src/core/lib/iomgr/iomgr.c +183 -0
- data/src/core/lib/iomgr/iomgr.h +47 -0
- data/src/core/lib/iomgr/iomgr_internal.h +58 -0
- data/src/core/lib/iomgr/iomgr_posix.c +56 -0
- data/src/core/lib/iomgr/iomgr_posix.h +39 -0
- data/src/core/lib/iomgr/iomgr_uv.c +49 -0
- data/src/core/lib/iomgr/iomgr_windows.c +76 -0
- data/src/core/lib/iomgr/load_file.c +92 -0
- data/src/core/lib/iomgr/load_file.h +56 -0
- data/src/core/lib/iomgr/lockfree_event.c +238 -0
- data/src/core/lib/iomgr/lockfree_event.h +54 -0
- data/src/core/lib/iomgr/network_status_tracker.c +48 -0
- data/src/core/lib/iomgr/network_status_tracker.h +45 -0
- data/src/core/lib/iomgr/polling_entity.c +104 -0
- data/src/core/lib/iomgr/polling_entity.h +81 -0
- data/src/core/lib/iomgr/pollset.h +97 -0
- data/src/core/lib/iomgr/pollset_set.h +62 -0
- data/src/core/lib/iomgr/pollset_set_uv.c +63 -0
- data/src/core/lib/iomgr/pollset_set_windows.c +64 -0
- data/src/core/lib/iomgr/pollset_set_windows.h +39 -0
- data/src/core/lib/iomgr/pollset_uv.c +156 -0
- data/src/core/lib/iomgr/pollset_uv.h +42 -0
- data/src/core/lib/iomgr/pollset_windows.c +232 -0
- data/src/core/lib/iomgr/pollset_windows.h +78 -0
- data/src/core/lib/iomgr/port.h +138 -0
- data/src/core/lib/iomgr/resolve_address.h +70 -0
- data/src/core/lib/iomgr/resolve_address_posix.c +207 -0
- data/src/core/lib/iomgr/resolve_address_uv.c +284 -0
- data/src/core/lib/iomgr/resolve_address_windows.c +190 -0
- data/src/core/lib/iomgr/resource_quota.c +877 -0
- data/src/core/lib/iomgr/resource_quota.h +167 -0
- data/src/core/lib/iomgr/sockaddr.h +55 -0
- data/src/core/lib/iomgr/sockaddr_posix.h +44 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +272 -0
- data/src/core/lib/iomgr/sockaddr_utils.h +93 -0
- data/src/core/lib/iomgr/sockaddr_windows.h +43 -0
- data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
- data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
- data/src/core/lib/iomgr/socket_mutator.c +98 -0
- data/src/core/lib/iomgr/socket_mutator.h +80 -0
- data/src/core/lib/iomgr/socket_utils.h +42 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.c +330 -0
- data/src/core/lib/iomgr/socket_utils_linux.c +57 -0
- data/src/core/lib/iomgr/socket_utils_posix.c +73 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +147 -0
- data/src/core/lib/iomgr/socket_utils_uv.c +49 -0
- data/src/core/lib/iomgr/socket_utils_windows.c +52 -0
- data/src/core/lib/iomgr/socket_windows.c +167 -0
- data/src/core/lib/iomgr/socket_windows.h +125 -0
- data/src/core/lib/iomgr/tcp_client.h +55 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +368 -0
- data/src/core/lib/iomgr/tcp_client_posix.h +45 -0
- data/src/core/lib/iomgr/tcp_client_uv.c +192 -0
- data/src/core/lib/iomgr/tcp_client_windows.c +260 -0
- data/src/core/lib/iomgr/tcp_posix.c +677 -0
- data/src/core/lib/iomgr/tcp_posix.h +70 -0
- data/src/core/lib/iomgr/tcp_server.h +116 -0
- data/src/core/lib/iomgr/tcp_server_posix.c +579 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
- data/src/core/lib/iomgr/tcp_server_uv.c +393 -0
- data/src/core/lib/iomgr/tcp_server_windows.c +558 -0
- data/src/core/lib/iomgr/tcp_uv.c +374 -0
- data/src/core/lib/iomgr/tcp_uv.h +59 -0
- data/src/core/lib/iomgr/tcp_windows.c +462 -0
- data/src/core/lib/iomgr/tcp_windows.h +59 -0
- data/src/core/lib/iomgr/time_averaged_stats.c +77 -0
- data/src/core/lib/iomgr/time_averaged_stats.h +88 -0
- data/src/core/lib/iomgr/timer.h +111 -0
- data/src/core/lib/iomgr/timer_generic.c +567 -0
- data/src/core/lib/iomgr/timer_generic.h +49 -0
- data/src/core/lib/iomgr/timer_heap.c +152 -0
- data/src/core/lib/iomgr/timer_heap.h +57 -0
- data/src/core/lib/iomgr/timer_uv.c +103 -0
- data/src/core/lib/iomgr/timer_uv.h +47 -0
- data/src/core/lib/iomgr/udp_server.c +529 -0
- data/src/core/lib/iomgr/udp_server.h +89 -0
- data/src/core/lib/iomgr/unix_sockets_posix.c +108 -0
- data/src/core/lib/iomgr/unix_sockets_posix.h +56 -0
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +62 -0
- data/src/core/lib/iomgr/wakeup_fd_cv.c +118 -0
- data/src/core/lib/iomgr/wakeup_fd_cv.h +80 -0
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +97 -0
- data/src/core/lib/iomgr/wakeup_fd_nospecial.c +51 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +112 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +41 -0
- data/src/core/lib/iomgr/wakeup_fd_posix.c +101 -0
- data/src/core/lib/iomgr/wakeup_fd_posix.h +109 -0
- data/src/core/lib/iomgr/workqueue.h +87 -0
- data/src/core/lib/iomgr/workqueue_uv.c +65 -0
- data/src/core/lib/iomgr/workqueue_uv.h +37 -0
- data/src/core/lib/iomgr/workqueue_windows.c +63 -0
- data/src/core/lib/iomgr/workqueue_windows.h +37 -0
- data/src/core/lib/json/json.c +63 -0
- data/src/core/lib/json/json.h +88 -0
- data/src/core/lib/json/json_common.h +49 -0
- data/src/core/lib/json/json_reader.c +675 -0
- data/src/core/lib/json/json_reader.h +160 -0
- data/src/core/lib/json/json_string.c +379 -0
- data/src/core/lib/json/json_writer.c +258 -0
- data/src/core/lib/json/json_writer.h +97 -0
- data/src/core/lib/profiling/basic_timers.c +298 -0
- data/src/core/lib/profiling/stap_timers.c +65 -0
- data/src/core/lib/profiling/timers.h +121 -0
- data/src/core/lib/security/context/security_context.c +350 -0
- data/src/core/lib/security/context/security_context.h +134 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.c +274 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
- data/src/core/lib/security/credentials/credentials.c +308 -0
- data/src/core/lib/security/credentials/credentials.h +268 -0
- data/src/core/lib/security/credentials/credentials_metadata.c +103 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.c +141 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +71 -0
- data/src/core/lib/security/credentials/google_default/credentials_generic.c +54 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +337 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +60 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
- data/src/core/lib/security/credentials/jwt/json_token.c +321 -0
- data/src/core/lib/security/credentials/jwt/json_token.h +88 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +195 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +63 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +910 -0
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +140 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +468 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +153 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +242 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
- data/src/core/lib/security/transport/auth_filters.h +42 -0
- data/src/core/lib/security/transport/client_auth_filter.c +384 -0
- data/src/core/lib/security/transport/lb_targets_info.c +70 -0
- data/src/core/lib/security/transport/lb_targets_info.h +47 -0
- data/src/core/lib/security/transport/secure_endpoint.c +427 -0
- data/src/core/lib/security/transport/secure_endpoint.h +49 -0
- data/src/core/lib/security/transport/security_connector.c +909 -0
- data/src/core/lib/security/transport/security_connector.h +252 -0
- data/src/core/lib/security/transport/security_handshaker.c +507 -0
- data/src/core/lib/security/transport/security_handshaker.h +49 -0
- data/src/core/lib/security/transport/server_auth_filter.c +277 -0
- data/src/core/lib/security/transport/tsi_error.c +42 -0
- data/src/core/lib/security/transport/tsi_error.h +42 -0
- data/src/core/lib/security/util/json_util.c +61 -0
- data/src/core/lib/security/util/json_util.h +55 -0
- data/src/core/lib/slice/b64.c +251 -0
- data/src/core/lib/slice/b64.h +65 -0
- data/src/core/lib/slice/percent_encoding.c +182 -0
- data/src/core/lib/slice/percent_encoding.h +78 -0
- data/src/core/lib/slice/slice.c +466 -0
- data/src/core/lib/slice/slice_buffer.c +355 -0
- data/src/core/lib/slice/slice_hash_table.c +125 -0
- data/src/core/lib/slice/slice_hash_table.h +77 -0
- data/src/core/lib/slice/slice_intern.c +346 -0
- data/src/core/lib/slice/slice_internal.h +64 -0
- data/src/core/lib/slice/slice_string_helpers.c +95 -0
- data/src/core/lib/slice/slice_string_helpers.h +63 -0
- data/src/core/lib/support/alloc.c +117 -0
- data/src/core/lib/support/arena.c +98 -0
- data/src/core/lib/support/arena.h +54 -0
- data/src/core/lib/support/atm.c +47 -0
- data/src/core/lib/support/avl.c +299 -0
- data/src/core/lib/support/backoff.c +87 -0
- data/src/core/lib/support/backoff.h +71 -0
- data/src/core/lib/support/block_annotate.h +48 -0
- data/src/core/lib/support/cmdline.c +345 -0
- data/src/core/lib/support/cpu_iphone.c +49 -0
- data/src/core/lib/support/cpu_linux.c +83 -0
- data/src/core/lib/support/cpu_posix.c +72 -0
- data/src/core/lib/support/cpu_windows.c +47 -0
- data/src/core/lib/support/env.h +58 -0
- data/src/core/lib/support/env_linux.c +89 -0
- data/src/core/lib/support/env_posix.c +57 -0
- data/src/core/lib/support/env_windows.c +79 -0
- data/src/core/lib/support/histogram.c +243 -0
- data/src/core/lib/support/host_port.c +110 -0
- data/src/core/lib/support/log.c +103 -0
- data/src/core/lib/support/log_android.c +87 -0
- data/src/core/lib/support/log_linux.c +105 -0
- data/src/core/lib/support/log_posix.c +106 -0
- data/src/core/lib/support/log_windows.c +112 -0
- data/src/core/lib/support/mpscq.c +83 -0
- data/src/core/lib/support/mpscq.h +65 -0
- data/src/core/lib/support/murmur_hash.c +94 -0
- data/src/core/lib/support/murmur_hash.h +44 -0
- data/src/core/lib/support/spinlock.h +52 -0
- data/src/core/lib/support/stack_lockfree.c +185 -0
- data/src/core/lib/support/stack_lockfree.h +53 -0
- data/src/core/lib/support/string.c +315 -0
- data/src/core/lib/support/string.h +128 -0
- data/src/core/lib/support/string_posix.c +86 -0
- data/src/core/lib/support/string_util_windows.c +94 -0
- data/src/core/lib/support/string_windows.c +83 -0
- data/src/core/lib/support/string_windows.h +47 -0
- data/src/core/lib/support/subprocess_posix.c +114 -0
- data/src/core/lib/support/subprocess_windows.c +141 -0
- data/src/core/lib/support/sync.c +137 -0
- data/src/core/lib/support/sync_posix.c +113 -0
- data/src/core/lib/support/sync_windows.c +133 -0
- data/src/core/lib/support/thd.c +64 -0
- data/src/core/lib/support/thd_internal.h +39 -0
- data/src/core/lib/support/thd_posix.c +95 -0
- data/src/core/lib/support/thd_windows.c +117 -0
- data/src/core/lib/support/time.c +262 -0
- data/src/core/lib/support/time_posix.c +176 -0
- data/src/core/lib/support/time_precise.c +89 -0
- data/src/core/lib/support/time_precise.h +42 -0
- data/src/core/lib/support/time_windows.c +116 -0
- data/src/core/lib/support/tls_pthread.c +45 -0
- data/src/core/lib/support/tmpfile.h +53 -0
- data/src/core/lib/support/tmpfile_msys.c +73 -0
- data/src/core/lib/support/tmpfile_posix.c +85 -0
- data/src/core/lib/support/tmpfile_windows.c +84 -0
- data/src/core/lib/support/wrap_memcpy.c +55 -0
- data/src/core/lib/surface/alarm.c +87 -0
- data/src/core/lib/surface/api_trace.c +36 -0
- data/src/core/lib/surface/api_trace.h +65 -0
- data/src/core/lib/surface/byte_buffer.c +103 -0
- data/src/core/lib/surface/byte_buffer_reader.c +140 -0
- data/src/core/lib/surface/call.c +1835 -0
- data/src/core/lib/surface/call.h +135 -0
- data/src/core/lib/surface/call_details.c +56 -0
- data/src/core/lib/surface/call_log_batch.c +131 -0
- data/src/core/lib/surface/call_test_only.h +64 -0
- data/src/core/lib/surface/channel.c +434 -0
- data/src/core/lib/surface/channel.h +99 -0
- data/src/core/lib/surface/channel_init.c +140 -0
- data/src/core/lib/surface/channel_init.h +96 -0
- data/src/core/lib/surface/channel_ping.c +80 -0
- data/src/core/lib/surface/channel_stack_type.c +54 -0
- data/src/core/lib/surface/channel_stack_type.h +58 -0
- data/src/core/lib/surface/completion_queue.c +692 -0
- data/src/core/lib/surface/completion_queue.h +102 -0
- data/src/core/lib/surface/completion_queue_factory.c +77 -0
- data/src/core/lib/surface/completion_queue_factory.h +51 -0
- data/src/core/lib/surface/event_string.c +81 -0
- data/src/core/lib/surface/event_string.h +42 -0
- data/src/core/lib/surface/init.c +261 -0
- data/src/core/lib/surface/init.h +42 -0
- data/src/core/lib/surface/init_secure.c +94 -0
- data/src/core/lib/surface/lame_client.c +188 -0
- data/src/core/lib/surface/lame_client.h +41 -0
- data/src/core/lib/surface/metadata_array.c +49 -0
- data/src/core/lib/surface/server.c +1529 -0
- data/src/core/lib/surface/server.h +71 -0
- data/src/core/lib/surface/validate_metadata.c +108 -0
- data/src/core/lib/surface/validate_metadata.h +43 -0
- data/src/core/lib/surface/version.c +41 -0
- data/src/core/lib/transport/bdp_estimator.c +104 -0
- data/src/core/lib/transport/bdp_estimator.h +76 -0
- data/src/core/lib/transport/byte_stream.c +81 -0
- data/src/core/lib/transport/byte_stream.h +85 -0
- data/src/core/lib/transport/connectivity_state.c +219 -0
- data/src/core/lib/transport/connectivity_state.h +101 -0
- data/src/core/lib/transport/error_utils.c +124 -0
- data/src/core/lib/transport/error_utils.h +56 -0
- data/src/core/lib/transport/http2_errors.h +56 -0
- data/src/core/lib/transport/metadata.c +529 -0
- data/src/core/lib/transport/metadata.h +186 -0
- data/src/core/lib/transport/metadata_batch.c +328 -0
- data/src/core/lib/transport/metadata_batch.h +166 -0
- data/src/core/lib/transport/pid_controller.c +78 -0
- data/src/core/lib/transport/pid_controller.h +77 -0
- data/src/core/lib/transport/service_config.c +266 -0
- data/src/core/lib/transport/service_config.h +77 -0
- data/src/core/lib/transport/static_metadata.c +801 -0
- data/src/core/lib/transport/static_metadata.h +557 -0
- data/src/core/lib/transport/status_conversion.c +113 -0
- data/src/core/lib/transport/status_conversion.h +49 -0
- data/src/core/lib/transport/timeout_encoding.c +190 -0
- data/src/core/lib/transport/timeout_encoding.h +49 -0
- data/src/core/lib/transport/transport.c +282 -0
- data/src/core/lib/transport/transport.h +354 -0
- data/src/core/lib/transport/transport_impl.h +90 -0
- data/src/core/lib/transport/transport_op_string.c +217 -0
- data/src/core/plugin_registry/grpc_plugin_registry.c +82 -0
- data/src/core/tsi/fake_transport_security.c +527 -0
- data/src/core/tsi/fake_transport_security.h +61 -0
- data/src/core/tsi/ssl_transport_security.c +1533 -0
- data/src/core/tsi/ssl_transport_security.h +214 -0
- data/src/core/tsi/ssl_types.h +55 -0
- data/src/core/tsi/transport_security.c +266 -0
- data/src/core/tsi/transport_security.h +111 -0
- data/src/core/tsi/transport_security_interface.h +353 -0
- data/src/ruby/bin/apis/google/protobuf/empty.rb +44 -0
- data/src/ruby/bin/apis/pubsub_demo.rb +256 -0
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +174 -0
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +103 -0
- data/src/ruby/bin/math_client.rb +147 -0
- data/src/ruby/bin/math_pb.rb +32 -0
- data/src/ruby/bin/math_server.rb +206 -0
- data/src/ruby/bin/math_services_pb.rb +66 -0
- data/src/ruby/bin/noproto_client.rb +108 -0
- data/src/ruby/bin/noproto_server.rb +112 -0
- data/src/ruby/ext/grpc/extconf.rb +131 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.c +77 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +50 -0
- data/src/ruby/ext/grpc/rb_call.c +1009 -0
- data/src/ruby/ext/grpc/rb_call.h +66 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +295 -0
- data/src/ruby/ext/grpc/rb_call_credentials.h +46 -0
- data/src/ruby/ext/grpc/rb_channel.c +662 -0
- data/src/ruby/ext/grpc/rb_channel.h +49 -0
- data/src/ruby/ext/grpc/rb_channel_args.c +168 -0
- data/src/ruby/ext/grpc/rb_channel_args.h +53 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +268 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.h +47 -0
- data/src/ruby/ext/grpc/rb_completion_queue.c +117 -0
- data/src/ruby/ext/grpc/rb_completion_queue.h +51 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +472 -0
- data/src/ruby/ext/grpc/rb_compression_options.h +44 -0
- data/src/ruby/ext/grpc/rb_event_thread.c +158 -0
- data/src/ruby/ext/grpc/rb_event_thread.h +37 -0
- data/src/ruby/ext/grpc/rb_grpc.c +343 -0
- data/src/ruby/ext/grpc/rb_grpc.h +87 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +634 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +955 -0
- data/src/ruby/ext/grpc/rb_loader.c +72 -0
- data/src/ruby/ext/grpc/rb_loader.h +40 -0
- data/src/ruby/ext/grpc/rb_server.c +359 -0
- data/src/ruby/ext/grpc/rb_server.h +47 -0
- data/src/ruby/ext/grpc/rb_server_credentials.c +258 -0
- data/src/ruby/ext/grpc/rb_server_credentials.h +47 -0
- data/src/ruby/lib/grpc/core/time_consts.rb +71 -0
- data/src/ruby/lib/grpc/errors.rb +215 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +547 -0
- data/src/ruby/lib/grpc/generic/bidi_call.rb +229 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +463 -0
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +173 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +476 -0
- data/src/ruby/lib/grpc/generic/service.rb +225 -0
- data/src/ruby/lib/grpc/grpc.rb +39 -0
- data/src/ruby/lib/grpc/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/logconfig.rb +59 -0
- data/src/ruby/lib/grpc/notifier.rb +60 -0
- data/src/ruby/lib/grpc/version.rb +33 -0
- data/src/ruby/lib/grpc.rb +49 -0
- data/src/ruby/pb/README.md +42 -0
- data/src/ruby/pb/generate_proto_ruby.sh +58 -0
- data/src/ruby/pb/grpc/health/checker.rb +77 -0
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +28 -0
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +56 -0
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +58 -0
- data/src/ruby/pb/grpc/testing/metrics_pb.rb +28 -0
- data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +64 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +15 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +82 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +14 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +117 -0
- data/src/ruby/pb/test/client.rb +779 -0
- data/src/ruby/pb/test/server.rb +267 -0
- data/src/ruby/spec/call_credentials_spec.rb +57 -0
- data/src/ruby/spec/call_spec.rb +162 -0
- data/src/ruby/spec/channel_connection_spec.rb +141 -0
- data/src/ruby/spec/channel_credentials_spec.rb +97 -0
- data/src/ruby/spec/channel_spec.rb +205 -0
- data/src/ruby/spec/client_server_spec.rb +491 -0
- data/src/ruby/spec/compression_options_spec.rb +164 -0
- data/src/ruby/spec/error_sanity_spec.rb +64 -0
- data/src/ruby/spec/generic/active_call_spec.rb +632 -0
- data/src/ruby/spec/generic/client_stub_spec.rb +556 -0
- data/src/ruby/spec/generic/rpc_desc_spec.rb +351 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +142 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +524 -0
- data/src/ruby/spec/generic/service_spec.rb +276 -0
- data/src/ruby/spec/pb/duplicate/codegen_spec.rb +71 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +222 -0
- data/src/ruby/spec/server_credentials_spec.rb +94 -0
- data/src/ruby/spec/server_spec.rb +205 -0
- data/src/ruby/spec/spec_helper.rb +71 -0
- data/src/ruby/spec/testdata/README +1 -0
- data/src/ruby/spec/testdata/ca.pem +15 -0
- data/src/ruby/spec/testdata/server1.key +16 -0
- data/src/ruby/spec/testdata/server1.pem +16 -0
- data/src/ruby/spec/time_consts_spec.rb +89 -0
- data/third_party/boringssl/crypto/aes/aes.c +1142 -0
- data/third_party/boringssl/crypto/aes/internal.h +87 -0
- data/third_party/boringssl/crypto/aes/mode_wrappers.c +112 -0
- data/third_party/boringssl/crypto/asn1/a_bitstr.c +263 -0
- data/third_party/boringssl/crypto/asn1/a_bool.c +110 -0
- data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +282 -0
- data/third_party/boringssl/crypto/asn1/a_dup.c +111 -0
- data/third_party/boringssl/crypto/asn1/a_enum.c +181 -0
- data/third_party/boringssl/crypto/asn1/a_gentm.c +256 -0
- data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +147 -0
- data/third_party/boringssl/crypto/asn1/a_int.c +460 -0
- data/third_party/boringssl/crypto/asn1/a_mbstr.c +409 -0
- data/third_party/boringssl/crypto/asn1/a_object.c +400 -0
- data/third_party/boringssl/crypto/asn1/a_octet.c +77 -0
- data/third_party/boringssl/crypto/asn1/a_print.c +121 -0
- data/third_party/boringssl/crypto/asn1/a_strnid.c +309 -0
- data/third_party/boringssl/crypto/asn1/a_time.c +206 -0
- data/third_party/boringssl/crypto/asn1/a_type.c +151 -0
- data/third_party/boringssl/crypto/asn1/a_utctm.c +304 -0
- data/third_party/boringssl/crypto/asn1/a_utf8.c +234 -0
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +483 -0
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +63 -0
- data/third_party/boringssl/crypto/asn1/asn1_par.c +80 -0
- data/third_party/boringssl/crypto/asn1/asn_pack.c +105 -0
- data/third_party/boringssl/crypto/asn1/f_enum.c +93 -0
- data/third_party/boringssl/crypto/asn1/f_int.c +97 -0
- data/third_party/boringssl/crypto/asn1/f_string.c +91 -0
- data/third_party/boringssl/crypto/asn1/t_bitst.c +103 -0
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +1221 -0
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +665 -0
- data/third_party/boringssl/crypto/asn1/tasn_fre.c +246 -0
- data/third_party/boringssl/crypto/asn1/tasn_new.c +381 -0
- data/third_party/boringssl/crypto/asn1/tasn_typ.c +131 -0
- data/third_party/boringssl/crypto/asn1/tasn_utl.c +266 -0
- data/third_party/boringssl/crypto/asn1/x_bignum.c +153 -0
- data/third_party/boringssl/crypto/asn1/x_long.c +197 -0
- data/third_party/boringssl/crypto/base64/base64.c +442 -0
- data/third_party/boringssl/crypto/bio/bio.c +598 -0
- data/third_party/boringssl/crypto/bio/bio_mem.c +328 -0
- data/third_party/boringssl/crypto/bio/buffer.c +496 -0
- data/third_party/boringssl/crypto/bio/connect.c +553 -0
- data/third_party/boringssl/crypto/bio/fd.c +277 -0
- data/third_party/boringssl/crypto/bio/file.c +313 -0
- data/third_party/boringssl/crypto/bio/hexdump.c +191 -0
- data/third_party/boringssl/crypto/bio/internal.h +111 -0
- data/third_party/boringssl/crypto/bio/pair.c +803 -0
- data/third_party/boringssl/crypto/bio/printf.c +119 -0
- data/third_party/boringssl/crypto/bio/socket.c +203 -0
- data/third_party/boringssl/crypto/bio/socket_helper.c +113 -0
- data/third_party/boringssl/crypto/bn/add.c +377 -0
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +531 -0
- data/third_party/boringssl/crypto/bn/bn.c +379 -0
- data/third_party/boringssl/crypto/bn/bn_asn1.c +80 -0
- data/third_party/boringssl/crypto/bn/cmp.c +225 -0
- data/third_party/boringssl/crypto/bn/convert.c +599 -0
- data/third_party/boringssl/crypto/bn/ctx.c +311 -0
- data/third_party/boringssl/crypto/bn/div.c +671 -0
- data/third_party/boringssl/crypto/bn/exponentiation.c +1258 -0
- data/third_party/boringssl/crypto/bn/gcd.c +628 -0
- data/third_party/boringssl/crypto/bn/generic.c +703 -0
- data/third_party/boringssl/crypto/bn/internal.h +245 -0
- data/third_party/boringssl/crypto/bn/kronecker.c +175 -0
- data/third_party/boringssl/crypto/bn/montgomery.c +410 -0
- data/third_party/boringssl/crypto/bn/montgomery_inv.c +160 -0
- data/third_party/boringssl/crypto/bn/mul.c +869 -0
- data/third_party/boringssl/crypto/bn/prime.c +861 -0
- data/third_party/boringssl/crypto/bn/random.c +340 -0
- data/third_party/boringssl/crypto/bn/rsaz_exp.c +319 -0
- data/third_party/boringssl/crypto/bn/rsaz_exp.h +56 -0
- data/third_party/boringssl/crypto/bn/shift.c +299 -0
- data/third_party/boringssl/crypto/bn/sqrt.c +504 -0
- data/third_party/boringssl/crypto/buf/buf.c +239 -0
- data/third_party/boringssl/crypto/bytestring/asn1_compat.c +51 -0
- data/third_party/boringssl/crypto/bytestring/ber.c +263 -0
- data/third_party/boringssl/crypto/bytestring/cbb.c +473 -0
- data/third_party/boringssl/crypto/bytestring/cbs.c +439 -0
- data/third_party/boringssl/crypto/bytestring/internal.h +75 -0
- data/third_party/boringssl/crypto/chacha/chacha.c +167 -0
- data/third_party/boringssl/crypto/cipher/aead.c +156 -0
- data/third_party/boringssl/crypto/cipher/cipher.c +652 -0
- data/third_party/boringssl/crypto/cipher/derive_key.c +154 -0
- data/third_party/boringssl/crypto/cipher/e_aes.c +1717 -0
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +300 -0
- data/third_party/boringssl/crypto/cipher/e_des.c +205 -0
- data/third_party/boringssl/crypto/cipher/e_null.c +85 -0
- data/third_party/boringssl/crypto/cipher/e_rc2.c +443 -0
- data/third_party/boringssl/crypto/cipher/e_rc4.c +87 -0
- data/third_party/boringssl/crypto/cipher/e_ssl3.c +403 -0
- data/third_party/boringssl/crypto/cipher/e_tls.c +602 -0
- data/third_party/boringssl/crypto/cipher/internal.h +162 -0
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +553 -0
- data/third_party/boringssl/crypto/cmac/cmac.c +239 -0
- data/third_party/boringssl/crypto/conf/conf.c +788 -0
- data/third_party/boringssl/crypto/conf/conf_def.h +127 -0
- data/third_party/boringssl/crypto/conf/internal.h +31 -0
- data/third_party/boringssl/crypto/cpu-aarch64-linux.c +61 -0
- data/third_party/boringssl/crypto/cpu-arm-linux.c +360 -0
- data/third_party/boringssl/crypto/cpu-arm.c +38 -0
- data/third_party/boringssl/crypto/cpu-intel.c +263 -0
- data/third_party/boringssl/crypto/cpu-ppc64le.c +40 -0
- data/third_party/boringssl/crypto/crypto.c +164 -0
- data/third_party/boringssl/crypto/curve25519/curve25519.c +4944 -0
- data/third_party/boringssl/crypto/curve25519/internal.h +109 -0
- data/third_party/boringssl/crypto/curve25519/spake25519.c +464 -0
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +246 -0
- data/third_party/boringssl/crypto/des/des.c +771 -0
- data/third_party/boringssl/crypto/des/internal.h +212 -0
- data/third_party/boringssl/crypto/dh/check.c +218 -0
- data/third_party/boringssl/crypto/dh/dh.c +487 -0
- data/third_party/boringssl/crypto/dh/dh_asn1.c +160 -0
- data/third_party/boringssl/crypto/dh/params.c +253 -0
- data/third_party/boringssl/crypto/digest/digest.c +248 -0
- data/third_party/boringssl/crypto/digest/digests.c +321 -0
- data/third_party/boringssl/crypto/digest/internal.h +112 -0
- data/third_party/boringssl/crypto/digest/md32_common.h +262 -0
- data/third_party/boringssl/crypto/dsa/dsa.c +964 -0
- data/third_party/boringssl/crypto/dsa/dsa_asn1.c +339 -0
- data/third_party/boringssl/crypto/ec/ec.c +847 -0
- data/third_party/boringssl/crypto/ec/ec_asn1.c +549 -0
- data/third_party/boringssl/crypto/ec/ec_key.c +479 -0
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +308 -0
- data/third_party/boringssl/crypto/ec/internal.h +276 -0
- data/third_party/boringssl/crypto/ec/oct.c +428 -0
- data/third_party/boringssl/crypto/ec/p224-64.c +1187 -0
- data/third_party/boringssl/crypto/ec/p256-64.c +1741 -0
- data/third_party/boringssl/crypto/ec/p256-x86_64-table.h +9543 -0
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +574 -0
- data/third_party/boringssl/crypto/ec/simple.c +1117 -0
- data/third_party/boringssl/crypto/ec/util-64.c +109 -0
- data/third_party/boringssl/crypto/ec/wnaf.c +449 -0
- data/third_party/boringssl/crypto/ecdh/ecdh.c +159 -0
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +478 -0
- data/third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c +227 -0
- data/third_party/boringssl/crypto/engine/engine.c +96 -0
- data/third_party/boringssl/crypto/err/err.c +756 -0
- data/third_party/boringssl/crypto/evp/digestsign.c +159 -0
- data/third_party/boringssl/crypto/evp/evp.c +367 -0
- data/third_party/boringssl/crypto/evp/evp_asn1.c +337 -0
- data/third_party/boringssl/crypto/evp/evp_ctx.c +448 -0
- data/third_party/boringssl/crypto/evp/internal.h +237 -0
- data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +268 -0
- data/third_party/boringssl/crypto/evp/p_ec.c +236 -0
- data/third_party/boringssl/crypto/evp/p_ec_asn1.c +257 -0
- data/third_party/boringssl/crypto/evp/p_rsa.c +673 -0
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +200 -0
- data/third_party/boringssl/crypto/evp/pbkdf.c +151 -0
- data/third_party/boringssl/crypto/evp/print.c +520 -0
- data/third_party/boringssl/crypto/evp/sign.c +151 -0
- data/third_party/boringssl/crypto/ex_data.c +292 -0
- data/third_party/boringssl/crypto/hkdf/hkdf.c +110 -0
- data/third_party/boringssl/crypto/hmac/hmac.c +213 -0
- data/third_party/boringssl/crypto/internal.h +527 -0
- data/third_party/boringssl/crypto/lhash/lhash.c +342 -0
- data/third_party/boringssl/crypto/md4/md4.c +234 -0
- data/third_party/boringssl/crypto/md5/md5.c +275 -0
- data/third_party/boringssl/crypto/mem.c +200 -0
- data/third_party/boringssl/crypto/modes/cbc.c +216 -0
- data/third_party/boringssl/crypto/modes/cfb.c +230 -0
- data/third_party/boringssl/crypto/modes/ctr.c +219 -0
- data/third_party/boringssl/crypto/modes/gcm.c +1288 -0
- data/third_party/boringssl/crypto/modes/internal.h +358 -0
- data/third_party/boringssl/crypto/modes/ofb.c +95 -0
- data/third_party/boringssl/crypto/newhope/error_correction.c +131 -0
- data/third_party/boringssl/crypto/newhope/internal.h +71 -0
- data/third_party/boringssl/crypto/newhope/newhope.c +174 -0
- data/third_party/boringssl/crypto/newhope/ntt.c +148 -0
- data/third_party/boringssl/crypto/newhope/poly.c +183 -0
- data/third_party/boringssl/crypto/newhope/precomp.c +306 -0
- data/third_party/boringssl/crypto/newhope/reduce.c +42 -0
- data/third_party/boringssl/crypto/obj/obj.c +640 -0
- data/third_party/boringssl/crypto/obj/obj_dat.h +5254 -0
- data/third_party/boringssl/crypto/obj/obj_xref.c +124 -0
- data/third_party/boringssl/crypto/obj/obj_xref.h +96 -0
- data/third_party/boringssl/crypto/pem/pem_all.c +262 -0
- data/third_party/boringssl/crypto/pem/pem_info.c +381 -0
- data/third_party/boringssl/crypto/pem/pem_lib.c +778 -0
- data/third_party/boringssl/crypto/pem/pem_oth.c +88 -0
- data/third_party/boringssl/crypto/pem/pem_pk8.c +257 -0
- data/third_party/boringssl/crypto/pem/pem_pkey.c +227 -0
- data/third_party/boringssl/crypto/pem/pem_x509.c +65 -0
- data/third_party/boringssl/crypto/pem/pem_xaux.c +67 -0
- data/third_party/boringssl/crypto/pkcs8/internal.h +83 -0
- data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +151 -0
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +441 -0
- data/third_party/boringssl/crypto/pkcs8/p8_pkey.c +85 -0
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +1219 -0
- data/third_party/boringssl/crypto/poly1305/internal.h +40 -0
- data/third_party/boringssl/crypto/poly1305/poly1305.c +324 -0
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +304 -0
- data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +890 -0
- data/third_party/boringssl/crypto/rand/deterministic.c +47 -0
- data/third_party/boringssl/crypto/rand/internal.h +32 -0
- data/third_party/boringssl/crypto/rand/rand.c +244 -0
- data/third_party/boringssl/crypto/rand/urandom.c +221 -0
- data/third_party/boringssl/crypto/rand/windows.c +53 -0
- data/third_party/boringssl/crypto/rc4/rc4.c +98 -0
- data/third_party/boringssl/crypto/refcount_c11.c +67 -0
- data/third_party/boringssl/crypto/refcount_lock.c +53 -0
- data/third_party/boringssl/crypto/rsa/blinding.c +264 -0
- data/third_party/boringssl/crypto/rsa/internal.h +148 -0
- data/third_party/boringssl/crypto/rsa/padding.c +708 -0
- data/third_party/boringssl/crypto/rsa/rsa.c +830 -0
- data/third_party/boringssl/crypto/rsa/rsa_asn1.c +446 -0
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +1139 -0
- data/third_party/boringssl/crypto/sha/sha1.c +337 -0
- data/third_party/boringssl/crypto/sha/sha256.c +327 -0
- data/third_party/boringssl/crypto/sha/sha512.c +607 -0
- data/third_party/boringssl/crypto/stack/stack.c +377 -0
- data/third_party/boringssl/crypto/thread.c +110 -0
- data/third_party/boringssl/crypto/thread_none.c +59 -0
- data/third_party/boringssl/crypto/thread_pthread.c +176 -0
- data/third_party/boringssl/crypto/thread_win.c +237 -0
- data/third_party/boringssl/crypto/time_support.c +206 -0
- data/third_party/boringssl/crypto/x509/a_digest.c +96 -0
- data/third_party/boringssl/crypto/x509/a_sign.c +135 -0
- data/third_party/boringssl/crypto/x509/a_strex.c +633 -0
- data/third_party/boringssl/crypto/x509/a_verify.c +127 -0
- data/third_party/boringssl/crypto/x509/algorithm.c +137 -0
- data/third_party/boringssl/crypto/x509/asn1_gen.c +818 -0
- data/third_party/boringssl/crypto/x509/by_dir.c +453 -0
- data/third_party/boringssl/crypto/x509/by_file.c +275 -0
- data/third_party/boringssl/crypto/x509/charmap.h +15 -0
- data/third_party/boringssl/crypto/x509/i2d_pr.c +83 -0
- data/third_party/boringssl/crypto/x509/internal.h +66 -0
- data/third_party/boringssl/crypto/x509/pkcs7.c +353 -0
- data/third_party/boringssl/crypto/x509/rsa_pss.c +385 -0
- data/third_party/boringssl/crypto/x509/t_crl.c +128 -0
- data/third_party/boringssl/crypto/x509/t_req.c +246 -0
- data/third_party/boringssl/crypto/x509/t_x509.c +506 -0
- data/third_party/boringssl/crypto/x509/t_x509a.c +111 -0
- data/third_party/boringssl/crypto/x509/vpm_int.h +70 -0
- data/third_party/boringssl/crypto/x509/x509.c +157 -0
- data/third_party/boringssl/crypto/x509/x509_att.c +381 -0
- data/third_party/boringssl/crypto/x509/x509_cmp.c +474 -0
- data/third_party/boringssl/crypto/x509/x509_d2.c +106 -0
- data/third_party/boringssl/crypto/x509/x509_def.c +98 -0
- data/third_party/boringssl/crypto/x509/x509_ext.c +206 -0
- data/third_party/boringssl/crypto/x509/x509_lu.c +690 -0
- data/third_party/boringssl/crypto/x509/x509_obj.c +197 -0
- data/third_party/boringssl/crypto/x509/x509_r2x.c +117 -0
- data/third_party/boringssl/crypto/x509/x509_req.c +322 -0
- data/third_party/boringssl/crypto/x509/x509_set.c +154 -0
- data/third_party/boringssl/crypto/x509/x509_trs.c +326 -0
- data/third_party/boringssl/crypto/x509/x509_txt.c +211 -0
- data/third_party/boringssl/crypto/x509/x509_v3.c +278 -0
- data/third_party/boringssl/crypto/x509/x509_vfy.c +2436 -0
- data/third_party/boringssl/crypto/x509/x509_vpm.c +647 -0
- data/third_party/boringssl/crypto/x509/x509cset.c +170 -0
- data/third_party/boringssl/crypto/x509/x509name.c +386 -0
- data/third_party/boringssl/crypto/x509/x509rset.c +81 -0
- data/third_party/boringssl/crypto/x509/x509spki.c +137 -0
- data/third_party/boringssl/crypto/x509/x509type.c +126 -0
- data/third_party/boringssl/crypto/x509/x_algor.c +151 -0
- data/third_party/boringssl/crypto/x509/x_all.c +501 -0
- data/third_party/boringssl/crypto/x509/x_attrib.c +111 -0
- data/third_party/boringssl/crypto/x509/x_crl.c +539 -0
- data/third_party/boringssl/crypto/x509/x_exten.c +75 -0
- data/third_party/boringssl/crypto/x509/x_info.c +98 -0
- data/third_party/boringssl/crypto/x509/x_name.c +534 -0
- data/third_party/boringssl/crypto/x509/x_pkey.c +103 -0
- data/third_party/boringssl/crypto/x509/x_pubkey.c +368 -0
- data/third_party/boringssl/crypto/x509/x_req.c +109 -0
- data/third_party/boringssl/crypto/x509/x_sig.c +69 -0
- data/third_party/boringssl/crypto/x509/x_spki.c +80 -0
- data/third_party/boringssl/crypto/x509/x_val.c +69 -0
- data/third_party/boringssl/crypto/x509/x_x509.c +289 -0
- data/third_party/boringssl/crypto/x509/x_x509a.c +205 -0
- data/third_party/boringssl/crypto/x509v3/ext_dat.h +135 -0
- data/third_party/boringssl/crypto/x509v3/pcy_cache.c +284 -0
- data/third_party/boringssl/crypto/x509v3/pcy_data.c +130 -0
- data/third_party/boringssl/crypto/x509v3/pcy_int.h +217 -0
- data/third_party/boringssl/crypto/x509v3/pcy_lib.c +164 -0
- data/third_party/boringssl/crypto/x509v3/pcy_map.c +130 -0
- data/third_party/boringssl/crypto/x509v3/pcy_node.c +188 -0
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +829 -0
- data/third_party/boringssl/crypto/x509v3/v3_akey.c +204 -0
- data/third_party/boringssl/crypto/x509v3/v3_akeya.c +72 -0
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +614 -0
- data/third_party/boringssl/crypto/x509v3/v3_bcons.c +133 -0
- data/third_party/boringssl/crypto/x509v3/v3_bitst.c +141 -0
- data/third_party/boringssl/crypto/x509v3/v3_conf.c +462 -0
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +496 -0
- data/third_party/boringssl/crypto/x509v3/v3_crld.c +561 -0
- data/third_party/boringssl/crypto/x509v3/v3_enum.c +100 -0
- data/third_party/boringssl/crypto/x509v3/v3_extku.c +148 -0
- data/third_party/boringssl/crypto/x509v3/v3_genn.c +250 -0
- data/third_party/boringssl/crypto/x509v3/v3_ia5.c +119 -0
- data/third_party/boringssl/crypto/x509v3/v3_info.c +212 -0
- data/third_party/boringssl/crypto/x509v3/v3_int.c +91 -0
- data/third_party/boringssl/crypto/x509v3/v3_lib.c +362 -0
- data/third_party/boringssl/crypto/x509v3/v3_ncons.c +482 -0
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +317 -0
- data/third_party/boringssl/crypto/x509v3/v3_pcia.c +57 -0
- data/third_party/boringssl/crypto/x509v3/v3_pcons.c +139 -0
- data/third_party/boringssl/crypto/x509v3/v3_pku.c +110 -0
- data/third_party/boringssl/crypto/x509v3/v3_pmaps.c +154 -0
- data/third_party/boringssl/crypto/x509v3/v3_prn.c +229 -0
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +874 -0
- data/third_party/boringssl/crypto/x509v3/v3_skey.c +152 -0
- data/third_party/boringssl/crypto/x509v3/v3_sxnet.c +274 -0
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +1327 -0
- data/third_party/boringssl/include/openssl/aead.h +345 -0
- data/third_party/boringssl/include/openssl/aes.h +158 -0
- data/third_party/boringssl/include/openssl/arm_arch.h +121 -0
- data/third_party/boringssl/include/openssl/asn1.h +1038 -0
- data/third_party/boringssl/include/openssl/asn1_mac.h +18 -0
- data/third_party/boringssl/include/openssl/asn1t.h +896 -0
- data/third_party/boringssl/include/openssl/base.h +412 -0
- data/third_party/boringssl/include/openssl/base64.h +187 -0
- data/third_party/boringssl/include/openssl/bio.h +926 -0
- data/third_party/boringssl/include/openssl/blowfish.h +93 -0
- data/third_party/boringssl/include/openssl/bn.h +955 -0
- data/third_party/boringssl/include/openssl/buf.h +133 -0
- data/third_party/boringssl/include/openssl/buffer.h +18 -0
- data/third_party/boringssl/include/openssl/bytestring.h +437 -0
- data/third_party/boringssl/include/openssl/cast.h +96 -0
- data/third_party/boringssl/include/openssl/chacha.h +37 -0
- data/third_party/boringssl/include/openssl/cipher.h +588 -0
- data/third_party/boringssl/include/openssl/cmac.h +87 -0
- data/third_party/boringssl/include/openssl/conf.h +181 -0
- data/third_party/boringssl/include/openssl/cpu.h +181 -0
- data/third_party/boringssl/include/openssl/crypto.h +94 -0
- data/third_party/boringssl/include/openssl/curve25519.h +183 -0
- data/third_party/boringssl/include/openssl/des.h +177 -0
- data/third_party/boringssl/include/openssl/dh.h +297 -0
- data/third_party/boringssl/include/openssl/digest.h +285 -0
- data/third_party/boringssl/include/openssl/dsa.h +436 -0
- data/third_party/boringssl/include/openssl/dtls1.h +16 -0
- data/third_party/boringssl/include/openssl/ec.h +406 -0
- data/third_party/boringssl/include/openssl/ec_key.h +337 -0
- data/third_party/boringssl/include/openssl/ecdh.h +102 -0
- data/third_party/boringssl/include/openssl/ecdsa.h +217 -0
- data/third_party/boringssl/include/openssl/engine.h +109 -0
- data/third_party/boringssl/include/openssl/err.h +488 -0
- data/third_party/boringssl/include/openssl/evp.h +797 -0
- data/third_party/boringssl/include/openssl/ex_data.h +213 -0
- data/third_party/boringssl/include/openssl/hkdf.h +64 -0
- data/third_party/boringssl/include/openssl/hmac.h +174 -0
- data/third_party/boringssl/include/openssl/lhash.h +192 -0
- data/third_party/boringssl/include/openssl/lhash_macros.h +132 -0
- data/third_party/boringssl/include/openssl/md4.h +106 -0
- data/third_party/boringssl/include/openssl/md5.h +107 -0
- data/third_party/boringssl/include/openssl/mem.h +150 -0
- data/third_party/boringssl/include/openssl/newhope.h +158 -0
- data/third_party/boringssl/include/openssl/nid.h +4166 -0
- data/third_party/boringssl/include/openssl/obj.h +226 -0
- data/third_party/boringssl/include/openssl/obj_mac.h +18 -0
- data/third_party/boringssl/include/openssl/objects.h +18 -0
- data/third_party/boringssl/include/openssl/opensslconf.h +60 -0
- data/third_party/boringssl/include/openssl/opensslv.h +18 -0
- data/third_party/boringssl/include/openssl/ossl_typ.h +18 -0
- data/third_party/boringssl/include/openssl/pem.h +517 -0
- data/third_party/boringssl/include/openssl/pkcs12.h +18 -0
- data/third_party/boringssl/include/openssl/pkcs7.h +16 -0
- data/third_party/boringssl/include/openssl/pkcs8.h +236 -0
- data/third_party/boringssl/include/openssl/poly1305.h +51 -0
- data/third_party/boringssl/include/openssl/rand.h +122 -0
- data/third_party/boringssl/include/openssl/rc4.h +96 -0
- data/third_party/boringssl/include/openssl/ripemd.h +107 -0
- data/third_party/boringssl/include/openssl/rsa.h +699 -0
- data/third_party/boringssl/include/openssl/safestack.h +16 -0
- data/third_party/boringssl/include/openssl/sha.h +260 -0
- data/third_party/boringssl/include/openssl/srtp.h +18 -0
- data/third_party/boringssl/include/openssl/ssl.h +4826 -0
- data/third_party/boringssl/include/openssl/ssl3.h +434 -0
- data/third_party/boringssl/include/openssl/stack.h +293 -0
- data/third_party/boringssl/include/openssl/stack_macros.h +3902 -0
- data/third_party/boringssl/include/openssl/thread.h +191 -0
- data/third_party/boringssl/include/openssl/time_support.h +91 -0
- data/third_party/boringssl/include/openssl/tls1.h +657 -0
- data/third_party/boringssl/include/openssl/type_check.h +91 -0
- data/third_party/boringssl/include/openssl/x509.h +1299 -0
- data/third_party/boringssl/include/openssl/x509_vfy.h +618 -0
- data/third_party/boringssl/include/openssl/x509v3.h +819 -0
- data/third_party/boringssl/ssl/custom_extensions.c +255 -0
- data/third_party/boringssl/ssl/d1_both.c +845 -0
- data/third_party/boringssl/ssl/d1_lib.c +270 -0
- data/third_party/boringssl/ssl/d1_pkt.c +419 -0
- data/third_party/boringssl/ssl/d1_srtp.c +236 -0
- data/third_party/boringssl/ssl/dtls_method.c +203 -0
- data/third_party/boringssl/ssl/dtls_record.c +309 -0
- data/third_party/boringssl/ssl/handshake_client.c +2002 -0
- data/third_party/boringssl/ssl/handshake_server.c +1932 -0
- data/third_party/boringssl/ssl/internal.h +1551 -0
- data/third_party/boringssl/ssl/s3_both.c +745 -0
- data/third_party/boringssl/ssl/s3_enc.c +412 -0
- data/third_party/boringssl/ssl/s3_lib.c +336 -0
- data/third_party/boringssl/ssl/s3_pkt.c +497 -0
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +329 -0
- data/third_party/boringssl/ssl/ssl_asn1.c +748 -0
- data/third_party/boringssl/ssl/ssl_buffer.c +311 -0
- data/third_party/boringssl/ssl/ssl_cert.c +814 -0
- data/third_party/boringssl/ssl/ssl_cipher.c +2062 -0
- data/third_party/boringssl/ssl/ssl_ecdh.c +610 -0
- data/third_party/boringssl/ssl/ssl_file.c +586 -0
- data/third_party/boringssl/ssl/ssl_lib.c +3063 -0
- data/third_party/boringssl/ssl/ssl_rsa.c +793 -0
- data/third_party/boringssl/ssl/ssl_session.c +985 -0
- data/third_party/boringssl/ssl/ssl_stat.c +509 -0
- data/third_party/boringssl/ssl/t1_enc.c +547 -0
- data/third_party/boringssl/ssl/t1_lib.c +3279 -0
- data/third_party/boringssl/ssl/tls13_both.c +440 -0
- data/third_party/boringssl/ssl/tls13_client.c +682 -0
- data/third_party/boringssl/ssl/tls13_enc.c +391 -0
- data/third_party/boringssl/ssl/tls13_server.c +672 -0
- data/third_party/boringssl/ssl/tls_method.c +245 -0
- data/third_party/boringssl/ssl/tls_record.c +461 -0
- data/third_party/cares/ares_build.h +264 -0
- data/third_party/cares/cares/ares.h +636 -0
- data/third_party/cares/cares/ares__close_sockets.c +61 -0
- data/third_party/cares/cares/ares__get_hostent.c +261 -0
- data/third_party/cares/cares/ares__read_line.c +73 -0
- data/third_party/cares/cares/ares__timeval.c +111 -0
- data/third_party/cares/cares/ares_cancel.c +63 -0
- data/third_party/cares/cares/ares_create_query.c +202 -0
- data/third_party/cares/cares/ares_data.c +221 -0
- data/third_party/cares/cares/ares_data.h +72 -0
- data/third_party/cares/cares/ares_destroy.c +108 -0
- data/third_party/cares/cares/ares_dns.h +103 -0
- data/third_party/cares/cares/ares_expand_name.c +205 -0
- data/third_party/cares/cares/ares_expand_string.c +70 -0
- data/third_party/cares/cares/ares_fds.c +59 -0
- data/third_party/cares/cares/ares_free_hostent.c +41 -0
- data/third_party/cares/cares/ares_free_string.c +25 -0
- data/third_party/cares/cares/ares_getenv.c +30 -0
- data/third_party/cares/cares/ares_getenv.h +26 -0
- data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
- data/third_party/cares/cares/ares_gethostbyname.c +518 -0
- data/third_party/cares/cares/ares_getnameinfo.c +422 -0
- data/third_party/cares/cares/ares_getopt.c +122 -0
- data/third_party/cares/cares/ares_getopt.h +53 -0
- data/third_party/cares/cares/ares_getsock.c +66 -0
- data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
- data/third_party/cares/cares/ares_init.c +2146 -0
- data/third_party/cares/cares/ares_iphlpapi.h +221 -0
- data/third_party/cares/cares/ares_ipv6.h +78 -0
- data/third_party/cares/cares/ares_library_init.c +167 -0
- data/third_party/cares/cares/ares_library_init.h +42 -0
- data/third_party/cares/cares/ares_llist.c +63 -0
- data/third_party/cares/cares/ares_llist.h +39 -0
- data/third_party/cares/cares/ares_mkquery.c +24 -0
- data/third_party/cares/cares/ares_nowarn.c +260 -0
- data/third_party/cares/cares/ares_nowarn.h +61 -0
- data/third_party/cares/cares/ares_options.c +402 -0
- data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
- data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
- data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
- data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
- data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
- data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
- data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
- data/third_party/cares/cares/ares_platform.c +11035 -0
- data/third_party/cares/cares/ares_platform.h +43 -0
- data/third_party/cares/cares/ares_private.h +363 -0
- data/third_party/cares/cares/ares_process.c +1359 -0
- data/third_party/cares/cares/ares_query.c +186 -0
- data/third_party/cares/cares/ares_rules.h +125 -0
- data/third_party/cares/cares/ares_search.c +316 -0
- data/third_party/cares/cares/ares_send.c +131 -0
- data/third_party/cares/cares/ares_setup.h +217 -0
- data/third_party/cares/cares/ares_strcasecmp.c +66 -0
- data/third_party/cares/cares/ares_strcasecmp.h +30 -0
- data/third_party/cares/cares/ares_strdup.c +49 -0
- data/third_party/cares/cares/ares_strdup.h +24 -0
- data/third_party/cares/cares/ares_strerror.c +56 -0
- data/third_party/cares/cares/ares_timeout.c +88 -0
- data/third_party/cares/cares/ares_version.c +11 -0
- data/third_party/cares/cares/ares_version.h +24 -0
- data/third_party/cares/cares/ares_writev.c +79 -0
- data/third_party/cares/cares/bitncmp.c +59 -0
- data/third_party/cares/cares/bitncmp.h +26 -0
- data/third_party/cares/cares/config-win32.h +377 -0
- data/third_party/cares/cares/inet_net_pton.c +450 -0
- data/third_party/cares/cares/inet_ntop.c +208 -0
- data/third_party/cares/cares/setup_once.h +554 -0
- data/third_party/cares/cares/windows_port.c +22 -0
- data/third_party/cares/config_darwin/ares_config.h +523 -0
- data/third_party/cares/config_linux/ares_config.h +524 -0
- data/third_party/nanopb/pb.h +579 -0
- data/third_party/nanopb/pb_common.c +97 -0
- data/third_party/nanopb/pb_common.h +42 -0
- data/third_party/nanopb/pb_decode.c +1347 -0
- data/third_party/nanopb/pb_decode.h +149 -0
- data/third_party/nanopb/pb_encode.c +696 -0
- data/third_party/nanopb/pb_encode.h +154 -0
- data/third_party/zlib/adler32.c +179 -0
- data/third_party/zlib/compress.c +80 -0
- data/third_party/zlib/crc32.c +425 -0
- data/third_party/zlib/crc32.h +441 -0
- data/third_party/zlib/deflate.c +1967 -0
- data/third_party/zlib/deflate.h +346 -0
- data/third_party/zlib/gzclose.c +25 -0
- data/third_party/zlib/gzguts.h +209 -0
- data/third_party/zlib/gzlib.c +634 -0
- data/third_party/zlib/gzread.c +594 -0
- data/third_party/zlib/gzwrite.c +577 -0
- data/third_party/zlib/infback.c +640 -0
- data/third_party/zlib/inffast.c +340 -0
- data/third_party/zlib/inffast.h +11 -0
- data/third_party/zlib/inffixed.h +94 -0
- data/third_party/zlib/inflate.c +1512 -0
- data/third_party/zlib/inflate.h +122 -0
- data/third_party/zlib/inftrees.c +306 -0
- data/third_party/zlib/inftrees.h +62 -0
- data/third_party/zlib/trees.c +1226 -0
- data/third_party/zlib/trees.h +128 -0
- data/third_party/zlib/uncompr.c +59 -0
- data/third_party/zlib/zconf.h +511 -0
- data/third_party/zlib/zlib.h +1768 -0
- data/third_party/zlib/zutil.c +324 -0
- data/third_party/zlib/zutil.h +253 -0
- metadata +1397 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2015, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#ifndef GRPC_CORE_LIB_IOMGR_EV_EPOLL_LINUX_H
|
35
|
+
#define GRPC_CORE_LIB_IOMGR_EV_EPOLL_LINUX_H
|
36
|
+
|
37
|
+
#include "src/core/lib/iomgr/ev_posix.h"
|
38
|
+
#include "src/core/lib/iomgr/port.h"
|
39
|
+
|
40
|
+
const grpc_event_engine_vtable *grpc_init_epoll_linux(void);
|
41
|
+
|
42
|
+
#ifdef GRPC_LINUX_EPOLL
|
43
|
+
void *grpc_fd_get_polling_island(grpc_fd *fd);
|
44
|
+
void *grpc_pollset_get_polling_island(grpc_pollset *ps);
|
45
|
+
bool grpc_are_polling_islands_equal(void *p, void *q);
|
46
|
+
#endif /* defined(GRPC_LINUX_EPOLL) */
|
47
|
+
|
48
|
+
#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL_LINUX_H */
|
@@ -0,0 +1,1593 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2016, Google Inc.
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions are
|
8
|
+
* met:
|
9
|
+
*
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
14
|
+
* in the documentation and/or other materials provided with the
|
15
|
+
* distribution.
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
18
|
+
* this software without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#include "src/core/lib/iomgr/port.h"
|
35
|
+
|
36
|
+
#ifdef GRPC_POSIX_SOCKET
|
37
|
+
|
38
|
+
#include "src/core/lib/iomgr/ev_poll_posix.h"
|
39
|
+
|
40
|
+
#include <assert.h>
|
41
|
+
#include <errno.h>
|
42
|
+
#include <poll.h>
|
43
|
+
#include <string.h>
|
44
|
+
#include <sys/socket.h>
|
45
|
+
#include <unistd.h>
|
46
|
+
|
47
|
+
#include <grpc/support/alloc.h>
|
48
|
+
#include <grpc/support/log.h>
|
49
|
+
#include <grpc/support/string_util.h>
|
50
|
+
#include <grpc/support/thd.h>
|
51
|
+
#include <grpc/support/tls.h>
|
52
|
+
#include <grpc/support/useful.h>
|
53
|
+
|
54
|
+
#include "src/core/lib/iomgr/iomgr_internal.h"
|
55
|
+
#include "src/core/lib/iomgr/timer.h"
|
56
|
+
#include "src/core/lib/iomgr/wakeup_fd_cv.h"
|
57
|
+
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
|
58
|
+
#include "src/core/lib/profiling/timers.h"
|
59
|
+
#include "src/core/lib/support/block_annotate.h"
|
60
|
+
|
61
|
+
/*******************************************************************************
|
62
|
+
* FD declarations
|
63
|
+
*/
|
64
|
+
|
65
|
+
typedef struct grpc_fd_watcher {
|
66
|
+
struct grpc_fd_watcher *next;
|
67
|
+
struct grpc_fd_watcher *prev;
|
68
|
+
grpc_pollset *pollset;
|
69
|
+
grpc_pollset_worker *worker;
|
70
|
+
grpc_fd *fd;
|
71
|
+
} grpc_fd_watcher;
|
72
|
+
|
73
|
+
struct grpc_fd {
|
74
|
+
int fd;
|
75
|
+
/* refst format:
|
76
|
+
bit0: 1=active/0=orphaned
|
77
|
+
bit1-n: refcount
|
78
|
+
meaning that mostly we ref by two to avoid altering the orphaned bit,
|
79
|
+
and just unref by 1 when we're ready to flag the object as orphaned */
|
80
|
+
gpr_atm refst;
|
81
|
+
|
82
|
+
gpr_mu mu;
|
83
|
+
int shutdown;
|
84
|
+
int closed;
|
85
|
+
int released;
|
86
|
+
grpc_error *shutdown_error;
|
87
|
+
|
88
|
+
/* The watcher list.
|
89
|
+
|
90
|
+
The following watcher related fields are protected by watcher_mu.
|
91
|
+
|
92
|
+
An fd_watcher is an ephemeral object created when an fd wants to
|
93
|
+
begin polling, and destroyed after the poll.
|
94
|
+
|
95
|
+
It denotes the fd's interest in whether to read poll or write poll
|
96
|
+
or both or neither on this fd.
|
97
|
+
|
98
|
+
If a watcher is asked to poll for reads or writes, the read_watcher
|
99
|
+
or write_watcher fields are set respectively. A watcher may be asked
|
100
|
+
to poll for both, in which case both fields will be set.
|
101
|
+
|
102
|
+
read_watcher and write_watcher may be NULL if no watcher has been
|
103
|
+
asked to poll for reads or writes.
|
104
|
+
|
105
|
+
If an fd_watcher is not asked to poll for reads or writes, it's added
|
106
|
+
to a linked list of inactive watchers, rooted at inactive_watcher_root.
|
107
|
+
If at a later time there becomes need of a poller to poll, one of
|
108
|
+
the inactive pollers may be kicked out of their poll loops to take
|
109
|
+
that responsibility. */
|
110
|
+
grpc_fd_watcher inactive_watcher_root;
|
111
|
+
grpc_fd_watcher *read_watcher;
|
112
|
+
grpc_fd_watcher *write_watcher;
|
113
|
+
|
114
|
+
grpc_closure *read_closure;
|
115
|
+
grpc_closure *write_closure;
|
116
|
+
|
117
|
+
grpc_closure *on_done_closure;
|
118
|
+
|
119
|
+
grpc_iomgr_object iomgr_object;
|
120
|
+
|
121
|
+
/* The pollset that last noticed and notified that the fd is readable */
|
122
|
+
grpc_pollset *read_notifier_pollset;
|
123
|
+
};
|
124
|
+
|
125
|
+
static grpc_wakeup_fd global_wakeup_fd;
|
126
|
+
|
127
|
+
/* Begin polling on an fd.
|
128
|
+
Registers that the given pollset is interested in this fd - so that if read
|
129
|
+
or writability interest changes, the pollset can be kicked to pick up that
|
130
|
+
new interest.
|
131
|
+
Return value is:
|
132
|
+
(fd_needs_read? read_mask : 0) | (fd_needs_write? write_mask : 0)
|
133
|
+
i.e. a combination of read_mask and write_mask determined by the fd's current
|
134
|
+
interest in said events.
|
135
|
+
Polling strategies that do not need to alter their behavior depending on the
|
136
|
+
fd's current interest (such as epoll) do not need to call this function.
|
137
|
+
MUST NOT be called with a pollset lock taken */
|
138
|
+
static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
|
139
|
+
grpc_pollset_worker *worker, uint32_t read_mask,
|
140
|
+
uint32_t write_mask, grpc_fd_watcher *rec);
|
141
|
+
/* Complete polling previously started with fd_begin_poll
|
142
|
+
MUST NOT be called with a pollset lock taken
|
143
|
+
if got_read or got_write are 1, also does the become_{readable,writable} as
|
144
|
+
appropriate. */
|
145
|
+
static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *rec,
|
146
|
+
int got_read, int got_write,
|
147
|
+
grpc_pollset *read_notifier_pollset);
|
148
|
+
|
149
|
+
/* Return 1 if this fd is orphaned, 0 otherwise */
|
150
|
+
static bool fd_is_orphaned(grpc_fd *fd);
|
151
|
+
|
152
|
+
/* Reference counting for fds */
|
153
|
+
//#define GRPC_FD_REF_COUNT_DEBUG
|
154
|
+
#ifdef GRPC_FD_REF_COUNT_DEBUG
|
155
|
+
static void fd_ref(grpc_fd *fd, const char *reason, const char *file, int line);
|
156
|
+
static void fd_unref(grpc_fd *fd, const char *reason, const char *file,
|
157
|
+
int line);
|
158
|
+
#define GRPC_FD_REF(fd, reason) fd_ref(fd, reason, __FILE__, __LINE__)
|
159
|
+
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd, reason, __FILE__, __LINE__)
|
160
|
+
#else
|
161
|
+
static void fd_ref(grpc_fd *fd);
|
162
|
+
static void fd_unref(grpc_fd *fd);
|
163
|
+
#define GRPC_FD_REF(fd, reason) fd_ref(fd)
|
164
|
+
#define GRPC_FD_UNREF(fd, reason) fd_unref(fd)
|
165
|
+
#endif
|
166
|
+
|
167
|
+
#define CLOSURE_NOT_READY ((grpc_closure *)0)
|
168
|
+
#define CLOSURE_READY ((grpc_closure *)1)
|
169
|
+
|
170
|
+
/*******************************************************************************
|
171
|
+
* pollset declarations
|
172
|
+
*/
|
173
|
+
|
174
|
+
typedef struct grpc_cached_wakeup_fd {
|
175
|
+
grpc_wakeup_fd fd;
|
176
|
+
struct grpc_cached_wakeup_fd *next;
|
177
|
+
} grpc_cached_wakeup_fd;
|
178
|
+
|
179
|
+
struct grpc_pollset_worker {
|
180
|
+
grpc_cached_wakeup_fd *wakeup_fd;
|
181
|
+
int reevaluate_polling_on_wakeup;
|
182
|
+
int kicked_specifically;
|
183
|
+
struct grpc_pollset_worker *next;
|
184
|
+
struct grpc_pollset_worker *prev;
|
185
|
+
};
|
186
|
+
|
187
|
+
struct grpc_pollset {
|
188
|
+
gpr_mu mu;
|
189
|
+
grpc_pollset_worker root_worker;
|
190
|
+
int shutting_down;
|
191
|
+
int called_shutdown;
|
192
|
+
int kicked_without_pollers;
|
193
|
+
grpc_closure *shutdown_done;
|
194
|
+
grpc_closure_list idle_jobs;
|
195
|
+
int pollset_set_count;
|
196
|
+
/* all polled fds */
|
197
|
+
size_t fd_count;
|
198
|
+
size_t fd_capacity;
|
199
|
+
grpc_fd **fds;
|
200
|
+
/* Local cache of eventfds for workers */
|
201
|
+
grpc_cached_wakeup_fd *local_wakeup_cache;
|
202
|
+
};
|
203
|
+
|
204
|
+
/* Add an fd to a pollset */
|
205
|
+
static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
206
|
+
struct grpc_fd *fd);
|
207
|
+
|
208
|
+
static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
|
209
|
+
grpc_pollset_set *pollset_set, grpc_fd *fd);
|
210
|
+
|
211
|
+
/* Convert a timespec to milliseconds:
|
212
|
+
- very small or negative poll times are clamped to zero to do a
|
213
|
+
non-blocking poll (which becomes spin polling)
|
214
|
+
- other small values are rounded up to one millisecond
|
215
|
+
- longer than a millisecond polls are rounded up to the next nearest
|
216
|
+
millisecond to avoid spinning
|
217
|
+
- infinite timeouts are converted to -1 */
|
218
|
+
static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
|
219
|
+
gpr_timespec now);
|
220
|
+
|
221
|
+
/* Allow kick to wakeup the currently polling worker */
|
222
|
+
#define GRPC_POLLSET_CAN_KICK_SELF 1
|
223
|
+
/* Force the wakee to repoll when awoken */
|
224
|
+
#define GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP 2
|
225
|
+
/* As per pollset_kick, with an extended set of flags (defined above)
|
226
|
+
-- mostly for fd_posix's use. */
|
227
|
+
static grpc_error *pollset_kick_ext(grpc_pollset *p,
|
228
|
+
grpc_pollset_worker *specific_worker,
|
229
|
+
uint32_t flags) GRPC_MUST_USE_RESULT;
|
230
|
+
|
231
|
+
/* Return 1 if the pollset has active threads in pollset_work (pollset must
|
232
|
+
* be locked) */
|
233
|
+
static bool pollset_has_workers(grpc_pollset *pollset);
|
234
|
+
|
235
|
+
/*******************************************************************************
|
236
|
+
* pollset_set definitions
|
237
|
+
*/
|
238
|
+
|
239
|
+
struct grpc_pollset_set {
|
240
|
+
gpr_mu mu;
|
241
|
+
|
242
|
+
size_t pollset_count;
|
243
|
+
size_t pollset_capacity;
|
244
|
+
grpc_pollset **pollsets;
|
245
|
+
|
246
|
+
size_t pollset_set_count;
|
247
|
+
size_t pollset_set_capacity;
|
248
|
+
struct grpc_pollset_set **pollset_sets;
|
249
|
+
|
250
|
+
size_t fd_count;
|
251
|
+
size_t fd_capacity;
|
252
|
+
grpc_fd **fds;
|
253
|
+
};
|
254
|
+
|
255
|
+
/*******************************************************************************
|
256
|
+
* condition variable polling definitions
|
257
|
+
*/
|
258
|
+
|
259
|
+
#define CV_POLL_PERIOD_MS 1000
|
260
|
+
#define CV_DEFAULT_TABLE_SIZE 16
|
261
|
+
|
262
|
+
typedef enum poll_status_t { INPROGRESS, COMPLETED, CANCELLED } poll_status_t;
|
263
|
+
|
264
|
+
typedef struct poll_args {
|
265
|
+
gpr_refcount refcount;
|
266
|
+
gpr_cv *cv;
|
267
|
+
struct pollfd *fds;
|
268
|
+
nfds_t nfds;
|
269
|
+
int timeout;
|
270
|
+
int retval;
|
271
|
+
int err;
|
272
|
+
gpr_atm status;
|
273
|
+
} poll_args;
|
274
|
+
|
275
|
+
cv_fd_table g_cvfds;
|
276
|
+
|
277
|
+
/*******************************************************************************
|
278
|
+
* fd_posix.c
|
279
|
+
*/
|
280
|
+
|
281
|
+
#ifdef GRPC_FD_REF_COUNT_DEBUG
|
282
|
+
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)
|
283
|
+
#define UNREF_BY(fd, n, reason) unref_by(fd, n, reason, __FILE__, __LINE__)
|
284
|
+
static void ref_by(grpc_fd *fd, int n, const char *reason, const char *file,
|
285
|
+
int line) {
|
286
|
+
gpr_log(GPR_DEBUG, "FD %d %p ref %d %d -> %d [%s; %s:%d]", fd->fd, fd, n,
|
287
|
+
(int)gpr_atm_no_barrier_load(&fd->refst),
|
288
|
+
(int)gpr_atm_no_barrier_load(&fd->refst) + n, reason, file, line);
|
289
|
+
#else
|
290
|
+
#define REF_BY(fd, n, reason) ref_by(fd, n)
|
291
|
+
#define UNREF_BY(fd, n, reason) unref_by(fd, n)
|
292
|
+
static void ref_by(grpc_fd *fd, int n) {
|
293
|
+
#endif
|
294
|
+
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
|
295
|
+
}
|
296
|
+
|
297
|
+
#ifdef GRPC_FD_REF_COUNT_DEBUG
|
298
|
+
static void unref_by(grpc_fd *fd, int n, const char *reason, const char *file,
|
299
|
+
int line) {
|
300
|
+
gpr_atm old;
|
301
|
+
gpr_log(GPR_DEBUG, "FD %d %p unref %d %d -> %d [%s; %s:%d]", fd->fd, fd, n,
|
302
|
+
(int)gpr_atm_no_barrier_load(&fd->refst),
|
303
|
+
(int)gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line);
|
304
|
+
#else
|
305
|
+
static void unref_by(grpc_fd *fd, int n) {
|
306
|
+
gpr_atm old;
|
307
|
+
#endif
|
308
|
+
old = gpr_atm_full_fetch_add(&fd->refst, -n);
|
309
|
+
if (old == n) {
|
310
|
+
gpr_mu_destroy(&fd->mu);
|
311
|
+
grpc_iomgr_unregister_object(&fd->iomgr_object);
|
312
|
+
if (fd->shutdown) GRPC_ERROR_UNREF(fd->shutdown_error);
|
313
|
+
gpr_free(fd);
|
314
|
+
} else {
|
315
|
+
GPR_ASSERT(old > n);
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
static grpc_fd *fd_create(int fd, const char *name) {
|
320
|
+
grpc_fd *r = gpr_malloc(sizeof(*r));
|
321
|
+
gpr_mu_init(&r->mu);
|
322
|
+
gpr_atm_rel_store(&r->refst, 1);
|
323
|
+
r->shutdown = 0;
|
324
|
+
r->read_closure = CLOSURE_NOT_READY;
|
325
|
+
r->write_closure = CLOSURE_NOT_READY;
|
326
|
+
r->fd = fd;
|
327
|
+
r->inactive_watcher_root.next = r->inactive_watcher_root.prev =
|
328
|
+
&r->inactive_watcher_root;
|
329
|
+
r->read_watcher = r->write_watcher = NULL;
|
330
|
+
r->on_done_closure = NULL;
|
331
|
+
r->closed = 0;
|
332
|
+
r->released = 0;
|
333
|
+
r->read_notifier_pollset = NULL;
|
334
|
+
|
335
|
+
char *name2;
|
336
|
+
gpr_asprintf(&name2, "%s fd=%d", name, fd);
|
337
|
+
grpc_iomgr_register_object(&r->iomgr_object, name2);
|
338
|
+
gpr_free(name2);
|
339
|
+
#ifdef GRPC_FD_REF_COUNT_DEBUG
|
340
|
+
gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, r, name);
|
341
|
+
#endif
|
342
|
+
return r;
|
343
|
+
}
|
344
|
+
|
345
|
+
static bool fd_is_orphaned(grpc_fd *fd) {
|
346
|
+
return (gpr_atm_acq_load(&fd->refst) & 1) == 0;
|
347
|
+
}
|
348
|
+
|
349
|
+
/* Return the read-notifier pollset */
|
350
|
+
static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
|
351
|
+
grpc_fd *fd) {
|
352
|
+
grpc_pollset *notifier = NULL;
|
353
|
+
|
354
|
+
gpr_mu_lock(&fd->mu);
|
355
|
+
notifier = fd->read_notifier_pollset;
|
356
|
+
gpr_mu_unlock(&fd->mu);
|
357
|
+
|
358
|
+
return notifier;
|
359
|
+
}
|
360
|
+
|
361
|
+
static grpc_error *pollset_kick_locked(grpc_fd_watcher *watcher) {
|
362
|
+
gpr_mu_lock(&watcher->pollset->mu);
|
363
|
+
GPR_ASSERT(watcher->worker);
|
364
|
+
grpc_error *err = pollset_kick_ext(watcher->pollset, watcher->worker,
|
365
|
+
GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
|
366
|
+
gpr_mu_unlock(&watcher->pollset->mu);
|
367
|
+
return err;
|
368
|
+
}
|
369
|
+
|
370
|
+
static void maybe_wake_one_watcher_locked(grpc_fd *fd) {
|
371
|
+
if (fd->inactive_watcher_root.next != &fd->inactive_watcher_root) {
|
372
|
+
pollset_kick_locked(fd->inactive_watcher_root.next);
|
373
|
+
} else if (fd->read_watcher) {
|
374
|
+
pollset_kick_locked(fd->read_watcher);
|
375
|
+
} else if (fd->write_watcher) {
|
376
|
+
pollset_kick_locked(fd->write_watcher);
|
377
|
+
}
|
378
|
+
}
|
379
|
+
|
380
|
+
static void wake_all_watchers_locked(grpc_fd *fd) {
|
381
|
+
grpc_fd_watcher *watcher;
|
382
|
+
for (watcher = fd->inactive_watcher_root.next;
|
383
|
+
watcher != &fd->inactive_watcher_root; watcher = watcher->next) {
|
384
|
+
pollset_kick_locked(watcher);
|
385
|
+
}
|
386
|
+
if (fd->read_watcher) {
|
387
|
+
pollset_kick_locked(fd->read_watcher);
|
388
|
+
}
|
389
|
+
if (fd->write_watcher && fd->write_watcher != fd->read_watcher) {
|
390
|
+
pollset_kick_locked(fd->write_watcher);
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
static int has_watchers(grpc_fd *fd) {
|
395
|
+
return fd->read_watcher != NULL || fd->write_watcher != NULL ||
|
396
|
+
fd->inactive_watcher_root.next != &fd->inactive_watcher_root;
|
397
|
+
}
|
398
|
+
|
399
|
+
static void close_fd_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
|
400
|
+
fd->closed = 1;
|
401
|
+
if (!fd->released) {
|
402
|
+
close(fd->fd);
|
403
|
+
}
|
404
|
+
grpc_closure_sched(exec_ctx, fd->on_done_closure, GRPC_ERROR_NONE);
|
405
|
+
}
|
406
|
+
|
407
|
+
static int fd_wrapped_fd(grpc_fd *fd) {
|
408
|
+
if (fd->released || fd->closed) {
|
409
|
+
return -1;
|
410
|
+
} else {
|
411
|
+
return fd->fd;
|
412
|
+
}
|
413
|
+
}
|
414
|
+
|
415
|
+
static void fd_orphan(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
416
|
+
grpc_closure *on_done, int *release_fd,
|
417
|
+
const char *reason) {
|
418
|
+
fd->on_done_closure = on_done;
|
419
|
+
fd->released = release_fd != NULL;
|
420
|
+
if (fd->released) {
|
421
|
+
*release_fd = fd->fd;
|
422
|
+
}
|
423
|
+
gpr_mu_lock(&fd->mu);
|
424
|
+
REF_BY(fd, 1, reason); /* remove active status, but keep referenced */
|
425
|
+
if (!has_watchers(fd)) {
|
426
|
+
close_fd_locked(exec_ctx, fd);
|
427
|
+
} else {
|
428
|
+
wake_all_watchers_locked(fd);
|
429
|
+
}
|
430
|
+
gpr_mu_unlock(&fd->mu);
|
431
|
+
UNREF_BY(fd, 2, reason); /* drop the reference */
|
432
|
+
}
|
433
|
+
|
434
|
+
/* increment refcount by two to avoid changing the orphan bit */
|
435
|
+
#ifdef GRPC_FD_REF_COUNT_DEBUG
|
436
|
+
static void fd_ref(grpc_fd *fd, const char *reason, const char *file,
|
437
|
+
int line) {
|
438
|
+
ref_by(fd, 2, reason, file, line);
|
439
|
+
}
|
440
|
+
|
441
|
+
static void fd_unref(grpc_fd *fd, const char *reason, const char *file,
|
442
|
+
int line) {
|
443
|
+
unref_by(fd, 2, reason, file, line);
|
444
|
+
}
|
445
|
+
#else
|
446
|
+
static void fd_ref(grpc_fd *fd) { ref_by(fd, 2); }
|
447
|
+
|
448
|
+
static void fd_unref(grpc_fd *fd) { unref_by(fd, 2); }
|
449
|
+
#endif
|
450
|
+
|
451
|
+
static grpc_error *fd_shutdown_error(grpc_fd *fd) {
|
452
|
+
if (!fd->shutdown) {
|
453
|
+
return GRPC_ERROR_NONE;
|
454
|
+
} else {
|
455
|
+
return GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
456
|
+
"FD shutdown", &fd->shutdown_error, 1);
|
457
|
+
}
|
458
|
+
}
|
459
|
+
|
460
|
+
static void notify_on_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
461
|
+
grpc_closure **st, grpc_closure *closure) {
|
462
|
+
if (fd->shutdown) {
|
463
|
+
grpc_closure_sched(exec_ctx, closure,
|
464
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("FD shutdown"));
|
465
|
+
} else if (*st == CLOSURE_NOT_READY) {
|
466
|
+
/* not ready ==> switch to a waiting state by setting the closure */
|
467
|
+
*st = closure;
|
468
|
+
} else if (*st == CLOSURE_READY) {
|
469
|
+
/* already ready ==> queue the closure to run immediately */
|
470
|
+
*st = CLOSURE_NOT_READY;
|
471
|
+
grpc_closure_sched(exec_ctx, closure, fd_shutdown_error(fd));
|
472
|
+
maybe_wake_one_watcher_locked(fd);
|
473
|
+
} else {
|
474
|
+
/* upcallptr was set to a different closure. This is an error! */
|
475
|
+
gpr_log(GPR_ERROR,
|
476
|
+
"User called a notify_on function with a previous callback still "
|
477
|
+
"pending");
|
478
|
+
abort();
|
479
|
+
}
|
480
|
+
}
|
481
|
+
|
482
|
+
/* returns 1 if state becomes not ready */
|
483
|
+
static int set_ready_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
484
|
+
grpc_closure **st) {
|
485
|
+
if (*st == CLOSURE_READY) {
|
486
|
+
/* duplicate ready ==> ignore */
|
487
|
+
return 0;
|
488
|
+
} else if (*st == CLOSURE_NOT_READY) {
|
489
|
+
/* not ready, and not waiting ==> flag ready */
|
490
|
+
*st = CLOSURE_READY;
|
491
|
+
return 0;
|
492
|
+
} else {
|
493
|
+
/* waiting ==> queue closure */
|
494
|
+
grpc_closure_sched(exec_ctx, *st, fd_shutdown_error(fd));
|
495
|
+
*st = CLOSURE_NOT_READY;
|
496
|
+
return 1;
|
497
|
+
}
|
498
|
+
}
|
499
|
+
|
500
|
+
static void set_read_notifier_pollset_locked(
|
501
|
+
grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_pollset *read_notifier_pollset) {
|
502
|
+
fd->read_notifier_pollset = read_notifier_pollset;
|
503
|
+
}
|
504
|
+
|
505
|
+
static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_error *why) {
|
506
|
+
gpr_mu_lock(&fd->mu);
|
507
|
+
/* only shutdown once */
|
508
|
+
if (!fd->shutdown) {
|
509
|
+
fd->shutdown = 1;
|
510
|
+
fd->shutdown_error = why;
|
511
|
+
/* signal read/write closed to OS so that future operations fail */
|
512
|
+
shutdown(fd->fd, SHUT_RDWR);
|
513
|
+
set_ready_locked(exec_ctx, fd, &fd->read_closure);
|
514
|
+
set_ready_locked(exec_ctx, fd, &fd->write_closure);
|
515
|
+
} else {
|
516
|
+
GRPC_ERROR_UNREF(why);
|
517
|
+
}
|
518
|
+
gpr_mu_unlock(&fd->mu);
|
519
|
+
}
|
520
|
+
|
521
|
+
static bool fd_is_shutdown(grpc_fd *fd) {
|
522
|
+
gpr_mu_lock(&fd->mu);
|
523
|
+
bool r = fd->shutdown;
|
524
|
+
gpr_mu_unlock(&fd->mu);
|
525
|
+
return r;
|
526
|
+
}
|
527
|
+
|
528
|
+
static void fd_notify_on_read(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
529
|
+
grpc_closure *closure) {
|
530
|
+
gpr_mu_lock(&fd->mu);
|
531
|
+
notify_on_locked(exec_ctx, fd, &fd->read_closure, closure);
|
532
|
+
gpr_mu_unlock(&fd->mu);
|
533
|
+
}
|
534
|
+
|
535
|
+
static void fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
|
536
|
+
grpc_closure *closure) {
|
537
|
+
gpr_mu_lock(&fd->mu);
|
538
|
+
notify_on_locked(exec_ctx, fd, &fd->write_closure, closure);
|
539
|
+
gpr_mu_unlock(&fd->mu);
|
540
|
+
}
|
541
|
+
|
542
|
+
static uint32_t fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
|
543
|
+
grpc_pollset_worker *worker, uint32_t read_mask,
|
544
|
+
uint32_t write_mask, grpc_fd_watcher *watcher) {
|
545
|
+
uint32_t mask = 0;
|
546
|
+
grpc_closure *cur;
|
547
|
+
int requested;
|
548
|
+
/* keep track of pollers that have requested our events, in case they change
|
549
|
+
*/
|
550
|
+
GRPC_FD_REF(fd, "poll");
|
551
|
+
|
552
|
+
gpr_mu_lock(&fd->mu);
|
553
|
+
|
554
|
+
/* if we are shutdown, then don't add to the watcher set */
|
555
|
+
if (fd->shutdown) {
|
556
|
+
watcher->fd = NULL;
|
557
|
+
watcher->pollset = NULL;
|
558
|
+
watcher->worker = NULL;
|
559
|
+
gpr_mu_unlock(&fd->mu);
|
560
|
+
GRPC_FD_UNREF(fd, "poll");
|
561
|
+
return 0;
|
562
|
+
}
|
563
|
+
|
564
|
+
/* if there is nobody polling for read, but we need to, then start doing so */
|
565
|
+
cur = fd->read_closure;
|
566
|
+
requested = cur != CLOSURE_READY;
|
567
|
+
if (read_mask && fd->read_watcher == NULL && requested) {
|
568
|
+
fd->read_watcher = watcher;
|
569
|
+
mask |= read_mask;
|
570
|
+
}
|
571
|
+
/* if there is nobody polling for write, but we need to, then start doing so
|
572
|
+
*/
|
573
|
+
cur = fd->write_closure;
|
574
|
+
requested = cur != CLOSURE_READY;
|
575
|
+
if (write_mask && fd->write_watcher == NULL && requested) {
|
576
|
+
fd->write_watcher = watcher;
|
577
|
+
mask |= write_mask;
|
578
|
+
}
|
579
|
+
/* if not polling, remember this watcher in case we need someone to later */
|
580
|
+
if (mask == 0 && worker != NULL) {
|
581
|
+
watcher->next = &fd->inactive_watcher_root;
|
582
|
+
watcher->prev = watcher->next->prev;
|
583
|
+
watcher->next->prev = watcher->prev->next = watcher;
|
584
|
+
}
|
585
|
+
watcher->pollset = pollset;
|
586
|
+
watcher->worker = worker;
|
587
|
+
watcher->fd = fd;
|
588
|
+
gpr_mu_unlock(&fd->mu);
|
589
|
+
|
590
|
+
return mask;
|
591
|
+
}
|
592
|
+
|
593
|
+
static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
|
594
|
+
int got_read, int got_write,
|
595
|
+
grpc_pollset *read_notifier_pollset) {
|
596
|
+
int was_polling = 0;
|
597
|
+
int kick = 0;
|
598
|
+
grpc_fd *fd = watcher->fd;
|
599
|
+
|
600
|
+
if (fd == NULL) {
|
601
|
+
return;
|
602
|
+
}
|
603
|
+
|
604
|
+
gpr_mu_lock(&fd->mu);
|
605
|
+
|
606
|
+
if (watcher == fd->read_watcher) {
|
607
|
+
/* remove read watcher, kick if we still need a read */
|
608
|
+
was_polling = 1;
|
609
|
+
if (!got_read) {
|
610
|
+
kick = 1;
|
611
|
+
}
|
612
|
+
fd->read_watcher = NULL;
|
613
|
+
}
|
614
|
+
if (watcher == fd->write_watcher) {
|
615
|
+
/* remove write watcher, kick if we still need a write */
|
616
|
+
was_polling = 1;
|
617
|
+
if (!got_write) {
|
618
|
+
kick = 1;
|
619
|
+
}
|
620
|
+
fd->write_watcher = NULL;
|
621
|
+
}
|
622
|
+
if (!was_polling && watcher->worker != NULL) {
|
623
|
+
/* remove from inactive list */
|
624
|
+
watcher->next->prev = watcher->prev;
|
625
|
+
watcher->prev->next = watcher->next;
|
626
|
+
}
|
627
|
+
if (got_read) {
|
628
|
+
if (set_ready_locked(exec_ctx, fd, &fd->read_closure)) {
|
629
|
+
kick = 1;
|
630
|
+
}
|
631
|
+
if (read_notifier_pollset != NULL) {
|
632
|
+
set_read_notifier_pollset_locked(exec_ctx, fd, read_notifier_pollset);
|
633
|
+
}
|
634
|
+
}
|
635
|
+
if (got_write) {
|
636
|
+
if (set_ready_locked(exec_ctx, fd, &fd->write_closure)) {
|
637
|
+
kick = 1;
|
638
|
+
}
|
639
|
+
}
|
640
|
+
if (kick) {
|
641
|
+
maybe_wake_one_watcher_locked(fd);
|
642
|
+
}
|
643
|
+
if (fd_is_orphaned(fd) && !has_watchers(fd) && !fd->closed) {
|
644
|
+
close_fd_locked(exec_ctx, fd);
|
645
|
+
}
|
646
|
+
gpr_mu_unlock(&fd->mu);
|
647
|
+
|
648
|
+
GRPC_FD_UNREF(fd, "poll");
|
649
|
+
}
|
650
|
+
|
651
|
+
static grpc_workqueue *fd_get_workqueue(grpc_fd *fd) { return NULL; }
|
652
|
+
|
653
|
+
/*******************************************************************************
|
654
|
+
* pollset_posix.c
|
655
|
+
*/
|
656
|
+
|
657
|
+
GPR_TLS_DECL(g_current_thread_poller);
|
658
|
+
GPR_TLS_DECL(g_current_thread_worker);
|
659
|
+
|
660
|
+
static void remove_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
|
661
|
+
worker->prev->next = worker->next;
|
662
|
+
worker->next->prev = worker->prev;
|
663
|
+
}
|
664
|
+
|
665
|
+
static bool pollset_has_workers(grpc_pollset *p) {
|
666
|
+
return p->root_worker.next != &p->root_worker;
|
667
|
+
}
|
668
|
+
|
669
|
+
static bool pollset_in_pollset_sets(grpc_pollset *p) {
|
670
|
+
return p->pollset_set_count;
|
671
|
+
}
|
672
|
+
|
673
|
+
static bool pollset_has_observers(grpc_pollset *p) {
|
674
|
+
return pollset_has_workers(p) || pollset_in_pollset_sets(p);
|
675
|
+
}
|
676
|
+
|
677
|
+
static grpc_pollset_worker *pop_front_worker(grpc_pollset *p) {
|
678
|
+
if (pollset_has_workers(p)) {
|
679
|
+
grpc_pollset_worker *w = p->root_worker.next;
|
680
|
+
remove_worker(p, w);
|
681
|
+
return w;
|
682
|
+
} else {
|
683
|
+
return NULL;
|
684
|
+
}
|
685
|
+
}
|
686
|
+
|
687
|
+
static void push_back_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
|
688
|
+
worker->next = &p->root_worker;
|
689
|
+
worker->prev = worker->next->prev;
|
690
|
+
worker->prev->next = worker->next->prev = worker;
|
691
|
+
}
|
692
|
+
|
693
|
+
static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) {
|
694
|
+
worker->prev = &p->root_worker;
|
695
|
+
worker->next = worker->prev->next;
|
696
|
+
worker->prev->next = worker->next->prev = worker;
|
697
|
+
}
|
698
|
+
|
699
|
+
static void kick_append_error(grpc_error **composite, grpc_error *error) {
|
700
|
+
if (error == GRPC_ERROR_NONE) return;
|
701
|
+
if (*composite == GRPC_ERROR_NONE) {
|
702
|
+
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Kick Failure");
|
703
|
+
}
|
704
|
+
*composite = grpc_error_add_child(*composite, error);
|
705
|
+
}
|
706
|
+
|
707
|
+
static grpc_error *pollset_kick_ext(grpc_pollset *p,
|
708
|
+
grpc_pollset_worker *specific_worker,
|
709
|
+
uint32_t flags) {
|
710
|
+
GPR_TIMER_BEGIN("pollset_kick_ext", 0);
|
711
|
+
grpc_error *error = GRPC_ERROR_NONE;
|
712
|
+
|
713
|
+
/* pollset->mu already held */
|
714
|
+
if (specific_worker != NULL) {
|
715
|
+
if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
|
716
|
+
GPR_TIMER_BEGIN("pollset_kick_ext.broadcast", 0);
|
717
|
+
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0);
|
718
|
+
for (specific_worker = p->root_worker.next;
|
719
|
+
specific_worker != &p->root_worker;
|
720
|
+
specific_worker = specific_worker->next) {
|
721
|
+
kick_append_error(
|
722
|
+
&error, grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd->fd));
|
723
|
+
}
|
724
|
+
p->kicked_without_pollers = true;
|
725
|
+
GPR_TIMER_END("pollset_kick_ext.broadcast", 0);
|
726
|
+
} else if (gpr_tls_get(&g_current_thread_worker) !=
|
727
|
+
(intptr_t)specific_worker) {
|
728
|
+
GPR_TIMER_MARK("different_thread_worker", 0);
|
729
|
+
if ((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) != 0) {
|
730
|
+
specific_worker->reevaluate_polling_on_wakeup = true;
|
731
|
+
}
|
732
|
+
specific_worker->kicked_specifically = true;
|
733
|
+
kick_append_error(&error,
|
734
|
+
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd->fd));
|
735
|
+
} else if ((flags & GRPC_POLLSET_CAN_KICK_SELF) != 0) {
|
736
|
+
GPR_TIMER_MARK("kick_yoself", 0);
|
737
|
+
if ((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) != 0) {
|
738
|
+
specific_worker->reevaluate_polling_on_wakeup = true;
|
739
|
+
}
|
740
|
+
specific_worker->kicked_specifically = true;
|
741
|
+
kick_append_error(&error,
|
742
|
+
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd->fd));
|
743
|
+
}
|
744
|
+
} else if (gpr_tls_get(&g_current_thread_poller) != (intptr_t)p) {
|
745
|
+
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0);
|
746
|
+
GPR_TIMER_MARK("kick_anonymous", 0);
|
747
|
+
specific_worker = pop_front_worker(p);
|
748
|
+
if (specific_worker != NULL) {
|
749
|
+
if (gpr_tls_get(&g_current_thread_worker) == (intptr_t)specific_worker) {
|
750
|
+
GPR_TIMER_MARK("kick_anonymous_not_self", 0);
|
751
|
+
push_back_worker(p, specific_worker);
|
752
|
+
specific_worker = pop_front_worker(p);
|
753
|
+
if ((flags & GRPC_POLLSET_CAN_KICK_SELF) == 0 &&
|
754
|
+
gpr_tls_get(&g_current_thread_worker) ==
|
755
|
+
(intptr_t)specific_worker) {
|
756
|
+
push_back_worker(p, specific_worker);
|
757
|
+
specific_worker = NULL;
|
758
|
+
}
|
759
|
+
}
|
760
|
+
if (specific_worker != NULL) {
|
761
|
+
GPR_TIMER_MARK("finally_kick", 0);
|
762
|
+
push_back_worker(p, specific_worker);
|
763
|
+
kick_append_error(
|
764
|
+
&error, grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd->fd));
|
765
|
+
}
|
766
|
+
} else {
|
767
|
+
GPR_TIMER_MARK("kicked_no_pollers", 0);
|
768
|
+
p->kicked_without_pollers = true;
|
769
|
+
}
|
770
|
+
}
|
771
|
+
|
772
|
+
GPR_TIMER_END("pollset_kick_ext", 0);
|
773
|
+
GRPC_LOG_IF_ERROR("pollset_kick_ext", GRPC_ERROR_REF(error));
|
774
|
+
return error;
|
775
|
+
}
|
776
|
+
|
777
|
+
static grpc_error *pollset_kick(grpc_pollset *p,
|
778
|
+
grpc_pollset_worker *specific_worker) {
|
779
|
+
return pollset_kick_ext(p, specific_worker, 0);
|
780
|
+
}
|
781
|
+
|
782
|
+
/* global state management */
|
783
|
+
|
784
|
+
static grpc_error *pollset_global_init(void) {
|
785
|
+
gpr_tls_init(&g_current_thread_poller);
|
786
|
+
gpr_tls_init(&g_current_thread_worker);
|
787
|
+
return grpc_wakeup_fd_init(&global_wakeup_fd);
|
788
|
+
}
|
789
|
+
|
790
|
+
static void pollset_global_shutdown(void) {
|
791
|
+
grpc_wakeup_fd_destroy(&global_wakeup_fd);
|
792
|
+
gpr_tls_destroy(&g_current_thread_poller);
|
793
|
+
gpr_tls_destroy(&g_current_thread_worker);
|
794
|
+
}
|
795
|
+
|
796
|
+
static grpc_error *kick_poller(void) {
|
797
|
+
return grpc_wakeup_fd_wakeup(&global_wakeup_fd);
|
798
|
+
}
|
799
|
+
|
800
|
+
/* main interface */
|
801
|
+
|
802
|
+
static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
|
803
|
+
gpr_mu_init(&pollset->mu);
|
804
|
+
*mu = &pollset->mu;
|
805
|
+
pollset->root_worker.next = pollset->root_worker.prev = &pollset->root_worker;
|
806
|
+
pollset->shutting_down = 0;
|
807
|
+
pollset->called_shutdown = 0;
|
808
|
+
pollset->kicked_without_pollers = 0;
|
809
|
+
pollset->idle_jobs.head = pollset->idle_jobs.tail = NULL;
|
810
|
+
pollset->local_wakeup_cache = NULL;
|
811
|
+
pollset->kicked_without_pollers = 0;
|
812
|
+
pollset->fd_count = 0;
|
813
|
+
pollset->fd_capacity = 0;
|
814
|
+
pollset->fds = NULL;
|
815
|
+
pollset->pollset_set_count = 0;
|
816
|
+
}
|
817
|
+
|
818
|
+
static void pollset_destroy(grpc_pollset *pollset) {
|
819
|
+
GPR_ASSERT(!pollset_has_workers(pollset));
|
820
|
+
GPR_ASSERT(pollset->idle_jobs.head == pollset->idle_jobs.tail);
|
821
|
+
while (pollset->local_wakeup_cache) {
|
822
|
+
grpc_cached_wakeup_fd *next = pollset->local_wakeup_cache->next;
|
823
|
+
grpc_wakeup_fd_destroy(&pollset->local_wakeup_cache->fd);
|
824
|
+
gpr_free(pollset->local_wakeup_cache);
|
825
|
+
pollset->local_wakeup_cache = next;
|
826
|
+
}
|
827
|
+
gpr_free(pollset->fds);
|
828
|
+
gpr_mu_destroy(&pollset->mu);
|
829
|
+
}
|
830
|
+
|
831
|
+
static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
832
|
+
grpc_fd *fd) {
|
833
|
+
gpr_mu_lock(&pollset->mu);
|
834
|
+
size_t i;
|
835
|
+
/* TODO(ctiller): this is O(num_fds^2); maybe switch to a hash set here */
|
836
|
+
for (i = 0; i < pollset->fd_count; i++) {
|
837
|
+
if (pollset->fds[i] == fd) goto exit;
|
838
|
+
}
|
839
|
+
if (pollset->fd_count == pollset->fd_capacity) {
|
840
|
+
pollset->fd_capacity =
|
841
|
+
GPR_MAX(pollset->fd_capacity + 8, pollset->fd_count * 3 / 2);
|
842
|
+
pollset->fds =
|
843
|
+
gpr_realloc(pollset->fds, sizeof(grpc_fd *) * pollset->fd_capacity);
|
844
|
+
}
|
845
|
+
pollset->fds[pollset->fd_count++] = fd;
|
846
|
+
GRPC_FD_REF(fd, "multipoller");
|
847
|
+
pollset_kick(pollset, NULL);
|
848
|
+
exit:
|
849
|
+
gpr_mu_unlock(&pollset->mu);
|
850
|
+
}
|
851
|
+
|
852
|
+
static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
|
853
|
+
GPR_ASSERT(grpc_closure_list_empty(pollset->idle_jobs));
|
854
|
+
size_t i;
|
855
|
+
for (i = 0; i < pollset->fd_count; i++) {
|
856
|
+
GRPC_FD_UNREF(pollset->fds[i], "multipoller");
|
857
|
+
}
|
858
|
+
pollset->fd_count = 0;
|
859
|
+
grpc_closure_sched(exec_ctx, pollset->shutdown_done, GRPC_ERROR_NONE);
|
860
|
+
}
|
861
|
+
|
862
|
+
static void work_combine_error(grpc_error **composite, grpc_error *error) {
|
863
|
+
if (error == GRPC_ERROR_NONE) return;
|
864
|
+
if (*composite == GRPC_ERROR_NONE) {
|
865
|
+
*composite = GRPC_ERROR_CREATE_FROM_STATIC_STRING("pollset_work");
|
866
|
+
}
|
867
|
+
*composite = grpc_error_add_child(*composite, error);
|
868
|
+
}
|
869
|
+
|
870
|
+
static grpc_error *pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
871
|
+
grpc_pollset_worker **worker_hdl,
|
872
|
+
gpr_timespec now, gpr_timespec deadline) {
|
873
|
+
grpc_pollset_worker worker;
|
874
|
+
if (worker_hdl) *worker_hdl = &worker;
|
875
|
+
grpc_error *error = GRPC_ERROR_NONE;
|
876
|
+
|
877
|
+
/* Avoid malloc for small number of elements. */
|
878
|
+
enum { inline_elements = 96 };
|
879
|
+
struct pollfd pollfd_space[inline_elements];
|
880
|
+
struct grpc_fd_watcher watcher_space[inline_elements];
|
881
|
+
|
882
|
+
/* pollset->mu already held */
|
883
|
+
int added_worker = 0;
|
884
|
+
int locked = 1;
|
885
|
+
int queued_work = 0;
|
886
|
+
int keep_polling = 0;
|
887
|
+
GPR_TIMER_BEGIN("pollset_work", 0);
|
888
|
+
/* this must happen before we (potentially) drop pollset->mu */
|
889
|
+
worker.next = worker.prev = NULL;
|
890
|
+
worker.reevaluate_polling_on_wakeup = 0;
|
891
|
+
if (pollset->local_wakeup_cache != NULL) {
|
892
|
+
worker.wakeup_fd = pollset->local_wakeup_cache;
|
893
|
+
pollset->local_wakeup_cache = worker.wakeup_fd->next;
|
894
|
+
} else {
|
895
|
+
worker.wakeup_fd = gpr_malloc(sizeof(*worker.wakeup_fd));
|
896
|
+
error = grpc_wakeup_fd_init(&worker.wakeup_fd->fd);
|
897
|
+
if (error != GRPC_ERROR_NONE) {
|
898
|
+
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
|
899
|
+
return error;
|
900
|
+
}
|
901
|
+
}
|
902
|
+
worker.kicked_specifically = 0;
|
903
|
+
/* If there's work waiting for the pollset to be idle, and the
|
904
|
+
pollset is idle, then do that work */
|
905
|
+
if (!pollset_has_workers(pollset) &&
|
906
|
+
!grpc_closure_list_empty(pollset->idle_jobs)) {
|
907
|
+
GPR_TIMER_MARK("pollset_work.idle_jobs", 0);
|
908
|
+
grpc_closure_list_sched(exec_ctx, &pollset->idle_jobs);
|
909
|
+
goto done;
|
910
|
+
}
|
911
|
+
/* If we're shutting down then we don't execute any extended work */
|
912
|
+
if (pollset->shutting_down) {
|
913
|
+
GPR_TIMER_MARK("pollset_work.shutting_down", 0);
|
914
|
+
goto done;
|
915
|
+
}
|
916
|
+
/* Start polling, and keep doing so while we're being asked to
|
917
|
+
re-evaluate our pollers (this allows poll() based pollers to
|
918
|
+
ensure they don't miss wakeups) */
|
919
|
+
keep_polling = 1;
|
920
|
+
gpr_tls_set(&g_current_thread_poller, (intptr_t)pollset);
|
921
|
+
while (keep_polling) {
|
922
|
+
keep_polling = 0;
|
923
|
+
if (!pollset->kicked_without_pollers) {
|
924
|
+
if (!added_worker) {
|
925
|
+
push_front_worker(pollset, &worker);
|
926
|
+
added_worker = 1;
|
927
|
+
gpr_tls_set(&g_current_thread_worker, (intptr_t)&worker);
|
928
|
+
}
|
929
|
+
GPR_TIMER_BEGIN("maybe_work_and_unlock", 0);
|
930
|
+
#define POLLOUT_CHECK (POLLOUT | POLLHUP | POLLERR)
|
931
|
+
#define POLLIN_CHECK (POLLIN | POLLHUP | POLLERR)
|
932
|
+
|
933
|
+
int timeout;
|
934
|
+
int r;
|
935
|
+
size_t i, fd_count;
|
936
|
+
nfds_t pfd_count;
|
937
|
+
grpc_fd_watcher *watchers;
|
938
|
+
struct pollfd *pfds;
|
939
|
+
|
940
|
+
timeout = poll_deadline_to_millis_timeout(deadline, now);
|
941
|
+
|
942
|
+
if (pollset->fd_count + 2 <= inline_elements) {
|
943
|
+
pfds = pollfd_space;
|
944
|
+
watchers = watcher_space;
|
945
|
+
} else {
|
946
|
+
/* Allocate one buffer to hold both pfds and watchers arrays */
|
947
|
+
const size_t pfd_size = sizeof(*pfds) * (pollset->fd_count + 2);
|
948
|
+
const size_t watch_size = sizeof(*watchers) * (pollset->fd_count + 2);
|
949
|
+
void *buf = gpr_malloc(pfd_size + watch_size);
|
950
|
+
pfds = buf;
|
951
|
+
watchers = (void *)((char *)buf + pfd_size);
|
952
|
+
}
|
953
|
+
|
954
|
+
fd_count = 0;
|
955
|
+
pfd_count = 2;
|
956
|
+
pfds[0].fd = GRPC_WAKEUP_FD_GET_READ_FD(&global_wakeup_fd);
|
957
|
+
pfds[0].events = POLLIN;
|
958
|
+
pfds[0].revents = 0;
|
959
|
+
pfds[1].fd = GRPC_WAKEUP_FD_GET_READ_FD(&worker.wakeup_fd->fd);
|
960
|
+
pfds[1].events = POLLIN;
|
961
|
+
pfds[1].revents = 0;
|
962
|
+
for (i = 0; i < pollset->fd_count; i++) {
|
963
|
+
if (fd_is_orphaned(pollset->fds[i])) {
|
964
|
+
GRPC_FD_UNREF(pollset->fds[i], "multipoller");
|
965
|
+
} else {
|
966
|
+
pollset->fds[fd_count++] = pollset->fds[i];
|
967
|
+
watchers[pfd_count].fd = pollset->fds[i];
|
968
|
+
GRPC_FD_REF(watchers[pfd_count].fd, "multipoller_start");
|
969
|
+
pfds[pfd_count].fd = pollset->fds[i]->fd;
|
970
|
+
pfds[pfd_count].revents = 0;
|
971
|
+
pfd_count++;
|
972
|
+
}
|
973
|
+
}
|
974
|
+
pollset->fd_count = fd_count;
|
975
|
+
gpr_mu_unlock(&pollset->mu);
|
976
|
+
|
977
|
+
for (i = 2; i < pfd_count; i++) {
|
978
|
+
grpc_fd *fd = watchers[i].fd;
|
979
|
+
pfds[i].events = (short)fd_begin_poll(fd, pollset, &worker, POLLIN,
|
980
|
+
POLLOUT, &watchers[i]);
|
981
|
+
GRPC_FD_UNREF(fd, "multipoller_start");
|
982
|
+
}
|
983
|
+
|
984
|
+
/* TODO(vpai): Consider first doing a 0 timeout poll here to avoid
|
985
|
+
even going into the blocking annotation if possible */
|
986
|
+
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
987
|
+
r = grpc_poll_function(pfds, pfd_count, timeout);
|
988
|
+
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
989
|
+
|
990
|
+
if (r < 0) {
|
991
|
+
if (errno != EINTR) {
|
992
|
+
work_combine_error(&error, GRPC_OS_ERROR(errno, "poll"));
|
993
|
+
}
|
994
|
+
|
995
|
+
for (i = 2; i < pfd_count; i++) {
|
996
|
+
if (watchers[i].fd == NULL) {
|
997
|
+
fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
|
998
|
+
} else {
|
999
|
+
// Wake up all the file descriptors, if we have an invalid one
|
1000
|
+
// we can identify it on the next pollset_work()
|
1001
|
+
fd_end_poll(exec_ctx, &watchers[i], 1, 1, pollset);
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
} else if (r == 0) {
|
1005
|
+
for (i = 2; i < pfd_count; i++) {
|
1006
|
+
fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
|
1007
|
+
}
|
1008
|
+
} else {
|
1009
|
+
if (pfds[0].revents & POLLIN_CHECK) {
|
1010
|
+
grpc_timer_consume_kick();
|
1011
|
+
work_combine_error(&error,
|
1012
|
+
grpc_wakeup_fd_consume_wakeup(&global_wakeup_fd));
|
1013
|
+
}
|
1014
|
+
if (pfds[1].revents & POLLIN_CHECK) {
|
1015
|
+
work_combine_error(
|
1016
|
+
&error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd));
|
1017
|
+
}
|
1018
|
+
for (i = 2; i < pfd_count; i++) {
|
1019
|
+
if (watchers[i].fd == NULL) {
|
1020
|
+
fd_end_poll(exec_ctx, &watchers[i], 0, 0, NULL);
|
1021
|
+
} else {
|
1022
|
+
fd_end_poll(exec_ctx, &watchers[i], pfds[i].revents & POLLIN_CHECK,
|
1023
|
+
pfds[i].revents & POLLOUT_CHECK, pollset);
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
if (pfds != pollfd_space) {
|
1029
|
+
/* pfds and watchers are in the same memory block pointed to by pfds */
|
1030
|
+
gpr_free(pfds);
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
GPR_TIMER_END("maybe_work_and_unlock", 0);
|
1034
|
+
locked = 0;
|
1035
|
+
} else {
|
1036
|
+
GPR_TIMER_MARK("pollset_work.kicked_without_pollers", 0);
|
1037
|
+
pollset->kicked_without_pollers = 0;
|
1038
|
+
}
|
1039
|
+
/* Finished execution - start cleaning up.
|
1040
|
+
Note that we may arrive here from outside the enclosing while() loop.
|
1041
|
+
In that case we won't loop though as we haven't added worker to the
|
1042
|
+
worker list, which means nobody could ask us to re-evaluate polling). */
|
1043
|
+
done:
|
1044
|
+
if (!locked) {
|
1045
|
+
queued_work |= grpc_exec_ctx_flush(exec_ctx);
|
1046
|
+
gpr_mu_lock(&pollset->mu);
|
1047
|
+
locked = 1;
|
1048
|
+
}
|
1049
|
+
/* If we're forced to re-evaluate polling (via pollset_kick with
|
1050
|
+
GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) then we land here and force
|
1051
|
+
a loop */
|
1052
|
+
if (worker.reevaluate_polling_on_wakeup && error == GRPC_ERROR_NONE) {
|
1053
|
+
worker.reevaluate_polling_on_wakeup = 0;
|
1054
|
+
pollset->kicked_without_pollers = 0;
|
1055
|
+
if (queued_work || worker.kicked_specifically) {
|
1056
|
+
/* If there's queued work on the list, then set the deadline to be
|
1057
|
+
immediate so we get back out of the polling loop quickly */
|
1058
|
+
deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC);
|
1059
|
+
}
|
1060
|
+
keep_polling = 1;
|
1061
|
+
}
|
1062
|
+
if (keep_polling) {
|
1063
|
+
now = gpr_now(now.clock_type);
|
1064
|
+
}
|
1065
|
+
}
|
1066
|
+
gpr_tls_set(&g_current_thread_poller, 0);
|
1067
|
+
if (added_worker) {
|
1068
|
+
remove_worker(pollset, &worker);
|
1069
|
+
gpr_tls_set(&g_current_thread_worker, 0);
|
1070
|
+
}
|
1071
|
+
/* release wakeup fd to the local pool */
|
1072
|
+
worker.wakeup_fd->next = pollset->local_wakeup_cache;
|
1073
|
+
pollset->local_wakeup_cache = worker.wakeup_fd;
|
1074
|
+
/* check shutdown conditions */
|
1075
|
+
if (pollset->shutting_down) {
|
1076
|
+
if (pollset_has_workers(pollset)) {
|
1077
|
+
pollset_kick(pollset, NULL);
|
1078
|
+
} else if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
|
1079
|
+
pollset->called_shutdown = 1;
|
1080
|
+
gpr_mu_unlock(&pollset->mu);
|
1081
|
+
finish_shutdown(exec_ctx, pollset);
|
1082
|
+
grpc_exec_ctx_flush(exec_ctx);
|
1083
|
+
/* Continuing to access pollset here is safe -- it is the caller's
|
1084
|
+
* responsibility to not destroy when it has outstanding calls to
|
1085
|
+
* pollset_work.
|
1086
|
+
* TODO(dklempner): Can we refactor the shutdown logic to avoid this? */
|
1087
|
+
gpr_mu_lock(&pollset->mu);
|
1088
|
+
} else if (!grpc_closure_list_empty(pollset->idle_jobs)) {
|
1089
|
+
grpc_closure_list_sched(exec_ctx, &pollset->idle_jobs);
|
1090
|
+
gpr_mu_unlock(&pollset->mu);
|
1091
|
+
grpc_exec_ctx_flush(exec_ctx);
|
1092
|
+
gpr_mu_lock(&pollset->mu);
|
1093
|
+
}
|
1094
|
+
}
|
1095
|
+
if (worker_hdl) *worker_hdl = NULL;
|
1096
|
+
GPR_TIMER_END("pollset_work", 0);
|
1097
|
+
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
|
1098
|
+
return error;
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
static void pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
|
1102
|
+
grpc_closure *closure) {
|
1103
|
+
GPR_ASSERT(!pollset->shutting_down);
|
1104
|
+
pollset->shutting_down = 1;
|
1105
|
+
pollset->shutdown_done = closure;
|
1106
|
+
pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
|
1107
|
+
if (!pollset_has_workers(pollset)) {
|
1108
|
+
grpc_closure_list_sched(exec_ctx, &pollset->idle_jobs);
|
1109
|
+
}
|
1110
|
+
if (!pollset->called_shutdown && !pollset_has_observers(pollset)) {
|
1111
|
+
pollset->called_shutdown = 1;
|
1112
|
+
finish_shutdown(exec_ctx, pollset);
|
1113
|
+
}
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
static int poll_deadline_to_millis_timeout(gpr_timespec deadline,
|
1117
|
+
gpr_timespec now) {
|
1118
|
+
gpr_timespec timeout;
|
1119
|
+
static const int64_t max_spin_polling_us = 10;
|
1120
|
+
if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) {
|
1121
|
+
return -1;
|
1122
|
+
}
|
1123
|
+
if (gpr_time_cmp(deadline, gpr_time_add(now, gpr_time_from_micros(
|
1124
|
+
max_spin_polling_us,
|
1125
|
+
GPR_TIMESPAN))) <= 0) {
|
1126
|
+
return 0;
|
1127
|
+
}
|
1128
|
+
timeout = gpr_time_sub(deadline, now);
|
1129
|
+
return gpr_time_to_millis(gpr_time_add(
|
1130
|
+
timeout, gpr_time_from_nanos(GPR_NS_PER_MS - 1, GPR_TIMESPAN)));
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
/*******************************************************************************
|
1134
|
+
* pollset_set_posix.c
|
1135
|
+
*/
|
1136
|
+
|
1137
|
+
static grpc_pollset_set *pollset_set_create(void) {
|
1138
|
+
grpc_pollset_set *pollset_set = gpr_zalloc(sizeof(*pollset_set));
|
1139
|
+
gpr_mu_init(&pollset_set->mu);
|
1140
|
+
return pollset_set;
|
1141
|
+
}
|
1142
|
+
|
1143
|
+
static void pollset_set_destroy(grpc_exec_ctx *exec_ctx,
|
1144
|
+
grpc_pollset_set *pollset_set) {
|
1145
|
+
size_t i;
|
1146
|
+
gpr_mu_destroy(&pollset_set->mu);
|
1147
|
+
for (i = 0; i < pollset_set->fd_count; i++) {
|
1148
|
+
GRPC_FD_UNREF(pollset_set->fds[i], "pollset_set");
|
1149
|
+
}
|
1150
|
+
for (i = 0; i < pollset_set->pollset_count; i++) {
|
1151
|
+
grpc_pollset *pollset = pollset_set->pollsets[i];
|
1152
|
+
gpr_mu_lock(&pollset->mu);
|
1153
|
+
pollset->pollset_set_count--;
|
1154
|
+
/* check shutdown */
|
1155
|
+
if (pollset->shutting_down && !pollset->called_shutdown &&
|
1156
|
+
!pollset_has_observers(pollset)) {
|
1157
|
+
pollset->called_shutdown = 1;
|
1158
|
+
gpr_mu_unlock(&pollset->mu);
|
1159
|
+
finish_shutdown(exec_ctx, pollset);
|
1160
|
+
} else {
|
1161
|
+
gpr_mu_unlock(&pollset->mu);
|
1162
|
+
}
|
1163
|
+
}
|
1164
|
+
gpr_free(pollset_set->pollsets);
|
1165
|
+
gpr_free(pollset_set->pollset_sets);
|
1166
|
+
gpr_free(pollset_set->fds);
|
1167
|
+
gpr_free(pollset_set);
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
static void pollset_set_add_pollset(grpc_exec_ctx *exec_ctx,
|
1171
|
+
grpc_pollset_set *pollset_set,
|
1172
|
+
grpc_pollset *pollset) {
|
1173
|
+
size_t i, j;
|
1174
|
+
gpr_mu_lock(&pollset->mu);
|
1175
|
+
pollset->pollset_set_count++;
|
1176
|
+
gpr_mu_unlock(&pollset->mu);
|
1177
|
+
gpr_mu_lock(&pollset_set->mu);
|
1178
|
+
if (pollset_set->pollset_count == pollset_set->pollset_capacity) {
|
1179
|
+
pollset_set->pollset_capacity =
|
1180
|
+
GPR_MAX(8, 2 * pollset_set->pollset_capacity);
|
1181
|
+
pollset_set->pollsets =
|
1182
|
+
gpr_realloc(pollset_set->pollsets, pollset_set->pollset_capacity *
|
1183
|
+
sizeof(*pollset_set->pollsets));
|
1184
|
+
}
|
1185
|
+
pollset_set->pollsets[pollset_set->pollset_count++] = pollset;
|
1186
|
+
for (i = 0, j = 0; i < pollset_set->fd_count; i++) {
|
1187
|
+
if (fd_is_orphaned(pollset_set->fds[i])) {
|
1188
|
+
GRPC_FD_UNREF(pollset_set->fds[i], "pollset_set");
|
1189
|
+
} else {
|
1190
|
+
pollset_add_fd(exec_ctx, pollset, pollset_set->fds[i]);
|
1191
|
+
pollset_set->fds[j++] = pollset_set->fds[i];
|
1192
|
+
}
|
1193
|
+
}
|
1194
|
+
pollset_set->fd_count = j;
|
1195
|
+
gpr_mu_unlock(&pollset_set->mu);
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
static void pollset_set_del_pollset(grpc_exec_ctx *exec_ctx,
|
1199
|
+
grpc_pollset_set *pollset_set,
|
1200
|
+
grpc_pollset *pollset) {
|
1201
|
+
size_t i;
|
1202
|
+
gpr_mu_lock(&pollset_set->mu);
|
1203
|
+
for (i = 0; i < pollset_set->pollset_count; i++) {
|
1204
|
+
if (pollset_set->pollsets[i] == pollset) {
|
1205
|
+
pollset_set->pollset_count--;
|
1206
|
+
GPR_SWAP(grpc_pollset *, pollset_set->pollsets[i],
|
1207
|
+
pollset_set->pollsets[pollset_set->pollset_count]);
|
1208
|
+
break;
|
1209
|
+
}
|
1210
|
+
}
|
1211
|
+
gpr_mu_unlock(&pollset_set->mu);
|
1212
|
+
gpr_mu_lock(&pollset->mu);
|
1213
|
+
pollset->pollset_set_count--;
|
1214
|
+
/* check shutdown */
|
1215
|
+
if (pollset->shutting_down && !pollset->called_shutdown &&
|
1216
|
+
!pollset_has_observers(pollset)) {
|
1217
|
+
pollset->called_shutdown = 1;
|
1218
|
+
gpr_mu_unlock(&pollset->mu);
|
1219
|
+
finish_shutdown(exec_ctx, pollset);
|
1220
|
+
} else {
|
1221
|
+
gpr_mu_unlock(&pollset->mu);
|
1222
|
+
}
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
static void pollset_set_add_pollset_set(grpc_exec_ctx *exec_ctx,
|
1226
|
+
grpc_pollset_set *bag,
|
1227
|
+
grpc_pollset_set *item) {
|
1228
|
+
size_t i, j;
|
1229
|
+
gpr_mu_lock(&bag->mu);
|
1230
|
+
if (bag->pollset_set_count == bag->pollset_set_capacity) {
|
1231
|
+
bag->pollset_set_capacity = GPR_MAX(8, 2 * bag->pollset_set_capacity);
|
1232
|
+
bag->pollset_sets =
|
1233
|
+
gpr_realloc(bag->pollset_sets,
|
1234
|
+
bag->pollset_set_capacity * sizeof(*bag->pollset_sets));
|
1235
|
+
}
|
1236
|
+
bag->pollset_sets[bag->pollset_set_count++] = item;
|
1237
|
+
for (i = 0, j = 0; i < bag->fd_count; i++) {
|
1238
|
+
if (fd_is_orphaned(bag->fds[i])) {
|
1239
|
+
GRPC_FD_UNREF(bag->fds[i], "pollset_set");
|
1240
|
+
} else {
|
1241
|
+
pollset_set_add_fd(exec_ctx, item, bag->fds[i]);
|
1242
|
+
bag->fds[j++] = bag->fds[i];
|
1243
|
+
}
|
1244
|
+
}
|
1245
|
+
bag->fd_count = j;
|
1246
|
+
gpr_mu_unlock(&bag->mu);
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
static void pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
|
1250
|
+
grpc_pollset_set *bag,
|
1251
|
+
grpc_pollset_set *item) {
|
1252
|
+
size_t i;
|
1253
|
+
gpr_mu_lock(&bag->mu);
|
1254
|
+
for (i = 0; i < bag->pollset_set_count; i++) {
|
1255
|
+
if (bag->pollset_sets[i] == item) {
|
1256
|
+
bag->pollset_set_count--;
|
1257
|
+
GPR_SWAP(grpc_pollset_set *, bag->pollset_sets[i],
|
1258
|
+
bag->pollset_sets[bag->pollset_set_count]);
|
1259
|
+
break;
|
1260
|
+
}
|
1261
|
+
}
|
1262
|
+
gpr_mu_unlock(&bag->mu);
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
static void pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
|
1266
|
+
grpc_pollset_set *pollset_set, grpc_fd *fd) {
|
1267
|
+
size_t i;
|
1268
|
+
gpr_mu_lock(&pollset_set->mu);
|
1269
|
+
if (pollset_set->fd_count == pollset_set->fd_capacity) {
|
1270
|
+
pollset_set->fd_capacity = GPR_MAX(8, 2 * pollset_set->fd_capacity);
|
1271
|
+
pollset_set->fds = gpr_realloc(
|
1272
|
+
pollset_set->fds, pollset_set->fd_capacity * sizeof(*pollset_set->fds));
|
1273
|
+
}
|
1274
|
+
GRPC_FD_REF(fd, "pollset_set");
|
1275
|
+
pollset_set->fds[pollset_set->fd_count++] = fd;
|
1276
|
+
for (i = 0; i < pollset_set->pollset_count; i++) {
|
1277
|
+
pollset_add_fd(exec_ctx, pollset_set->pollsets[i], fd);
|
1278
|
+
}
|
1279
|
+
for (i = 0; i < pollset_set->pollset_set_count; i++) {
|
1280
|
+
pollset_set_add_fd(exec_ctx, pollset_set->pollset_sets[i], fd);
|
1281
|
+
}
|
1282
|
+
gpr_mu_unlock(&pollset_set->mu);
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
|
1286
|
+
grpc_pollset_set *pollset_set, grpc_fd *fd) {
|
1287
|
+
size_t i;
|
1288
|
+
gpr_mu_lock(&pollset_set->mu);
|
1289
|
+
for (i = 0; i < pollset_set->fd_count; i++) {
|
1290
|
+
if (pollset_set->fds[i] == fd) {
|
1291
|
+
pollset_set->fd_count--;
|
1292
|
+
GPR_SWAP(grpc_fd *, pollset_set->fds[i],
|
1293
|
+
pollset_set->fds[pollset_set->fd_count]);
|
1294
|
+
GRPC_FD_UNREF(fd, "pollset_set");
|
1295
|
+
break;
|
1296
|
+
}
|
1297
|
+
}
|
1298
|
+
for (i = 0; i < pollset_set->pollset_set_count; i++) {
|
1299
|
+
pollset_set_del_fd(exec_ctx, pollset_set->pollset_sets[i], fd);
|
1300
|
+
}
|
1301
|
+
gpr_mu_unlock(&pollset_set->mu);
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
/*******************************************************************************
|
1305
|
+
* workqueue stubs
|
1306
|
+
*/
|
1307
|
+
|
1308
|
+
#ifdef GRPC_WORKQUEUE_REFCOUNT_DEBUG
|
1309
|
+
static grpc_workqueue *workqueue_ref(grpc_workqueue *workqueue,
|
1310
|
+
const char *file, int line,
|
1311
|
+
const char *reason) {
|
1312
|
+
return workqueue;
|
1313
|
+
}
|
1314
|
+
static void workqueue_unref(grpc_exec_ctx *exec_ctx, grpc_workqueue *workqueue,
|
1315
|
+
const char *file, int line, const char *reason) {}
|
1316
|
+
#else
|
1317
|
+
static grpc_workqueue *workqueue_ref(grpc_workqueue *workqueue) {
|
1318
|
+
return workqueue;
|
1319
|
+
}
|
1320
|
+
static void workqueue_unref(grpc_exec_ctx *exec_ctx,
|
1321
|
+
grpc_workqueue *workqueue) {}
|
1322
|
+
#endif
|
1323
|
+
|
1324
|
+
static grpc_closure_scheduler *workqueue_scheduler(grpc_workqueue *workqueue) {
|
1325
|
+
return grpc_schedule_on_exec_ctx;
|
1326
|
+
}
|
1327
|
+
|
1328
|
+
/*******************************************************************************
|
1329
|
+
* Condition Variable polling extensions
|
1330
|
+
*/
|
1331
|
+
|
1332
|
+
static void decref_poll_args(poll_args *args) {
|
1333
|
+
if (gpr_unref(&args->refcount)) {
|
1334
|
+
gpr_free(args->fds);
|
1335
|
+
gpr_cv_destroy(args->cv);
|
1336
|
+
gpr_free(args->cv);
|
1337
|
+
gpr_free(args);
|
1338
|
+
}
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
// Poll in a background thread
|
1342
|
+
static void run_poll(void *arg) {
|
1343
|
+
int timeout, retval;
|
1344
|
+
poll_args *pargs = (poll_args *)arg;
|
1345
|
+
while (gpr_atm_no_barrier_load(&pargs->status) == INPROGRESS) {
|
1346
|
+
if (pargs->timeout < 0) {
|
1347
|
+
timeout = CV_POLL_PERIOD_MS;
|
1348
|
+
} else {
|
1349
|
+
timeout = GPR_MIN(CV_POLL_PERIOD_MS, pargs->timeout);
|
1350
|
+
pargs->timeout -= timeout;
|
1351
|
+
}
|
1352
|
+
retval = g_cvfds.poll(pargs->fds, pargs->nfds, timeout);
|
1353
|
+
if (retval != 0 || pargs->timeout == 0) {
|
1354
|
+
pargs->retval = retval;
|
1355
|
+
pargs->err = errno;
|
1356
|
+
break;
|
1357
|
+
}
|
1358
|
+
}
|
1359
|
+
gpr_mu_lock(&g_cvfds.mu);
|
1360
|
+
if (gpr_atm_no_barrier_load(&pargs->status) == INPROGRESS) {
|
1361
|
+
// Signal main thread that the poll completed
|
1362
|
+
gpr_atm_no_barrier_store(&pargs->status, COMPLETED);
|
1363
|
+
gpr_cv_signal(pargs->cv);
|
1364
|
+
}
|
1365
|
+
decref_poll_args(pargs);
|
1366
|
+
g_cvfds.pollcount--;
|
1367
|
+
if (g_cvfds.shutdown && g_cvfds.pollcount == 0) {
|
1368
|
+
gpr_cv_signal(&g_cvfds.shutdown_complete);
|
1369
|
+
}
|
1370
|
+
gpr_mu_unlock(&g_cvfds.mu);
|
1371
|
+
}
|
1372
|
+
|
1373
|
+
// This function overrides poll() to handle condition variable wakeup fds
|
1374
|
+
static int cvfd_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
1375
|
+
unsigned int i;
|
1376
|
+
int res, idx;
|
1377
|
+
gpr_cv *pollcv;
|
1378
|
+
cv_node *cvn, *prev;
|
1379
|
+
int skip_poll = 0;
|
1380
|
+
nfds_t nsockfds = 0;
|
1381
|
+
gpr_thd_id t_id;
|
1382
|
+
gpr_thd_options opt;
|
1383
|
+
poll_args *pargs = NULL;
|
1384
|
+
gpr_mu_lock(&g_cvfds.mu);
|
1385
|
+
pollcv = gpr_malloc(sizeof(gpr_cv));
|
1386
|
+
gpr_cv_init(pollcv);
|
1387
|
+
for (i = 0; i < nfds; i++) {
|
1388
|
+
fds[i].revents = 0;
|
1389
|
+
if (fds[i].fd < 0 && (fds[i].events & POLLIN)) {
|
1390
|
+
idx = FD_TO_IDX(fds[i].fd);
|
1391
|
+
cvn = gpr_malloc(sizeof(cv_node));
|
1392
|
+
cvn->cv = pollcv;
|
1393
|
+
cvn->next = g_cvfds.cvfds[idx].cvs;
|
1394
|
+
g_cvfds.cvfds[idx].cvs = cvn;
|
1395
|
+
// Don't bother polling if a wakeup fd is ready
|
1396
|
+
if (g_cvfds.cvfds[idx].is_set) {
|
1397
|
+
skip_poll = 1;
|
1398
|
+
}
|
1399
|
+
} else if (fds[i].fd >= 0) {
|
1400
|
+
nsockfds++;
|
1401
|
+
}
|
1402
|
+
}
|
1403
|
+
|
1404
|
+
res = 0;
|
1405
|
+
if (!skip_poll && nsockfds > 0) {
|
1406
|
+
pargs = gpr_malloc(sizeof(struct poll_args));
|
1407
|
+
// Both the main thread and calling thread get a reference
|
1408
|
+
gpr_ref_init(&pargs->refcount, 2);
|
1409
|
+
pargs->cv = pollcv;
|
1410
|
+
pargs->fds = gpr_malloc(sizeof(struct pollfd) * nsockfds);
|
1411
|
+
pargs->nfds = nsockfds;
|
1412
|
+
pargs->timeout = timeout;
|
1413
|
+
pargs->retval = 0;
|
1414
|
+
pargs->err = 0;
|
1415
|
+
gpr_atm_no_barrier_store(&pargs->status, INPROGRESS);
|
1416
|
+
idx = 0;
|
1417
|
+
for (i = 0; i < nfds; i++) {
|
1418
|
+
if (fds[i].fd >= 0) {
|
1419
|
+
pargs->fds[idx].fd = fds[i].fd;
|
1420
|
+
pargs->fds[idx].events = fds[i].events;
|
1421
|
+
pargs->fds[idx].revents = 0;
|
1422
|
+
idx++;
|
1423
|
+
}
|
1424
|
+
}
|
1425
|
+
g_cvfds.pollcount++;
|
1426
|
+
opt = gpr_thd_options_default();
|
1427
|
+
gpr_thd_options_set_detached(&opt);
|
1428
|
+
GPR_ASSERT(gpr_thd_new(&t_id, &run_poll, pargs, &opt));
|
1429
|
+
// We want the poll() thread to trigger the deadline, so wait forever here
|
1430
|
+
gpr_cv_wait(pollcv, &g_cvfds.mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
|
1431
|
+
if (gpr_atm_no_barrier_load(&pargs->status) == COMPLETED) {
|
1432
|
+
res = pargs->retval;
|
1433
|
+
errno = pargs->err;
|
1434
|
+
} else {
|
1435
|
+
errno = 0;
|
1436
|
+
gpr_atm_no_barrier_store(&pargs->status, CANCELLED);
|
1437
|
+
}
|
1438
|
+
} else if (!skip_poll) {
|
1439
|
+
gpr_timespec deadline = gpr_now(GPR_CLOCK_REALTIME);
|
1440
|
+
deadline =
|
1441
|
+
gpr_time_add(deadline, gpr_time_from_millis(timeout, GPR_TIMESPAN));
|
1442
|
+
gpr_cv_wait(pollcv, &g_cvfds.mu, deadline);
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
idx = 0;
|
1446
|
+
for (i = 0; i < nfds; i++) {
|
1447
|
+
if (fds[i].fd < 0 && (fds[i].events & POLLIN)) {
|
1448
|
+
cvn = g_cvfds.cvfds[FD_TO_IDX(fds[i].fd)].cvs;
|
1449
|
+
prev = NULL;
|
1450
|
+
while (cvn->cv != pollcv) {
|
1451
|
+
prev = cvn;
|
1452
|
+
cvn = cvn->next;
|
1453
|
+
GPR_ASSERT(cvn);
|
1454
|
+
}
|
1455
|
+
if (!prev) {
|
1456
|
+
g_cvfds.cvfds[FD_TO_IDX(fds[i].fd)].cvs = cvn->next;
|
1457
|
+
} else {
|
1458
|
+
prev->next = cvn->next;
|
1459
|
+
}
|
1460
|
+
gpr_free(cvn);
|
1461
|
+
|
1462
|
+
if (g_cvfds.cvfds[FD_TO_IDX(fds[i].fd)].is_set) {
|
1463
|
+
fds[i].revents = POLLIN;
|
1464
|
+
if (res >= 0) res++;
|
1465
|
+
}
|
1466
|
+
} else if (!skip_poll && fds[i].fd >= 0 &&
|
1467
|
+
gpr_atm_no_barrier_load(&pargs->status) == COMPLETED) {
|
1468
|
+
fds[i].revents = pargs->fds[idx].revents;
|
1469
|
+
idx++;
|
1470
|
+
}
|
1471
|
+
}
|
1472
|
+
|
1473
|
+
if (pargs) {
|
1474
|
+
decref_poll_args(pargs);
|
1475
|
+
} else {
|
1476
|
+
gpr_cv_destroy(pollcv);
|
1477
|
+
gpr_free(pollcv);
|
1478
|
+
}
|
1479
|
+
gpr_mu_unlock(&g_cvfds.mu);
|
1480
|
+
|
1481
|
+
return res;
|
1482
|
+
}
|
1483
|
+
|
1484
|
+
static void global_cv_fd_table_init() {
|
1485
|
+
gpr_mu_init(&g_cvfds.mu);
|
1486
|
+
gpr_mu_lock(&g_cvfds.mu);
|
1487
|
+
gpr_cv_init(&g_cvfds.shutdown_complete);
|
1488
|
+
g_cvfds.shutdown = 0;
|
1489
|
+
g_cvfds.pollcount = 0;
|
1490
|
+
g_cvfds.size = CV_DEFAULT_TABLE_SIZE;
|
1491
|
+
g_cvfds.cvfds = gpr_malloc(sizeof(fd_node) * CV_DEFAULT_TABLE_SIZE);
|
1492
|
+
g_cvfds.free_fds = NULL;
|
1493
|
+
for (int i = 0; i < CV_DEFAULT_TABLE_SIZE; i++) {
|
1494
|
+
g_cvfds.cvfds[i].is_set = 0;
|
1495
|
+
g_cvfds.cvfds[i].cvs = NULL;
|
1496
|
+
g_cvfds.cvfds[i].next_free = g_cvfds.free_fds;
|
1497
|
+
g_cvfds.free_fds = &g_cvfds.cvfds[i];
|
1498
|
+
}
|
1499
|
+
// Override the poll function with one that supports cvfds
|
1500
|
+
g_cvfds.poll = grpc_poll_function;
|
1501
|
+
grpc_poll_function = &cvfd_poll;
|
1502
|
+
gpr_mu_unlock(&g_cvfds.mu);
|
1503
|
+
}
|
1504
|
+
|
1505
|
+
static void global_cv_fd_table_shutdown() {
|
1506
|
+
gpr_mu_lock(&g_cvfds.mu);
|
1507
|
+
g_cvfds.shutdown = 1;
|
1508
|
+
// Attempt to wait for all abandoned poll() threads to terminate
|
1509
|
+
// Not doing so will result in reported memory leaks
|
1510
|
+
if (g_cvfds.pollcount > 0) {
|
1511
|
+
int res = gpr_cv_wait(&g_cvfds.shutdown_complete, &g_cvfds.mu,
|
1512
|
+
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
|
1513
|
+
gpr_time_from_seconds(3, GPR_TIMESPAN)));
|
1514
|
+
GPR_ASSERT(res == 0);
|
1515
|
+
}
|
1516
|
+
gpr_cv_destroy(&g_cvfds.shutdown_complete);
|
1517
|
+
grpc_poll_function = g_cvfds.poll;
|
1518
|
+
gpr_free(g_cvfds.cvfds);
|
1519
|
+
gpr_mu_unlock(&g_cvfds.mu);
|
1520
|
+
gpr_mu_destroy(&g_cvfds.mu);
|
1521
|
+
}
|
1522
|
+
|
1523
|
+
/*******************************************************************************
|
1524
|
+
* event engine binding
|
1525
|
+
*/
|
1526
|
+
|
1527
|
+
static void shutdown_engine(void) {
|
1528
|
+
pollset_global_shutdown();
|
1529
|
+
if (grpc_cv_wakeup_fds_enabled()) {
|
1530
|
+
global_cv_fd_table_shutdown();
|
1531
|
+
}
|
1532
|
+
}
|
1533
|
+
|
1534
|
+
static const grpc_event_engine_vtable vtable = {
|
1535
|
+
.pollset_size = sizeof(grpc_pollset),
|
1536
|
+
|
1537
|
+
.fd_create = fd_create,
|
1538
|
+
.fd_wrapped_fd = fd_wrapped_fd,
|
1539
|
+
.fd_orphan = fd_orphan,
|
1540
|
+
.fd_shutdown = fd_shutdown,
|
1541
|
+
.fd_is_shutdown = fd_is_shutdown,
|
1542
|
+
.fd_notify_on_read = fd_notify_on_read,
|
1543
|
+
.fd_notify_on_write = fd_notify_on_write,
|
1544
|
+
.fd_get_read_notifier_pollset = fd_get_read_notifier_pollset,
|
1545
|
+
.fd_get_workqueue = fd_get_workqueue,
|
1546
|
+
|
1547
|
+
.pollset_init = pollset_init,
|
1548
|
+
.pollset_shutdown = pollset_shutdown,
|
1549
|
+
.pollset_destroy = pollset_destroy,
|
1550
|
+
.pollset_work = pollset_work,
|
1551
|
+
.pollset_kick = pollset_kick,
|
1552
|
+
.pollset_add_fd = pollset_add_fd,
|
1553
|
+
|
1554
|
+
.pollset_set_create = pollset_set_create,
|
1555
|
+
.pollset_set_destroy = pollset_set_destroy,
|
1556
|
+
.pollset_set_add_pollset = pollset_set_add_pollset,
|
1557
|
+
.pollset_set_del_pollset = pollset_set_del_pollset,
|
1558
|
+
.pollset_set_add_pollset_set = pollset_set_add_pollset_set,
|
1559
|
+
.pollset_set_del_pollset_set = pollset_set_del_pollset_set,
|
1560
|
+
.pollset_set_add_fd = pollset_set_add_fd,
|
1561
|
+
.pollset_set_del_fd = pollset_set_del_fd,
|
1562
|
+
|
1563
|
+
.kick_poller = kick_poller,
|
1564
|
+
|
1565
|
+
.workqueue_ref = workqueue_ref,
|
1566
|
+
.workqueue_unref = workqueue_unref,
|
1567
|
+
.workqueue_scheduler = workqueue_scheduler,
|
1568
|
+
|
1569
|
+
.shutdown_engine = shutdown_engine,
|
1570
|
+
};
|
1571
|
+
|
1572
|
+
const grpc_event_engine_vtable *grpc_init_poll_posix(void) {
|
1573
|
+
if (!grpc_has_wakeup_fd()) {
|
1574
|
+
return NULL;
|
1575
|
+
}
|
1576
|
+
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
|
1577
|
+
return NULL;
|
1578
|
+
}
|
1579
|
+
return &vtable;
|
1580
|
+
}
|
1581
|
+
|
1582
|
+
const grpc_event_engine_vtable *grpc_init_poll_cv_posix(void) {
|
1583
|
+
global_cv_fd_table_init();
|
1584
|
+
grpc_enable_cv_wakeup_fds(1);
|
1585
|
+
if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) {
|
1586
|
+
global_cv_fd_table_shutdown();
|
1587
|
+
grpc_enable_cv_wakeup_fds(0);
|
1588
|
+
return NULL;
|
1589
|
+
}
|
1590
|
+
return &vtable;
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
#endif
|