grpc 1.4.5 → 1.6.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +1235 -1100
- data/etc/roots.pem +0 -412
- data/include/grpc/byte_buffer.h +10 -25
- data/include/grpc/byte_buffer_reader.h +10 -25
- data/include/grpc/census.h +10 -25
- data/include/grpc/compression.h +10 -25
- data/include/grpc/grpc.h +15 -26
- data/include/grpc/grpc_cronet.h +10 -25
- data/include/grpc/grpc_posix.h +10 -25
- data/include/grpc/grpc_security.h +10 -25
- data/include/grpc/grpc_security_constants.h +10 -25
- data/include/grpc/impl/codegen/atm.h +11 -25
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +10 -25
- data/include/grpc/impl/codegen/atm_gcc_sync.h +10 -25
- data/include/grpc/impl/codegen/atm_windows.h +10 -25
- data/include/grpc/impl/codegen/byte_buffer_reader.h +11 -26
- data/include/grpc/impl/codegen/compression_types.h +12 -27
- data/include/grpc/impl/codegen/connectivity_state.h +10 -25
- data/include/grpc/impl/codegen/exec_ctx_fwd.h +10 -25
- data/include/grpc/impl/codegen/gpr_slice.h +10 -25
- data/include/grpc/impl/codegen/gpr_types.h +10 -25
- data/include/grpc/impl/codegen/grpc_types.h +42 -43
- data/include/grpc/impl/codegen/port_platform.h +10 -25
- data/include/grpc/impl/codegen/propagation_bits.h +10 -25
- data/include/grpc/impl/codegen/slice.h +13 -28
- data/include/grpc/impl/codegen/status.h +10 -25
- data/include/grpc/impl/codegen/sync.h +10 -25
- data/include/grpc/impl/codegen/sync_generic.h +10 -25
- data/include/grpc/impl/codegen/sync_posix.h +10 -25
- data/include/grpc/impl/codegen/sync_windows.h +10 -25
- data/include/grpc/load_reporting.h +10 -25
- data/include/grpc/slice.h +10 -25
- data/include/grpc/slice_buffer.h +10 -25
- data/include/grpc/status.h +10 -25
- data/include/grpc/support/alloc.h +10 -25
- data/include/grpc/support/atm.h +10 -25
- data/include/grpc/support/atm_gcc_atomic.h +10 -25
- data/include/grpc/support/atm_gcc_sync.h +10 -25
- data/include/grpc/support/atm_windows.h +10 -25
- data/include/grpc/support/avl.h +46 -49
- data/include/grpc/support/cmdline.h +10 -25
- data/include/grpc/support/cpu.h +10 -25
- data/include/grpc/support/histogram.h +10 -25
- data/include/grpc/support/host_port.h +10 -25
- data/include/grpc/support/log.h +10 -25
- data/include/grpc/support/log_windows.h +10 -25
- data/include/grpc/support/port_platform.h +10 -25
- data/include/grpc/support/string_util.h +10 -25
- data/include/grpc/support/subprocess.h +10 -25
- data/include/grpc/support/sync.h +10 -25
- data/include/grpc/support/sync_generic.h +10 -25
- data/include/grpc/support/sync_posix.h +10 -25
- data/include/grpc/support/sync_windows.h +10 -25
- data/include/grpc/support/thd.h +10 -25
- data/include/grpc/support/time.h +10 -25
- data/include/grpc/support/tls.h +10 -25
- data/include/grpc/support/tls_gcc.h +10 -25
- data/include/grpc/support/tls_msvc.h +10 -25
- data/include/grpc/support/tls_pthread.h +10 -25
- data/include/grpc/support/useful.h +10 -25
- data/include/grpc/support/workaround_list.h +11 -26
- data/src/boringssl/err_data.c +277 -259
- data/src/core/ext/census/aggregation.h +10 -25
- data/src/core/ext/census/base_resources.c +10 -25
- data/src/core/ext/census/base_resources.h +10 -25
- data/src/core/ext/census/census_interface.h +10 -25
- data/src/core/ext/census/census_rpc_stats.h +10 -25
- data/src/core/ext/census/context.c +10 -25
- data/src/core/ext/census/gen/census.pb.c +10 -25
- data/src/core/ext/census/gen/census.pb.h +10 -25
- data/src/core/ext/census/gen/trace_context.pb.c +10 -25
- data/src/core/ext/census/gen/trace_context.pb.h +10 -25
- data/src/core/ext/census/grpc_context.c +10 -25
- data/src/core/ext/census/grpc_filter.c +11 -26
- data/src/core/ext/census/grpc_filter.h +10 -25
- data/src/core/ext/census/grpc_plugin.c +10 -25
- data/src/core/ext/census/initialize.c +10 -25
- data/src/core/ext/census/intrusive_hash_map.c +10 -25
- data/src/core/ext/census/intrusive_hash_map.h +10 -25
- data/src/core/ext/census/intrusive_hash_map_internal.h +10 -25
- data/src/core/ext/census/mlog.c +10 -25
- data/src/core/ext/census/mlog.h +10 -25
- data/src/core/ext/census/operation.c +10 -25
- data/src/core/ext/census/placeholders.c +10 -25
- data/src/core/ext/census/resource.c +10 -25
- data/src/core/ext/census/resource.h +10 -25
- data/src/core/ext/census/rpc_metric_id.h +10 -25
- data/src/core/ext/census/trace_context.c +10 -25
- data/src/core/ext/census/trace_context.h +10 -25
- data/src/core/ext/census/trace_label.h +10 -25
- data/src/core/ext/census/trace_propagation.h +10 -25
- data/src/core/ext/census/trace_status.h +10 -25
- data/src/core/ext/census/trace_string.h +10 -25
- data/src/core/ext/census/tracing.c +10 -26
- data/src/core/ext/census/tracing.h +10 -25
- data/src/core/ext/filters/client_channel/channel_connectivity.c +20 -33
- data/src/core/ext/filters/client_channel/client_channel.c +617 -520
- data/src/core/ext/filters/client_channel/client_channel.h +15 -28
- data/src/core/ext/filters/client_channel/client_channel_factory.c +13 -31
- data/src/core/ext/filters/client_channel/client_channel_factory.h +10 -25
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +16 -29
- data/src/core/ext/filters/client_channel/connector.c +10 -25
- data/src/core/ext/filters/client_channel/connector.h +10 -25
- data/src/core/ext/filters/client_channel/http_connect_handshaker.c +15 -30
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +10 -25
- data/src/core/ext/filters/client_channel/http_proxy.c +112 -38
- data/src/core/ext/filters/client_channel/http_proxy.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy.c +32 -36
- data/src/core/ext/filters/client_channel/lb_policy.h +24 -27
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +14 -30
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +464 -279
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +15 -28
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c +40 -48
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +65 -49
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +31 -31
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +11 -26
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +13 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +27 -21
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +373 -136
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +504 -279
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +12 -31
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +12 -27
- data/src/core/ext/filters/client_channel/lb_policy_registry.c +10 -25
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -25
- data/src/core/ext/filters/client_channel/parse_address.c +10 -25
- data/src/core/ext/filters/client_channel/parse_address.h +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper.c +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper.h +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +10 -25
- data/src/core/ext/filters/client_channel/resolver.c +33 -38
- data/src/core/ext/filters/client_channel/resolver.h +19 -30
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +153 -50
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +14 -27
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +33 -30
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +326 -116
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +35 -36
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +60 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +19 -34
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +254 -0
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +60 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +16 -28
- data/src/core/ext/filters/client_channel/resolver_factory.c +10 -25
- data/src/core/ext/filters/client_channel/resolver_factory.h +10 -25
- data/src/core/ext/filters/client_channel/resolver_registry.c +10 -25
- data/src/core/ext/filters/client_channel/resolver_registry.h +10 -25
- data/src/core/ext/filters/client_channel/retry_throttle.c +23 -34
- data/src/core/ext/filters/client_channel/retry_throttle.h +10 -25
- data/src/core/ext/filters/client_channel/subchannel.c +33 -55
- data/src/core/ext/filters/client_channel/subchannel.h +16 -26
- data/src/core/ext/filters/client_channel/subchannel_index.c +55 -92
- data/src/core/ext/filters/client_channel/subchannel_index.h +26 -29
- data/src/core/ext/filters/client_channel/uri_parser.c +10 -25
- data/src/core/ext/filters/client_channel/uri_parser.h +10 -25
- data/src/core/ext/filters/deadline/deadline_filter.c +30 -45
- data/src/core/ext/filters/deadline/deadline_filter.h +10 -25
- data/src/core/ext/filters/http/client/http_client_filter.c +255 -294
- data/src/core/ext/filters/http/client/http_client_filter.h +10 -25
- data/src/core/ext/filters/http/http_filters_plugin.c +11 -26
- data/src/core/ext/filters/http/message_compress/message_compress_filter.c +133 -105
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +10 -25
- data/src/core/ext/filters/http/server/http_server_filter.c +17 -32
- data/src/core/ext/filters/http/server/http_server_filter.h +10 -25
- data/src/core/ext/filters/load_reporting/load_reporting.c +11 -30
- data/src/core/ext/filters/load_reporting/load_reporting.h +10 -25
- data/src/core/ext/filters/load_reporting/load_reporting_filter.c +11 -26
- data/src/core/ext/filters/load_reporting/load_reporting_filter.h +10 -25
- data/src/core/ext/filters/max_age/max_age_filter.c +28 -43
- data/src/core/ext/filters/max_age/max_age_filter.h +10 -25
- data/src/core/ext/filters/message_size/message_size_filter.c +24 -37
- data/src/core/ext/filters/message_size/message_size_filter.h +10 -25
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +16 -31
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +10 -25
- data/src/core/ext/filters/workarounds/workaround_utils.c +12 -26
- data/src/core/ext/filters/workarounds/workaround_utils.h +11 -26
- data/src/core/ext/transport/chttp2/alpn/alpn.c +10 -25
- data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -25
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +13 -28
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +10 -25
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +13 -30
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +12 -29
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +13 -30
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +11 -26
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +10 -25
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +10 -25
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +10 -25
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +11 -25
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +10 -25
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +15 -27
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +421 -443
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -25
- data/src/core/ext/transport/chttp2/transport/flow_control.c +500 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_data.c +20 -28
- data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +11 -26
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +11 -26
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +16 -29
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -33
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +18 -31
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +12 -25
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +15 -30
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -25
- data/src/core/ext/transport/chttp2/transport/http2_settings.c +10 -25
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -25
- data/src/core/ext/transport/chttp2/transport/huffsyms.c +10 -25
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +10 -25
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +10 -25
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +10 -25
- data/src/core/ext/transport/chttp2/transport/internal.h +191 -179
- data/src/core/ext/transport/chttp2/transport/parsing.c +33 -102
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +26 -28
- data/src/core/ext/transport/chttp2/transport/stream_map.c +10 -25
- data/src/core/ext/transport/chttp2/transport/stream_map.h +10 -25
- data/src/core/ext/transport/chttp2/transport/varint.c +14 -25
- data/src/core/ext/transport/chttp2/transport/varint.h +10 -25
- data/src/core/ext/transport/chttp2/transport/writing.c +164 -106
- data/src/core/ext/transport/inproc/inproc_plugin.c +29 -0
- data/src/core/ext/transport/inproc/inproc_transport.c +1303 -0
- data/src/core/ext/transport/inproc/inproc_transport.h +41 -0
- data/src/core/lib/channel/channel_args.c +52 -27
- data/src/core/lib/channel/channel_args.h +18 -27
- data/src/core/lib/channel/channel_stack.c +11 -26
- data/src/core/lib/channel/channel_stack.h +12 -27
- data/src/core/lib/channel/channel_stack_builder.c +11 -26
- data/src/core/lib/channel/channel_stack_builder.h +10 -25
- data/src/core/lib/channel/connected_channel.c +10 -25
- data/src/core/lib/channel/connected_channel.h +10 -25
- data/src/core/lib/channel/context.h +10 -25
- data/src/core/lib/channel/handshaker.c +14 -29
- data/src/core/lib/channel/handshaker.h +10 -25
- data/src/core/lib/channel/handshaker_factory.c +10 -25
- data/src/core/lib/channel/handshaker_factory.h +10 -25
- data/src/core/lib/channel/handshaker_registry.c +10 -25
- data/src/core/lib/channel/handshaker_registry.h +10 -25
- data/src/core/lib/compression/algorithm_metadata.h +10 -25
- data/src/core/lib/compression/compression.c +10 -25
- data/src/core/lib/compression/message_compress.c +10 -25
- data/src/core/lib/compression/message_compress.h +10 -25
- data/src/core/lib/compression/stream_compression.c +191 -0
- data/src/core/lib/compression/stream_compression.h +90 -0
- data/src/core/lib/debug/trace.c +28 -29
- data/src/core/lib/debug/trace.h +16 -30
- data/src/core/lib/http/format_request.c +10 -25
- data/src/core/lib/http/format_request.h +10 -25
- data/src/core/lib/http/httpcli.c +19 -35
- data/src/core/lib/http/httpcli.h +10 -25
- data/src/core/lib/http/httpcli_security_connector.c +17 -30
- data/src/core/lib/http/parser.c +11 -26
- data/src/core/lib/http/parser.h +10 -25
- data/src/core/lib/iomgr/closure.c +62 -25
- data/src/core/lib/iomgr/closure.h +81 -26
- data/src/core/lib/iomgr/combiner.c +103 -200
- data/src/core/lib/iomgr/combiner.h +14 -32
- data/src/core/lib/iomgr/endpoint.c +10 -29
- data/src/core/lib/iomgr/endpoint.h +10 -29
- data/src/core/lib/iomgr/endpoint_pair.h +10 -25
- data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -25
- data/src/core/lib/iomgr/endpoint_pair_uv.c +10 -25
- data/src/core/lib/iomgr/endpoint_pair_windows.c +10 -25
- data/src/core/lib/iomgr/error.c +45 -46
- data/src/core/lib/iomgr/error.h +21 -34
- data/src/core/lib/iomgr/error_internal.h +10 -25
- data/src/core/lib/iomgr/ev_epoll1_linux.c +279 -179
- data/src/core/lib/iomgr/ev_epoll1_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +75 -264
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +44 -199
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epollex_linux.c +184 -247
- data/src/core/lib/iomgr/ev_epollex_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epollsig_linux.c +116 -323
- data/src/core/lib/iomgr/ev_epollsig_linux.h +10 -25
- data/src/core/lib/iomgr/ev_poll_posix.c +328 -184
- data/src/core/lib/iomgr/ev_poll_posix.h +10 -25
- data/src/core/lib/iomgr/ev_posix.c +25 -56
- data/src/core/lib/iomgr/ev_posix.h +15 -44
- data/src/core/lib/iomgr/ev_windows.c +11 -26
- data/src/core/lib/iomgr/exec_ctx.c +36 -45
- data/src/core/lib/iomgr/exec_ctx.h +10 -25
- data/src/core/lib/iomgr/executor.c +152 -127
- data/src/core/lib/iomgr/executor.h +18 -26
- data/src/core/lib/iomgr/gethostname.h +26 -0
- data/src/core/lib/iomgr/gethostname_fallback.c +27 -0
- data/src/core/lib/iomgr/gethostname_host_name_max.c +37 -0
- data/src/core/lib/iomgr/gethostname_sysconf.c +37 -0
- data/src/core/lib/iomgr/iocp_windows.c +10 -25
- data/src/core/lib/iomgr/iocp_windows.h +10 -25
- data/src/core/lib/iomgr/iomgr.c +17 -28
- data/src/core/lib/iomgr/iomgr.h +12 -27
- data/src/core/lib/iomgr/iomgr_internal.h +10 -25
- data/src/core/lib/iomgr/iomgr_posix.c +11 -26
- data/src/core/lib/iomgr/iomgr_posix.h +10 -25
- data/src/core/lib/iomgr/iomgr_uv.c +19 -26
- data/src/core/lib/iomgr/iomgr_uv.h +37 -0
- data/src/core/lib/iomgr/iomgr_windows.c +10 -25
- data/src/core/lib/iomgr/is_epollexclusive_available.c +10 -25
- data/src/core/lib/iomgr/is_epollexclusive_available.h +10 -25
- data/src/core/lib/iomgr/load_file.c +10 -25
- data/src/core/lib/iomgr/load_file.h +10 -25
- data/src/core/lib/iomgr/lockfree_event.c +22 -35
- data/src/core/lib/iomgr/lockfree_event.h +13 -27
- data/src/core/lib/iomgr/nameser.h +104 -0
- data/src/core/lib/iomgr/network_status_tracker.c +10 -25
- data/src/core/lib/iomgr/network_status_tracker.h +10 -25
- data/src/core/lib/iomgr/polling_entity.c +10 -25
- data/src/core/lib/iomgr/polling_entity.h +14 -34
- data/src/core/lib/iomgr/pollset.h +14 -25
- data/src/core/lib/iomgr/pollset_set.h +10 -25
- data/src/core/lib/iomgr/pollset_set_uv.c +10 -25
- data/src/core/lib/iomgr/pollset_set_windows.c +10 -25
- data/src/core/lib/iomgr/pollset_set_windows.h +10 -25
- data/src/core/lib/iomgr/pollset_uv.c +25 -26
- data/src/core/lib/iomgr/pollset_uv.h +10 -25
- data/src/core/lib/iomgr/pollset_windows.c +17 -27
- data/src/core/lib/iomgr/pollset_windows.h +10 -25
- data/src/core/lib/iomgr/port.h +24 -25
- data/src/core/lib/iomgr/resolve_address.h +10 -25
- data/src/core/lib/iomgr/resolve_address_posix.c +13 -28
- data/src/core/lib/iomgr/resolve_address_uv.c +31 -35
- data/src/core/lib/iomgr/resolve_address_windows.c +13 -28
- data/src/core/lib/iomgr/resource_quota.c +52 -67
- data/src/core/lib/iomgr/resource_quota.h +10 -25
- data/src/core/lib/iomgr/sockaddr.h +10 -25
- data/src/core/lib/iomgr/sockaddr_posix.h +10 -25
- data/src/core/lib/iomgr/sockaddr_utils.c +15 -25
- data/src/core/lib/iomgr/sockaddr_utils.h +12 -25
- data/src/core/lib/iomgr/sockaddr_windows.h +10 -25
- data/src/core/lib/iomgr/socket_factory_posix.c +13 -31
- data/src/core/lib/iomgr/socket_factory_posix.h +10 -25
- data/src/core/lib/iomgr/socket_mutator.c +14 -31
- data/src/core/lib/iomgr/socket_mutator.h +10 -25
- data/src/core/lib/iomgr/socket_utils.h +10 -25
- data/src/core/lib/iomgr/socket_utils_common_posix.c +10 -25
- data/src/core/lib/iomgr/socket_utils_linux.c +10 -25
- data/src/core/lib/iomgr/socket_utils_posix.c +10 -25
- data/src/core/lib/iomgr/socket_utils_posix.h +10 -25
- data/src/core/lib/iomgr/socket_utils_uv.c +10 -25
- data/src/core/lib/iomgr/socket_utils_windows.c +10 -25
- data/src/core/lib/iomgr/socket_windows.c +12 -27
- data/src/core/lib/iomgr/socket_windows.h +10 -25
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +10 -25
- data/src/core/lib/iomgr/tcp_client.h +10 -25
- data/src/core/lib/iomgr/tcp_client_posix.c +21 -34
- data/src/core/lib/iomgr/tcp_client_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_client_uv.c +18 -27
- data/src/core/lib/iomgr/tcp_client_windows.c +14 -29
- data/src/core/lib/iomgr/tcp_posix.c +36 -55
- data/src/core/lib/iomgr/tcp_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_server.h +10 -25
- data/src/core/lib/iomgr/tcp_server_posix.c +16 -31
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +11 -26
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +10 -25
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +10 -25
- data/src/core/lib/iomgr/tcp_server_uv.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +14 -29
- data/src/core/lib/iomgr/tcp_uv.c +41 -45
- data/src/core/lib/iomgr/tcp_uv.h +10 -25
- data/src/core/lib/iomgr/tcp_windows.c +39 -53
- data/src/core/lib/iomgr/tcp_windows.h +10 -25
- data/src/core/lib/iomgr/time_averaged_stats.c +10 -25
- data/src/core/lib/iomgr/time_averaged_stats.h +10 -25
- data/src/core/lib/iomgr/timer.h +18 -27
- data/src/core/lib/iomgr/timer_generic.c +91 -87
- data/src/core/lib/iomgr/timer_generic.h +10 -25
- data/src/core/lib/iomgr/timer_heap.c +10 -25
- data/src/core/lib/iomgr/timer_heap.h +10 -25
- data/src/core/lib/iomgr/timer_manager.c +178 -100
- data/src/core/lib/iomgr/timer_manager.h +10 -25
- data/src/core/lib/iomgr/timer_uv.c +23 -33
- data/src/core/lib/iomgr/timer_uv.h +10 -25
- data/src/core/lib/iomgr/udp_server.c +17 -32
- data/src/core/lib/iomgr/udp_server.h +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix.c +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix.h +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_cv.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_cv.h +13 -28
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_nospecial.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +10 -25
- data/src/core/lib/iomgr/wakeup_fd_posix.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_posix.h +10 -25
- data/src/core/lib/json/json.c +10 -25
- data/src/core/lib/json/json.h +10 -25
- data/src/core/lib/json/json_common.h +10 -25
- data/src/core/lib/json/json_reader.c +11 -25
- data/src/core/lib/json/json_reader.h +10 -25
- data/src/core/lib/json/json_string.c +10 -25
- data/src/core/lib/json/json_writer.c +10 -25
- data/src/core/lib/json/json_writer.h +10 -25
- data/src/core/lib/profiling/basic_timers.c +10 -25
- data/src/core/lib/profiling/stap_timers.c +10 -25
- data/src/core/lib/profiling/timers.h +10 -25
- data/src/core/lib/security/context/security_context.c +32 -40
- data/src/core/lib/security/context/security_context.h +15 -26
- data/src/core/lib/security/credentials/composite/composite_credentials.c +76 -81
- data/src/core/lib/security/credentials/composite/composite_credentials.h +10 -25
- data/src/core/lib/security/credentials/credentials.c +29 -49
- data/src/core/lib/security/credentials/credentials.h +48 -61
- data/src/core/lib/security/credentials/credentials_metadata.c +34 -78
- data/src/core/lib/security/credentials/fake/fake_credentials.c +33 -56
- data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -27
- data/src/core/lib/security/credentials/google_default/credentials_generic.c +10 -25
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +12 -27
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +10 -25
- data/src/core/lib/security/credentials/iam/iam_credentials.c +40 -40
- data/src/core/lib/security/credentials/iam/iam_credentials.h +11 -26
- data/src/core/lib/security/credentials/jwt/json_token.c +10 -25
- data/src/core/lib/security/credentials/jwt/json_token.h +10 -25
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +45 -48
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -26
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +53 -33
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +10 -25
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +155 -87
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +24 -28
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +118 -82
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +24 -27
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +13 -32
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +10 -25
- data/src/core/lib/security/transport/auth_filters.h +10 -25
- data/src/core/lib/security/transport/client_auth_filter.c +217 -112
- data/src/core/lib/security/transport/lb_targets_info.c +16 -32
- data/src/core/lib/security/transport/lb_targets_info.h +10 -25
- data/src/core/lib/security/transport/secure_endpoint.c +29 -43
- data/src/core/lib/security/transport/secure_endpoint.h +10 -25
- data/src/core/lib/security/transport/security_connector.c +80 -61
- data/src/core/lib/security/transport/security_connector.h +35 -35
- data/src/core/lib/security/transport/security_handshaker.c +18 -33
- data/src/core/lib/security/transport/security_handshaker.h +10 -25
- data/src/core/lib/security/transport/server_auth_filter.c +62 -116
- data/src/core/lib/security/transport/tsi_error.c +10 -25
- data/src/core/lib/security/transport/tsi_error.h +10 -25
- data/src/core/lib/security/util/json_util.c +10 -25
- data/src/core/lib/security/util/json_util.h +10 -25
- data/src/core/lib/slice/b64.c +10 -25
- data/src/core/lib/slice/b64.h +10 -25
- data/src/core/lib/slice/percent_encoding.c +10 -25
- data/src/core/lib/slice/percent_encoding.h +10 -25
- data/src/core/lib/slice/slice.c +10 -25
- data/src/core/lib/slice/slice_buffer.c +10 -25
- data/src/core/lib/slice/slice_hash_table.c +48 -26
- data/src/core/lib/slice/slice_hash_table.h +26 -28
- data/src/core/lib/slice/slice_intern.c +10 -25
- data/src/core/lib/slice/slice_internal.h +10 -25
- data/src/core/lib/slice/slice_string_helpers.c +10 -25
- data/src/core/lib/slice/slice_string_helpers.h +10 -25
- data/src/core/lib/support/alloc.c +10 -25
- data/src/core/lib/support/arena.c +12 -27
- data/src/core/lib/support/arena.h +10 -25
- data/src/core/lib/support/atm.c +17 -32
- data/src/core/lib/support/atomic.h +10 -25
- data/src/core/lib/support/atomic_with_atm.h +10 -25
- data/src/core/lib/support/atomic_with_std.h +10 -25
- data/src/core/lib/support/avl.c +101 -101
- data/src/core/lib/support/backoff.c +10 -25
- data/src/core/lib/support/backoff.h +10 -25
- data/src/core/lib/support/block_annotate.h +10 -25
- data/src/core/lib/support/cmdline.c +10 -25
- data/src/core/lib/support/cpu_iphone.c +10 -25
- data/src/core/lib/support/cpu_linux.c +10 -25
- data/src/core/lib/support/cpu_posix.c +10 -25
- data/src/core/lib/support/cpu_windows.c +10 -25
- data/src/core/lib/support/env.h +16 -25
- data/src/core/lib/support/env_linux.c +30 -37
- data/src/core/lib/support/env_posix.c +15 -25
- data/src/core/lib/support/env_windows.c +15 -25
- data/src/core/lib/support/histogram.c +10 -25
- data/src/core/lib/support/host_port.c +10 -25
- data/src/core/lib/support/log.c +20 -29
- data/src/core/lib/support/log_android.c +10 -25
- data/src/core/lib/support/log_linux.c +13 -26
- data/src/core/lib/support/log_posix.c +10 -25
- data/src/core/lib/support/log_windows.c +10 -25
- data/src/core/lib/support/memory.h +10 -25
- data/src/core/lib/support/mpscq.c +11 -49
- data/src/core/lib/support/mpscq.h +11 -50
- data/src/core/lib/support/murmur_hash.c +12 -25
- data/src/core/lib/support/murmur_hash.h +10 -25
- data/src/core/lib/support/spinlock.h +10 -25
- data/src/core/lib/support/stack_lockfree.c +10 -25
- data/src/core/lib/support/stack_lockfree.h +10 -25
- data/src/core/lib/support/string.c +10 -25
- data/src/core/lib/support/string.h +10 -25
- data/src/core/lib/support/string_posix.c +10 -25
- data/src/core/lib/support/string_util_windows.c +10 -25
- data/src/core/lib/support/string_windows.c +10 -25
- data/src/core/lib/support/string_windows.h +10 -25
- data/src/core/lib/support/subprocess_posix.c +10 -25
- data/src/core/lib/support/subprocess_windows.c +10 -25
- data/src/core/lib/support/sync.c +10 -25
- data/src/core/lib/support/sync_posix.c +10 -25
- data/src/core/lib/support/sync_windows.c +10 -25
- data/src/core/lib/support/thd.c +10 -25
- data/src/core/lib/support/thd_internal.h +10 -25
- data/src/core/lib/support/thd_posix.c +10 -25
- data/src/core/lib/support/thd_windows.c +10 -25
- data/src/core/lib/support/time.c +10 -25
- data/src/core/lib/support/time_posix.c +10 -25
- data/src/core/lib/support/time_precise.c +18 -33
- data/src/core/lib/support/time_precise.h +10 -25
- data/src/core/lib/support/time_windows.c +10 -25
- data/src/core/lib/support/tls_pthread.c +10 -25
- data/src/core/lib/support/tmpfile.h +10 -25
- data/src/core/lib/support/tmpfile_msys.c +10 -25
- data/src/core/lib/support/tmpfile_posix.c +10 -25
- data/src/core/lib/support/tmpfile_windows.c +10 -25
- data/src/core/lib/support/wrap_memcpy.c +10 -25
- data/src/core/lib/surface/alarm.c +78 -35
- data/src/core/lib/surface/alarm_internal.h +40 -0
- data/src/core/lib/surface/api_trace.c +11 -26
- data/src/core/lib/surface/api_trace.h +10 -25
- data/src/core/lib/surface/byte_buffer.c +10 -25
- data/src/core/lib/surface/byte_buffer_reader.c +10 -25
- data/src/core/lib/surface/call.c +64 -84
- data/src/core/lib/surface/call.h +11 -26
- data/src/core/lib/surface/call_details.c +10 -25
- data/src/core/lib/surface/call_log_batch.c +10 -25
- data/src/core/lib/surface/call_test_only.h +10 -25
- data/src/core/lib/surface/channel.c +11 -26
- data/src/core/lib/surface/channel.h +11 -26
- data/src/core/lib/surface/channel_init.c +10 -25
- data/src/core/lib/surface/channel_init.h +10 -25
- data/src/core/lib/surface/channel_ping.c +12 -27
- data/src/core/lib/surface/channel_stack_type.c +10 -25
- data/src/core/lib/surface/channel_stack_type.h +10 -25
- data/src/core/lib/surface/completion_queue.c +442 -331
- data/src/core/lib/surface/completion_queue.h +16 -33
- data/src/core/lib/surface/completion_queue_factory.c +10 -25
- data/src/core/lib/surface/completion_queue_factory.h +10 -25
- data/src/core/lib/surface/event_string.c +10 -25
- data/src/core/lib/surface/event_string.h +10 -25
- data/src/core/lib/surface/init.c +38 -47
- data/src/core/lib/surface/init.h +10 -25
- data/src/core/lib/surface/init_secure.c +20 -27
- data/src/core/lib/surface/lame_client.cc +14 -29
- data/src/core/lib/surface/lame_client.h +10 -25
- data/src/core/lib/surface/metadata_array.c +10 -25
- data/src/core/lib/surface/server.c +128 -81
- data/src/core/lib/surface/server.h +10 -25
- data/src/core/lib/surface/validate_metadata.c +10 -25
- data/src/core/lib/surface/validate_metadata.h +10 -25
- data/src/core/lib/surface/version.c +11 -26
- data/src/core/lib/transport/bdp_estimator.c +19 -29
- data/src/core/lib/transport/bdp_estimator.h +16 -29
- data/src/core/lib/transport/byte_stream.c +127 -36
- data/src/core/lib/transport/byte_stream.h +88 -46
- data/src/core/lib/transport/connectivity_state.c +17 -31
- data/src/core/lib/transport/connectivity_state.h +10 -25
- data/src/core/lib/transport/error_utils.c +10 -25
- data/src/core/lib/transport/error_utils.h +10 -25
- data/src/core/lib/transport/http2_errors.h +10 -25
- data/src/core/lib/transport/metadata.c +87 -85
- data/src/core/lib/transport/metadata.h +15 -28
- data/src/core/lib/transport/metadata_batch.c +10 -25
- data/src/core/lib/transport/metadata_batch.h +10 -25
- data/src/core/lib/transport/pid_controller.c +10 -25
- data/src/core/lib/transport/pid_controller.h +10 -25
- data/src/core/lib/transport/service_config.c +11 -26
- data/src/core/lib/transport/service_config.h +10 -25
- data/src/core/lib/transport/static_metadata.c +12 -26
- data/src/core/lib/transport/static_metadata.h +10 -25
- data/src/core/lib/transport/status_conversion.c +10 -25
- data/src/core/lib/transport/status_conversion.h +10 -25
- data/src/core/lib/transport/timeout_encoding.c +10 -25
- data/src/core/lib/transport/timeout_encoding.h +10 -25
- data/src/core/lib/transport/transport.c +60 -53
- data/src/core/lib/transport/transport.h +36 -34
- data/src/core/lib/transport/transport_impl.h +10 -25
- data/src/core/lib/transport/transport_op_string.c +10 -28
- data/src/core/plugin_registry/grpc_plugin_registry.c +22 -25
- data/src/core/tsi/fake_transport_security.c +199 -94
- data/src/core/tsi/fake_transport_security.h +11 -26
- data/src/core/tsi/gts_transport_security.c +40 -0
- data/src/core/tsi/gts_transport_security.h +37 -0
- data/src/core/tsi/ssl_transport_security.c +13 -32
- data/src/core/tsi/ssl_transport_security.h +10 -25
- data/src/core/tsi/ssl_types.h +10 -25
- data/src/core/tsi/transport_security.c +48 -78
- data/src/core/tsi/transport_security.h +18 -27
- data/src/core/tsi/transport_security_adapter.c +17 -29
- data/src/core/tsi/transport_security_adapter.h +10 -25
- data/src/core/tsi/transport_security_grpc.c +64 -0
- data/src/core/tsi/transport_security_grpc.h +80 -0
- data/src/core/tsi/transport_security_interface.h +21 -27
- data/src/ruby/bin/apis/google/protobuf/empty.rb +10 -25
- data/src/ruby/bin/apis/pubsub_demo.rb +10 -25
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +10 -25
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +10 -25
- data/src/ruby/bin/math_client.rb +10 -25
- data/src/ruby/bin/math_server.rb +10 -25
- data/src/ruby/bin/math_services_pb.rb +10 -25
- data/src/ruby/bin/noproto_client.rb +10 -25
- data/src/ruby/bin/noproto_server.rb +10 -25
- data/src/ruby/ext/grpc/extconf.rb +10 -25
- data/src/ruby/ext/grpc/rb_byte_buffer.c +10 -25
- data/src/ruby/ext/grpc/rb_byte_buffer.h +10 -25
- data/src/ruby/ext/grpc/rb_call.c +44 -25
- data/src/ruby/ext/grpc/rb_call.h +10 -25
- data/src/ruby/ext/grpc/rb_call_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_call_credentials.h +10 -25
- data/src/ruby/ext/grpc/rb_channel.c +10 -25
- data/src/ruby/ext/grpc/rb_channel.h +10 -25
- data/src/ruby/ext/grpc/rb_channel_args.c +10 -25
- data/src/ruby/ext/grpc/rb_channel_args.h +10 -25
- data/src/ruby/ext/grpc/rb_channel_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_channel_credentials.h +10 -25
- data/src/ruby/ext/grpc/rb_completion_queue.c +10 -25
- data/src/ruby/ext/grpc/rb_completion_queue.h +10 -25
- data/src/ruby/ext/grpc/rb_compression_options.c +10 -25
- data/src/ruby/ext/grpc/rb_compression_options.h +10 -25
- data/src/ruby/ext/grpc/rb_event_thread.c +10 -25
- data/src/ruby/ext/grpc/rb_event_thread.h +10 -25
- data/src/ruby/ext/grpc/rb_grpc.c +10 -25
- data/src/ruby/ext/grpc/rb_grpc.h +10 -25
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -25
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +16 -31
- data/src/ruby/ext/grpc/rb_loader.c +10 -25
- data/src/ruby/ext/grpc/rb_loader.h +10 -25
- data/src/ruby/ext/grpc/rb_server.c +10 -25
- data/src/ruby/ext/grpc/rb_server.h +10 -25
- data/src/ruby/ext/grpc/rb_server_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_server_credentials.h +10 -25
- data/src/ruby/lib/grpc.rb +10 -25
- data/src/ruby/lib/grpc/core/time_consts.rb +10 -25
- data/src/ruby/lib/grpc/errors.rb +16 -30
- data/src/ruby/lib/grpc/generic/active_call.rb +25 -27
- data/src/ruby/lib/grpc/generic/bidi_call.rb +17 -27
- data/src/ruby/lib/grpc/generic/client_stub.rb +10 -25
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +10 -25
- data/src/ruby/lib/grpc/generic/rpc_server.rb +10 -25
- data/src/ruby/lib/grpc/generic/service.rb +10 -25
- data/src/ruby/lib/grpc/grpc.rb +10 -25
- data/src/ruby/lib/grpc/logconfig.rb +10 -25
- data/src/ruby/lib/grpc/notifier.rb +10 -25
- data/src/ruby/lib/grpc/version.rb +11 -26
- data/src/ruby/pb/generate_proto_ruby.sh +10 -25
- data/src/ruby/pb/grpc/health/checker.rb +10 -25
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +10 -25
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +10 -25
- data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +10 -25
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +10 -25
- data/src/ruby/pb/test/client.rb +10 -25
- data/src/ruby/pb/test/server.rb +10 -25
- data/src/ruby/spec/call_credentials_spec.rb +10 -25
- data/src/ruby/spec/call_spec.rb +43 -25
- data/src/ruby/spec/channel_connection_spec.rb +10 -25
- data/src/ruby/spec/channel_credentials_spec.rb +11 -26
- data/src/ruby/spec/channel_spec.rb +10 -25
- data/src/ruby/spec/client_auth_spec.rb +10 -25
- data/src/ruby/spec/client_server_spec.rb +66 -25
- data/src/ruby/spec/compression_options_spec.rb +10 -25
- data/src/ruby/spec/error_sanity_spec.rb +10 -25
- data/src/ruby/spec/generic/active_call_spec.rb +10 -25
- data/src/ruby/spec/generic/client_stub_spec.rb +146 -35
- data/src/ruby/spec/generic/rpc_desc_spec.rb +10 -25
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +10 -25
- data/src/ruby/spec/generic/rpc_server_spec.rb +124 -34
- data/src/ruby/spec/generic/service_spec.rb +10 -25
- data/src/ruby/spec/pb/duplicate/codegen_spec.rb +10 -25
- data/src/ruby/spec/pb/health/checker_spec.rb +10 -25
- data/src/ruby/spec/server_credentials_spec.rb +10 -25
- data/src/ruby/spec/server_spec.rb +10 -25
- data/src/ruby/spec/spec_helper.rb +10 -25
- data/src/ruby/spec/time_consts_spec.rb +10 -25
- data/third_party/boringssl/crypto/aes/key_wrap.c +138 -0
- data/third_party/boringssl/crypto/asn1/a_bitstr.c +6 -3
- data/third_party/boringssl/crypto/asn1/a_enum.c +4 -1
- data/third_party/boringssl/crypto/asn1/a_gentm.c +20 -15
- data/third_party/boringssl/crypto/asn1/a_int.c +7 -4
- data/third_party/boringssl/crypto/asn1/a_object.c +5 -2
- data/third_party/boringssl/crypto/asn1/a_time.c +0 -1
- data/third_party/boringssl/crypto/asn1/a_utctm.c +1 -2
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -2
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +35 -0
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +3 -1
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +6 -3
- data/third_party/boringssl/crypto/asn1/tasn_new.c +12 -7
- data/third_party/boringssl/crypto/asn1/tasn_utl.c +22 -8
- data/third_party/boringssl/crypto/{time_support.c → asn1/time_support.c} +1 -1
- data/third_party/boringssl/crypto/asn1/x_long.c +5 -2
- data/third_party/boringssl/crypto/base64/base64.c +7 -5
- data/third_party/boringssl/crypto/bio/bio.c +24 -10
- data/third_party/boringssl/crypto/bio/bio_mem.c +12 -10
- data/third_party/boringssl/crypto/bio/connect.c +7 -18
- data/third_party/boringssl/crypto/bio/fd.c +3 -6
- data/third_party/boringssl/crypto/bio/file.c +6 -6
- data/third_party/boringssl/crypto/bio/hexdump.c +4 -2
- data/third_party/boringssl/crypto/bio/pair.c +30 -344
- data/third_party/boringssl/crypto/bio/socket.c +6 -7
- data/third_party/boringssl/crypto/bio/socket_helper.c +4 -3
- data/third_party/boringssl/crypto/bn/add.c +1 -1
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +11 -10
- data/third_party/boringssl/crypto/bn/bn.c +6 -20
- data/third_party/boringssl/crypto/bn/cmp.c +14 -0
- data/third_party/boringssl/crypto/bn/convert.c +73 -2
- data/third_party/boringssl/crypto/bn/ctx.c +3 -1
- data/third_party/boringssl/crypto/bn/div.c +108 -51
- data/third_party/boringssl/crypto/bn/exponentiation.c +15 -33
- data/third_party/boringssl/crypto/bn/gcd.c +29 -22
- data/third_party/boringssl/crypto/bn/generic.c +71 -67
- data/third_party/boringssl/crypto/bn/internal.h +19 -6
- data/third_party/boringssl/crypto/bn/kronecker.c +1 -0
- data/third_party/boringssl/crypto/bn/montgomery.c +9 -10
- data/third_party/boringssl/crypto/bn/montgomery_inv.c +47 -0
- data/third_party/boringssl/crypto/bn/mul.c +11 -9
- data/third_party/boringssl/crypto/bn/random.c +6 -3
- data/third_party/boringssl/crypto/bn/rsaz_exp.c +0 -65
- data/third_party/boringssl/crypto/bn/rsaz_exp.h +0 -3
- data/third_party/boringssl/crypto/bn/shift.c +9 -1
- data/third_party/boringssl/crypto/bn/sqrt.c +3 -1
- data/third_party/boringssl/crypto/buf/buf.c +6 -4
- data/third_party/boringssl/crypto/bytestring/asn1_compat.c +2 -1
- data/third_party/boringssl/crypto/bytestring/ber.c +2 -1
- data/third_party/boringssl/crypto/bytestring/cbb.c +9 -7
- data/third_party/boringssl/crypto/bytestring/cbs.c +54 -2
- data/third_party/boringssl/crypto/chacha/chacha.c +1 -1
- data/third_party/boringssl/crypto/cipher/aead.c +3 -3
- data/third_party/boringssl/crypto/cipher/cipher.c +18 -13
- data/third_party/boringssl/crypto/cipher/e_aes.c +335 -281
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +113 -137
- data/third_party/boringssl/crypto/cipher/e_null.c +2 -1
- data/third_party/boringssl/crypto/cipher/e_rc2.c +54 -49
- data/third_party/boringssl/crypto/cipher/e_ssl3.c +4 -3
- data/third_party/boringssl/crypto/cipher/e_tls.c +5 -5
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +41 -112
- data/third_party/boringssl/crypto/cmac/cmac.c +6 -4
- data/third_party/boringssl/crypto/conf/conf.c +6 -3
- data/third_party/boringssl/crypto/cpu-arm-linux.c +2 -2
- data/third_party/boringssl/crypto/curve25519/curve25519.c +28 -34
- data/third_party/boringssl/crypto/curve25519/spake25519.c +7 -6
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +2 -1
- data/third_party/boringssl/crypto/des/des.c +1 -1
- data/third_party/boringssl/crypto/des/internal.h +58 -46
- data/third_party/boringssl/crypto/dh/dh.c +4 -8
- data/third_party/boringssl/crypto/digest/digest.c +5 -2
- data/third_party/boringssl/crypto/digest/digests.c +70 -33
- data/third_party/boringssl/crypto/digest/md32_common.h +39 -27
- data/third_party/boringssl/crypto/dsa/dsa.c +11 -19
- data/third_party/boringssl/crypto/ec/ec.c +1 -1
- data/third_party/boringssl/crypto/ec/ec_asn1.c +3 -2
- data/third_party/boringssl/crypto/ec/ec_key.c +1 -1
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +6 -11
- data/third_party/boringssl/crypto/ec/oct.c +2 -14
- data/third_party/boringssl/crypto/ec/p224-64.c +78 -122
- data/third_party/boringssl/crypto/ec/p256-64.c +93 -133
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +48 -61
- data/third_party/boringssl/crypto/ec/p256-x86_64.h +113 -0
- data/third_party/boringssl/crypto/ec/simple.c +2 -1
- data/third_party/boringssl/crypto/ec/wnaf.c +52 -43
- data/third_party/boringssl/crypto/ecdh/ecdh.c +4 -2
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +17 -16
- data/third_party/boringssl/crypto/engine/engine.c +3 -1
- data/third_party/boringssl/crypto/err/err.c +5 -5
- data/third_party/boringssl/crypto/evp/evp.c +1 -1
- data/third_party/boringssl/crypto/evp/evp_asn1.c +1 -1
- data/third_party/boringssl/crypto/evp/evp_ctx.c +23 -29
- data/third_party/boringssl/crypto/evp/p_ec.c +2 -1
- data/third_party/boringssl/crypto/evp/p_rsa.c +9 -3
- data/third_party/boringssl/crypto/evp/pbkdf.c +3 -1
- data/third_party/boringssl/crypto/hkdf/hkdf.c +3 -1
- data/third_party/boringssl/crypto/hmac/hmac.c +4 -2
- data/third_party/boringssl/crypto/internal.h +81 -0
- data/third_party/boringssl/crypto/lhash/lhash.c +7 -13
- data/third_party/boringssl/crypto/md4/md4.c +20 -18
- data/third_party/boringssl/crypto/md5/md5.c +31 -21
- data/third_party/boringssl/crypto/mem.c +4 -10
- data/third_party/boringssl/crypto/modes/cbc.c +2 -6
- data/third_party/boringssl/crypto/modes/cfb.c +2 -2
- data/third_party/boringssl/crypto/modes/ctr.c +1 -1
- data/third_party/boringssl/crypto/modes/gcm.c +117 -334
- data/third_party/boringssl/crypto/modes/internal.h +107 -84
- data/third_party/boringssl/crypto/modes/ofb.c +3 -3
- data/third_party/boringssl/crypto/modes/polyval.c +94 -0
- data/third_party/boringssl/crypto/obj/obj.c +13 -8
- data/third_party/boringssl/crypto/obj/obj_dat.h +6109 -5187
- data/third_party/boringssl/crypto/obj/obj_xref.c +55 -57
- data/third_party/boringssl/crypto/pem/pem_lib.c +6 -3
- data/third_party/boringssl/crypto/pkcs8/internal.h +27 -8
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +137 -352
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +371 -364
- data/third_party/boringssl/crypto/poly1305/poly1305.c +12 -18
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +2 -2
- data/third_party/boringssl/crypto/{newhope/reduce.c → pool/internal.h} +24 -21
- data/third_party/boringssl/crypto/pool/pool.c +200 -0
- data/third_party/boringssl/crypto/rand/deterministic.c +6 -5
- data/third_party/boringssl/crypto/rand/fuchsia.c +43 -0
- data/third_party/boringssl/crypto/rand/rand.c +7 -7
- data/third_party/boringssl/crypto/rand/urandom.c +136 -22
- data/third_party/boringssl/crypto/rand/windows.c +2 -2
- data/third_party/boringssl/crypto/rsa/blinding.c +2 -1
- data/third_party/boringssl/crypto/rsa/padding.c +11 -11
- data/third_party/boringssl/crypto/rsa/rsa.c +4 -4
- data/third_party/boringssl/crypto/rsa/rsa_asn1.c +7 -1
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +41 -80
- data/third_party/boringssl/crypto/sha/sha1-altivec.c +346 -0
- data/third_party/boringssl/crypto/sha/sha1.c +60 -42
- data/third_party/boringssl/crypto/sha/sha256.c +4 -2
- data/third_party/boringssl/crypto/sha/sha512.c +9 -7
- data/third_party/boringssl/crypto/stack/stack.c +10 -7
- data/third_party/boringssl/crypto/thread_pthread.c +2 -2
- data/third_party/boringssl/crypto/thread_win.c +2 -2
- data/third_party/boringssl/crypto/x509/a_verify.c +1 -1
- data/third_party/boringssl/crypto/x509/asn1_gen.c +1 -1
- data/third_party/boringssl/crypto/x509/by_dir.c +1 -1
- data/third_party/boringssl/crypto/x509/t_x509.c +78 -38
- data/third_party/boringssl/crypto/x509/x509_cmp.c +8 -5
- data/third_party/boringssl/crypto/x509/x509_lu.c +6 -1
- data/third_party/boringssl/crypto/x509/x509_obj.c +4 -1
- data/third_party/boringssl/crypto/x509/x509_vfy.c +42 -8
- data/third_party/boringssl/crypto/x509/x509_vpm.c +8 -6
- data/third_party/boringssl/crypto/x509/x509name.c +4 -1
- data/third_party/boringssl/crypto/x509/x_crl.c +4 -2
- data/third_party/boringssl/crypto/x509/x_name.c +23 -13
- data/third_party/boringssl/crypto/x509/x_pkey.c +4 -1
- data/third_party/boringssl/crypto/x509/x_x509.c +42 -3
- data/third_party/boringssl/crypto/x509v3/pcy_int.h +2 -2
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +2 -1
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +1 -1
- data/third_party/boringssl/crypto/x509v3/v3_ia5.c +4 -1
- data/third_party/boringssl/crypto/x509v3/v3_ncons.c +4 -1
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +6 -3
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +13 -21
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +19 -33
- data/third_party/boringssl/include/openssl/aead.h +9 -20
- data/third_party/boringssl/include/openssl/aes.h +21 -9
- data/third_party/boringssl/include/openssl/asn1.h +9 -1
- data/third_party/boringssl/include/openssl/base.h +33 -6
- data/third_party/boringssl/include/openssl/bio.h +10 -103
- data/third_party/boringssl/include/openssl/bn.h +58 -42
- data/third_party/boringssl/include/openssl/bytestring.h +17 -0
- data/third_party/boringssl/include/openssl/cipher.h +4 -3
- data/third_party/boringssl/include/openssl/conf.h +4 -1
- data/third_party/boringssl/include/openssl/curve25519.h +13 -0
- data/third_party/boringssl/include/openssl/digest.h +5 -3
- data/third_party/boringssl/include/openssl/dsa.h +5 -5
- data/third_party/boringssl/include/openssl/ec.h +2 -2
- data/third_party/boringssl/include/openssl/ecdh.h +3 -4
- data/third_party/boringssl/include/openssl/ecdsa.h +10 -10
- data/third_party/boringssl/include/openssl/err.h +5 -5
- data/third_party/boringssl/include/openssl/evp.h +11 -7
- data/third_party/boringssl/include/openssl/lhash.h +2 -3
- data/third_party/boringssl/include/openssl/lhash_macros.h +56 -14
- data/third_party/boringssl/include/openssl/nid.h +2949 -2916
- data/third_party/boringssl/include/openssl/obj.h +1 -1
- data/third_party/boringssl/include/openssl/pkcs8.h +21 -42
- data/third_party/boringssl/include/openssl/pool.h +87 -0
- data/third_party/boringssl/include/openssl/rand.h +1 -1
- data/third_party/boringssl/include/openssl/rsa.h +4 -2
- data/third_party/boringssl/include/openssl/sha.h +0 -4
- data/third_party/boringssl/include/openssl/ssl.h +327 -662
- data/third_party/boringssl/include/openssl/ssl3.h +1 -21
- data/third_party/boringssl/include/openssl/stack.h +1 -0
- data/third_party/boringssl/include/openssl/stack_macros.h +85 -0
- data/third_party/boringssl/include/openssl/tls1.h +23 -52
- data/third_party/boringssl/include/openssl/type_check.h +4 -0
- data/third_party/boringssl/include/openssl/x509.h +10 -59
- data/third_party/boringssl/include/openssl/x509_vfy.h +7 -1
- data/third_party/boringssl/include/openssl/x509v3.h +4 -4
- data/third_party/boringssl/ssl/bio_ssl.c +175 -0
- data/third_party/boringssl/ssl/custom_extensions.c +24 -21
- data/third_party/boringssl/ssl/d1_both.c +259 -289
- data/third_party/boringssl/ssl/d1_lib.c +8 -20
- data/third_party/boringssl/ssl/d1_pkt.c +6 -15
- data/third_party/boringssl/ssl/dtls_method.c +22 -8
- data/third_party/boringssl/ssl/dtls_record.c +27 -2
- data/third_party/boringssl/ssl/handshake_client.c +460 -579
- data/third_party/boringssl/ssl/handshake_server.c +662 -644
- data/third_party/boringssl/ssl/internal.h +1009 -375
- data/third_party/boringssl/ssl/s3_both.c +312 -162
- data/third_party/boringssl/ssl/s3_lib.c +12 -128
- data/third_party/boringssl/ssl/s3_pkt.c +22 -30
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +28 -22
- data/third_party/boringssl/ssl/ssl_asn1.c +210 -114
- data/third_party/boringssl/ssl/ssl_buffer.c +2 -1
- data/third_party/boringssl/ssl/ssl_cert.c +417 -219
- data/third_party/boringssl/ssl/ssl_cipher.c +191 -393
- data/third_party/boringssl/ssl/ssl_ecdh.c +19 -164
- data/third_party/boringssl/ssl/ssl_file.c +0 -11
- data/third_party/boringssl/ssl/ssl_lib.c +325 -652
- data/third_party/boringssl/ssl/{ssl_rsa.c → ssl_privkey.c} +21 -131
- data/third_party/boringssl/ssl/ssl_privkey_cc.cc +76 -0
- data/third_party/boringssl/ssl/ssl_session.c +206 -95
- data/third_party/boringssl/ssl/ssl_stat.c +18 -84
- data/third_party/boringssl/ssl/{s3_enc.c → ssl_transcript.c} +150 -157
- data/third_party/boringssl/ssl/ssl_x509.c +815 -0
- data/third_party/boringssl/ssl/t1_enc.c +188 -174
- data/third_party/boringssl/ssl/t1_lib.c +1064 -764
- data/third_party/boringssl/ssl/tls13_both.c +290 -96
- data/third_party/boringssl/ssl/tls13_client.c +344 -314
- data/third_party/boringssl/ssl/tls13_enc.c +239 -200
- data/third_party/boringssl/ssl/tls13_server.c +374 -366
- data/third_party/boringssl/ssl/tls_method.c +40 -5
- data/third_party/boringssl/ssl/tls_record.c +166 -71
- metadata +39 -25
- data/src/core/lib/iomgr/workqueue.h +0 -87
- data/src/core/lib/iomgr/workqueue_uv.c +0 -65
- data/src/core/lib/iomgr/workqueue_uv.h +0 -37
- data/src/core/lib/iomgr/workqueue_windows.c +0 -63
- data/src/core/lib/iomgr/workqueue_windows.h +0 -37
- data/third_party/boringssl/crypto/bio/buffer.c +0 -496
- data/third_party/boringssl/crypto/newhope/error_correction.c +0 -131
- data/third_party/boringssl/crypto/newhope/internal.h +0 -71
- data/third_party/boringssl/crypto/newhope/newhope.c +0 -174
- data/third_party/boringssl/crypto/newhope/ntt.c +0 -148
- data/third_party/boringssl/crypto/newhope/poly.c +0 -183
- data/third_party/boringssl/crypto/newhope/precomp.c +0 -306
- data/third_party/boringssl/crypto/obj/obj_xref.h +0 -96
- data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +0 -151
- data/third_party/boringssl/include/openssl/newhope.h +0 -158
- data/third_party/boringssl/include/openssl/time_support.h +0 -91
@@ -1,33 +1,18 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015-2016
|
4
|
-
* All rights reserved.
|
3
|
+
* Copyright 2015-2016 gRPC authors.
|
5
4
|
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
9
8
|
*
|
10
|
-
*
|
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.
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
19
10
|
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
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.
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
31
16
|
*
|
32
17
|
*/
|
33
18
|
#include "src/core/lib/surface/completion_queue.h"
|
@@ -50,9 +35,13 @@
|
|
50
35
|
#include "src/core/lib/surface/call.h"
|
51
36
|
#include "src/core/lib/surface/event_string.h"
|
52
37
|
|
53
|
-
grpc_tracer_flag grpc_trace_operation_failures =
|
38
|
+
grpc_tracer_flag grpc_trace_operation_failures =
|
39
|
+
GRPC_TRACER_INITIALIZER(false, "op_failure");
|
54
40
|
#ifndef NDEBUG
|
55
|
-
grpc_tracer_flag grpc_trace_pending_tags =
|
41
|
+
grpc_tracer_flag grpc_trace_pending_tags =
|
42
|
+
GRPC_TRACER_INITIALIZER(false, "pending_tags");
|
43
|
+
grpc_tracer_flag grpc_trace_cq_refcount =
|
44
|
+
GRPC_TRACER_INITIALIZER(false, "cq_refcount");
|
56
45
|
#endif
|
57
46
|
|
58
47
|
typedef struct {
|
@@ -128,7 +117,7 @@ static grpc_error *non_polling_poller_work(grpc_exec_ctx *exec_ctx,
|
|
128
117
|
npp->root = w.next;
|
129
118
|
if (&w == npp->root) {
|
130
119
|
if (npp->shutdown) {
|
131
|
-
|
120
|
+
GRPC_CLOSURE_SCHED(exec_ctx, npp->shutdown, GRPC_ERROR_NONE);
|
132
121
|
}
|
133
122
|
npp->root = NULL;
|
134
123
|
}
|
@@ -161,7 +150,7 @@ static void non_polling_poller_shutdown(grpc_exec_ctx *exec_ctx,
|
|
161
150
|
GPR_ASSERT(closure != NULL);
|
162
151
|
p->shutdown = closure;
|
163
152
|
if (p->root == NULL) {
|
164
|
-
|
153
|
+
GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_NONE);
|
165
154
|
} else {
|
166
155
|
non_polling_worker *w = p->root;
|
167
156
|
do {
|
@@ -203,16 +192,19 @@ static const cq_poller_vtable g_poller_vtable_by_poller_type[] = {
|
|
203
192
|
|
204
193
|
typedef struct cq_vtable {
|
205
194
|
grpc_cq_completion_type cq_completion_type;
|
206
|
-
size_t
|
207
|
-
void (*
|
208
|
-
void (*
|
195
|
+
size_t data_size;
|
196
|
+
void (*init)(void *data);
|
197
|
+
void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq);
|
198
|
+
void (*destroy)(void *data);
|
199
|
+
bool (*begin_op)(grpc_completion_queue *cq, void *tag);
|
200
|
+
void (*end_op)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq, void *tag,
|
209
201
|
grpc_error *error,
|
210
202
|
void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg,
|
211
203
|
grpc_cq_completion *storage),
|
212
204
|
void *done_arg, grpc_cq_completion *storage);
|
213
|
-
grpc_event (*next)(grpc_completion_queue *
|
205
|
+
grpc_event (*next)(grpc_completion_queue *cq, gpr_timespec deadline,
|
214
206
|
void *reserved);
|
215
|
-
grpc_event (*pluck)(grpc_completion_queue *
|
207
|
+
grpc_event (*pluck)(grpc_completion_queue *cq, void *tag,
|
216
208
|
gpr_timespec deadline, void *reserved);
|
217
209
|
} cq_vtable;
|
218
210
|
|
@@ -232,64 +224,81 @@ typedef struct grpc_cq_event_queue {
|
|
232
224
|
gpr_atm num_queue_items;
|
233
225
|
} grpc_cq_event_queue;
|
234
226
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
227
|
+
typedef struct cq_next_data {
|
228
|
+
/** Completed events for completion-queues of type GRPC_CQ_NEXT */
|
229
|
+
grpc_cq_event_queue queue;
|
230
|
+
|
231
|
+
/** Counter of how many things have ever been queued on this completion queue
|
232
|
+
useful for avoiding locks to check the queue */
|
233
|
+
gpr_atm things_queued_ever;
|
234
|
+
|
235
|
+
/* Number of outstanding events (+1 if not shut down) */
|
236
|
+
gpr_atm pending_events;
|
240
237
|
|
238
|
+
/** 0 initially. 1 once we initiated shutdown */
|
239
|
+
bool shutdown_called;
|
240
|
+
} cq_next_data;
|
241
|
+
|
242
|
+
typedef struct cq_pluck_data {
|
241
243
|
/** Completed events for completion-queues of type GRPC_CQ_PLUCK */
|
242
244
|
grpc_cq_completion completed_head;
|
243
245
|
grpc_cq_completion *completed_tail;
|
244
246
|
|
245
|
-
/** Completed events for completion-queues of type GRPC_CQ_NEXT */
|
246
|
-
grpc_cq_event_queue queue;
|
247
|
-
|
248
247
|
/** Number of pending events (+1 if we're not shutdown) */
|
249
|
-
|
250
|
-
|
251
|
-
/** Once owning_refs drops to zero, we will destroy the cq */
|
252
|
-
gpr_refcount owning_refs;
|
248
|
+
gpr_atm pending_events;
|
253
249
|
|
254
250
|
/** Counter of how many things have ever been queued on this completion queue
|
255
251
|
useful for avoiding locks to check the queue */
|
256
252
|
gpr_atm things_queued_ever;
|
257
253
|
|
258
|
-
/** 0 initially
|
254
|
+
/** 0 initially. 1 once we completed shutting */
|
255
|
+
/* TODO: (sreek) This is not needed since (shutdown == 1) if and only if
|
256
|
+
* (pending_events == 0). So consider removing this in future and use
|
257
|
+
* pending_events */
|
259
258
|
gpr_atm shutdown;
|
260
|
-
int shutdown_called;
|
261
259
|
|
262
|
-
|
260
|
+
/** 0 initially. 1 once we initiated shutdown */
|
261
|
+
bool shutdown_called;
|
263
262
|
|
264
263
|
int num_pluckers;
|
265
|
-
int num_polls;
|
266
264
|
plucker pluckers[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS];
|
267
|
-
|
265
|
+
} cq_pluck_data;
|
266
|
+
|
267
|
+
/* Completion queue structure */
|
268
|
+
struct grpc_completion_queue {
|
269
|
+
/** Once owning_refs drops to zero, we will destroy the cq */
|
270
|
+
gpr_refcount owning_refs;
|
271
|
+
|
272
|
+
gpr_mu *mu;
|
273
|
+
|
274
|
+
const cq_vtable *vtable;
|
275
|
+
const cq_poller_vtable *poller_vtable;
|
268
276
|
|
269
277
|
#ifndef NDEBUG
|
270
278
|
void **outstanding_tags;
|
271
279
|
size_t outstanding_tag_count;
|
272
280
|
size_t outstanding_tag_capacity;
|
273
281
|
#endif
|
274
|
-
} cq_data;
|
275
282
|
|
276
|
-
|
277
|
-
|
278
|
-
cq_data data;
|
279
|
-
const cq_vtable *vtable;
|
280
|
-
const cq_poller_vtable *poller_vtable;
|
283
|
+
grpc_closure pollset_shutdown_done;
|
284
|
+
int num_polls;
|
281
285
|
};
|
282
286
|
|
283
287
|
/* Forward declarations */
|
284
|
-
static void
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
288
|
+
static void cq_finish_shutdown_next(grpc_exec_ctx *exec_ctx,
|
289
|
+
grpc_completion_queue *cq);
|
290
|
+
static void cq_finish_shutdown_pluck(grpc_exec_ctx *exec_ctx,
|
291
|
+
grpc_completion_queue *cq);
|
292
|
+
static void cq_shutdown_next(grpc_exec_ctx *exec_ctx,
|
293
|
+
grpc_completion_queue *cq);
|
294
|
+
static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx,
|
295
|
+
grpc_completion_queue *cq);
|
296
|
+
|
297
|
+
static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag);
|
298
|
+
static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag);
|
290
299
|
|
291
300
|
static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
|
292
|
-
grpc_completion_queue *
|
301
|
+
grpc_completion_queue *cq, void *tag,
|
293
302
|
grpc_error *error,
|
294
303
|
void (*done)(grpc_exec_ctx *exec_ctx,
|
295
304
|
void *done_arg,
|
@@ -297,42 +306,56 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
|
|
297
306
|
void *done_arg, grpc_cq_completion *storage);
|
298
307
|
|
299
308
|
static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
|
300
|
-
grpc_completion_queue *
|
309
|
+
grpc_completion_queue *cq, void *tag,
|
301
310
|
grpc_error *error,
|
302
311
|
void (*done)(grpc_exec_ctx *exec_ctx,
|
303
312
|
void *done_arg,
|
304
313
|
grpc_cq_completion *storage),
|
305
314
|
void *done_arg, grpc_cq_completion *storage);
|
306
315
|
|
307
|
-
static grpc_event cq_next(grpc_completion_queue *
|
316
|
+
static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
|
308
317
|
void *reserved);
|
309
318
|
|
310
|
-
static grpc_event cq_pluck(grpc_completion_queue *
|
319
|
+
static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag,
|
311
320
|
gpr_timespec deadline, void *reserved);
|
312
321
|
|
322
|
+
static void cq_init_next(void *data);
|
323
|
+
static void cq_init_pluck(void *data);
|
324
|
+
static void cq_destroy_next(void *data);
|
325
|
+
static void cq_destroy_pluck(void *data);
|
326
|
+
|
313
327
|
/* Completion queue vtables based on the completion-type */
|
314
328
|
static const cq_vtable g_cq_vtable[] = {
|
315
329
|
/* GRPC_CQ_NEXT */
|
316
|
-
{.
|
317
|
-
.
|
318
|
-
.
|
330
|
+
{.data_size = sizeof(cq_next_data),
|
331
|
+
.cq_completion_type = GRPC_CQ_NEXT,
|
332
|
+
.init = cq_init_next,
|
333
|
+
.shutdown = cq_shutdown_next,
|
334
|
+
.destroy = cq_destroy_next,
|
335
|
+
.begin_op = cq_begin_op_for_next,
|
319
336
|
.end_op = cq_end_op_for_next,
|
320
337
|
.next = cq_next,
|
321
338
|
.pluck = NULL},
|
322
339
|
/* GRPC_CQ_PLUCK */
|
323
|
-
{.
|
324
|
-
.
|
325
|
-
.
|
340
|
+
{.data_size = sizeof(cq_pluck_data),
|
341
|
+
.cq_completion_type = GRPC_CQ_PLUCK,
|
342
|
+
.init = cq_init_pluck,
|
343
|
+
.shutdown = cq_shutdown_pluck,
|
344
|
+
.destroy = cq_destroy_pluck,
|
345
|
+
.begin_op = cq_begin_op_for_pluck,
|
326
346
|
.end_op = cq_end_op_for_pluck,
|
327
347
|
.next = NULL,
|
328
348
|
.pluck = cq_pluck},
|
329
349
|
};
|
330
350
|
|
331
|
-
#define
|
332
|
-
#define
|
351
|
+
#define DATA_FROM_CQ(cq) ((void *)(cq + 1))
|
352
|
+
#define POLLSET_FROM_CQ(cq) \
|
353
|
+
((grpc_pollset *)(cq->vtable->data_size + (char *)DATA_FROM_CQ(cq)))
|
333
354
|
|
334
|
-
grpc_tracer_flag grpc_cq_pluck_trace =
|
335
|
-
|
355
|
+
grpc_tracer_flag grpc_cq_pluck_trace =
|
356
|
+
GRPC_TRACER_INITIALIZER(true, "queue_pluck");
|
357
|
+
grpc_tracer_flag grpc_cq_event_timeout_trace =
|
358
|
+
GRPC_TRACER_INITIALIZER(true, "queue_timeout");
|
336
359
|
|
337
360
|
#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \
|
338
361
|
if (GRPC_TRACER_ON(grpc_api_trace) && \
|
@@ -343,7 +366,7 @@ grpc_tracer_flag grpc_cq_event_timeout_trace = GRPC_TRACER_INITIALIZER(true);
|
|
343
366
|
gpr_free(_ev); \
|
344
367
|
}
|
345
368
|
|
346
|
-
static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *
|
369
|
+
static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *cq,
|
347
370
|
grpc_error *error);
|
348
371
|
|
349
372
|
static void cq_event_queue_init(grpc_cq_event_queue *q) {
|
@@ -356,9 +379,9 @@ static void cq_event_queue_destroy(grpc_cq_event_queue *q) {
|
|
356
379
|
gpr_mpscq_destroy(&q->queue);
|
357
380
|
}
|
358
381
|
|
359
|
-
static
|
382
|
+
static bool cq_event_queue_push(grpc_cq_event_queue *q, grpc_cq_completion *c) {
|
360
383
|
gpr_mpscq_push(&q->queue, (gpr_mpscq_node *)c);
|
361
|
-
gpr_atm_no_barrier_fetch_add(&q->num_queue_items, 1);
|
384
|
+
return gpr_atm_no_barrier_fetch_add(&q->num_queue_items, 1) == 0;
|
362
385
|
}
|
363
386
|
|
364
387
|
static grpc_cq_completion *cq_event_queue_pop(grpc_cq_event_queue *q) {
|
@@ -381,16 +404,10 @@ static long cq_event_queue_num_items(grpc_cq_event_queue *q) {
|
|
381
404
|
return (long)gpr_atm_no_barrier_load(&q->num_queue_items);
|
382
405
|
}
|
383
406
|
|
384
|
-
static size_t cq_size(grpc_completion_queue *cc) {
|
385
|
-
/* Size of the completion queue and the size of the pollset whose memory is
|
386
|
-
allocated right after that of completion queue */
|
387
|
-
return sizeof(grpc_completion_queue) + cc->poller_vtable->size();
|
388
|
-
}
|
389
|
-
|
390
407
|
grpc_completion_queue *grpc_completion_queue_create_internal(
|
391
408
|
grpc_cq_completion_type completion_type,
|
392
409
|
grpc_cq_polling_type polling_type) {
|
393
|
-
grpc_completion_queue *
|
410
|
+
grpc_completion_queue *cq;
|
394
411
|
|
395
412
|
GPR_TIMER_BEGIN("grpc_completion_queue_create_internal", 0);
|
396
413
|
|
@@ -403,150 +420,189 @@ grpc_completion_queue *grpc_completion_queue_create_internal(
|
|
403
420
|
const cq_poller_vtable *poller_vtable =
|
404
421
|
&g_poller_vtable_by_poller_type[polling_type];
|
405
422
|
|
406
|
-
|
407
|
-
|
423
|
+
cq = gpr_zalloc(sizeof(grpc_completion_queue) + vtable->data_size +
|
424
|
+
poller_vtable->size());
|
408
425
|
|
409
|
-
|
410
|
-
|
426
|
+
cq->vtable = vtable;
|
427
|
+
cq->poller_vtable = poller_vtable;
|
411
428
|
|
412
|
-
|
429
|
+
/* One for destroy(), one for pollset_shutdown */
|
430
|
+
gpr_ref_init(&cq->owning_refs, 2);
|
413
431
|
|
414
|
-
|
415
|
-
|
416
|
-
cqd->outstanding_tag_capacity = 0;
|
417
|
-
#endif
|
432
|
+
poller_vtable->init(POLLSET_FROM_CQ(cq), &cq->mu);
|
433
|
+
vtable->init(DATA_FROM_CQ(cq));
|
418
434
|
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
435
|
+
GRPC_CLOSURE_INIT(&cq->pollset_shutdown_done, on_pollset_shutdown_done, cq,
|
436
|
+
grpc_schedule_on_exec_ctx);
|
437
|
+
|
438
|
+
GPR_TIMER_END("grpc_completion_queue_create_internal", 0);
|
439
|
+
|
440
|
+
return cq;
|
441
|
+
}
|
442
|
+
|
443
|
+
static void cq_init_next(void *ptr) {
|
444
|
+
cq_next_data *cqd = ptr;
|
445
|
+
/* Initial count is dropped by grpc_completion_queue_shutdown */
|
446
|
+
gpr_atm_no_barrier_store(&cqd->pending_events, 1);
|
447
|
+
cqd->shutdown_called = false;
|
448
|
+
gpr_atm_no_barrier_store(&cqd->things_queued_ever, 0);
|
449
|
+
cq_event_queue_init(&cqd->queue);
|
450
|
+
}
|
451
|
+
|
452
|
+
static void cq_destroy_next(void *ptr) {
|
453
|
+
cq_next_data *cqd = ptr;
|
454
|
+
GPR_ASSERT(cq_event_queue_num_items(&cqd->queue) == 0);
|
455
|
+
cq_event_queue_destroy(&cqd->queue);
|
456
|
+
}
|
457
|
+
|
458
|
+
static void cq_init_pluck(void *ptr) {
|
459
|
+
cq_pluck_data *cqd = ptr;
|
460
|
+
/* Initial count is dropped by grpc_completion_queue_shutdown */
|
461
|
+
gpr_atm_no_barrier_store(&cqd->pending_events, 1);
|
423
462
|
cqd->completed_tail = &cqd->completed_head;
|
424
463
|
cqd->completed_head.next = (uintptr_t)cqd->completed_tail;
|
425
464
|
gpr_atm_no_barrier_store(&cqd->shutdown, 0);
|
426
|
-
cqd->shutdown_called =
|
427
|
-
cqd->is_server_cq = 0;
|
465
|
+
cqd->shutdown_called = false;
|
428
466
|
cqd->num_pluckers = 0;
|
429
|
-
cqd->num_polls = 0;
|
430
467
|
gpr_atm_no_barrier_store(&cqd->things_queued_ever, 0);
|
431
|
-
|
432
|
-
cqd->outstanding_tag_count = 0;
|
433
|
-
#endif
|
434
|
-
cq_event_queue_init(&cqd->queue);
|
435
|
-
grpc_closure_init(&cqd->pollset_shutdown_done, on_pollset_shutdown_done, cc,
|
436
|
-
grpc_schedule_on_exec_ctx);
|
437
|
-
|
438
|
-
GPR_TIMER_END("grpc_completion_queue_create_internal", 0);
|
468
|
+
}
|
439
469
|
|
440
|
-
|
470
|
+
static void cq_destroy_pluck(void *ptr) {
|
471
|
+
cq_pluck_data *cqd = ptr;
|
472
|
+
GPR_ASSERT(cqd->completed_head.next == (uintptr_t)&cqd->completed_head);
|
441
473
|
}
|
442
474
|
|
443
|
-
grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *
|
444
|
-
return
|
475
|
+
grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cq) {
|
476
|
+
return cq->vtable->cq_completion_type;
|
445
477
|
}
|
446
478
|
|
447
|
-
int grpc_get_cq_poll_num(grpc_completion_queue *
|
479
|
+
int grpc_get_cq_poll_num(grpc_completion_queue *cq) {
|
448
480
|
int cur_num_polls;
|
449
|
-
gpr_mu_lock(
|
450
|
-
cur_num_polls =
|
451
|
-
gpr_mu_unlock(
|
481
|
+
gpr_mu_lock(cq->mu);
|
482
|
+
cur_num_polls = cq->num_polls;
|
483
|
+
gpr_mu_unlock(cq->mu);
|
452
484
|
return cur_num_polls;
|
453
485
|
}
|
454
486
|
|
455
|
-
#
|
456
|
-
void grpc_cq_internal_ref(grpc_completion_queue *
|
487
|
+
#ifndef NDEBUG
|
488
|
+
void grpc_cq_internal_ref(grpc_completion_queue *cq, const char *reason,
|
457
489
|
const char *file, int line) {
|
458
|
-
|
459
|
-
|
460
|
-
|
490
|
+
if (GRPC_TRACER_ON(grpc_trace_cq_refcount)) {
|
491
|
+
gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
|
492
|
+
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
|
493
|
+
"CQ:%p ref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val + 1,
|
494
|
+
reason);
|
495
|
+
}
|
461
496
|
#else
|
462
|
-
void grpc_cq_internal_ref(grpc_completion_queue *
|
463
|
-
cq_data *cqd = &cc->data;
|
497
|
+
void grpc_cq_internal_ref(grpc_completion_queue *cq) {
|
464
498
|
#endif
|
465
|
-
gpr_ref(&
|
499
|
+
gpr_ref(&cq->owning_refs);
|
466
500
|
}
|
467
501
|
|
468
502
|
static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *arg,
|
469
503
|
grpc_error *error) {
|
470
|
-
grpc_completion_queue *
|
471
|
-
GRPC_CQ_INTERNAL_UNREF(exec_ctx,
|
504
|
+
grpc_completion_queue *cq = arg;
|
505
|
+
GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "pollset_destroy");
|
472
506
|
}
|
473
507
|
|
474
|
-
#
|
475
|
-
void grpc_cq_internal_unref(
|
476
|
-
const char *file, int line) {
|
477
|
-
|
478
|
-
|
479
|
-
|
508
|
+
#ifndef NDEBUG
|
509
|
+
void grpc_cq_internal_unref(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq,
|
510
|
+
const char *reason, const char *file, int line) {
|
511
|
+
if (GRPC_TRACER_ON(grpc_trace_cq_refcount)) {
|
512
|
+
gpr_atm val = gpr_atm_no_barrier_load(&cq->owning_refs.count);
|
513
|
+
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
|
514
|
+
"CQ:%p unref %" PRIdPTR " -> %" PRIdPTR " %s", cq, val, val - 1,
|
515
|
+
reason);
|
516
|
+
}
|
480
517
|
#else
|
481
518
|
void grpc_cq_internal_unref(grpc_exec_ctx *exec_ctx,
|
482
|
-
grpc_completion_queue *
|
483
|
-
cq_data *cqd = &cc->data;
|
519
|
+
grpc_completion_queue *cq) {
|
484
520
|
#endif
|
485
|
-
if (gpr_unref(&
|
486
|
-
|
487
|
-
|
488
|
-
cq_event_queue_destroy(&cqd->queue);
|
521
|
+
if (gpr_unref(&cq->owning_refs)) {
|
522
|
+
cq->vtable->destroy(DATA_FROM_CQ(cq));
|
523
|
+
cq->poller_vtable->destroy(exec_ctx, POLLSET_FROM_CQ(cq));
|
489
524
|
#ifndef NDEBUG
|
490
|
-
gpr_free(
|
525
|
+
gpr_free(cq->outstanding_tags);
|
491
526
|
#endif
|
492
|
-
gpr_free(
|
527
|
+
gpr_free(cq);
|
493
528
|
}
|
494
529
|
}
|
495
530
|
|
496
|
-
static void cq_begin_op(grpc_completion_queue *cc, void *tag) {
|
497
|
-
cq_data *cqd = &cc->data;
|
498
531
|
#ifndef NDEBUG
|
499
|
-
|
500
|
-
GPR_ASSERT(!cqd->shutdown_called);
|
501
|
-
if (cqd->outstanding_tag_count == cqd->outstanding_tag_capacity) {
|
502
|
-
cqd->outstanding_tag_capacity =
|
503
|
-
GPR_MAX(4, 2 * cqd->outstanding_tag_capacity);
|
504
|
-
cqd->outstanding_tags =
|
505
|
-
gpr_realloc(cqd->outstanding_tags, sizeof(*cqd->outstanding_tags) *
|
506
|
-
cqd->outstanding_tag_capacity);
|
507
|
-
}
|
508
|
-
cqd->outstanding_tags[cqd->outstanding_tag_count++] = tag;
|
509
|
-
gpr_mu_unlock(cqd->mu);
|
510
|
-
#endif
|
511
|
-
gpr_ref(&cqd->pending_events);
|
512
|
-
}
|
513
|
-
|
514
|
-
void grpc_cq_begin_op(grpc_completion_queue *cc, void *tag) {
|
515
|
-
cc->vtable->begin_op(cc, tag);
|
516
|
-
}
|
517
|
-
|
518
|
-
#ifndef NDEBUG
|
519
|
-
static void cq_check_tag(grpc_completion_queue *cc, void *tag, bool lock_cq) {
|
520
|
-
cq_data *cqd = &cc->data;
|
532
|
+
static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) {
|
521
533
|
int found = 0;
|
522
534
|
if (lock_cq) {
|
523
|
-
gpr_mu_lock(
|
535
|
+
gpr_mu_lock(cq->mu);
|
524
536
|
}
|
525
537
|
|
526
|
-
for (int i = 0; i < (int)
|
527
|
-
if (
|
528
|
-
|
529
|
-
GPR_SWAP(void *,
|
530
|
-
|
538
|
+
for (int i = 0; i < (int)cq->outstanding_tag_count; i++) {
|
539
|
+
if (cq->outstanding_tags[i] == tag) {
|
540
|
+
cq->outstanding_tag_count--;
|
541
|
+
GPR_SWAP(void *, cq->outstanding_tags[i],
|
542
|
+
cq->outstanding_tags[cq->outstanding_tag_count]);
|
531
543
|
found = 1;
|
532
544
|
break;
|
533
545
|
}
|
534
546
|
}
|
535
547
|
|
536
548
|
if (lock_cq) {
|
537
|
-
gpr_mu_unlock(
|
549
|
+
gpr_mu_unlock(cq->mu);
|
538
550
|
}
|
539
551
|
|
540
552
|
GPR_ASSERT(found);
|
541
553
|
}
|
542
554
|
#else
|
543
|
-
static void cq_check_tag(grpc_completion_queue *
|
555
|
+
static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) {}
|
544
556
|
#endif
|
545
557
|
|
546
|
-
/*
|
558
|
+
/* Atomically increments a counter only if the counter is not zero. Returns
|
559
|
+
* true if the increment was successful; false if the counter is zero */
|
560
|
+
static bool atm_inc_if_nonzero(gpr_atm *counter) {
|
561
|
+
while (true) {
|
562
|
+
gpr_atm count = gpr_atm_no_barrier_load(counter);
|
563
|
+
/* If zero, we are done. If not, we must to a CAS (instead of an atomic
|
564
|
+
* increment) to maintain the contract: do not increment the counter if it
|
565
|
+
* is zero. */
|
566
|
+
if (count == 0) {
|
567
|
+
return false;
|
568
|
+
} else if (gpr_atm_no_barrier_cas(counter, count, count + 1)) {
|
569
|
+
break;
|
570
|
+
}
|
571
|
+
}
|
572
|
+
|
573
|
+
return true;
|
574
|
+
}
|
575
|
+
|
576
|
+
static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag) {
|
577
|
+
cq_next_data *cqd = DATA_FROM_CQ(cq);
|
578
|
+
return atm_inc_if_nonzero(&cqd->pending_events);
|
579
|
+
}
|
580
|
+
|
581
|
+
static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag) {
|
582
|
+
cq_pluck_data *cqd = DATA_FROM_CQ(cq);
|
583
|
+
return atm_inc_if_nonzero(&cqd->pending_events);
|
584
|
+
}
|
585
|
+
|
586
|
+
bool grpc_cq_begin_op(grpc_completion_queue *cq, void *tag) {
|
587
|
+
#ifndef NDEBUG
|
588
|
+
gpr_mu_lock(cq->mu);
|
589
|
+
if (cq->outstanding_tag_count == cq->outstanding_tag_capacity) {
|
590
|
+
cq->outstanding_tag_capacity = GPR_MAX(4, 2 * cq->outstanding_tag_capacity);
|
591
|
+
cq->outstanding_tags =
|
592
|
+
gpr_realloc(cq->outstanding_tags, sizeof(*cq->outstanding_tags) *
|
593
|
+
cq->outstanding_tag_capacity);
|
594
|
+
}
|
595
|
+
cq->outstanding_tags[cq->outstanding_tag_count++] = tag;
|
596
|
+
gpr_mu_unlock(cq->mu);
|
597
|
+
#endif
|
598
|
+
return cq->vtable->begin_op(cq, tag);
|
599
|
+
}
|
600
|
+
|
601
|
+
/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
|
602
|
+
* completion
|
547
603
|
* type of GRPC_CQ_NEXT) */
|
548
604
|
static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
|
549
|
-
grpc_completion_queue *
|
605
|
+
grpc_completion_queue *cq, void *tag,
|
550
606
|
grpc_error *error,
|
551
607
|
void (*done)(grpc_exec_ctx *exec_ctx,
|
552
608
|
void *done_arg,
|
@@ -559,16 +615,16 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
|
|
559
615
|
error != GRPC_ERROR_NONE)) {
|
560
616
|
const char *errmsg = grpc_error_string(error);
|
561
617
|
GRPC_API_TRACE(
|
562
|
-
"cq_end_op_for_next(exec_ctx=%p,
|
618
|
+
"cq_end_op_for_next(exec_ctx=%p, cq=%p, tag=%p, error=%s, "
|
563
619
|
"done=%p, done_arg=%p, storage=%p)",
|
564
|
-
7, (exec_ctx,
|
620
|
+
7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
|
565
621
|
if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
|
566
622
|
error != GRPC_ERROR_NONE) {
|
567
623
|
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
|
568
624
|
}
|
569
625
|
}
|
570
626
|
|
571
|
-
|
627
|
+
cq_next_data *cqd = DATA_FROM_CQ(cq);
|
572
628
|
int is_success = (error == GRPC_ERROR_NONE);
|
573
629
|
|
574
630
|
storage->tag = tag;
|
@@ -576,28 +632,42 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
|
|
576
632
|
storage->done_arg = done_arg;
|
577
633
|
storage->next = (uintptr_t)(is_success);
|
578
634
|
|
579
|
-
cq_check_tag(
|
635
|
+
cq_check_tag(cq, tag, true); /* Used in debug builds only */
|
580
636
|
|
581
637
|
/* Add the completion to the queue */
|
582
|
-
cq_event_queue_push(&cqd->queue, storage);
|
638
|
+
bool is_first = cq_event_queue_push(&cqd->queue, storage);
|
583
639
|
gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
640
|
+
bool will_definitely_shutdown =
|
641
|
+
gpr_atm_no_barrier_load(&cqd->pending_events) == 1;
|
642
|
+
|
643
|
+
if (!will_definitely_shutdown) {
|
644
|
+
/* Only kick if this is the first item queued */
|
645
|
+
if (is_first) {
|
646
|
+
gpr_mu_lock(cq->mu);
|
647
|
+
grpc_error *kick_error =
|
648
|
+
cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), NULL);
|
649
|
+
gpr_mu_unlock(cq->mu);
|
650
|
+
|
651
|
+
if (kick_error != GRPC_ERROR_NONE) {
|
652
|
+
const char *msg = grpc_error_string(kick_error);
|
653
|
+
gpr_log(GPR_ERROR, "Kick failed: %s", msg);
|
654
|
+
GRPC_ERROR_UNREF(kick_error);
|
655
|
+
}
|
656
|
+
}
|
657
|
+
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
|
658
|
+
GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
|
659
|
+
gpr_mu_lock(cq->mu);
|
660
|
+
cq_finish_shutdown_next(exec_ctx, cq);
|
661
|
+
gpr_mu_unlock(cq->mu);
|
662
|
+
GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
|
597
663
|
}
|
598
664
|
} else {
|
599
|
-
|
600
|
-
|
665
|
+
GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
|
666
|
+
gpr_atm_rel_store(&cqd->pending_events, 0);
|
667
|
+
gpr_mu_lock(cq->mu);
|
668
|
+
cq_finish_shutdown_next(exec_ctx, cq);
|
669
|
+
gpr_mu_unlock(cq->mu);
|
670
|
+
GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
|
601
671
|
}
|
602
672
|
|
603
673
|
GPR_TIMER_END("cq_end_op_for_next", 0);
|
@@ -605,16 +675,17 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx,
|
|
605
675
|
GRPC_ERROR_UNREF(error);
|
606
676
|
}
|
607
677
|
|
608
|
-
/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
|
678
|
+
/* Queue a GRPC_OP_COMPLETED operation to a completion queue (with a
|
679
|
+
* completion
|
609
680
|
* type of GRPC_CQ_PLUCK) */
|
610
681
|
static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
|
611
|
-
grpc_completion_queue *
|
682
|
+
grpc_completion_queue *cq, void *tag,
|
612
683
|
grpc_error *error,
|
613
684
|
void (*done)(grpc_exec_ctx *exec_ctx,
|
614
685
|
void *done_arg,
|
615
686
|
grpc_cq_completion *storage),
|
616
687
|
void *done_arg, grpc_cq_completion *storage) {
|
617
|
-
|
688
|
+
cq_pluck_data *cqd = DATA_FROM_CQ(cq);
|
618
689
|
int is_success = (error == GRPC_ERROR_NONE);
|
619
690
|
|
620
691
|
GPR_TIMER_BEGIN("cq_end_op_for_pluck", 0);
|
@@ -624,9 +695,9 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
|
|
624
695
|
error != GRPC_ERROR_NONE)) {
|
625
696
|
const char *errmsg = grpc_error_string(error);
|
626
697
|
GRPC_API_TRACE(
|
627
|
-
"cq_end_op_for_pluck(exec_ctx=%p,
|
698
|
+
"cq_end_op_for_pluck(exec_ctx=%p, cq=%p, tag=%p, error=%s, "
|
628
699
|
"done=%p, done_arg=%p, storage=%p)",
|
629
|
-
7, (exec_ctx,
|
700
|
+
7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage));
|
630
701
|
if (GRPC_TRACER_ON(grpc_trace_operation_failures) &&
|
631
702
|
error != GRPC_ERROR_NONE) {
|
632
703
|
gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg);
|
@@ -638,8 +709,8 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
|
|
638
709
|
storage->done_arg = done_arg;
|
639
710
|
storage->next = ((uintptr_t)&cqd->completed_head) | ((uintptr_t)(is_success));
|
640
711
|
|
641
|
-
gpr_mu_lock(
|
642
|
-
cq_check_tag(
|
712
|
+
gpr_mu_lock(cq->mu);
|
713
|
+
cq_check_tag(cq, tag, false); /* Used in debug builds only */
|
643
714
|
|
644
715
|
/* Add to the list of completions */
|
645
716
|
gpr_atm_no_barrier_fetch_add(&cqd->things_queued_ever, 1);
|
@@ -647,8 +718,10 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
|
|
647
718
|
((uintptr_t)storage) | (1u & (uintptr_t)cqd->completed_tail->next);
|
648
719
|
cqd->completed_tail = storage;
|
649
720
|
|
650
|
-
|
651
|
-
|
721
|
+
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
|
722
|
+
cq_finish_shutdown_pluck(exec_ctx, cq);
|
723
|
+
gpr_mu_unlock(cq->mu);
|
724
|
+
} else {
|
652
725
|
grpc_pollset_worker *pluck_worker = NULL;
|
653
726
|
for (int i = 0; i < cqd->num_pluckers; i++) {
|
654
727
|
if (cqd->pluckers[i].tag == tag) {
|
@@ -658,9 +731,9 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
|
|
658
731
|
}
|
659
732
|
|
660
733
|
grpc_error *kick_error =
|
661
|
-
|
734
|
+
cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), pluck_worker);
|
662
735
|
|
663
|
-
gpr_mu_unlock(
|
736
|
+
gpr_mu_unlock(cq->mu);
|
664
737
|
|
665
738
|
if (kick_error != GRPC_ERROR_NONE) {
|
666
739
|
const char *msg = grpc_error_string(kick_error);
|
@@ -668,9 +741,6 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
|
|
668
741
|
|
669
742
|
GRPC_ERROR_UNREF(kick_error);
|
670
743
|
}
|
671
|
-
} else {
|
672
|
-
cq_finish_shutdown(exec_ctx, cc);
|
673
|
-
gpr_mu_unlock(cqd->mu);
|
674
744
|
}
|
675
745
|
|
676
746
|
GPR_TIMER_END("cq_end_op_for_pluck", 0);
|
@@ -678,12 +748,12 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx,
|
|
678
748
|
GRPC_ERROR_UNREF(error);
|
679
749
|
}
|
680
750
|
|
681
|
-
void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *
|
751
|
+
void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq,
|
682
752
|
void *tag, grpc_error *error,
|
683
753
|
void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg,
|
684
754
|
grpc_cq_completion *storage),
|
685
755
|
void *done_arg, grpc_cq_completion *storage) {
|
686
|
-
|
756
|
+
cq->vtable->end_op(exec_ctx, cq, tag, error, done, done_arg, storage);
|
687
757
|
}
|
688
758
|
|
689
759
|
typedef struct {
|
@@ -698,7 +768,7 @@ typedef struct {
|
|
698
768
|
static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) {
|
699
769
|
cq_is_finished_arg *a = arg;
|
700
770
|
grpc_completion_queue *cq = a->cq;
|
701
|
-
|
771
|
+
cq_next_data *cqd = DATA_FROM_CQ(cq);
|
702
772
|
GPR_ASSERT(a->stolen_completion == NULL);
|
703
773
|
|
704
774
|
gpr_atm current_last_seen_things_queued_ever =
|
@@ -709,7 +779,8 @@ static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) {
|
|
709
779
|
gpr_atm_no_barrier_load(&cqd->things_queued_ever);
|
710
780
|
|
711
781
|
/* Pop a cq_completion from the queue. Returns NULL if the queue is empty
|
712
|
-
* might return NULL in some cases even if the queue is not empty; but
|
782
|
+
* might return NULL in some cases even if the queue is not empty; but
|
783
|
+
* that
|
713
784
|
* is ok and doesn't affect correctness. Might effect the tail latencies a
|
714
785
|
* bit) */
|
715
786
|
a->stolen_completion = cq_event_queue_pop(&cqd->queue);
|
@@ -722,58 +793,56 @@ static bool cq_is_next_finished(grpc_exec_ctx *exec_ctx, void *arg) {
|
|
722
793
|
}
|
723
794
|
|
724
795
|
#ifndef NDEBUG
|
725
|
-
static void dump_pending_tags(grpc_completion_queue *
|
796
|
+
static void dump_pending_tags(grpc_completion_queue *cq) {
|
726
797
|
if (!GRPC_TRACER_ON(grpc_trace_pending_tags)) return;
|
727
798
|
|
728
|
-
cq_data *cqd = &cc->data;
|
729
|
-
|
730
799
|
gpr_strvec v;
|
731
800
|
gpr_strvec_init(&v);
|
732
801
|
gpr_strvec_add(&v, gpr_strdup("PENDING TAGS:"));
|
733
|
-
gpr_mu_lock(
|
734
|
-
for (size_t i = 0; i <
|
802
|
+
gpr_mu_lock(cq->mu);
|
803
|
+
for (size_t i = 0; i < cq->outstanding_tag_count; i++) {
|
735
804
|
char *s;
|
736
|
-
gpr_asprintf(&s, " %p",
|
805
|
+
gpr_asprintf(&s, " %p", cq->outstanding_tags[i]);
|
737
806
|
gpr_strvec_add(&v, s);
|
738
807
|
}
|
739
|
-
gpr_mu_unlock(
|
808
|
+
gpr_mu_unlock(cq->mu);
|
740
809
|
char *out = gpr_strvec_flatten(&v, NULL);
|
741
810
|
gpr_strvec_destroy(&v);
|
742
811
|
gpr_log(GPR_DEBUG, "%s", out);
|
743
812
|
gpr_free(out);
|
744
813
|
}
|
745
814
|
#else
|
746
|
-
static void dump_pending_tags(grpc_completion_queue *
|
815
|
+
static void dump_pending_tags(grpc_completion_queue *cq) {}
|
747
816
|
#endif
|
748
817
|
|
749
|
-
static grpc_event cq_next(grpc_completion_queue *
|
818
|
+
static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
|
750
819
|
void *reserved) {
|
751
820
|
grpc_event ret;
|
752
821
|
gpr_timespec now;
|
753
|
-
|
822
|
+
cq_next_data *cqd = DATA_FROM_CQ(cq);
|
754
823
|
|
755
824
|
GPR_TIMER_BEGIN("grpc_completion_queue_next", 0);
|
756
825
|
|
757
826
|
GRPC_API_TRACE(
|
758
827
|
"grpc_completion_queue_next("
|
759
|
-
"
|
828
|
+
"cq=%p, "
|
760
829
|
"deadline=gpr_timespec { tv_sec: %" PRId64
|
761
830
|
", tv_nsec: %d, clock_type: %d }, "
|
762
831
|
"reserved=%p)",
|
763
|
-
5, (
|
832
|
+
5, (cq, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type,
|
764
833
|
reserved));
|
765
834
|
GPR_ASSERT(!reserved);
|
766
835
|
|
767
|
-
dump_pending_tags(
|
836
|
+
dump_pending_tags(cq);
|
768
837
|
|
769
838
|
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
|
770
839
|
|
771
|
-
GRPC_CQ_INTERNAL_REF(
|
840
|
+
GRPC_CQ_INTERNAL_REF(cq, "next");
|
772
841
|
|
773
842
|
cq_is_finished_arg is_finished_arg = {
|
774
843
|
.last_seen_things_queued_ever =
|
775
844
|
gpr_atm_no_barrier_load(&cqd->things_queued_ever),
|
776
|
-
.cq =
|
845
|
+
.cq = cq,
|
777
846
|
.deadline = deadline,
|
778
847
|
.stolen_completion = NULL,
|
779
848
|
.tag = NULL,
|
@@ -806,22 +875,22 @@ static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
|
|
806
875
|
/* If c == NULL it means either the queue is empty OR in an transient
|
807
876
|
inconsistent state. If it is the latter, we shold do a 0-timeout poll
|
808
877
|
so that the thread comes back quickly from poll to make a second
|
809
|
-
attempt at popping. Not doing this can potentially deadlock this
|
810
|
-
forever (if the deadline is infinity) */
|
878
|
+
attempt at popping. Not doing this can potentially deadlock this
|
879
|
+
thread forever (if the deadline is infinity) */
|
811
880
|
if (cq_event_queue_num_items(&cqd->queue) > 0) {
|
812
881
|
iteration_deadline = gpr_time_0(GPR_CLOCK_MONOTONIC);
|
813
882
|
}
|
814
883
|
}
|
815
884
|
|
816
|
-
if (gpr_atm_no_barrier_load(&cqd->
|
885
|
+
if (gpr_atm_no_barrier_load(&cqd->pending_events) == 0) {
|
817
886
|
/* Before returning, check if the queue has any items left over (since
|
818
887
|
gpr_mpscq_pop() can sometimes return NULL even if the queue is not
|
819
888
|
empty. If so, keep retrying but do not return GRPC_QUEUE_SHUTDOWN */
|
820
889
|
if (cq_event_queue_num_items(&cqd->queue) > 0) {
|
821
890
|
/* Go to the beginning of the loop. No point doing a poll because
|
822
|
-
(
|
823
|
-
(i.e
|
824
|
-
events
|
891
|
+
(cq->shutdown == true) is only possible when there is no pending
|
892
|
+
work (i.e cq->pending_events == 0) and any outstanding completion
|
893
|
+
events should have already been queued on this cq */
|
825
894
|
continue;
|
826
895
|
}
|
827
896
|
|
@@ -834,16 +903,16 @@ static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
|
|
834
903
|
if (!is_finished_arg.first_loop && gpr_time_cmp(now, deadline) >= 0) {
|
835
904
|
memset(&ret, 0, sizeof(ret));
|
836
905
|
ret.type = GRPC_QUEUE_TIMEOUT;
|
837
|
-
dump_pending_tags(
|
906
|
+
dump_pending_tags(cq);
|
838
907
|
break;
|
839
908
|
}
|
840
909
|
|
841
910
|
/* The main polling work happens in grpc_pollset_work */
|
842
|
-
gpr_mu_lock(
|
843
|
-
|
844
|
-
grpc_error *err =
|
911
|
+
gpr_mu_lock(cq->mu);
|
912
|
+
cq->num_polls++;
|
913
|
+
grpc_error *err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
|
845
914
|
NULL, now, iteration_deadline);
|
846
|
-
gpr_mu_unlock(
|
915
|
+
gpr_mu_unlock(cq->mu);
|
847
916
|
|
848
917
|
if (err != GRPC_ERROR_NONE) {
|
849
918
|
const char *msg = grpc_error_string(err);
|
@@ -852,14 +921,21 @@ static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
|
|
852
921
|
GRPC_ERROR_UNREF(err);
|
853
922
|
memset(&ret, 0, sizeof(ret));
|
854
923
|
ret.type = GRPC_QUEUE_TIMEOUT;
|
855
|
-
dump_pending_tags(
|
924
|
+
dump_pending_tags(cq);
|
856
925
|
break;
|
857
926
|
}
|
858
927
|
is_finished_arg.first_loop = false;
|
859
928
|
}
|
860
929
|
|
861
|
-
|
862
|
-
|
930
|
+
if (cq_event_queue_num_items(&cqd->queue) > 0 &&
|
931
|
+
gpr_atm_no_barrier_load(&cqd->pending_events) > 0) {
|
932
|
+
gpr_mu_lock(cq->mu);
|
933
|
+
cq->poller_vtable->kick(POLLSET_FROM_CQ(cq), NULL);
|
934
|
+
gpr_mu_unlock(cq->mu);
|
935
|
+
}
|
936
|
+
|
937
|
+
GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
|
938
|
+
GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "next");
|
863
939
|
grpc_exec_ctx_finish(&exec_ctx);
|
864
940
|
GPR_ASSERT(is_finished_arg.stolen_completion == NULL);
|
865
941
|
|
@@ -868,14 +944,57 @@ static grpc_event cq_next(grpc_completion_queue *cc, gpr_timespec deadline,
|
|
868
944
|
return ret;
|
869
945
|
}
|
870
946
|
|
871
|
-
|
947
|
+
/* Finishes the completion queue shutdown. This means that there are no more
|
948
|
+
completion events / tags expected from the completion queue
|
949
|
+
- Must be called under completion queue lock
|
950
|
+
- Must be called only once in completion queue's lifetime
|
951
|
+
- grpc_completion_queue_shutdown() MUST have been called before calling
|
952
|
+
this function */
|
953
|
+
static void cq_finish_shutdown_next(grpc_exec_ctx *exec_ctx,
|
954
|
+
grpc_completion_queue *cq) {
|
955
|
+
cq_next_data *cqd = DATA_FROM_CQ(cq);
|
956
|
+
|
957
|
+
GPR_ASSERT(cqd->shutdown_called);
|
958
|
+
GPR_ASSERT(gpr_atm_no_barrier_load(&cqd->pending_events) == 0);
|
959
|
+
|
960
|
+
cq->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cq),
|
961
|
+
&cq->pollset_shutdown_done);
|
962
|
+
}
|
963
|
+
|
964
|
+
static void cq_shutdown_next(grpc_exec_ctx *exec_ctx,
|
965
|
+
grpc_completion_queue *cq) {
|
966
|
+
cq_next_data *cqd = DATA_FROM_CQ(cq);
|
967
|
+
|
968
|
+
/* Need an extra ref for cq here because:
|
969
|
+
* We call cq_finish_shutdown_next() below, that would call pollset shutdown.
|
970
|
+
* Pollset shutdown decrements the cq ref count which can potentially destroy
|
971
|
+
* the cq (if that happens to be the last ref).
|
972
|
+
* Creating an extra ref here prevents the cq from getting destroyed while
|
973
|
+
* this function is still active */
|
974
|
+
GRPC_CQ_INTERNAL_REF(cq, "shutting_down");
|
975
|
+
gpr_mu_lock(cq->mu);
|
976
|
+
if (cqd->shutdown_called) {
|
977
|
+
gpr_mu_unlock(cq->mu);
|
978
|
+
GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
|
979
|
+
GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
|
980
|
+
return;
|
981
|
+
}
|
982
|
+
cqd->shutdown_called = true;
|
983
|
+
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
|
984
|
+
cq_finish_shutdown_next(exec_ctx, cq);
|
985
|
+
}
|
986
|
+
gpr_mu_unlock(cq->mu);
|
987
|
+
GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down");
|
988
|
+
}
|
989
|
+
|
990
|
+
grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
|
872
991
|
gpr_timespec deadline, void *reserved) {
|
873
|
-
return
|
992
|
+
return cq->vtable->next(cq, deadline, reserved);
|
874
993
|
}
|
875
994
|
|
876
|
-
static int add_plucker(grpc_completion_queue *
|
995
|
+
static int add_plucker(grpc_completion_queue *cq, void *tag,
|
877
996
|
grpc_pollset_worker **worker) {
|
878
|
-
|
997
|
+
cq_pluck_data *cqd = DATA_FROM_CQ(cq);
|
879
998
|
if (cqd->num_pluckers == GRPC_MAX_COMPLETION_QUEUE_PLUCKERS) {
|
880
999
|
return 0;
|
881
1000
|
}
|
@@ -885,9 +1004,9 @@ static int add_plucker(grpc_completion_queue *cc, void *tag,
|
|
885
1004
|
return 1;
|
886
1005
|
}
|
887
1006
|
|
888
|
-
static void del_plucker(grpc_completion_queue *
|
1007
|
+
static void del_plucker(grpc_completion_queue *cq, void *tag,
|
889
1008
|
grpc_pollset_worker **worker) {
|
890
|
-
|
1009
|
+
cq_pluck_data *cqd = DATA_FROM_CQ(cq);
|
891
1010
|
for (int i = 0; i < cqd->num_pluckers; i++) {
|
892
1011
|
if (cqd->pluckers[i].tag == tag && cqd->pluckers[i].worker == worker) {
|
893
1012
|
cqd->num_pluckers--;
|
@@ -901,13 +1020,13 @@ static void del_plucker(grpc_completion_queue *cc, void *tag,
|
|
901
1020
|
static bool cq_is_pluck_finished(grpc_exec_ctx *exec_ctx, void *arg) {
|
902
1021
|
cq_is_finished_arg *a = arg;
|
903
1022
|
grpc_completion_queue *cq = a->cq;
|
904
|
-
|
1023
|
+
cq_pluck_data *cqd = DATA_FROM_CQ(cq);
|
905
1024
|
|
906
1025
|
GPR_ASSERT(a->stolen_completion == NULL);
|
907
1026
|
gpr_atm current_last_seen_things_queued_ever =
|
908
1027
|
gpr_atm_no_barrier_load(&cqd->things_queued_ever);
|
909
1028
|
if (current_last_seen_things_queued_ever != a->last_seen_things_queued_ever) {
|
910
|
-
gpr_mu_lock(
|
1029
|
+
gpr_mu_lock(cq->mu);
|
911
1030
|
a->last_seen_things_queued_ever =
|
912
1031
|
gpr_atm_no_barrier_load(&cqd->things_queued_ever);
|
913
1032
|
grpc_cq_completion *c;
|
@@ -919,51 +1038,51 @@ static bool cq_is_pluck_finished(grpc_exec_ctx *exec_ctx, void *arg) {
|
|
919
1038
|
if (c == cqd->completed_tail) {
|
920
1039
|
cqd->completed_tail = prev;
|
921
1040
|
}
|
922
|
-
gpr_mu_unlock(
|
1041
|
+
gpr_mu_unlock(cq->mu);
|
923
1042
|
a->stolen_completion = c;
|
924
1043
|
return true;
|
925
1044
|
}
|
926
1045
|
prev = c;
|
927
1046
|
}
|
928
|
-
gpr_mu_unlock(
|
1047
|
+
gpr_mu_unlock(cq->mu);
|
929
1048
|
}
|
930
1049
|
return !a->first_loop &&
|
931
1050
|
gpr_time_cmp(a->deadline, gpr_now(a->deadline.clock_type)) < 0;
|
932
1051
|
}
|
933
1052
|
|
934
|
-
static grpc_event cq_pluck(grpc_completion_queue *
|
1053
|
+
static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag,
|
935
1054
|
gpr_timespec deadline, void *reserved) {
|
936
1055
|
grpc_event ret;
|
937
1056
|
grpc_cq_completion *c;
|
938
1057
|
grpc_cq_completion *prev;
|
939
1058
|
grpc_pollset_worker *worker = NULL;
|
940
1059
|
gpr_timespec now;
|
941
|
-
|
1060
|
+
cq_pluck_data *cqd = DATA_FROM_CQ(cq);
|
942
1061
|
|
943
1062
|
GPR_TIMER_BEGIN("grpc_completion_queue_pluck", 0);
|
944
1063
|
|
945
1064
|
if (GRPC_TRACER_ON(grpc_cq_pluck_trace)) {
|
946
1065
|
GRPC_API_TRACE(
|
947
1066
|
"grpc_completion_queue_pluck("
|
948
|
-
"
|
1067
|
+
"cq=%p, tag=%p, "
|
949
1068
|
"deadline=gpr_timespec { tv_sec: %" PRId64
|
950
1069
|
", tv_nsec: %d, clock_type: %d }, "
|
951
1070
|
"reserved=%p)",
|
952
|
-
6, (
|
1071
|
+
6, (cq, tag, deadline.tv_sec, deadline.tv_nsec,
|
953
1072
|
(int)deadline.clock_type, reserved));
|
954
1073
|
}
|
955
1074
|
GPR_ASSERT(!reserved);
|
956
1075
|
|
957
|
-
dump_pending_tags(
|
1076
|
+
dump_pending_tags(cq);
|
958
1077
|
|
959
1078
|
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
|
960
1079
|
|
961
|
-
GRPC_CQ_INTERNAL_REF(
|
962
|
-
gpr_mu_lock(
|
1080
|
+
GRPC_CQ_INTERNAL_REF(cq, "pluck");
|
1081
|
+
gpr_mu_lock(cq->mu);
|
963
1082
|
cq_is_finished_arg is_finished_arg = {
|
964
1083
|
.last_seen_things_queued_ever =
|
965
1084
|
gpr_atm_no_barrier_load(&cqd->things_queued_ever),
|
966
|
-
.cq =
|
1085
|
+
.cq = cq,
|
967
1086
|
.deadline = deadline,
|
968
1087
|
.stolen_completion = NULL,
|
969
1088
|
.tag = tag,
|
@@ -972,7 +1091,7 @@ static grpc_event cq_pluck(grpc_completion_queue *cc, void *tag,
|
|
972
1091
|
GRPC_EXEC_CTX_INITIALIZER(0, cq_is_pluck_finished, &is_finished_arg);
|
973
1092
|
for (;;) {
|
974
1093
|
if (is_finished_arg.stolen_completion != NULL) {
|
975
|
-
gpr_mu_unlock(
|
1094
|
+
gpr_mu_unlock(cq->mu);
|
976
1095
|
c = is_finished_arg.stolen_completion;
|
977
1096
|
is_finished_arg.stolen_completion = NULL;
|
978
1097
|
ret.type = GRPC_OP_COMPLETE;
|
@@ -989,7 +1108,7 @@ static grpc_event cq_pluck(grpc_completion_queue *cc, void *tag,
|
|
989
1108
|
if (c == cqd->completed_tail) {
|
990
1109
|
cqd->completed_tail = prev;
|
991
1110
|
}
|
992
|
-
gpr_mu_unlock(
|
1111
|
+
gpr_mu_unlock(cq->mu);
|
993
1112
|
ret.type = GRPC_OP_COMPLETE;
|
994
1113
|
ret.success = c->next & 1u;
|
995
1114
|
ret.tag = c->tag;
|
@@ -999,54 +1118,54 @@ static grpc_event cq_pluck(grpc_completion_queue *cc, void *tag,
|
|
999
1118
|
prev = c;
|
1000
1119
|
}
|
1001
1120
|
if (gpr_atm_no_barrier_load(&cqd->shutdown)) {
|
1002
|
-
gpr_mu_unlock(
|
1121
|
+
gpr_mu_unlock(cq->mu);
|
1003
1122
|
memset(&ret, 0, sizeof(ret));
|
1004
1123
|
ret.type = GRPC_QUEUE_SHUTDOWN;
|
1005
1124
|
break;
|
1006
1125
|
}
|
1007
|
-
if (!add_plucker(
|
1126
|
+
if (!add_plucker(cq, tag, &worker)) {
|
1008
1127
|
gpr_log(GPR_DEBUG,
|
1009
1128
|
"Too many outstanding grpc_completion_queue_pluck calls: maximum "
|
1010
1129
|
"is %d",
|
1011
1130
|
GRPC_MAX_COMPLETION_QUEUE_PLUCKERS);
|
1012
|
-
gpr_mu_unlock(
|
1131
|
+
gpr_mu_unlock(cq->mu);
|
1013
1132
|
memset(&ret, 0, sizeof(ret));
|
1014
1133
|
/* TODO(ctiller): should we use a different result here */
|
1015
1134
|
ret.type = GRPC_QUEUE_TIMEOUT;
|
1016
|
-
dump_pending_tags(
|
1135
|
+
dump_pending_tags(cq);
|
1017
1136
|
break;
|
1018
1137
|
}
|
1019
1138
|
now = gpr_now(GPR_CLOCK_MONOTONIC);
|
1020
1139
|
if (!is_finished_arg.first_loop && gpr_time_cmp(now, deadline) >= 0) {
|
1021
|
-
del_plucker(
|
1022
|
-
gpr_mu_unlock(
|
1140
|
+
del_plucker(cq, tag, &worker);
|
1141
|
+
gpr_mu_unlock(cq->mu);
|
1023
1142
|
memset(&ret, 0, sizeof(ret));
|
1024
1143
|
ret.type = GRPC_QUEUE_TIMEOUT;
|
1025
|
-
dump_pending_tags(
|
1144
|
+
dump_pending_tags(cq);
|
1026
1145
|
break;
|
1027
1146
|
}
|
1028
1147
|
|
1029
|
-
|
1030
|
-
grpc_error *err =
|
1148
|
+
cq->num_polls++;
|
1149
|
+
grpc_error *err = cq->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cq),
|
1031
1150
|
&worker, now, deadline);
|
1032
1151
|
if (err != GRPC_ERROR_NONE) {
|
1033
|
-
del_plucker(
|
1034
|
-
gpr_mu_unlock(
|
1152
|
+
del_plucker(cq, tag, &worker);
|
1153
|
+
gpr_mu_unlock(cq->mu);
|
1035
1154
|
const char *msg = grpc_error_string(err);
|
1036
1155
|
gpr_log(GPR_ERROR, "Completion queue pluck failed: %s", msg);
|
1037
1156
|
|
1038
1157
|
GRPC_ERROR_UNREF(err);
|
1039
1158
|
memset(&ret, 0, sizeof(ret));
|
1040
1159
|
ret.type = GRPC_QUEUE_TIMEOUT;
|
1041
|
-
dump_pending_tags(
|
1160
|
+
dump_pending_tags(cq);
|
1042
1161
|
break;
|
1043
1162
|
}
|
1044
1163
|
is_finished_arg.first_loop = false;
|
1045
|
-
del_plucker(
|
1164
|
+
del_plucker(cq, tag, &worker);
|
1046
1165
|
}
|
1047
1166
|
done:
|
1048
|
-
GRPC_SURFACE_TRACE_RETURNED_EVENT(
|
1049
|
-
GRPC_CQ_INTERNAL_UNREF(&exec_ctx,
|
1167
|
+
GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, &ret);
|
1168
|
+
GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "pluck");
|
1050
1169
|
grpc_exec_ctx_finish(&exec_ctx);
|
1051
1170
|
GPR_ASSERT(is_finished_arg.stolen_completion == NULL);
|
1052
1171
|
|
@@ -1055,85 +1174,77 @@ done:
|
|
1055
1174
|
return ret;
|
1056
1175
|
}
|
1057
1176
|
|
1058
|
-
grpc_event grpc_completion_queue_pluck(grpc_completion_queue *
|
1177
|
+
grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
|
1059
1178
|
gpr_timespec deadline, void *reserved) {
|
1060
|
-
return
|
1179
|
+
return cq->vtable->pluck(cq, tag, deadline, reserved);
|
1061
1180
|
}
|
1062
1181
|
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
- Must be called only once in completion queue's lifetime
|
1067
|
-
- grpc_completion_queue_shutdown() MUST have been called before calling
|
1068
|
-
this function */
|
1069
|
-
static void cq_finish_shutdown(grpc_exec_ctx *exec_ctx,
|
1070
|
-
grpc_completion_queue *cc) {
|
1071
|
-
cq_data *cqd = &cc->data;
|
1182
|
+
static void cq_finish_shutdown_pluck(grpc_exec_ctx *exec_ctx,
|
1183
|
+
grpc_completion_queue *cq) {
|
1184
|
+
cq_pluck_data *cqd = DATA_FROM_CQ(cq);
|
1072
1185
|
|
1073
1186
|
GPR_ASSERT(cqd->shutdown_called);
|
1074
1187
|
GPR_ASSERT(!gpr_atm_no_barrier_load(&cqd->shutdown));
|
1075
1188
|
gpr_atm_no_barrier_store(&cqd->shutdown, 1);
|
1076
1189
|
|
1077
|
-
|
1078
|
-
&
|
1190
|
+
cq->poller_vtable->shutdown(exec_ctx, POLLSET_FROM_CQ(cq),
|
1191
|
+
&cq->pollset_shutdown_done);
|
1079
1192
|
}
|
1080
1193
|
|
1081
|
-
/*
|
1082
|
-
|
1083
|
-
void
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1194
|
+
/* NOTE: This function is almost exactly identical to cq_shutdown_next() but
|
1195
|
+
* merging them is a bit tricky and probably not worth it */
|
1196
|
+
static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx,
|
1197
|
+
grpc_completion_queue *cq) {
|
1198
|
+
cq_pluck_data *cqd = DATA_FROM_CQ(cq);
|
1199
|
+
|
1200
|
+
/* Need an extra ref for cq here because:
|
1201
|
+
* We call cq_finish_shutdown_pluck() below, that would call pollset shutdown.
|
1202
|
+
* Pollset shutdown decrements the cq ref count which can potentially destroy
|
1203
|
+
* the cq (if that happens to be the last ref).
|
1204
|
+
* Creating an extra ref here prevents the cq from getting destroyed while
|
1205
|
+
* this function is still active */
|
1206
|
+
GRPC_CQ_INTERNAL_REF(cq, "shutting_down (pluck cq)");
|
1207
|
+
gpr_mu_lock(cq->mu);
|
1090
1208
|
if (cqd->shutdown_called) {
|
1091
|
-
gpr_mu_unlock(
|
1209
|
+
gpr_mu_unlock(cq->mu);
|
1210
|
+
GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
|
1092
1211
|
GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
|
1093
1212
|
return;
|
1094
1213
|
}
|
1095
|
-
cqd->shutdown_called =
|
1096
|
-
if (
|
1097
|
-
|
1214
|
+
cqd->shutdown_called = true;
|
1215
|
+
if (gpr_atm_full_fetch_add(&cqd->pending_events, -1) == 1) {
|
1216
|
+
cq_finish_shutdown_pluck(exec_ctx, cq);
|
1098
1217
|
}
|
1099
|
-
gpr_mu_unlock(
|
1218
|
+
gpr_mu_unlock(cq->mu);
|
1219
|
+
GRPC_CQ_INTERNAL_UNREF(exec_ctx, cq, "shutting_down (pluck cq)");
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
/* Shutdown simply drops a ref that we reserved at creation time; if we drop
|
1223
|
+
to zero here, then enter shutdown mode and wake up any waiters */
|
1224
|
+
void grpc_completion_queue_shutdown(grpc_completion_queue *cq) {
|
1225
|
+
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1226
|
+
GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0);
|
1227
|
+
GRPC_API_TRACE("grpc_completion_queue_shutdown(cq=%p)", 1, (cq));
|
1228
|
+
cq->vtable->shutdown(&exec_ctx, cq);
|
1100
1229
|
grpc_exec_ctx_finish(&exec_ctx);
|
1101
1230
|
GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
|
1102
1231
|
}
|
1103
1232
|
|
1104
|
-
void grpc_completion_queue_destroy(grpc_completion_queue *
|
1105
|
-
GRPC_API_TRACE("grpc_completion_queue_destroy(
|
1233
|
+
void grpc_completion_queue_destroy(grpc_completion_queue *cq) {
|
1234
|
+
GRPC_API_TRACE("grpc_completion_queue_destroy(cq=%p)", 1, (cq));
|
1106
1235
|
GPR_TIMER_BEGIN("grpc_completion_queue_destroy", 0);
|
1107
|
-
grpc_completion_queue_shutdown(
|
1108
|
-
|
1109
|
-
/* TODO (sreek): This should not ideally be here. Refactor it into the
|
1110
|
-
* cq_vtable (perhaps have a create/destroy methods in the cq vtable) */
|
1111
|
-
if (cc->vtable->cq_completion_type == GRPC_CQ_NEXT) {
|
1112
|
-
GPR_ASSERT(cq_event_queue_num_items(&cc->data.queue) == 0);
|
1113
|
-
}
|
1236
|
+
grpc_completion_queue_shutdown(cq);
|
1114
1237
|
|
1115
1238
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1116
|
-
GRPC_CQ_INTERNAL_UNREF(&exec_ctx,
|
1239
|
+
GRPC_CQ_INTERNAL_UNREF(&exec_ctx, cq, "destroy");
|
1117
1240
|
grpc_exec_ctx_finish(&exec_ctx);
|
1118
1241
|
GPR_TIMER_END("grpc_completion_queue_destroy", 0);
|
1119
1242
|
}
|
1120
1243
|
|
1121
|
-
grpc_pollset *grpc_cq_pollset(grpc_completion_queue *
|
1122
|
-
return
|
1123
|
-
}
|
1124
|
-
|
1125
|
-
grpc_completion_queue *grpc_cq_from_pollset(grpc_pollset *ps) {
|
1126
|
-
return CQ_FROM_POLLSET(ps);
|
1127
|
-
}
|
1128
|
-
|
1129
|
-
void grpc_cq_mark_server_cq(grpc_completion_queue *cc) {
|
1130
|
-
cc->data.is_server_cq = 1;
|
1131
|
-
}
|
1132
|
-
|
1133
|
-
bool grpc_cq_is_server_cq(grpc_completion_queue *cc) {
|
1134
|
-
return cc->data.is_server_cq;
|
1244
|
+
grpc_pollset *grpc_cq_pollset(grpc_completion_queue *cq) {
|
1245
|
+
return cq->poller_vtable->can_get_pollset ? POLLSET_FROM_CQ(cq) : NULL;
|
1135
1246
|
}
|
1136
1247
|
|
1137
|
-
bool grpc_cq_can_listen(grpc_completion_queue *
|
1138
|
-
return
|
1248
|
+
bool grpc_cq_can_listen(grpc_completion_queue *cq) {
|
1249
|
+
return cq->poller_vtable->can_listen;
|
1139
1250
|
}
|