grpc 1.8.7 → 1.9.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 +549 -325
- data/include/grpc/impl/codegen/grpc_types.h +1 -2
- data/include/grpc/impl/codegen/port_platform.h +46 -5
- data/include/grpc/impl/codegen/slice.h +1 -2
- data/include/grpc/module.modulemap +0 -2
- data/include/grpc/slice_buffer.h +1 -2
- data/include/grpc/support/log.h +4 -2
- data/include/grpc/support/thd.h +4 -1
- data/include/grpc/support/tls.h +6 -0
- data/include/grpc/support/tls_gcc.h +5 -40
- data/include/grpc/support/tls_msvc.h +9 -0
- data/include/grpc/support/tls_pthread.h +9 -0
- data/src/core/ext/filters/client_channel/backup_poller.cc +32 -29
- data/src/core/ext/filters/client_channel/backup_poller.h +2 -2
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +26 -32
- data/src/core/ext/filters/client_channel/client_channel.cc +325 -356
- data/src/core/ext/filters/client_channel/client_channel.h +4 -12
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +9 -14
- data/src/core/ext/filters/client_channel/client_channel_factory.h +7 -20
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +7 -10
- data/src/core/ext/filters/client_channel/connector.cc +6 -7
- data/src/core/ext/filters/client_channel/connector.h +6 -16
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +38 -50
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +0 -8
- data/src/core/ext/filters/client_channel/http_proxy.cc +9 -13
- data/src/core/ext/filters/client_channel/http_proxy.h +0 -8
- data/src/core/ext/filters/client_channel/lb_policy.cc +72 -94
- data/src/core/ext/filters/client_channel/lb_policy.h +83 -92
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -19
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +0 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +474 -591
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +2 -10
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +6 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +0 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +0 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +0 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +3 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +9 -12
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +160 -182
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +182 -221
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +24 -35
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -20
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +6 -9
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -15
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -9
- data/src/core/ext/filters/client_channel/parse_address.cc +1 -1
- data/src/core/ext/filters/client_channel/parse_address.h +0 -8
- data/src/core/ext/filters/client_channel/proxy_mapper.cc +6 -8
- data/src/core/ext/filters/client_channel/proxy_mapper.h +6 -16
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +13 -17
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +2 -12
- data/src/core/ext/filters/client_channel/resolver.cc +11 -13
- data/src/core/ext/filters/client_channel/resolver.h +14 -25
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +57 -70
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +2 -12
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +23 -31
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +27 -45
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +9 -11
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +53 -66
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +25 -33
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -9
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +26 -35
- data/src/core/ext/filters/client_channel/resolver_factory.cc +2 -3
- data/src/core/ext/filters/client_channel/resolver_factory.h +2 -12
- data/src/core/ext/filters/client_channel/resolver_registry.cc +12 -15
- data/src/core/ext/filters/client_channel/resolver_registry.h +3 -12
- data/src/core/ext/filters/client_channel/retry_throttle.h +0 -8
- data/src/core/ext/filters/client_channel/subchannel.cc +289 -301
- data/src/core/ext/filters/client_channel/subchannel.h +57 -84
- data/src/core/ext/filters/client_channel/subchannel_index.cc +30 -33
- data/src/core/ext/filters/client_channel/subchannel_index.h +4 -16
- data/src/core/ext/filters/client_channel/uri_parser.cc +13 -17
- data/src/core/ext/filters/client_channel/uri_parser.h +1 -10
- data/src/core/ext/filters/deadline/deadline_filter.cc +49 -67
- data/src/core/ext/filters/deadline/deadline_filter.h +4 -14
- data/src/core/ext/filters/http/client/http_client_filter.cc +60 -77
- data/src/core/ext/filters/http/client/http_client_filter.h +0 -8
- data/src/core/ext/filters/http/http_filters_plugin.cc +4 -6
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +63 -79
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +0 -8
- data/src/core/ext/filters/http/server/http_server_filter.cc +57 -71
- data/src/core/ext/filters/http/server/http_server_filter.h +0 -8
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +19 -24
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +0 -8
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +3 -3
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +0 -8
- data/src/core/ext/filters/max_age/max_age_filter.cc +49 -62
- data/src/core/ext/filters/max_age/max_age_filter.h +0 -8
- data/src/core/ext/filters/message_size/message_size_filter.cc +23 -29
- data/src/core/ext/filters/message_size/message_size_filter.h +0 -8
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +15 -18
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +0 -8
- data/src/core/ext/filters/workarounds/workaround_utils.h +0 -8
- data/src/core/ext/transport/chttp2/alpn/alpn.h +0 -8
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +33 -40
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +0 -8
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +15 -17
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +8 -8
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +23 -28
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +50 -57
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +1 -10
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -3
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +7 -10
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +5 -6
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -9
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -11
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -9
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +10 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +516 -636
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +4 -11
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +29 -13
- data/src/core/ext/transport/chttp2/transport/flow_control.h +196 -53
- data/src/core/ext/transport/chttp2/transport/frame.h +0 -8
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +31 -33
- data/src/core/ext/transport/chttp2/transport/frame_data.h +3 -12
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +1 -10
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -9
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +1 -10
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +8 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -10
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +8 -8
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +5 -11
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +63 -81
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -12
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +230 -318
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +6 -19
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +14 -20
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -16
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +0 -7
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +0 -8
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +8 -11
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +4 -13
- data/src/core/ext/transport/chttp2/transport/internal.h +51 -75
- data/src/core/ext/transport/chttp2/transport/parsing.cc +83 -109
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/stream_map.h +0 -8
- data/src/core/ext/transport/chttp2/transport/varint.h +0 -8
- data/src/core/ext/transport/chttp2/transport/writing.cc +61 -65
- data/src/core/ext/transport/inproc/inproc_plugin.cc +2 -4
- data/src/core/ext/transport/inproc/inproc_transport.cc +177 -188
- data/src/core/ext/transport/inproc/inproc_transport.h +0 -8
- data/src/core/lib/backoff/backoff.cc +39 -44
- data/src/core/lib/backoff/backoff.h +61 -57
- data/src/core/lib/channel/channel_args.cc +8 -10
- data/src/core/lib/channel/channel_args.h +4 -13
- data/src/core/lib/channel/channel_stack.cc +19 -27
- data/src/core/lib/channel/channel_stack.h +27 -47
- data/src/core/lib/channel/channel_stack_builder.cc +11 -14
- data/src/core/lib/channel/channel_stack_builder.h +4 -15
- data/src/core/lib/channel/connected_channel.cc +23 -36
- data/src/core/lib/channel/connected_channel.h +1 -10
- data/src/core/lib/channel/handshaker.cc +31 -40
- data/src/core/lib/channel/handshaker.h +14 -25
- data/src/core/lib/channel/handshaker_factory.cc +6 -6
- data/src/core/lib/channel/handshaker_factory.h +5 -15
- data/src/core/lib/channel/handshaker_registry.cc +9 -13
- data/src/core/lib/channel/handshaker_registry.h +2 -11
- data/src/core/lib/compression/algorithm_metadata.h +0 -8
- data/src/core/lib/compression/message_compress.cc +19 -23
- data/src/core/lib/compression/message_compress.h +2 -12
- data/src/core/lib/compression/stream_compression.cc +1 -1
- data/src/core/lib/compression/stream_compression.h +0 -8
- data/src/core/lib/compression/stream_compression_gzip.cc +12 -11
- data/src/core/lib/compression/stream_compression_gzip.h +0 -8
- data/src/core/lib/compression/stream_compression_identity.h +0 -8
- data/src/core/lib/debug/stats.cc +4 -4
- data/src/core/lib/debug/stats.h +9 -19
- data/src/core/lib/debug/stats_data.cc +85 -116
- data/src/core/lib/debug/stats_data.h +236 -312
- data/src/core/lib/debug/trace.cc +1 -1
- data/src/core/lib/debug/trace.h +0 -12
- data/src/core/lib/{support → gpr++}/abstract.h +8 -3
- data/src/core/lib/{support → gpr++}/atomic.h +5 -5
- data/src/core/lib/{support → gpr++}/atomic_with_atm.h +3 -3
- data/src/core/lib/{support → gpr++}/atomic_with_std.h +3 -3
- data/src/core/lib/gpr++/debug_location.h +52 -0
- data/src/core/lib/gpr++/inlined_vector.h +112 -0
- data/src/core/lib/{support → gpr++}/manual_constructor.h +2 -2
- data/src/core/lib/{support → gpr++}/memory.h +3 -3
- data/src/core/lib/gpr++/orphanable.h +171 -0
- data/src/core/lib/gpr++/ref_counted.h +133 -0
- data/src/core/lib/gpr++/ref_counted_ptr.h +99 -0
- data/src/core/lib/{support → gpr}/alloc.cc +0 -0
- data/src/core/lib/{support → gpr}/arena.cc +1 -1
- data/src/core/lib/{support → gpr}/arena.h +3 -11
- data/src/core/lib/{support → gpr}/atm.cc +0 -0
- data/src/core/lib/{support → gpr}/avl.cc +0 -0
- data/src/core/lib/{support → gpr}/cmdline.cc +1 -1
- data/src/core/lib/{support → gpr}/cpu_iphone.cc +0 -0
- data/src/core/lib/{support → gpr}/cpu_linux.cc +0 -0
- data/src/core/lib/{support → gpr}/cpu_posix.cc +0 -0
- data/src/core/lib/{support → gpr}/cpu_windows.cc +0 -0
- data/src/core/lib/{support → gpr}/env.h +3 -11
- data/src/core/lib/{support → gpr}/env_linux.cc +2 -2
- data/src/core/lib/{support → gpr}/env_posix.cc +4 -4
- data/src/core/lib/{support → gpr}/env_windows.cc +3 -3
- data/src/core/lib/{support → gpr}/fork.cc +3 -3
- data/src/core/lib/{support → gpr}/fork.h +3 -3
- data/src/core/lib/{support → gpr}/host_port.cc +1 -1
- data/src/core/lib/{support → gpr}/log.cc +3 -3
- data/src/core/lib/{support → gpr}/log_android.cc +3 -3
- data/src/core/lib/{support → gpr}/log_linux.cc +1 -1
- data/src/core/lib/{support → gpr}/log_posix.cc +5 -5
- data/src/core/lib/{support → gpr}/log_windows.cc +3 -3
- data/src/core/lib/{support → gpr}/mpscq.cc +1 -1
- data/src/core/lib/{support → gpr}/mpscq.h +3 -10
- data/src/core/lib/{support → gpr}/murmur_hash.cc +1 -1
- data/src/core/lib/{support → gpr}/murmur_hash.h +3 -11
- data/src/core/lib/{support → gpr}/spinlock.h +3 -3
- data/src/core/lib/{support → gpr}/string.cc +1 -1
- data/src/core/lib/{support → gpr}/string.h +3 -10
- data/src/core/lib/{support → gpr}/string_posix.cc +0 -0
- data/src/core/lib/{support → gpr}/string_util_windows.cc +2 -2
- data/src/core/lib/{support → gpr}/string_windows.cc +1 -1
- data/src/core/lib/{support → gpr}/string_windows.h +3 -11
- data/src/core/lib/{support → gpr}/subprocess_posix.cc +0 -0
- data/src/core/lib/{support → gpr}/subprocess_windows.cc +2 -2
- data/src/core/lib/{support → gpr}/sync.cc +0 -0
- data/src/core/lib/{support → gpr}/sync_posix.cc +10 -1
- data/src/core/lib/{support → gpr}/sync_windows.cc +0 -0
- data/src/core/lib/{support → gpr}/thd.cc +0 -0
- data/src/core/lib/{support → gpr}/thd_internal.h +3 -3
- data/src/core/lib/{support → gpr}/thd_posix.cc +18 -2
- data/src/core/lib/{support → gpr}/thd_windows.cc +2 -1
- data/src/core/lib/{support → gpr}/time.cc +0 -0
- data/src/core/lib/{support → gpr}/time_posix.cc +2 -4
- data/src/core/lib/{support → gpr}/time_precise.cc +1 -1
- data/src/core/lib/{support → gpr}/time_precise.h +3 -11
- data/src/core/lib/{support → gpr}/time_windows.cc +1 -3
- data/src/core/lib/{support → gpr}/tls_pthread.cc +0 -0
- data/src/core/lib/{support → gpr}/tmpfile.h +3 -11
- data/src/core/lib/{support → gpr}/tmpfile_msys.cc +2 -2
- data/src/core/lib/{support → gpr}/tmpfile_posix.cc +2 -2
- data/src/core/lib/{support → gpr}/tmpfile_windows.cc +2 -2
- data/src/core/lib/{support → gpr}/wrap_memcpy.cc +0 -0
- data/src/core/lib/http/format_request.cc +1 -1
- data/src/core/lib/http/format_request.h +0 -8
- data/src/core/lib/http/httpcli.cc +55 -74
- data/src/core/lib/http/httpcli.h +13 -22
- data/src/core/lib/http/httpcli_security_connector.cc +27 -33
- data/src/core/lib/http/parser.h +0 -8
- data/src/core/lib/iomgr/block_annotate.h +10 -17
- data/src/core/lib/iomgr/call_combiner.cc +14 -17
- data/src/core/lib/iomgr/call_combiner.h +16 -34
- data/src/core/lib/iomgr/closure.h +24 -37
- data/src/core/lib/iomgr/combiner.cc +62 -66
- data/src/core/lib/iomgr/combiner.h +6 -16
- data/src/core/lib/iomgr/endpoint.cc +15 -21
- data/src/core/lib/iomgr/endpoint.h +16 -33
- data/src/core/lib/iomgr/endpoint_pair.h +0 -8
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +4 -5
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +4 -6
- data/src/core/lib/iomgr/error.cc +2 -6
- data/src/core/lib/iomgr/error.h +4 -9
- data/src/core/lib/iomgr/error_internal.h +0 -8
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +110 -117
- data/src/core/lib/iomgr/ev_epoll1_linux.h +0 -8
- data/src/core/lib/iomgr/ev_epollex_linux.cc +111 -141
- data/src/core/lib/iomgr/ev_epollex_linux.h +0 -8
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +83 -109
- data/src/core/lib/iomgr/ev_epollsig_linux.h +2 -10
- data/src/core/lib/iomgr/ev_poll_posix.cc +103 -125
- data/src/core/lib/iomgr/ev_poll_posix.h +0 -8
- data/src/core/lib/iomgr/ev_posix.cc +35 -50
- data/src/core/lib/iomgr/ev_posix.h +27 -53
- data/src/core/lib/iomgr/exec_ctx.cc +46 -78
- data/src/core/lib/iomgr/exec_ctx.h +127 -60
- data/src/core/lib/iomgr/executor.cc +34 -38
- data/src/core/lib/iomgr/executor.h +3 -11
- data/src/core/lib/iomgr/fork_posix.cc +13 -12
- data/src/core/lib/iomgr/gethostname.h +0 -8
- data/src/core/lib/iomgr/gethostname_sysconf.cc +1 -1
- data/src/core/lib/iomgr/iocp_windows.cc +14 -16
- data/src/core/lib/iomgr/iocp_windows.h +1 -10
- data/src/core/lib/iomgr/iomgr.cc +60 -59
- data/src/core/lib/iomgr/iomgr.h +3 -12
- data/src/core/lib/iomgr/iomgr_internal.h +0 -8
- data/src/core/lib/iomgr/iomgr_uv.cc +2 -3
- data/src/core/lib/iomgr/iomgr_uv.h +0 -8
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +1 -1
- data/src/core/lib/iomgr/load_file.cc +1 -1
- data/src/core/lib/iomgr/load_file.h +0 -8
- data/src/core/lib/iomgr/lockfree_event.cc +7 -8
- data/src/core/lib/iomgr/lockfree_event.h +3 -3
- data/src/core/lib/iomgr/polling_entity.cc +6 -10
- data/src/core/lib/iomgr/polling_entity.h +2 -11
- data/src/core/lib/iomgr/pollset.h +4 -13
- data/src/core/lib/iomgr/pollset_set.h +5 -18
- data/src/core/lib/iomgr/pollset_set_uv.cc +5 -10
- data/src/core/lib/iomgr/pollset_set_windows.cc +5 -10
- data/src/core/lib/iomgr/pollset_uv.cc +8 -9
- data/src/core/lib/iomgr/pollset_uv.h +0 -8
- data/src/core/lib/iomgr/pollset_windows.cc +14 -15
- data/src/core/lib/iomgr/pollset_windows.h +0 -8
- data/src/core/lib/iomgr/port.h +6 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -10
- data/src/core/lib/iomgr/resolve_address_posix.cc +10 -12
- data/src/core/lib/iomgr/resolve_address_uv.cc +7 -8
- data/src/core/lib/iomgr/resolve_address_windows.cc +8 -9
- data/src/core/lib/iomgr/resource_quota.cc +77 -107
- data/src/core/lib/iomgr/resource_quota.h +8 -25
- data/src/core/lib/iomgr/sockaddr_utils.cc +1 -1
- data/src/core/lib/iomgr/sockaddr_utils.h +0 -8
- data/src/core/lib/iomgr/socket_factory_posix.cc +1 -1
- data/src/core/lib/iomgr/socket_factory_posix.h +0 -8
- data/src/core/lib/iomgr/socket_mutator.cc +1 -1
- data/src/core/lib/iomgr/socket_mutator.h +1 -9
- data/src/core/lib/iomgr/socket_utils.h +0 -8
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +0 -8
- data/src/core/lib/iomgr/socket_windows.cc +8 -11
- data/src/core/lib/iomgr/socket_windows.h +3 -14
- data/src/core/lib/iomgr/tcp_client.h +1 -10
- data/src/core/lib/iomgr/tcp_client_posix.cc +94 -78
- data/src/core/lib/iomgr/tcp_client_posix.h +36 -8
- data/src/core/lib/iomgr/tcp_client_uv.cc +16 -23
- data/src/core/lib/iomgr/tcp_client_windows.cc +22 -25
- data/src/core/lib/iomgr/tcp_posix.cc +131 -153
- data/src/core/lib/iomgr/tcp_posix.h +3 -12
- data/src/core/lib/iomgr/tcp_server.h +6 -17
- data/src/core/lib/iomgr/tcp_server_posix.cc +31 -35
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -8
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -1
- data/src/core/lib/iomgr/tcp_server_uv.cc +23 -34
- data/src/core/lib/iomgr/tcp_server_windows.cc +24 -34
- data/src/core/lib/iomgr/tcp_uv.cc +42 -56
- data/src/core/lib/iomgr/tcp_uv.h +0 -8
- data/src/core/lib/iomgr/tcp_windows.cc +43 -50
- data/src/core/lib/iomgr/tcp_windows.h +1 -9
- data/src/core/lib/iomgr/time_averaged_stats.h +0 -8
- data/src/core/lib/iomgr/timer.h +6 -15
- data/src/core/lib/iomgr/timer_generic.cc +22 -27
- data/src/core/lib/iomgr/timer_heap.h +0 -8
- data/src/core/lib/iomgr/timer_manager.cc +17 -19
- data/src/core/lib/iomgr/timer_manager.h +0 -8
- data/src/core/lib/iomgr/timer_uv.cc +12 -14
- data/src/core/lib/iomgr/udp_server.cc +148 -54
- data/src/core/lib/iomgr/udp_server.h +16 -21
- data/src/core/lib/iomgr/unix_sockets_posix.h +0 -8
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +4 -4
- data/src/core/lib/iomgr/wakeup_fd_cv.h +12 -20
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +0 -8
- data/src/core/lib/iomgr/wakeup_fd_posix.h +0 -8
- data/src/core/lib/json/json.h +0 -8
- data/src/core/lib/json/json_reader.h +0 -8
- data/src/core/lib/json/json_writer.h +0 -8
- data/src/core/lib/profiling/basic_timers.cc +3 -2
- data/src/core/lib/profiling/timers.h +0 -8
- data/src/core/lib/security/context/security_context.cc +9 -10
- data/src/core/lib/security/context/security_context.h +0 -8
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +23 -28
- data/src/core/lib/security/credentials/composite/composite_credentials.h +0 -8
- data/src/core/lib/security/credentials/credentials.cc +33 -42
- data/src/core/lib/security/credentials/credentials.h +24 -43
- data/src/core/lib/security/credentials/credentials_metadata.cc +2 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +16 -22
- data/src/core/lib/security/credentials/fake/fake_credentials.h +0 -8
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +3 -3
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +28 -34
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +0 -8
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +9 -13
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/json_token.h +0 -8
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +14 -20
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +1 -10
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +56 -72
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +5 -17
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +47 -55
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +3 -12
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +23 -28
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +8 -13
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +0 -8
- data/src/core/lib/security/transport/auth_filters.h +0 -8
- data/src/core/lib/security/transport/client_auth_filter.cc +45 -54
- data/src/core/lib/security/transport/lb_targets_info.cc +2 -2
- data/src/core/lib/security/transport/lb_targets_info.h +0 -8
- data/src/core/lib/security/transport/secure_endpoint.cc +54 -68
- data/src/core/lib/security/transport/secure_endpoint.h +0 -8
- data/src/core/lib/security/transport/security_connector.cc +62 -86
- data/src/core/lib/security/transport/security_connector.h +22 -39
- data/src/core/lib/security/transport/security_handshaker.cc +83 -106
- data/src/core/lib/security/transport/security_handshaker.h +1 -10
- data/src/core/lib/security/transport/server_auth_filter.cc +31 -38
- data/src/core/lib/security/transport/tsi_error.h +0 -8
- data/src/core/lib/security/util/json_util.h +0 -8
- data/src/core/lib/slice/b64.cc +5 -6
- data/src/core/lib/slice/b64.h +3 -12
- data/src/core/lib/slice/percent_encoding.h +0 -8
- data/src/core/lib/slice/slice.cc +8 -9
- data/src/core/lib/slice/slice_buffer.cc +11 -16
- data/src/core/lib/slice/slice_hash_table.cc +5 -7
- data/src/core/lib/slice/slice_hash_table.h +2 -12
- data/src/core/lib/slice/slice_intern.cc +4 -5
- data/src/core/lib/slice/slice_internal.h +4 -15
- data/src/core/lib/slice/slice_string_helpers.cc +1 -1
- data/src/core/lib/slice/slice_string_helpers.h +1 -9
- data/src/core/lib/surface/alarm.cc +11 -14
- data/src/core/lib/surface/alarm_internal.h +0 -8
- data/src/core/lib/surface/byte_buffer.cc +2 -3
- data/src/core/lib/surface/byte_buffer_reader.cc +7 -9
- data/src/core/lib/surface/call.cc +198 -241
- data/src/core/lib/surface/call.h +9 -23
- data/src/core/lib/surface/call_details.cc +3 -4
- data/src/core/lib/surface/call_log_batch.cc +1 -1
- data/src/core/lib/surface/call_test_only.h +0 -8
- data/src/core/lib/surface/channel.cc +53 -64
- data/src/core/lib/surface/channel.h +12 -23
- data/src/core/lib/surface/channel_init.cc +2 -3
- data/src/core/lib/surface/channel_init.h +2 -12
- data/src/core/lib/surface/channel_ping.cc +7 -9
- data/src/core/lib/surface/channel_stack_type.h +0 -8
- data/src/core/lib/surface/completion_queue.cc +158 -176
- data/src/core/lib/surface/completion_queue.h +9 -20
- data/src/core/lib/surface/completion_queue_factory.h +0 -8
- data/src/core/lib/surface/event_string.cc +1 -1
- data/src/core/lib/surface/event_string.h +0 -8
- data/src/core/lib/surface/init.cc +27 -25
- data/src/core/lib/surface/init.h +0 -8
- data/src/core/lib/surface/init_secure.cc +2 -2
- data/src/core/lib/surface/lame_client.cc +30 -33
- data/src/core/lib/surface/lame_client.h +0 -8
- data/src/core/lib/surface/server.cc +151 -203
- data/src/core/lib/surface/server.h +7 -16
- data/src/core/lib/surface/validate_metadata.h +0 -8
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.h +1 -1
- data/src/core/lib/transport/byte_stream.cc +24 -38
- data/src/core/lib/transport/byte_stream.h +10 -25
- data/src/core/lib/transport/connectivity_state.cc +9 -13
- data/src/core/lib/transport/connectivity_state.h +4 -14
- data/src/core/lib/transport/error_utils.cc +6 -6
- data/src/core/lib/transport/error_utils.h +2 -11
- data/src/core/lib/transport/metadata.cc +21 -23
- data/src/core/lib/transport/metadata.h +8 -20
- data/src/core/lib/transport/metadata_batch.cc +34 -45
- data/src/core/lib/transport/metadata_batch.h +18 -32
- data/src/core/lib/transport/service_config.cc +11 -15
- data/src/core/lib/transport/service_config.h +3 -13
- data/src/core/lib/transport/static_metadata.cc +1 -1
- data/src/core/lib/transport/static_metadata.h +1 -7
- data/src/core/lib/transport/status_conversion.cc +2 -3
- data/src/core/lib/transport/status_conversion.h +1 -10
- data/src/core/lib/transport/timeout_encoding.cc +1 -1
- data/src/core/lib/transport/timeout_encoding.h +1 -9
- data/src/core/lib/transport/transport.cc +36 -50
- data/src/core/lib/transport/transport.h +28 -30
- data/src/core/lib/transport/transport_impl.h +12 -23
- data/src/core/lib/transport/transport_op_string.cc +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.cc +34 -34
- data/src/core/tsi/fake_transport_security.cc +7 -10
- data/src/core/tsi/fake_transport_security.h +0 -8
- data/src/core/tsi/gts_transport_security.cc +2 -2
- data/src/core/tsi/gts_transport_security.h +0 -8
- data/src/core/tsi/ssl_transport_security.cc +3 -0
- data/src/core/tsi/ssl_transport_security.h +0 -8
- data/src/core/tsi/ssl_types.h +0 -8
- data/src/core/tsi/transport_security.h +1 -9
- data/src/core/tsi/transport_security_adapter.h +0 -8
- data/src/core/tsi/transport_security_grpc.cc +11 -18
- data/src/core/tsi/transport_security_grpc.h +9 -21
- data/src/core/tsi/transport_security_interface.h +0 -8
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -30
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +2 -48
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_connection_spec.rb +2 -1
- data/src/ruby/spec/client_auth_spec.rb +1 -1
- data/src/ruby/spec/client_server_spec.rb +2 -2
- data/src/ruby/spec/generic/active_call_spec.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
- data/src/ruby/spec/generic/interceptor_registry_spec.rb +1 -1
- data/src/ruby/spec/generic/rpc_server_spec.rb +12 -12
- data/src/ruby/spec/google_rpc_status_utils_spec.rb +3 -2
- data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
- data/src/ruby/spec/server_spec.rb +9 -9
- data/src/ruby/spec/support/helpers.rb +35 -1
- metadata +68 -66
- data/include/grpc/impl/codegen/exec_ctx_fwd.h +0 -26
- data/include/grpc/support/histogram.h +0 -64
- data/src/core/lib/support/histogram.cc +0 -227
@@ -33,15 +33,16 @@
|
|
33
33
|
#include <grpc/support/thd.h>
|
34
34
|
#include <grpc/support/time.h>
|
35
35
|
#include <grpc/support/useful.h>
|
36
|
+
#include "src/core/lib/gpr/string.h"
|
36
37
|
#include "src/core/lib/iomgr/block_annotate.h"
|
37
38
|
#include "src/core/lib/iomgr/executor.h"
|
38
39
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
39
40
|
#include "src/core/lib/iomgr/unix_sockets_posix.h"
|
40
|
-
#include "src/core/lib/support/string.h"
|
41
41
|
|
42
42
|
static grpc_error* blocking_resolve_address_impl(
|
43
43
|
const char* name, const char* default_port,
|
44
44
|
grpc_resolved_addresses** addresses) {
|
45
|
+
grpc_core::ExecCtx exec_ctx;
|
45
46
|
struct addrinfo hints;
|
46
47
|
struct addrinfo *result = nullptr, *resp;
|
47
48
|
char* host;
|
@@ -81,7 +82,7 @@ static grpc_error* blocking_resolve_address_impl(
|
|
81
82
|
|
82
83
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
83
84
|
s = getaddrinfo(host, port, &hints, &result);
|
84
|
-
|
85
|
+
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
85
86
|
|
86
87
|
if (s != 0) {
|
87
88
|
/* Retry if well-known service name is recognized */
|
@@ -90,7 +91,7 @@ static grpc_error* blocking_resolve_address_impl(
|
|
90
91
|
if (strcmp(port, svc[i][0]) == 0) {
|
91
92
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
92
93
|
s = getaddrinfo(host, svc[i][1], &hints, &result);
|
93
|
-
|
94
|
+
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
94
95
|
break;
|
95
96
|
}
|
96
97
|
}
|
@@ -152,12 +153,10 @@ typedef struct {
|
|
152
153
|
|
153
154
|
/* Callback to be passed to grpc_executor to asynch-ify
|
154
155
|
* grpc_blocking_resolve_address */
|
155
|
-
static void do_request_thread(
|
156
|
-
grpc_error* error) {
|
156
|
+
static void do_request_thread(void* rp, grpc_error* error) {
|
157
157
|
request* r = (request*)rp;
|
158
|
-
GRPC_CLOSURE_SCHED(
|
159
|
-
|
160
|
-
grpc_blocking_resolve_address(r->name, r->default_port, r->addrs_out));
|
158
|
+
GRPC_CLOSURE_SCHED(r->on_done, grpc_blocking_resolve_address(
|
159
|
+
r->name, r->default_port, r->addrs_out));
|
161
160
|
gpr_free(r->name);
|
162
161
|
gpr_free(r->default_port);
|
163
162
|
gpr_free(r);
|
@@ -170,8 +169,7 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
|
|
170
169
|
gpr_free(addrs);
|
171
170
|
}
|
172
171
|
|
173
|
-
static void resolve_address_impl(
|
174
|
-
const char* default_port,
|
172
|
+
static void resolve_address_impl(const char* name, const char* default_port,
|
175
173
|
grpc_pollset_set* interested_parties,
|
176
174
|
grpc_closure* on_done,
|
177
175
|
grpc_resolved_addresses** addrs) {
|
@@ -182,11 +180,11 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
|
|
182
180
|
r->default_port = gpr_strdup(default_port);
|
183
181
|
r->on_done = on_done;
|
184
182
|
r->addrs_out = addrs;
|
185
|
-
GRPC_CLOSURE_SCHED(
|
183
|
+
GRPC_CLOSURE_SCHED(&r->request_closure, GRPC_ERROR_NONE);
|
186
184
|
}
|
187
185
|
|
188
186
|
void (*grpc_resolve_address)(
|
189
|
-
|
187
|
+
const char* name, const char* default_port,
|
190
188
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
191
189
|
grpc_resolved_addresses** addrs) = resolve_address_impl;
|
192
190
|
|
@@ -114,7 +114,7 @@ static grpc_error* handle_addrinfo_result(int status, struct addrinfo* result,
|
|
114
114
|
static void getaddrinfo_callback(uv_getaddrinfo_t* req, int status,
|
115
115
|
struct addrinfo* res) {
|
116
116
|
request* r = (request*)req->data;
|
117
|
-
|
117
|
+
grpc_core::ExecCtx exec_ctx;
|
118
118
|
grpc_error* error;
|
119
119
|
int retry_status;
|
120
120
|
char* port = r->port;
|
@@ -130,8 +130,8 @@ static void getaddrinfo_callback(uv_getaddrinfo_t* req, int status,
|
|
130
130
|
/* Either no retry was attempted, or the retry failed. Either way, the
|
131
131
|
original error probably has more interesting information */
|
132
132
|
error = handle_addrinfo_result(status, res, r->addresses);
|
133
|
-
GRPC_CLOSURE_SCHED(
|
134
|
-
|
133
|
+
GRPC_CLOSURE_SCHED(r->on_done, error);
|
134
|
+
|
135
135
|
gpr_free(r->hints);
|
136
136
|
gpr_free(r->host);
|
137
137
|
gpr_free(r->port);
|
@@ -224,8 +224,7 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
|
|
224
224
|
gpr_free(addrs);
|
225
225
|
}
|
226
226
|
|
227
|
-
static void resolve_address_impl(
|
228
|
-
const char* default_port,
|
227
|
+
static void resolve_address_impl(const char* name, const char* default_port,
|
229
228
|
grpc_pollset_set* interested_parties,
|
230
229
|
grpc_closure* on_done,
|
231
230
|
grpc_resolved_addresses** addrs) {
|
@@ -239,7 +238,7 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
|
|
239
238
|
GRPC_UV_ASSERT_SAME_THREAD();
|
240
239
|
err = try_split_host_port(name, default_port, &host, &port);
|
241
240
|
if (err != GRPC_ERROR_NONE) {
|
242
|
-
GRPC_CLOSURE_SCHED(
|
241
|
+
GRPC_CLOSURE_SCHED(on_done, err);
|
243
242
|
gpr_free(host);
|
244
243
|
gpr_free(port);
|
245
244
|
return;
|
@@ -268,7 +267,7 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
|
|
268
267
|
err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("getaddrinfo failed");
|
269
268
|
err = grpc_error_set_str(err, GRPC_ERROR_STR_OS_ERROR,
|
270
269
|
grpc_slice_from_static_string(uv_strerror(s)));
|
271
|
-
GRPC_CLOSURE_SCHED(
|
270
|
+
GRPC_CLOSURE_SCHED(on_done, err);
|
272
271
|
gpr_free(r);
|
273
272
|
gpr_free(req);
|
274
273
|
gpr_free(hints);
|
@@ -278,7 +277,7 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
|
|
278
277
|
}
|
279
278
|
|
280
279
|
void (*grpc_resolve_address)(
|
281
|
-
|
280
|
+
const char* name, const char* default_port,
|
282
281
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
283
282
|
grpc_resolved_addresses** addrs) = resolve_address_impl;
|
284
283
|
|
@@ -34,11 +34,11 @@
|
|
34
34
|
#include <grpc/support/string_util.h>
|
35
35
|
#include <grpc/support/thd.h>
|
36
36
|
#include <grpc/support/time.h>
|
37
|
+
#include "src/core/lib/gpr/string.h"
|
37
38
|
#include "src/core/lib/iomgr/block_annotate.h"
|
38
39
|
#include "src/core/lib/iomgr/executor.h"
|
39
40
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
40
41
|
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
41
|
-
#include "src/core/lib/support/string.h"
|
42
42
|
|
43
43
|
typedef struct {
|
44
44
|
char* name;
|
@@ -51,6 +51,7 @@ typedef struct {
|
|
51
51
|
static grpc_error* blocking_resolve_address_impl(
|
52
52
|
const char* name, const char* default_port,
|
53
53
|
grpc_resolved_addresses** addresses) {
|
54
|
+
grpc_core::ExecCtx exec_ctx;
|
54
55
|
struct addrinfo hints;
|
55
56
|
struct addrinfo *result = NULL, *resp;
|
56
57
|
char* host;
|
@@ -87,7 +88,7 @@ static grpc_error* blocking_resolve_address_impl(
|
|
87
88
|
|
88
89
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
89
90
|
s = getaddrinfo(host, port, &hints, &result);
|
90
|
-
|
91
|
+
GRPC_SCHEDULING_END_BLOCKING_REGION;
|
91
92
|
if (s != 0) {
|
92
93
|
error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo");
|
93
94
|
goto done;
|
@@ -132,8 +133,7 @@ grpc_error* (*grpc_blocking_resolve_address)(
|
|
132
133
|
|
133
134
|
/* Callback to be passed to grpc_executor to asynch-ify
|
134
135
|
* grpc_blocking_resolve_address */
|
135
|
-
static void do_request_thread(
|
136
|
-
grpc_error* error) {
|
136
|
+
static void do_request_thread(void* rp, grpc_error* error) {
|
137
137
|
request* r = (request*)rp;
|
138
138
|
if (error == GRPC_ERROR_NONE) {
|
139
139
|
error =
|
@@ -141,7 +141,7 @@ static void do_request_thread(grpc_exec_ctx* exec_ctx, void* rp,
|
|
141
141
|
} else {
|
142
142
|
GRPC_ERROR_REF(error);
|
143
143
|
}
|
144
|
-
GRPC_CLOSURE_SCHED(
|
144
|
+
GRPC_CLOSURE_SCHED(r->on_done, error);
|
145
145
|
gpr_free(r->name);
|
146
146
|
gpr_free(r->default_port);
|
147
147
|
gpr_free(r);
|
@@ -154,8 +154,7 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
|
|
154
154
|
gpr_free(addrs);
|
155
155
|
}
|
156
156
|
|
157
|
-
static void resolve_address_impl(
|
158
|
-
const char* default_port,
|
157
|
+
static void resolve_address_impl(const char* name, const char* default_port,
|
159
158
|
grpc_pollset_set* interested_parties,
|
160
159
|
grpc_closure* on_done,
|
161
160
|
grpc_resolved_addresses** addresses) {
|
@@ -166,11 +165,11 @@ static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
|
|
166
165
|
r->default_port = gpr_strdup(default_port);
|
167
166
|
r->on_done = on_done;
|
168
167
|
r->addresses = addresses;
|
169
|
-
GRPC_CLOSURE_SCHED(
|
168
|
+
GRPC_CLOSURE_SCHED(&r->request_closure, GRPC_ERROR_NONE);
|
170
169
|
}
|
171
170
|
|
172
171
|
void (*grpc_resolve_address)(
|
173
|
-
|
172
|
+
const char* name, const char* default_port,
|
174
173
|
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
175
174
|
grpc_resolved_addresses** addresses) = resolve_address_impl;
|
176
175
|
|
@@ -154,8 +154,7 @@ struct grpc_resource_quota {
|
|
154
154
|
char* name;
|
155
155
|
};
|
156
156
|
|
157
|
-
static void ru_unref_by(
|
158
|
-
grpc_resource_user* resource_user, gpr_atm amount);
|
157
|
+
static void ru_unref_by(grpc_resource_user* resource_user, gpr_atm amount);
|
159
158
|
|
160
159
|
/*******************************************************************************
|
161
160
|
* list management
|
@@ -239,35 +238,31 @@ static void rulist_remove(grpc_resource_user* resource_user, grpc_rulist list) {
|
|
239
238
|
* resource quota state machine
|
240
239
|
*/
|
241
240
|
|
242
|
-
static bool rq_alloc(
|
243
|
-
grpc_resource_quota* resource_quota);
|
241
|
+
static bool rq_alloc(grpc_resource_quota* resource_quota);
|
244
242
|
static bool rq_reclaim_from_per_user_free_pool(
|
245
|
-
|
246
|
-
static bool rq_reclaim(
|
247
|
-
grpc_resource_quota* resource_quota, bool destructive);
|
243
|
+
grpc_resource_quota* resource_quota);
|
244
|
+
static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive);
|
248
245
|
|
249
|
-
static void rq_step(
|
246
|
+
static void rq_step(void* rq, grpc_error* error) {
|
250
247
|
grpc_resource_quota* resource_quota = (grpc_resource_quota*)rq;
|
251
248
|
resource_quota->step_scheduled = false;
|
252
249
|
do {
|
253
|
-
if (rq_alloc(
|
254
|
-
} while (rq_reclaim_from_per_user_free_pool(
|
250
|
+
if (rq_alloc(resource_quota)) goto done;
|
251
|
+
} while (rq_reclaim_from_per_user_free_pool(resource_quota));
|
255
252
|
|
256
|
-
if (!rq_reclaim(
|
257
|
-
rq_reclaim(
|
253
|
+
if (!rq_reclaim(resource_quota, false)) {
|
254
|
+
rq_reclaim(resource_quota, true);
|
258
255
|
}
|
259
256
|
|
260
257
|
done:
|
261
|
-
grpc_resource_quota_unref_internal(
|
258
|
+
grpc_resource_quota_unref_internal(resource_quota);
|
262
259
|
}
|
263
260
|
|
264
|
-
static void rq_step_sched(
|
265
|
-
grpc_resource_quota* resource_quota) {
|
261
|
+
static void rq_step_sched(grpc_resource_quota* resource_quota) {
|
266
262
|
if (resource_quota->step_scheduled) return;
|
267
263
|
resource_quota->step_scheduled = true;
|
268
264
|
grpc_resource_quota_ref_internal(resource_quota);
|
269
|
-
GRPC_CLOSURE_SCHED(
|
270
|
-
GRPC_ERROR_NONE);
|
265
|
+
GRPC_CLOSURE_SCHED(&resource_quota->rq_step_closure, GRPC_ERROR_NONE);
|
271
266
|
}
|
272
267
|
|
273
268
|
/* update the atomically available resource estimate - use no barriers since
|
@@ -286,8 +281,7 @@ static void rq_update_estimate(grpc_resource_quota* resource_quota) {
|
|
286
281
|
}
|
287
282
|
|
288
283
|
/* returns true if all allocations are completed */
|
289
|
-
static bool rq_alloc(
|
290
|
-
grpc_resource_quota* resource_quota) {
|
284
|
+
static bool rq_alloc(grpc_resource_quota* resource_quota) {
|
291
285
|
grpc_resource_user* resource_user;
|
292
286
|
while ((resource_user = rulist_pop_head(resource_quota,
|
293
287
|
GRPC_RULIST_AWAITING_ALLOCATION))) {
|
@@ -307,9 +301,9 @@ static bool rq_alloc(grpc_exec_ctx* exec_ctx,
|
|
307
301
|
int64_t aborted_allocations = resource_user->outstanding_allocations;
|
308
302
|
resource_user->outstanding_allocations = 0;
|
309
303
|
resource_user->free_pool += aborted_allocations;
|
310
|
-
GRPC_CLOSURE_LIST_SCHED(
|
304
|
+
GRPC_CLOSURE_LIST_SCHED(&resource_user->on_allocated);
|
311
305
|
gpr_mu_unlock(&resource_user->mu);
|
312
|
-
ru_unref_by(
|
306
|
+
ru_unref_by(resource_user, (gpr_atm)aborted_allocations);
|
313
307
|
continue;
|
314
308
|
}
|
315
309
|
if (resource_user->free_pool < 0 &&
|
@@ -333,7 +327,7 @@ static bool rq_alloc(grpc_exec_ctx* exec_ctx,
|
|
333
327
|
if (resource_user->free_pool >= 0) {
|
334
328
|
resource_user->allocating = false;
|
335
329
|
resource_user->outstanding_allocations = 0;
|
336
|
-
GRPC_CLOSURE_LIST_SCHED(
|
330
|
+
GRPC_CLOSURE_LIST_SCHED(&resource_user->on_allocated);
|
337
331
|
gpr_mu_unlock(&resource_user->mu);
|
338
332
|
} else {
|
339
333
|
rulist_add_head(resource_user, GRPC_RULIST_AWAITING_ALLOCATION);
|
@@ -346,7 +340,7 @@ static bool rq_alloc(grpc_exec_ctx* exec_ctx,
|
|
346
340
|
|
347
341
|
/* returns true if any memory could be reclaimed from buffers */
|
348
342
|
static bool rq_reclaim_from_per_user_free_pool(
|
349
|
-
|
343
|
+
grpc_resource_quota* resource_quota) {
|
350
344
|
grpc_resource_user* resource_user;
|
351
345
|
while ((resource_user = rulist_pop_head(resource_quota,
|
352
346
|
GRPC_RULIST_NON_EMPTY_FREE_POOL))) {
|
@@ -373,8 +367,7 @@ static bool rq_reclaim_from_per_user_free_pool(
|
|
373
367
|
}
|
374
368
|
|
375
369
|
/* returns true if reclamation is proceeding */
|
376
|
-
static bool rq_reclaim(
|
377
|
-
grpc_resource_quota* resource_quota, bool destructive) {
|
370
|
+
static bool rq_reclaim(grpc_resource_quota* resource_quota, bool destructive) {
|
378
371
|
if (resource_quota->reclaiming) return true;
|
379
372
|
grpc_rulist list = destructive ? GRPC_RULIST_RECLAIMER_DESTRUCTIVE
|
380
373
|
: GRPC_RULIST_RECLAIMER_BENIGN;
|
@@ -392,7 +385,7 @@ static bool rq_reclaim(grpc_exec_ctx* exec_ctx,
|
|
392
385
|
resource_quota->debug_only_last_reclaimer_resource_user = resource_user;
|
393
386
|
resource_quota->debug_only_last_initiated_reclaimer = c;
|
394
387
|
resource_user->reclaimers[destructive] = nullptr;
|
395
|
-
GRPC_CLOSURE_RUN(
|
388
|
+
GRPC_CLOSURE_RUN(c, GRPC_ERROR_NONE);
|
396
389
|
return true;
|
397
390
|
}
|
398
391
|
|
@@ -412,10 +405,10 @@ static void ru_slice_ref(void* p) {
|
|
412
405
|
gpr_ref(&rc->refs);
|
413
406
|
}
|
414
407
|
|
415
|
-
static void ru_slice_unref(
|
408
|
+
static void ru_slice_unref(void* p) {
|
416
409
|
ru_slice_refcount* rc = (ru_slice_refcount*)p;
|
417
410
|
if (gpr_unref(&rc->refs)) {
|
418
|
-
grpc_resource_user_free(
|
411
|
+
grpc_resource_user_free(rc->resource_user, rc->size);
|
419
412
|
gpr_free(rc);
|
420
413
|
}
|
421
414
|
}
|
@@ -445,61 +438,57 @@ static grpc_slice ru_slice_create(grpc_resource_user* resource_user,
|
|
445
438
|
* the combiner
|
446
439
|
*/
|
447
440
|
|
448
|
-
static void ru_allocate(
|
441
|
+
static void ru_allocate(void* ru, grpc_error* error) {
|
449
442
|
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
450
443
|
if (rulist_empty(resource_user->resource_quota,
|
451
444
|
GRPC_RULIST_AWAITING_ALLOCATION)) {
|
452
|
-
rq_step_sched(
|
445
|
+
rq_step_sched(resource_user->resource_quota);
|
453
446
|
}
|
454
447
|
rulist_add_tail(resource_user, GRPC_RULIST_AWAITING_ALLOCATION);
|
455
448
|
}
|
456
449
|
|
457
|
-
static void ru_add_to_free_pool(
|
458
|
-
grpc_error* error) {
|
450
|
+
static void ru_add_to_free_pool(void* ru, grpc_error* error) {
|
459
451
|
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
460
452
|
if (!rulist_empty(resource_user->resource_quota,
|
461
453
|
GRPC_RULIST_AWAITING_ALLOCATION) &&
|
462
454
|
rulist_empty(resource_user->resource_quota,
|
463
455
|
GRPC_RULIST_NON_EMPTY_FREE_POOL)) {
|
464
|
-
rq_step_sched(
|
456
|
+
rq_step_sched(resource_user->resource_quota);
|
465
457
|
}
|
466
458
|
rulist_add_tail(resource_user, GRPC_RULIST_NON_EMPTY_FREE_POOL);
|
467
459
|
}
|
468
460
|
|
469
|
-
static bool ru_post_reclaimer(
|
470
|
-
grpc_resource_user* resource_user,
|
461
|
+
static bool ru_post_reclaimer(grpc_resource_user* resource_user,
|
471
462
|
bool destructive) {
|
472
463
|
grpc_closure* closure = resource_user->new_reclaimers[destructive];
|
473
464
|
GPR_ASSERT(closure != nullptr);
|
474
465
|
resource_user->new_reclaimers[destructive] = nullptr;
|
475
466
|
GPR_ASSERT(resource_user->reclaimers[destructive] == nullptr);
|
476
467
|
if (gpr_atm_acq_load(&resource_user->shutdown) > 0) {
|
477
|
-
GRPC_CLOSURE_SCHED(
|
468
|
+
GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_CANCELLED);
|
478
469
|
return false;
|
479
470
|
}
|
480
471
|
resource_user->reclaimers[destructive] = closure;
|
481
472
|
return true;
|
482
473
|
}
|
483
474
|
|
484
|
-
static void ru_post_benign_reclaimer(
|
485
|
-
grpc_error* error) {
|
475
|
+
static void ru_post_benign_reclaimer(void* ru, grpc_error* error) {
|
486
476
|
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
487
|
-
if (!ru_post_reclaimer(
|
477
|
+
if (!ru_post_reclaimer(resource_user, false)) return;
|
488
478
|
if (!rulist_empty(resource_user->resource_quota,
|
489
479
|
GRPC_RULIST_AWAITING_ALLOCATION) &&
|
490
480
|
rulist_empty(resource_user->resource_quota,
|
491
481
|
GRPC_RULIST_NON_EMPTY_FREE_POOL) &&
|
492
482
|
rulist_empty(resource_user->resource_quota,
|
493
483
|
GRPC_RULIST_RECLAIMER_BENIGN)) {
|
494
|
-
rq_step_sched(
|
484
|
+
rq_step_sched(resource_user->resource_quota);
|
495
485
|
}
|
496
486
|
rulist_add_tail(resource_user, GRPC_RULIST_RECLAIMER_BENIGN);
|
497
487
|
}
|
498
488
|
|
499
|
-
static void ru_post_destructive_reclaimer(
|
500
|
-
grpc_error* error) {
|
489
|
+
static void ru_post_destructive_reclaimer(void* ru, grpc_error* error) {
|
501
490
|
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
502
|
-
if (!ru_post_reclaimer(
|
491
|
+
if (!ru_post_reclaimer(resource_user, true)) return;
|
503
492
|
if (!rulist_empty(resource_user->resource_quota,
|
504
493
|
GRPC_RULIST_AWAITING_ALLOCATION) &&
|
505
494
|
rulist_empty(resource_user->resource_quota,
|
@@ -508,51 +497,48 @@ static void ru_post_destructive_reclaimer(grpc_exec_ctx* exec_ctx, void* ru,
|
|
508
497
|
GRPC_RULIST_RECLAIMER_BENIGN) &&
|
509
498
|
rulist_empty(resource_user->resource_quota,
|
510
499
|
GRPC_RULIST_RECLAIMER_DESTRUCTIVE)) {
|
511
|
-
rq_step_sched(
|
500
|
+
rq_step_sched(resource_user->resource_quota);
|
512
501
|
}
|
513
502
|
rulist_add_tail(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE);
|
514
503
|
}
|
515
504
|
|
516
|
-
static void ru_shutdown(
|
505
|
+
static void ru_shutdown(void* ru, grpc_error* error) {
|
517
506
|
if (grpc_resource_quota_trace.enabled()) {
|
518
507
|
gpr_log(GPR_DEBUG, "RU shutdown %p", ru);
|
519
508
|
}
|
520
509
|
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
521
|
-
|
522
|
-
|
523
|
-
GRPC_CLOSURE_SCHED(
|
524
|
-
GRPC_ERROR_CANCELLED);
|
510
|
+
gpr_mu_lock(&resource_user->mu);
|
511
|
+
GRPC_CLOSURE_SCHED(resource_user->reclaimers[0], GRPC_ERROR_CANCELLED);
|
512
|
+
GRPC_CLOSURE_SCHED(resource_user->reclaimers[1], GRPC_ERROR_CANCELLED);
|
525
513
|
resource_user->reclaimers[0] = nullptr;
|
526
514
|
resource_user->reclaimers[1] = nullptr;
|
527
515
|
rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_BENIGN);
|
528
516
|
rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE);
|
529
517
|
if (resource_user->allocating) {
|
530
|
-
rq_step_sched(
|
518
|
+
rq_step_sched(resource_user->resource_quota);
|
531
519
|
}
|
520
|
+
gpr_mu_unlock(&resource_user->mu);
|
532
521
|
}
|
533
522
|
|
534
|
-
static void ru_destroy(
|
523
|
+
static void ru_destroy(void* ru, grpc_error* error) {
|
535
524
|
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
536
525
|
GPR_ASSERT(gpr_atm_no_barrier_load(&resource_user->refs) == 0);
|
537
526
|
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
|
538
527
|
rulist_remove(resource_user, (grpc_rulist)i);
|
539
528
|
}
|
540
|
-
GRPC_CLOSURE_SCHED(
|
541
|
-
|
542
|
-
GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[1],
|
543
|
-
GRPC_ERROR_CANCELLED);
|
529
|
+
GRPC_CLOSURE_SCHED(resource_user->reclaimers[0], GRPC_ERROR_CANCELLED);
|
530
|
+
GRPC_CLOSURE_SCHED(resource_user->reclaimers[1], GRPC_ERROR_CANCELLED);
|
544
531
|
if (resource_user->free_pool != 0) {
|
545
532
|
resource_user->resource_quota->free_pool += resource_user->free_pool;
|
546
|
-
rq_step_sched(
|
533
|
+
rq_step_sched(resource_user->resource_quota);
|
547
534
|
}
|
548
|
-
grpc_resource_quota_unref_internal(
|
535
|
+
grpc_resource_quota_unref_internal(resource_user->resource_quota);
|
549
536
|
gpr_mu_destroy(&resource_user->mu);
|
550
537
|
gpr_free(resource_user->name);
|
551
538
|
gpr_free(resource_user);
|
552
539
|
}
|
553
540
|
|
554
|
-
static void ru_allocated_slices(
|
555
|
-
grpc_error* error) {
|
541
|
+
static void ru_allocated_slices(void* arg, grpc_error* error) {
|
556
542
|
grpc_resource_user_slice_allocator* slice_allocator =
|
557
543
|
(grpc_resource_user_slice_allocator*)arg;
|
558
544
|
if (error == GRPC_ERROR_NONE) {
|
@@ -562,7 +548,7 @@ static void ru_allocated_slices(grpc_exec_ctx* exec_ctx, void* arg,
|
|
562
548
|
slice_allocator->length));
|
563
549
|
}
|
564
550
|
}
|
565
|
-
GRPC_CLOSURE_RUN(
|
551
|
+
GRPC_CLOSURE_RUN(&slice_allocator->on_done, GRPC_ERROR_REF(error));
|
566
552
|
}
|
567
553
|
|
568
554
|
/*******************************************************************************
|
@@ -576,23 +562,22 @@ typedef struct {
|
|
576
562
|
grpc_closure closure;
|
577
563
|
} rq_resize_args;
|
578
564
|
|
579
|
-
static void rq_resize(
|
565
|
+
static void rq_resize(void* args, grpc_error* error) {
|
580
566
|
rq_resize_args* a = (rq_resize_args*)args;
|
581
567
|
int64_t delta = a->size - a->resource_quota->size;
|
582
568
|
a->resource_quota->size += delta;
|
583
569
|
a->resource_quota->free_pool += delta;
|
584
570
|
rq_update_estimate(a->resource_quota);
|
585
|
-
rq_step_sched(
|
586
|
-
grpc_resource_quota_unref_internal(
|
571
|
+
rq_step_sched(a->resource_quota);
|
572
|
+
grpc_resource_quota_unref_internal(a->resource_quota);
|
587
573
|
gpr_free(a);
|
588
574
|
}
|
589
575
|
|
590
|
-
static void rq_reclamation_done(
|
591
|
-
grpc_error* error) {
|
576
|
+
static void rq_reclamation_done(void* rq, grpc_error* error) {
|
592
577
|
grpc_resource_quota* resource_quota = (grpc_resource_quota*)rq;
|
593
578
|
resource_quota->reclaiming = false;
|
594
|
-
rq_step_sched(
|
595
|
-
grpc_resource_quota_unref_internal(
|
579
|
+
rq_step_sched(resource_quota);
|
580
|
+
grpc_resource_quota_unref_internal(resource_quota);
|
596
581
|
}
|
597
582
|
|
598
583
|
/*******************************************************************************
|
@@ -628,10 +613,9 @@ grpc_resource_quota* grpc_resource_quota_create(const char* name) {
|
|
628
613
|
return resource_quota;
|
629
614
|
}
|
630
615
|
|
631
|
-
void grpc_resource_quota_unref_internal(
|
632
|
-
grpc_resource_quota* resource_quota) {
|
616
|
+
void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota) {
|
633
617
|
if (gpr_unref(&resource_quota->refs)) {
|
634
|
-
GRPC_COMBINER_UNREF(
|
618
|
+
GRPC_COMBINER_UNREF(resource_quota->combiner, "resource_quota");
|
635
619
|
gpr_free(resource_quota->name);
|
636
620
|
gpr_free(resource_quota);
|
637
621
|
}
|
@@ -639,9 +623,8 @@ void grpc_resource_quota_unref_internal(grpc_exec_ctx* exec_ctx,
|
|
639
623
|
|
640
624
|
/* Public API */
|
641
625
|
void grpc_resource_quota_unref(grpc_resource_quota* resource_quota) {
|
642
|
-
|
643
|
-
grpc_resource_quota_unref_internal(
|
644
|
-
grpc_exec_ctx_finish(&exec_ctx);
|
626
|
+
grpc_core::ExecCtx exec_ctx;
|
627
|
+
grpc_resource_quota_unref_internal(resource_quota);
|
645
628
|
}
|
646
629
|
|
647
630
|
grpc_resource_quota* grpc_resource_quota_ref_internal(
|
@@ -665,15 +648,14 @@ double grpc_resource_quota_get_memory_pressure(
|
|
665
648
|
/* Public API */
|
666
649
|
void grpc_resource_quota_resize(grpc_resource_quota* resource_quota,
|
667
650
|
size_t size) {
|
668
|
-
|
651
|
+
grpc_core::ExecCtx exec_ctx;
|
669
652
|
rq_resize_args* a = (rq_resize_args*)gpr_malloc(sizeof(*a));
|
670
653
|
a->resource_quota = grpc_resource_quota_ref_internal(resource_quota);
|
671
654
|
a->size = (int64_t)size;
|
672
655
|
gpr_atm_no_barrier_store(&resource_quota->last_size,
|
673
656
|
(gpr_atm)GPR_MIN((size_t)GPR_ATM_MAX, size));
|
674
657
|
GRPC_CLOSURE_INIT(&a->closure, rq_resize, a, grpc_schedule_on_exec_ctx);
|
675
|
-
GRPC_CLOSURE_SCHED(&
|
676
|
-
grpc_exec_ctx_finish(&exec_ctx);
|
658
|
+
GRPC_CLOSURE_SCHED(&a->closure, GRPC_ERROR_NONE);
|
677
659
|
}
|
678
660
|
|
679
661
|
size_t grpc_resource_quota_peek_size(grpc_resource_quota* resource_quota) {
|
@@ -704,8 +686,8 @@ static void* rq_copy(void* rq) {
|
|
704
686
|
return rq;
|
705
687
|
}
|
706
688
|
|
707
|
-
static void rq_destroy(
|
708
|
-
grpc_resource_quota_unref_internal(
|
689
|
+
static void rq_destroy(void* rq) {
|
690
|
+
grpc_resource_quota_unref_internal((grpc_resource_quota*)rq);
|
709
691
|
}
|
710
692
|
|
711
693
|
static int rq_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
|
@@ -773,14 +755,12 @@ static void ru_ref_by(grpc_resource_user* resource_user, gpr_atm amount) {
|
|
773
755
|
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&resource_user->refs, amount) != 0);
|
774
756
|
}
|
775
757
|
|
776
|
-
static void ru_unref_by(
|
777
|
-
grpc_resource_user* resource_user, gpr_atm amount) {
|
758
|
+
static void ru_unref_by(grpc_resource_user* resource_user, gpr_atm amount) {
|
778
759
|
GPR_ASSERT(amount > 0);
|
779
760
|
gpr_atm old = gpr_atm_full_fetch_add(&resource_user->refs, -amount);
|
780
761
|
GPR_ASSERT(old >= amount);
|
781
762
|
if (old == amount) {
|
782
|
-
GRPC_CLOSURE_SCHED(
|
783
|
-
GRPC_ERROR_NONE);
|
763
|
+
GRPC_CLOSURE_SCHED(&resource_user->destroy_closure, GRPC_ERROR_NONE);
|
784
764
|
}
|
785
765
|
}
|
786
766
|
|
@@ -788,16 +768,13 @@ void grpc_resource_user_ref(grpc_resource_user* resource_user) {
|
|
788
768
|
ru_ref_by(resource_user, 1);
|
789
769
|
}
|
790
770
|
|
791
|
-
void grpc_resource_user_unref(
|
792
|
-
|
793
|
-
ru_unref_by(exec_ctx, resource_user, 1);
|
771
|
+
void grpc_resource_user_unref(grpc_resource_user* resource_user) {
|
772
|
+
ru_unref_by(resource_user, 1);
|
794
773
|
}
|
795
774
|
|
796
|
-
void grpc_resource_user_shutdown(
|
797
|
-
grpc_resource_user* resource_user) {
|
775
|
+
void grpc_resource_user_shutdown(grpc_resource_user* resource_user) {
|
798
776
|
if (gpr_atm_full_fetch_add(&resource_user->shutdown, 1) == 0) {
|
799
777
|
GRPC_CLOSURE_SCHED(
|
800
|
-
exec_ctx,
|
801
778
|
GRPC_CLOSURE_CREATE(
|
802
779
|
ru_shutdown, resource_user,
|
803
780
|
grpc_combiner_scheduler(resource_user->resource_quota->combiner)),
|
@@ -805,8 +782,7 @@ void grpc_resource_user_shutdown(grpc_exec_ctx* exec_ctx,
|
|
805
782
|
}
|
806
783
|
}
|
807
784
|
|
808
|
-
void grpc_resource_user_alloc(
|
809
|
-
grpc_resource_user* resource_user, size_t size,
|
785
|
+
void grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size,
|
810
786
|
grpc_closure* optional_on_done) {
|
811
787
|
gpr_mu_lock(&resource_user->mu);
|
812
788
|
ru_ref_by(resource_user, (gpr_atm)size);
|
@@ -822,18 +798,16 @@ void grpc_resource_user_alloc(grpc_exec_ctx* exec_ctx,
|
|
822
798
|
GRPC_ERROR_NONE);
|
823
799
|
if (!resource_user->allocating) {
|
824
800
|
resource_user->allocating = true;
|
825
|
-
GRPC_CLOSURE_SCHED(
|
826
|
-
GRPC_ERROR_NONE);
|
801
|
+
GRPC_CLOSURE_SCHED(&resource_user->allocate_closure, GRPC_ERROR_NONE);
|
827
802
|
}
|
828
803
|
} else {
|
829
804
|
resource_user->outstanding_allocations -= (int64_t)size;
|
830
|
-
GRPC_CLOSURE_SCHED(
|
805
|
+
GRPC_CLOSURE_SCHED(optional_on_done, GRPC_ERROR_NONE);
|
831
806
|
}
|
832
807
|
gpr_mu_unlock(&resource_user->mu);
|
833
808
|
}
|
834
809
|
|
835
|
-
void grpc_resource_user_free(
|
836
|
-
grpc_resource_user* resource_user, size_t size) {
|
810
|
+
void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size) {
|
837
811
|
gpr_mu_lock(&resource_user->mu);
|
838
812
|
bool was_zero_or_negative = resource_user->free_pool <= 0;
|
839
813
|
resource_user->free_pool += (int64_t)size;
|
@@ -846,32 +820,29 @@ void grpc_resource_user_free(grpc_exec_ctx* exec_ctx,
|
|
846
820
|
if (is_bigger_than_zero && was_zero_or_negative &&
|
847
821
|
!resource_user->added_to_free_pool) {
|
848
822
|
resource_user->added_to_free_pool = true;
|
849
|
-
GRPC_CLOSURE_SCHED(
|
823
|
+
GRPC_CLOSURE_SCHED(&resource_user->add_to_free_pool_closure,
|
850
824
|
GRPC_ERROR_NONE);
|
851
825
|
}
|
852
826
|
gpr_mu_unlock(&resource_user->mu);
|
853
|
-
ru_unref_by(
|
827
|
+
ru_unref_by(resource_user, (gpr_atm)size);
|
854
828
|
}
|
855
829
|
|
856
|
-
void grpc_resource_user_post_reclaimer(
|
857
|
-
grpc_resource_user* resource_user,
|
830
|
+
void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user,
|
858
831
|
bool destructive,
|
859
832
|
grpc_closure* closure) {
|
860
833
|
GPR_ASSERT(resource_user->new_reclaimers[destructive] == nullptr);
|
861
834
|
resource_user->new_reclaimers[destructive] = closure;
|
862
|
-
GRPC_CLOSURE_SCHED(
|
863
|
-
&resource_user->post_reclaimer_closure[destructive],
|
835
|
+
GRPC_CLOSURE_SCHED(&resource_user->post_reclaimer_closure[destructive],
|
864
836
|
GRPC_ERROR_NONE);
|
865
837
|
}
|
866
838
|
|
867
|
-
void grpc_resource_user_finish_reclamation(
|
868
|
-
grpc_resource_user* resource_user) {
|
839
|
+
void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user) {
|
869
840
|
if (grpc_resource_quota_trace.enabled()) {
|
870
841
|
gpr_log(GPR_DEBUG, "RQ %s %s: reclamation complete",
|
871
842
|
resource_user->resource_quota->name, resource_user->name);
|
872
843
|
}
|
873
844
|
GRPC_CLOSURE_SCHED(
|
874
|
-
|
845
|
+
&resource_user->resource_quota->rq_reclamation_done_closure,
|
875
846
|
GRPC_ERROR_NONE);
|
876
847
|
}
|
877
848
|
|
@@ -886,12 +857,11 @@ void grpc_resource_user_slice_allocator_init(
|
|
886
857
|
}
|
887
858
|
|
888
859
|
void grpc_resource_user_alloc_slices(
|
889
|
-
grpc_exec_ctx* exec_ctx,
|
890
860
|
grpc_resource_user_slice_allocator* slice_allocator, size_t length,
|
891
861
|
size_t count, grpc_slice_buffer* dest) {
|
892
862
|
slice_allocator->length = length;
|
893
863
|
slice_allocator->count = count;
|
894
864
|
slice_allocator->dest = dest;
|
895
|
-
grpc_resource_user_alloc(
|
896
|
-
|
865
|
+
grpc_resource_user_alloc(slice_allocator->resource_user, count * length,
|
866
|
+
&slice_allocator->on_allocated);
|
897
867
|
}
|