grpc 1.7.3 → 1.8.0
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 +2106 -2116
- data/include/grpc/census.h +1 -432
- data/include/grpc/compression.h +9 -9
- data/include/grpc/grpc.h +115 -98
- data/include/grpc/grpc_cronet.h +3 -3
- data/include/grpc/grpc_posix.h +4 -4
- data/include/grpc/grpc_security.h +160 -88
- data/include/grpc/grpc_security_constants.h +7 -0
- data/include/grpc/impl/codegen/atm.h +9 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +13 -4
- data/include/grpc/impl/codegen/atm_gcc_sync.h +6 -5
- data/include/grpc/impl/codegen/atm_windows.h +23 -22
- data/include/grpc/impl/codegen/byte_buffer.h +14 -14
- data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -2
- data/include/grpc/impl/codegen/connectivity_state.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +32 -28
- data/include/grpc/impl/codegen/port_platform.h +48 -0
- data/include/grpc/impl/codegen/slice.h +10 -10
- data/include/grpc/impl/codegen/sync_generic.h +9 -3
- data/include/grpc/slice.h +16 -17
- data/include/grpc/slice_buffer.h +22 -22
- data/include/grpc/support/alloc.h +11 -11
- data/include/grpc/support/avl.h +28 -20
- data/include/grpc/support/cmdline.h +13 -13
- data/include/grpc/support/histogram.h +17 -17
- data/include/grpc/support/host_port.h +2 -2
- data/include/grpc/support/log.h +9 -9
- data/include/grpc/support/log_windows.h +1 -1
- data/include/grpc/support/string_util.h +2 -2
- data/include/grpc/support/subprocess.h +5 -5
- data/include/grpc/support/sync.h +43 -27
- data/include/grpc/support/thd.h +6 -6
- data/include/grpc/support/tls_gcc.h +1 -1
- data/include/grpc/support/tls_pthread.h +1 -1
- data/src/core/ext/census/{grpc_context.c → grpc_context.cc} +5 -8
- data/src/core/ext/filters/client_channel/backup_poller.cc +165 -0
- data/src/core/ext/{census/grpc_filter.h → filters/client_channel/backup_poller.h} +12 -7
- data/src/core/ext/filters/client_channel/{channel_connectivity.c → channel_connectivity.cc} +45 -42
- data/src/core/ext/filters/client_channel/{client_channel.c → client_channel.cc} +452 -417
- data/src/core/ext/filters/client_channel/client_channel.h +16 -8
- data/src/core/ext/filters/client_channel/{client_channel_factory.c → client_channel_factory.cc} +0 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.h +29 -21
- data/src/core/ext/filters/client_channel/{client_channel_plugin.c → client_channel_plugin.cc} +15 -19
- data/src/core/ext/filters/client_channel/{connector.c → connector.cc} +0 -0
- data/src/core/ext/filters/client_channel/connector.h +29 -21
- data/src/core/ext/filters/client_channel/{http_connect_handshaker.c → http_connect_handshaker.cc} +10 -10
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +8 -0
- data/src/core/ext/filters/client_channel/{http_proxy.c → http_proxy.cc} +14 -14
- data/src/core/ext/filters/client_channel/http_proxy.h +8 -0
- data/src/core/ext/filters/client_channel/{lb_policy.c → lb_policy.cc} +47 -48
- data/src/core/ext/filters/client_channel/lb_policy.h +76 -70
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{client_load_reporting_filter.c → client_load_reporting_filter.cc} +28 -29
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb.c → grpclb.cc} +554 -563
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +17 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_channel_secure.c → grpclb_channel_secure.cc} +17 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_client_stats.c → grpclb_client_stats.cc} +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{load_balancer_api.c → load_balancer_api.cc} +64 -67
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +20 -21
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +599 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +695 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +270 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +153 -0
- data/src/core/ext/filters/client_channel/{lb_policy_factory.c → lb_policy_factory.cc} +10 -10
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +48 -40
- data/src/core/ext/filters/client_channel/{lb_policy_registry.c → lb_policy_registry.cc} +9 -9
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +11 -3
- data/src/core/ext/filters/client_channel/{parse_address.c → parse_address.cc} +24 -24
- data/src/core/ext/filters/client_channel/parse_address.h +14 -6
- data/src/core/ext/filters/client_channel/{proxy_mapper.c → proxy_mapper.cc} +0 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.h +8 -0
- data/src/core/ext/filters/client_channel/{proxy_mapper_registry.c → proxy_mapper_registry.cc} +0 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +8 -0
- data/src/core/ext/filters/client_channel/{resolver.c → resolver.cc} +21 -23
- data/src/core/ext/filters/client_channel/resolver.h +33 -27
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{dns_resolver_ares.c → dns_resolver_ares.cc} +133 -133
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +18 -9
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_ev_driver_posix.c → grpc_ares_ev_driver_posix.cc} +58 -56
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_wrapper.c → grpc_ares_wrapper.cc} +118 -115
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +23 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +60 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/{dns_resolver.c → dns_resolver.cc} +100 -94
- data/src/core/ext/filters/client_channel/resolver/fake/{fake_resolver.c → fake_resolver.cc} +14 -14
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +9 -1
- data/src/core/ext/filters/client_channel/resolver/sockaddr/{sockaddr_resolver.c → sockaddr_resolver.cc} +60 -60
- data/src/core/ext/filters/client_channel/{resolver_factory.c → resolver_factory.cc} +2 -2
- data/src/core/ext/filters/client_channel/resolver_factory.h +27 -19
- data/src/core/ext/filters/client_channel/{resolver_registry.c → resolver_registry.cc} +35 -35
- data/src/core/ext/filters/client_channel/resolver_registry.h +18 -10
- data/src/core/ext/filters/client_channel/{retry_throttle.c → retry_throttle.cc} +10 -10
- data/src/core/ext/filters/client_channel/retry_throttle.h +8 -0
- data/src/core/ext/filters/client_channel/{subchannel.c → subchannel.cc} +210 -213
- data/src/core/ext/filters/client_channel/subchannel.h +68 -60
- data/src/core/ext/filters/client_channel/{subchannel_index.c → subchannel_index.cc} +52 -52
- data/src/core/ext/filters/client_channel/subchannel_index.h +22 -14
- data/src/core/ext/filters/client_channel/{uri_parser.c → uri_parser.cc} +29 -27
- data/src/core/ext/filters/client_channel/uri_parser.h +18 -10
- data/src/core/ext/filters/deadline/{deadline_filter.c → deadline_filter.cc} +12 -15
- data/src/core/ext/filters/deadline/deadline_filter.h +11 -2
- data/src/core/ext/filters/http/client/{http_client_filter.c → http_client_filter.cc} +83 -83
- data/src/core/ext/filters/http/client/http_client_filter.h +8 -0
- data/src/core/ext/filters/http/{http_filters_plugin.c → http_filters_plugin.cc} +20 -21
- data/src/core/ext/filters/http/message_compress/{message_compress_filter.c → message_compress_filter.cc} +84 -83
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +9 -1
- data/src/core/ext/filters/http/server/{http_server_filter.c → http_server_filter.cc} +80 -78
- data/src/core/ext/filters/http/server/http_server_filter.h +8 -0
- data/src/core/ext/filters/load_reporting/{server_load_reporting_filter.c → server_load_reporting_filter.cc} +29 -29
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +9 -1
- data/src/core/ext/filters/load_reporting/{server_load_reporting_plugin.c → server_load_reporting_plugin.cc} +11 -11
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +13 -5
- data/src/core/ext/filters/max_age/{max_age_filter.c → max_age_filter.cc} +46 -56
- data/src/core/ext/filters/max_age/max_age_filter.h +8 -0
- data/src/core/ext/filters/message_size/{message_size_filter.c → message_size_filter.cc} +62 -40
- data/src/core/ext/filters/message_size/message_size_filter.h +8 -0
- data/src/core/ext/filters/workarounds/{workaround_cronet_compression_filter.c → workaround_cronet_compression_filter.cc} +11 -11
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +8 -0
- data/src/core/ext/filters/workarounds/{workaround_utils.c → workaround_utils.cc} +7 -7
- data/src/core/ext/filters/workarounds/workaround_utils.h +9 -1
- data/src/core/ext/transport/chttp2/alpn/{alpn.c → alpn.cc} +3 -3
- data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -2
- data/src/core/ext/transport/chttp2/client/{chttp2_connector.c → chttp2_connector.cc} +49 -45
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +8 -0
- data/src/core/ext/transport/chttp2/client/insecure/{channel_create.c → channel_create.cc} +28 -27
- data/src/core/ext/transport/chttp2/client/insecure/{channel_create_posix.c → channel_create_posix.cc} +14 -13
- data/src/core/ext/transport/chttp2/client/secure/{secure_channel_create.c → secure_channel_create.cc} +68 -66
- data/src/core/ext/transport/chttp2/server/{chttp2_server.c → chttp2_server.cc} +76 -77
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +11 -3
- data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2.c → server_chttp2.cc} +3 -3
- data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2_posix.c → server_chttp2_posix.cc} +13 -12
- data/src/core/ext/transport/chttp2/server/secure/{server_secure_chttp2.c → server_secure_chttp2.cc} +12 -10
- data/src/core/ext/transport/chttp2/transport/{bin_decoder.c → bin_decoder.cc} +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +15 -7
- data/src/core/ext/transport/chttp2/transport/{bin_encoder.c → bin_encoder.cc} +11 -11
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{chttp2_plugin.c → chttp2_plugin.cc} +2 -9
- data/src/core/ext/transport/chttp2/transport/{chttp2_transport.c → chttp2_transport.cc} +778 -778
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -10
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +385 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +337 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{frame_data.c → frame_data.cc} +34 -34
- data/src/core/ext/transport/chttp2/transport/frame_data.h +25 -17
- data/src/core/ext/transport/chttp2/transport/{frame_goaway.c → frame_goaway.cc} +18 -18
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +18 -10
- data/src/core/ext/transport/chttp2/transport/{frame_ping.c → frame_ping.cc} +18 -19
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +12 -4
- data/src/core/ext/transport/chttp2/transport/{frame_rst_stream.c → frame_rst_stream.cc} +16 -16
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +16 -8
- data/src/core/ext/transport/chttp2/transport/{frame_settings.c → frame_settings.cc} +23 -24
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +17 -9
- data/src/core/ext/transport/chttp2/transport/{frame_window_update.c → frame_window_update.cc} +22 -24
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +14 -6
- data/src/core/ext/transport/chttp2/transport/{hpack_encoder.c → hpack_encoder.cc} +206 -161
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +23 -13
- data/src/core/ext/transport/chttp2/transport/{hpack_parser.c → hpack_parser.cc} +340 -334
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +30 -22
- data/src/core/ext/transport/chttp2/transport/{hpack_table.c → hpack_table.cc} +25 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +19 -11
- data/src/core/ext/transport/chttp2/transport/{http2_settings.c → http2_settings.cc} +1 -1
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -2
- data/src/core/ext/transport/chttp2/transport/{huffsyms.c → huffsyms.cc} +0 -0
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{incoming_metadata.c → incoming_metadata.cc} +14 -13
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +18 -10
- data/src/core/ext/transport/chttp2/transport/internal.h +214 -340
- data/src/core/ext/transport/chttp2/transport/{parsing.c → parsing.cc} +152 -141
- data/src/core/ext/transport/chttp2/transport/{stream_lists.c → stream_lists.cc} +53 -53
- data/src/core/ext/transport/chttp2/transport/{stream_map.c → stream_map.cc} +35 -34
- data/src/core/ext/transport/chttp2/transport/stream_map.h +22 -14
- data/src/core/ext/transport/chttp2/transport/{varint.c → varint.cc} +0 -0
- data/src/core/ext/transport/chttp2/transport/varint.h +8 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +636 -0
- data/src/core/ext/transport/inproc/{inproc_plugin.c → inproc_plugin.cc} +5 -6
- data/src/core/ext/transport/inproc/{inproc_transport.c → inproc_transport.cc} +479 -544
- data/src/core/ext/transport/inproc/inproc_transport.h +4 -4
- data/src/core/lib/backoff/backoff.cc +80 -0
- data/src/core/lib/backoff/backoff.h +83 -0
- data/src/core/lib/channel/{channel_args.c → channel_args.cc} +92 -92
- data/src/core/lib/channel/channel_args.h +45 -37
- data/src/core/lib/channel/{channel_stack.c → channel_stack.cc} +67 -68
- data/src/core/lib/channel/channel_stack.h +76 -75
- data/src/core/lib/channel/{channel_stack_builder.c → channel_stack_builder.cc} +91 -91
- data/src/core/lib/channel/channel_stack_builder.h +45 -45
- data/src/core/lib/channel/{connected_channel.c → connected_channel.cc} +70 -70
- data/src/core/lib/channel/connected_channel.h +12 -4
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/channel/{handshaker.c → handshaker.cc} +7 -9
- data/src/core/lib/channel/handshaker.h +9 -1
- data/src/core/lib/channel/{handshaker_factory.c → handshaker_factory.cc} +7 -7
- data/src/core/lib/channel/handshaker_factory.h +18 -10
- data/src/core/lib/channel/{handshaker_registry.c → handshaker_registry.cc} +0 -0
- data/src/core/lib/channel/handshaker_registry.h +8 -0
- data/src/core/lib/compression/algorithm_metadata.h +8 -0
- data/src/core/lib/compression/{compression.c → compression.cc} +9 -9
- data/src/core/lib/compression/{message_compress.c → message_compress.cc} +0 -0
- data/src/core/lib/compression/message_compress.h +8 -0
- data/src/core/lib/compression/{stream_compression.c → stream_compression.cc} +12 -12
- data/src/core/lib/compression/stream_compression.h +27 -19
- data/src/core/lib/compression/{stream_compression_gzip.c → stream_compression_gzip.cc} +35 -36
- data/src/core/lib/compression/stream_compression_gzip.h +8 -0
- data/src/core/lib/compression/{stream_compression_identity.c → stream_compression_identity.cc} +19 -20
- data/src/core/lib/compression/stream_compression_identity.h +8 -0
- data/src/core/lib/debug/{stats.c → stats.cc} +19 -19
- data/src/core/lib/debug/stats.h +17 -9
- data/src/core/lib/debug/{stats_data.c → stats_data.cc} +45 -22
- data/src/core/lib/debug/stats_data.h +58 -19
- data/src/core/lib/debug/trace.cc +142 -0
- data/src/core/lib/debug/trace.h +74 -14
- data/src/core/lib/http/{format_request.c → format_request.cc} +10 -10
- data/src/core/lib/http/format_request.h +12 -4
- data/src/core/lib/http/{httpcli.c → httpcli.cc} +80 -80
- data/src/core/lib/http/httpcli.h +41 -33
- data/src/core/lib/http/{httpcli_security_connector.c → httpcli_security_connector.cc} +69 -55
- data/src/core/lib/http/{parser.c → parser.cc} +42 -42
- data/src/core/lib/http/parser.h +28 -20
- data/src/core/lib/{support → iomgr}/block_annotate.h +17 -8
- data/src/core/lib/iomgr/{call_combiner.c → call_combiner.cc} +29 -17
- data/src/core/lib/iomgr/call_combiner.h +9 -1
- data/src/core/lib/iomgr/closure.h +220 -62
- data/src/core/lib/iomgr/{combiner.c → combiner.cc} +63 -62
- data/src/core/lib/iomgr/combiner.h +16 -8
- data/src/core/lib/iomgr/{endpoint.c → endpoint.cc} +6 -0
- data/src/core/lib/iomgr/endpoint.h +47 -32
- data/src/core/lib/iomgr/endpoint_pair.h +12 -4
- data/src/core/lib/iomgr/{endpoint_pair_posix.c → endpoint_pair_posix.cc} +3 -3
- data/src/core/lib/iomgr/{endpoint_pair_uv.c → endpoint_pair_uv.cc} +2 -2
- data/src/core/lib/iomgr/{endpoint_pair_windows.c → endpoint_pair_windows.cc} +6 -6
- data/src/core/lib/iomgr/{error.c → error.cc} +125 -124
- data/src/core/lib/iomgr/error.h +32 -27
- data/src/core/lib/iomgr/error_internal.h +11 -2
- data/src/core/lib/iomgr/{ev_epoll1_linux.c → ev_epoll1_linux.cc} +214 -215
- data/src/core/lib/iomgr/ev_epoll1_linux.h +9 -1
- data/src/core/lib/iomgr/ev_epollex_linux.cc +1488 -0
- data/src/core/lib/iomgr/ev_epollex_linux.h +9 -1
- data/src/core/lib/iomgr/{ev_epollsig_linux.c → ev_epollsig_linux.cc} +304 -305
- data/src/core/lib/iomgr/ev_epollsig_linux.h +12 -4
- data/src/core/lib/iomgr/{ev_poll_posix.c → ev_poll_posix.cc} +272 -283
- data/src/core/lib/iomgr/ev_poll_posix.h +10 -2
- data/src/core/lib/iomgr/ev_posix.cc +288 -0
- data/src/core/lib/iomgr/ev_posix.h +75 -67
- data/src/core/lib/iomgr/{ev_windows.c → ev_windows.cc} +2 -2
- data/src/core/lib/iomgr/exec_ctx.cc +177 -0
- data/src/core/lib/iomgr/exec_ctx.h +35 -13
- data/src/core/lib/iomgr/{executor.c → executor.cc} +34 -35
- data/src/core/lib/iomgr/executor.h +12 -4
- data/src/core/lib/iomgr/{fork_posix.c → fork_posix.cc} +0 -0
- data/src/core/lib/iomgr/{fork_windows.c → fork_windows.cc} +0 -0
- data/src/core/lib/iomgr/gethostname.h +9 -1
- data/src/core/lib/iomgr/{gethostname_fallback.c → gethostname_fallback.cc} +2 -1
- data/src/core/lib/iomgr/{gethostname_host_name_max.c → gethostname_host_name_max.cc} +4 -3
- data/src/core/lib/iomgr/{gethostname_sysconf.c → gethostname_sysconf.cc} +3 -2
- data/src/core/lib/iomgr/{iocp_windows.c → iocp_windows.cc} +23 -25
- data/src/core/lib/iomgr/iocp_windows.h +17 -3
- data/src/core/lib/iomgr/{iomgr.c → iomgr.cc} +25 -19
- data/src/core/lib/iomgr/iomgr.h +11 -3
- data/src/core/lib/iomgr/iomgr_internal.h +13 -5
- data/src/core/lib/iomgr/{iomgr_posix.c → iomgr_posix.cc} +0 -1
- data/src/core/lib/iomgr/{iomgr_uv.c → iomgr_uv.cc} +1 -1
- data/src/core/lib/iomgr/iomgr_uv.h +8 -0
- data/src/core/lib/iomgr/{iomgr_windows.c → iomgr_windows.cc} +0 -0
- data/src/core/lib/iomgr/{is_epollexclusive_available.c → is_epollexclusive_available.cc} +1 -1
- data/src/core/lib/iomgr/is_epollexclusive_available.h +8 -0
- data/src/core/lib/iomgr/{load_file.c → load_file.cc} +12 -12
- data/src/core/lib/iomgr/load_file.h +2 -2
- data/src/core/lib/iomgr/{lockfree_event.c → lockfree_event.cc} +76 -68
- data/src/core/lib/iomgr/lockfree_event.h +30 -11
- data/src/core/lib/iomgr/{network_status_tracker.c → network_status_tracker.cc} +3 -2
- data/src/core/lib/iomgr/network_status_tracker.h +2 -2
- data/src/core/lib/iomgr/{polling_entity.c → polling_entity.cc} +18 -18
- data/src/core/lib/iomgr/polling_entity.h +21 -13
- data/src/core/lib/iomgr/pollset.h +17 -11
- data/src/core/lib/iomgr/pollset_set.h +23 -15
- data/src/core/lib/iomgr/{pollset_set_uv.c → pollset_set_uv.cc} +0 -0
- data/src/core/lib/iomgr/{pollset_set_windows.c → pollset_set_windows.cc} +0 -0
- data/src/core/lib/iomgr/{pollset_uv.c → pollset_uv.cc} +31 -29
- data/src/core/lib/iomgr/pollset_uv.h +8 -0
- data/src/core/lib/iomgr/{pollset_windows.c → pollset_windows.cc} +24 -24
- data/src/core/lib/iomgr/pollset_windows.h +17 -4
- data/src/core/lib/iomgr/port.h +10 -0
- data/src/core/lib/iomgr/resolve_address.h +18 -10
- data/src/core/lib/iomgr/{resolve_address_posix.c → resolve_address_posix.cc} +40 -40
- data/src/core/lib/iomgr/{resolve_address_uv.c → resolve_address_uv.cc} +61 -56
- data/src/core/lib/iomgr/{resolve_address_windows.c → resolve_address_windows.cc} +36 -34
- data/src/core/lib/iomgr/{resource_quota.c → resource_quota.cc} +209 -180
- data/src/core/lib/iomgr/resource_quota.h +45 -37
- data/src/core/lib/iomgr/{sockaddr_utils.c → sockaddr_utils.cc} +61 -61
- data/src/core/lib/iomgr/sockaddr_utils.h +23 -15
- data/src/core/lib/iomgr/sockaddr_windows.h +6 -0
- data/src/core/lib/iomgr/{socket_factory_posix.c → socket_factory_posix.cc} +20 -20
- data/src/core/lib/iomgr/socket_factory_posix.h +15 -15
- data/src/core/lib/iomgr/{socket_mutator.c → socket_mutator.cc} +18 -18
- data/src/core/lib/iomgr/socket_mutator.h +11 -11
- data/src/core/lib/iomgr/socket_utils.h +9 -1
- data/src/core/lib/iomgr/{socket_utils_common_posix.c → socket_utils_common_posix.cc} +28 -28
- data/src/core/lib/iomgr/{socket_utils_linux.c → socket_utils_linux.cc} +3 -3
- data/src/core/lib/iomgr/{socket_utils_posix.c → socket_utils_posix.cc} +3 -3
- data/src/core/lib/iomgr/socket_utils_posix.h +26 -18
- data/src/core/lib/iomgr/{socket_utils_uv.c → socket_utils_uv.cc} +1 -1
- data/src/core/lib/iomgr/{socket_utils_windows.c → socket_utils_windows.cc} +2 -2
- data/src/core/lib/iomgr/{socket_windows.c → socket_windows.cc} +18 -18
- data/src/core/lib/iomgr/socket_windows.h +26 -13
- data/src/core/lib/iomgr/tcp_client.h +14 -6
- data/src/core/lib/iomgr/{tcp_client_posix.c → tcp_client_posix.cc} +69 -70
- data/src/core/lib/iomgr/tcp_client_posix.h +11 -3
- data/src/core/lib/iomgr/{tcp_client_uv.c → tcp_client_uv.cc} +47 -48
- data/src/core/lib/iomgr/{tcp_client_windows.c → tcp_client_windows.cc} +46 -44
- data/src/core/lib/iomgr/{tcp_posix.c → tcp_posix.cc} +198 -175
- data/src/core/lib/iomgr/tcp_posix.h +15 -7
- data/src/core/lib/iomgr/tcp_server.h +31 -23
- data/src/core/lib/iomgr/{tcp_server_posix.c → tcp_server_posix.cc} +78 -77
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +27 -19
- data/src/core/lib/iomgr/{tcp_server_utils_posix_common.c → tcp_server_utils_posix_common.cc} +27 -27
- data/src/core/lib/iomgr/{tcp_server_utils_posix_ifaddrs.c → tcp_server_utils_posix_ifaddrs.cc} +25 -25
- data/src/core/lib/iomgr/{tcp_server_utils_posix_noifaddrs.c → tcp_server_utils_posix_noifaddrs.cc} +2 -2
- data/src/core/lib/iomgr/{tcp_server_uv.c → tcp_server_uv.cc} +133 -105
- data/src/core/lib/iomgr/{tcp_server_windows.c → tcp_server_windows.cc} +81 -77
- data/src/core/lib/iomgr/tcp_uv.cc +420 -0
- data/src/core/lib/iomgr/tcp_uv.h +18 -4
- data/src/core/lib/iomgr/{tcp_windows.c → tcp_windows.cc} +90 -79
- data/src/core/lib/iomgr/tcp_windows.h +17 -4
- data/src/core/lib/iomgr/{time_averaged_stats.c → time_averaged_stats.cc} +0 -0
- data/src/core/lib/iomgr/time_averaged_stats.h +8 -0
- data/src/core/lib/iomgr/timer.h +16 -9
- data/src/core/lib/iomgr/{timer_generic.c → timer_generic.cc} +130 -171
- data/src/core/lib/iomgr/timer_generic.h +4 -4
- data/src/core/lib/iomgr/{timer_heap.c → timer_heap.cc} +20 -21
- data/src/core/lib/iomgr/timer_heap.h +16 -8
- data/src/core/lib/iomgr/{timer_manager.c → timer_manager.cc} +54 -52
- data/src/core/lib/iomgr/timer_manager.h +8 -0
- data/src/core/lib/iomgr/{timer_uv.c → timer_uv.cc} +22 -24
- data/src/core/lib/iomgr/timer_uv.h +2 -2
- data/src/core/lib/iomgr/{udp_server.c → udp_server.cc} +75 -75
- data/src/core/lib/iomgr/udp_server.h +25 -17
- data/src/core/lib/iomgr/{unix_sockets_posix.c → unix_sockets_posix.cc} +22 -21
- data/src/core/lib/iomgr/unix_sockets_posix.h +14 -6
- data/src/core/lib/iomgr/{unix_sockets_posix_noop.c → unix_sockets_posix_noop.cc} +5 -5
- data/src/core/lib/iomgr/{wakeup_fd_cv.c → wakeup_fd_cv.cc} +2 -2
- data/src/core/lib/iomgr/wakeup_fd_cv.h +10 -0
- data/src/core/lib/iomgr/{wakeup_fd_eventfd.c → wakeup_fd_eventfd.cc} +0 -0
- data/src/core/lib/iomgr/{wakeup_fd_nospecial.c → wakeup_fd_nospecial.cc} +0 -0
- data/src/core/lib/iomgr/{wakeup_fd_pipe.c → wakeup_fd_pipe.cc} +1 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +9 -1
- data/src/core/lib/iomgr/{wakeup_fd_posix.c → wakeup_fd_posix.cc} +6 -7
- data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -0
- data/src/core/lib/json/{json.c → json.cc} +0 -0
- data/src/core/lib/json/json.h +8 -0
- data/src/core/lib/json/{json_reader.c → json_reader.cc} +18 -18
- data/src/core/lib/json/json_reader.h +26 -18
- data/src/core/lib/json/{json_string.c → json_string.cc} +57 -57
- data/src/core/lib/json/{json_writer.c → json_writer.cc} +20 -20
- data/src/core/lib/json/json_writer.h +23 -15
- data/src/core/lib/profiling/{basic_timers.c → basic_timers.cc} +34 -34
- data/src/core/lib/profiling/{stap_timers.c → stap_timers.cc} +5 -5
- data/src/core/lib/profiling/timers.h +6 -6
- data/src/core/lib/security/context/{security_context.c → security_context.cc} +98 -95
- data/src/core/lib/security/context/security_context.h +27 -29
- data/src/core/lib/security/credentials/composite/{composite_credentials.c → composite_credentials.cc} +79 -73
- data/src/core/lib/security/credentials/composite/composite_credentials.h +17 -9
- data/src/core/lib/security/credentials/{credentials.c → credentials.cc} +97 -92
- data/src/core/lib/security/credentials/credentials.h +83 -75
- data/src/core/lib/security/credentials/{credentials_metadata.c → credentials_metadata.cc} +7 -6
- data/src/core/lib/security/credentials/fake/{fake_credentials.c → fake_credentials.cc} +39 -36
- data/src/core/lib/security/credentials/fake/fake_credentials.h +13 -5
- data/src/core/lib/security/credentials/google_default/{credentials_generic.c → credentials_generic.cc} +5 -5
- data/src/core/lib/security/credentials/google_default/{google_default_credentials.c → google_default_credentials.cc} +55 -55
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +9 -1
- data/src/core/lib/security/credentials/iam/{iam_credentials.c → iam_credentials.cc} +19 -18
- data/src/core/lib/security/credentials/jwt/{json_token.c → json_token.cc} +80 -75
- data/src/core/lib/security/credentials/jwt/json_token.h +23 -15
- data/src/core/lib/security/credentials/jwt/{jwt_credentials.c → jwt_credentials.cc} +45 -41
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -3
- data/src/core/lib/security/credentials/jwt/{jwt_verifier.c → jwt_verifier.cc} +262 -252
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +38 -30
- data/src/core/lib/security/credentials/oauth2/{oauth2_credentials.c → oauth2_credentials.cc} +138 -141
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +30 -22
- data/src/core/lib/security/credentials/plugin/{plugin_credentials.c → plugin_credentials.cc} +52 -53
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +7 -7
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +344 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +27 -0
- data/src/core/lib/security/transport/auth_filters.h +16 -0
- data/src/core/lib/security/transport/{client_auth_filter.c → client_auth_filter.cc} +127 -115
- data/src/core/lib/security/transport/{lb_targets_info.c → lb_targets_info.cc} +16 -13
- data/src/core/lib/security/transport/lb_targets_info.h +11 -3
- data/src/core/lib/security/transport/{secure_endpoint.c → secure_endpoint.cc} +84 -76
- data/src/core/lib/security/transport/secure_endpoint.h +13 -5
- data/src/core/lib/security/transport/security_connector.cc +1121 -0
- data/src/core/lib/security/transport/security_connector.h +97 -79
- data/src/core/lib/security/transport/{security_handshaker.c → security_handshaker.cc} +139 -132
- data/src/core/lib/security/transport/security_handshaker.h +11 -3
- data/src/core/lib/security/transport/{server_auth_filter.c → server_auth_filter.cc} +68 -68
- data/src/core/lib/security/transport/{tsi_error.c → tsi_error.cc} +1 -1
- data/src/core/lib/security/transport/tsi_error.h +9 -1
- data/src/core/lib/security/util/{json_util.c → json_util.cc} +11 -11
- data/src/core/lib/security/util/json_util.h +12 -4
- data/src/core/lib/slice/{b64.c → b64.cc} +15 -15
- data/src/core/lib/slice/b64.h +12 -4
- data/src/core/lib/slice/{percent_encoding.c → percent_encoding.cc} +15 -15
- data/src/core/lib/slice/percent_encoding.h +11 -3
- data/src/core/lib/slice/{slice.c → slice.cc} +64 -64
- data/src/core/lib/slice/{slice_buffer.c → slice_buffer.cc} +38 -38
- data/src/core/lib/slice/{slice_hash_table.c → slice_hash_table.cc} +7 -7
- data/src/core/lib/slice/slice_hash_table.h +19 -11
- data/src/core/lib/slice/{slice_intern.c → slice_intern.cc} +35 -34
- data/src/core/lib/slice/slice_internal.h +17 -6
- data/src/core/lib/slice/{slice_string_helpers.c → slice_string_helpers.cc} +9 -9
- data/src/core/lib/slice/slice_string_helpers.h +3 -3
- data/src/core/lib/support/abstract.h +29 -0
- data/src/core/lib/support/{alloc.c → alloc.cc} +22 -22
- data/src/core/lib/support/{arena.c → arena.cc} +12 -12
- data/src/core/lib/support/arena.h +11 -3
- data/src/core/lib/support/{atm.c → atm.cc} +1 -1
- data/src/core/lib/support/{avl.c → avl.cc} +71 -70
- data/src/core/lib/support/{cmdline.c → cmdline.cc} +62 -62
- data/src/core/lib/support/{cpu_iphone.c → cpu_iphone.cc} +2 -0
- data/src/core/lib/support/{cpu_linux.c → cpu_linux.cc} +10 -0
- data/src/core/lib/support/{cpu_posix.c → cpu_posix.cc} +27 -4
- data/src/core/lib/support/{cpu_windows.c → cpu_windows.cc} +1 -0
- data/src/core/lib/support/env.h +3 -3
- data/src/core/lib/support/{env_linux.c → env_linux.cc} +11 -11
- data/src/core/lib/support/{env_posix.c → env_posix.cc} +4 -4
- data/src/core/lib/support/{env_windows.c → env_windows.cc} +5 -5
- data/src/core/lib/support/{fork.c → fork.cc} +2 -2
- data/src/core/lib/support/{histogram.c → histogram.cc} +25 -26
- data/src/core/lib/support/{host_port.c → host_port.cc} +16 -16
- data/src/core/lib/support/{log.c → log.cc} +8 -8
- data/src/core/lib/support/{log_android.c → log_android.cc} +7 -7
- data/src/core/lib/support/{log_linux.c → log_linux.cc} +8 -8
- data/src/core/lib/support/{log_posix.c → log_posix.cc} +9 -10
- data/src/core/lib/support/{log_windows.c → log_windows.cc} +7 -7
- data/src/core/lib/support/manual_constructor.h +211 -0
- data/src/core/lib/support/memory.h +41 -0
- data/src/core/lib/support/mpscq.cc +114 -0
- data/src/core/lib/support/mpscq.h +45 -7
- data/src/core/lib/support/{murmur_hash.c → murmur_hash.cc} +9 -12
- data/src/core/lib/support/murmur_hash.h +9 -1
- data/src/core/lib/support/spinlock.h +8 -1
- data/src/core/lib/support/{string.c → string.cc} +56 -55
- data/src/core/lib/support/string.h +21 -21
- data/src/core/lib/support/{string_posix.c → string_posix.cc} +5 -4
- data/src/core/lib/support/{string_util_windows.c → string_util_windows.cc} +9 -6
- data/src/core/lib/support/{string_windows.c → string_windows.cc} +3 -2
- data/src/core/lib/support/string_windows.h +8 -0
- data/src/core/lib/support/{subprocess_posix.c → subprocess_posix.cc} +13 -13
- data/src/core/lib/support/{subprocess_windows.c → subprocess_windows.cc} +9 -9
- data/src/core/lib/support/{sync.c → sync.cc} +22 -22
- data/src/core/lib/support/{sync_posix.c → sync_posix.cc} +6 -2
- data/src/core/lib/support/{sync_windows.c → sync_windows.cc} +14 -14
- data/src/core/lib/support/{thd.c → thd.cc} +0 -0
- data/src/core/lib/support/{thd_posix.c → thd_posix.cc} +10 -10
- data/src/core/lib/support/{thd_windows.c → thd_windows.cc} +10 -10
- data/src/core/lib/support/{time.c → time.cc} +0 -0
- data/src/core/lib/support/{time_posix.c → time_posix.cc} +5 -6
- data/src/core/lib/support/{time_precise.c → time_precise.cc} +6 -4
- data/src/core/lib/support/time_precise.h +9 -1
- data/src/core/lib/support/{time_windows.c → time_windows.cc} +2 -3
- data/src/core/lib/support/{tls_pthread.c → tls_pthread.cc} +2 -2
- data/src/core/lib/support/tmpfile.h +1 -1
- data/src/core/lib/support/{tmpfile_msys.c → tmpfile_msys.cc} +2 -2
- data/src/core/lib/support/{tmpfile_posix.c → tmpfile_posix.cc} +7 -7
- data/src/core/lib/support/{tmpfile_windows.c → tmpfile_windows.cc} +2 -2
- data/src/core/lib/support/{wrap_memcpy.c → wrap_memcpy.cc} +4 -2
- data/src/core/lib/surface/{alarm.c → alarm.cc} +32 -31
- data/src/core/lib/surface/alarm_internal.h +10 -2
- data/src/core/lib/surface/{api_trace.c → api_trace.cc} +1 -1
- data/src/core/lib/surface/api_trace.h +2 -2
- data/src/core/lib/surface/{byte_buffer.c → byte_buffer.cc} +13 -13
- data/src/core/lib/surface/{byte_buffer_reader.c → byte_buffer_reader.cc} +9 -9
- data/src/core/lib/surface/{call.c → call.cc} +379 -372
- data/src/core/lib/surface/call.h +37 -38
- data/src/core/lib/surface/{call_details.c → call_details.cc} +0 -0
- data/src/core/lib/surface/{call_log_batch.c → call_log_batch.cc} +13 -11
- data/src/core/lib/surface/call_test_only.h +5 -5
- data/src/core/lib/surface/{channel.c → channel.cc} +94 -95
- data/src/core/lib/surface/channel.h +29 -21
- data/src/core/lib/surface/{channel_init.c → channel_init.cc} +13 -13
- data/src/core/lib/surface/channel_init.h +6 -6
- data/src/core/lib/surface/{channel_ping.c → channel_ping.cc} +12 -12
- data/src/core/lib/surface/{channel_stack_type.c → channel_stack_type.cc} +1 -1
- data/src/core/lib/surface/channel_stack_type.h +9 -1
- data/src/core/lib/surface/{completion_queue.c → completion_queue.cc} +416 -379
- data/src/core/lib/surface/completion_queue.h +29 -29
- data/src/core/lib/surface/{completion_queue_factory.c → completion_queue_factory.cc} +1 -1
- data/src/core/lib/surface/completion_queue_factory.h +8 -0
- data/src/core/lib/surface/{event_string.c → event_string.cc} +9 -9
- data/src/core/lib/surface/event_string.h +9 -1
- data/src/core/lib/surface/{init.c → init.cc} +16 -39
- data/src/core/lib/surface/init.h +8 -0
- data/src/core/lib/surface/{init_secure.c → init_secure.cc} +12 -25
- data/src/core/lib/surface/lame_client.cc +38 -40
- data/src/core/lib/surface/lame_client.h +8 -0
- data/src/core/lib/surface/{metadata_array.c → metadata_array.cc} +0 -0
- data/src/core/lib/surface/{server.c → server.cc} +340 -404
- data/src/core/lib/surface/server.h +22 -14
- data/src/core/lib/surface/{validate_metadata.c → validate_metadata.cc} +10 -9
- data/src/core/lib/surface/validate_metadata.h +10 -2
- data/src/core/lib/surface/{version.c → version.cc} +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +84 -0
- data/src/core/lib/transport/bdp_estimator.h +67 -42
- data/src/core/lib/transport/{byte_stream.c → byte_stream.cc} +51 -51
- data/src/core/lib/transport/byte_stream.h +41 -33
- data/src/core/lib/transport/{connectivity_state.c → connectivity_state.cc} +36 -40
- data/src/core/lib/transport/connectivity_state.h +29 -21
- data/src/core/lib/transport/{error_utils.c → error_utils.cc} +26 -22
- data/src/core/lib/transport/error_utils.h +18 -6
- data/src/core/lib/transport/{metadata.c → metadata.cc} +92 -88
- data/src/core/lib/transport/metadata.h +22 -20
- data/src/core/lib/transport/{metadata_batch.c → metadata_batch.cc} +78 -79
- data/src/core/lib/transport/metadata_batch.h +46 -45
- data/src/core/lib/transport/pid_controller.cc +48 -0
- data/src/core/lib/transport/pid_controller.h +84 -32
- data/src/core/lib/transport/{service_config.c → service_config.cc} +66 -48
- data/src/core/lib/transport/service_config.h +11 -2
- data/src/core/lib/transport/{static_metadata.c → static_metadata.cc} +2 -2
- data/src/core/lib/transport/static_metadata.h +30 -23
- data/src/core/lib/transport/{status_conversion.c → status_conversion.cc} +4 -3
- data/src/core/lib/transport/status_conversion.h +12 -2
- data/src/core/lib/transport/{timeout_encoding.c → timeout_encoding.cc} +28 -61
- data/src/core/lib/transport/timeout_encoding.h +11 -2
- data/src/core/lib/transport/{transport.c → transport.cc} +79 -79
- data/src/core/lib/transport/transport.h +78 -80
- data/src/core/lib/transport/transport_impl.h +27 -19
- data/src/core/lib/transport/{transport_op_string.c → transport_op_string.cc} +32 -30
- data/src/core/plugin_registry/{grpc_plugin_registry.c → grpc_plugin_registry.cc} +34 -38
- data/src/core/tsi/{fake_transport_security.c → fake_transport_security.cc} +141 -132
- data/src/core/tsi/fake_transport_security.h +5 -5
- data/src/core/tsi/{gts_transport_security.c → gts_transport_security.cc} +4 -4
- data/src/core/tsi/gts_transport_security.h +11 -3
- data/src/core/tsi/{ssl_transport_security.c → ssl_transport_security.cc} +309 -300
- data/src/core/tsi/ssl_transport_security.h +25 -25
- data/src/core/tsi/ssl_types.h +8 -0
- data/src/core/tsi/{transport_security.c → transport_security.cc} +94 -87
- data/src/core/tsi/transport_security.h +55 -55
- data/src/core/tsi/{transport_security_adapter.c → transport_security_adapter.cc} +58 -55
- data/src/core/tsi/transport_security_adapter.h +2 -2
- data/src/core/tsi/{transport_security_grpc.c → transport_security_grpc.cc} +21 -21
- data/src/core/tsi/transport_security_grpc.h +19 -19
- data/src/core/tsi/transport_security_interface.h +41 -41
- data/src/ruby/ext/grpc/extconf.rb +4 -2
- data/src/ruby/ext/grpc/rb_byte_buffer.c +5 -5
- data/src/ruby/ext/grpc/rb_byte_buffer.h +2 -2
- data/src/ruby/ext/grpc/rb_call.c +41 -42
- data/src/ruby/ext/grpc/rb_call.h +6 -6
- data/src/ruby/ext/grpc/rb_call_credentials.c +30 -30
- data/src/ruby/ext/grpc/rb_channel.c +87 -87
- data/src/ruby/ext/grpc/rb_channel_credentials.c +23 -23
- data/src/ruby/ext/grpc/rb_completion_queue.c +11 -11
- data/src/ruby/ext/grpc/rb_completion_queue.h +3 -3
- data/src/ruby/ext/grpc/rb_compression_options.c +20 -20
- data/src/ruby/ext/grpc/rb_event_thread.c +14 -14
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +8 -8
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -58
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +242 -306
- data/src/ruby/ext/grpc/rb_server.c +23 -23
- data/src/ruby/ext/grpc/rb_server_credentials.c +13 -13
- data/src/ruby/lib/grpc/generic/rpc_server.rb +25 -12
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +14 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +29 -0
- data/third_party/cares/config_freebsd/ares_config.h +502 -0
- data/third_party/cares/config_openbsd/ares_config.h +502 -0
- metadata +302 -328
- data/src/core/ext/census/aggregation.h +0 -51
- data/src/core/ext/census/base_resources.c +0 -56
- data/src/core/ext/census/base_resources.h +0 -24
- data/src/core/ext/census/census_interface.h +0 -61
- data/src/core/ext/census/census_rpc_stats.h +0 -86
- data/src/core/ext/census/context.c +0 -496
- data/src/core/ext/census/gen/census.pb.c +0 -161
- data/src/core/ext/census/gen/census.pb.h +0 -280
- data/src/core/ext/census/gen/trace_context.pb.c +0 -39
- data/src/core/ext/census/gen/trace_context.pb.h +0 -78
- data/src/core/ext/census/grpc_filter.c +0 -196
- data/src/core/ext/census/grpc_plugin.c +0 -70
- data/src/core/ext/census/initialize.c +0 -51
- data/src/core/ext/census/intrusive_hash_map.c +0 -305
- data/src/core/ext/census/intrusive_hash_map.h +0 -152
- data/src/core/ext/census/intrusive_hash_map_internal.h +0 -48
- data/src/core/ext/census/mlog.c +0 -586
- data/src/core/ext/census/mlog.h +0 -80
- data/src/core/ext/census/operation.c +0 -48
- data/src/core/ext/census/placeholders.c +0 -49
- data/src/core/ext/census/resource.c +0 -303
- data/src/core/ext/census/resource.h +0 -48
- data/src/core/ext/census/rpc_metric_id.h +0 -36
- data/src/core/ext/census/trace_context.c +0 -71
- data/src/core/ext/census/trace_context.h +0 -56
- data/src/core/ext/census/trace_label.h +0 -46
- data/src/core/ext/census/trace_propagation.h +0 -48
- data/src/core/ext/census/trace_status.h +0 -30
- data/src/core/ext/census/trace_string.h +0 -35
- data/src/core/ext/census/tracing.c +0 -55
- data/src/core/ext/census/tracing.h +0 -109
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +0 -714
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +0 -924
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +0 -60
- data/src/core/ext/transport/chttp2/transport/flow_control.c +0 -502
- data/src/core/ext/transport/chttp2/transport/writing.c +0 -534
- data/src/core/lib/debug/trace.c +0 -146
- data/src/core/lib/iomgr/closure.c +0 -219
- data/src/core/lib/iomgr/ev_epollex_linux.c +0 -1461
- data/src/core/lib/iomgr/ev_posix.c +0 -266
- data/src/core/lib/iomgr/exec_ctx.c +0 -113
- data/src/core/lib/iomgr/tcp_uv.c +0 -381
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +0 -194
- data/src/core/lib/security/transport/security_connector.c +0 -914
- data/src/core/lib/support/backoff.c +0 -72
- data/src/core/lib/support/backoff.h +0 -56
- data/src/core/lib/support/mpscq.c +0 -79
- data/src/core/lib/support/stack_lockfree.c +0 -137
- data/src/core/lib/support/stack_lockfree.h +0 -38
- data/src/core/lib/transport/bdp_estimator.c +0 -110
- data/src/core/lib/transport/pid_controller.c +0 -63
@@ -23,6 +23,7 @@
|
|
23
23
|
|
24
24
|
#include "src/core/lib/iomgr/resolve_address.h"
|
25
25
|
|
26
|
+
#include <inttypes.h>
|
26
27
|
#include <string.h>
|
27
28
|
#include <sys/types.h>
|
28
29
|
|
@@ -33,35 +34,35 @@
|
|
33
34
|
#include <grpc/support/string_util.h>
|
34
35
|
#include <grpc/support/thd.h>
|
35
36
|
#include <grpc/support/time.h>
|
37
|
+
#include "src/core/lib/iomgr/block_annotate.h"
|
36
38
|
#include "src/core/lib/iomgr/executor.h"
|
37
39
|
#include "src/core/lib/iomgr/iomgr_internal.h"
|
38
40
|
#include "src/core/lib/iomgr/sockaddr_utils.h"
|
39
|
-
#include "src/core/lib/support/block_annotate.h"
|
40
41
|
#include "src/core/lib/support/string.h"
|
41
42
|
|
42
43
|
typedef struct {
|
43
|
-
char
|
44
|
-
char
|
44
|
+
char* name;
|
45
|
+
char* default_port;
|
45
46
|
grpc_closure request_closure;
|
46
|
-
grpc_closure
|
47
|
-
grpc_resolved_addresses
|
47
|
+
grpc_closure* on_done;
|
48
|
+
grpc_resolved_addresses** addresses;
|
48
49
|
} request;
|
49
50
|
|
50
|
-
static grpc_error
|
51
|
-
const char
|
52
|
-
grpc_resolved_addresses
|
51
|
+
static grpc_error* blocking_resolve_address_impl(
|
52
|
+
const char* name, const char* default_port,
|
53
|
+
grpc_resolved_addresses** addresses) {
|
53
54
|
struct addrinfo hints;
|
54
55
|
struct addrinfo *result = NULL, *resp;
|
55
|
-
char
|
56
|
-
char
|
56
|
+
char* host;
|
57
|
+
char* port;
|
57
58
|
int s;
|
58
59
|
size_t i;
|
59
|
-
grpc_error
|
60
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
60
61
|
|
61
62
|
/* parse name, splitting it into host and port parts */
|
62
63
|
gpr_split_host_port(name, &host, &port);
|
63
64
|
if (host == NULL) {
|
64
|
-
char
|
65
|
+
char* msg;
|
65
66
|
gpr_asprintf(&msg, "unparseable host:port: '%s'", name);
|
66
67
|
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
67
68
|
gpr_free(msg);
|
@@ -69,7 +70,7 @@ static grpc_error *blocking_resolve_address_impl(
|
|
69
70
|
}
|
70
71
|
if (port == NULL) {
|
71
72
|
if (default_port == NULL) {
|
72
|
-
char
|
73
|
+
char* msg;
|
73
74
|
gpr_asprintf(&msg, "no port in name '%s'", name);
|
74
75
|
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
75
76
|
gpr_free(msg);
|
@@ -86,20 +87,21 @@ static grpc_error *blocking_resolve_address_impl(
|
|
86
87
|
|
87
88
|
GRPC_SCHEDULING_START_BLOCKING_REGION;
|
88
89
|
s = getaddrinfo(host, port, &hints, &result);
|
89
|
-
|
90
|
+
GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX;
|
90
91
|
if (s != 0) {
|
91
92
|
error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo");
|
92
93
|
goto done;
|
93
94
|
}
|
94
95
|
|
95
96
|
/* Success path: set addrs non-NULL, fill it in */
|
96
|
-
(*addresses) =
|
97
|
+
(*addresses) =
|
98
|
+
(grpc_resolved_addresses*)gpr_malloc(sizeof(grpc_resolved_addresses));
|
97
99
|
(*addresses)->naddrs = 0;
|
98
100
|
for (resp = result; resp != NULL; resp = resp->ai_next) {
|
99
101
|
(*addresses)->naddrs++;
|
100
102
|
}
|
101
|
-
(*addresses)->addrs =
|
102
|
-
|
103
|
+
(*addresses)->addrs = (grpc_resolved_address*)gpr_malloc(
|
104
|
+
sizeof(grpc_resolved_address) * (*addresses)->naddrs);
|
103
105
|
i = 0;
|
104
106
|
for (resp = result; resp != NULL; resp = resp->ai_next) {
|
105
107
|
memcpy(&(*addresses)->addrs[i].addr, resp->ai_addr, resp->ai_addrlen);
|
@@ -109,7 +111,7 @@ static grpc_error *blocking_resolve_address_impl(
|
|
109
111
|
|
110
112
|
{
|
111
113
|
for (i = 0; i < (*addresses)->naddrs; i++) {
|
112
|
-
char
|
114
|
+
char* buf;
|
113
115
|
grpc_sockaddr_to_string(&buf, &(*addresses)->addrs[i], 0);
|
114
116
|
gpr_free(buf);
|
115
117
|
}
|
@@ -124,15 +126,15 @@ done:
|
|
124
126
|
return error;
|
125
127
|
}
|
126
128
|
|
127
|
-
grpc_error
|
128
|
-
const char
|
129
|
-
grpc_resolved_addresses
|
129
|
+
grpc_error* (*grpc_blocking_resolve_address)(
|
130
|
+
const char* name, const char* default_port,
|
131
|
+
grpc_resolved_addresses** addresses) = blocking_resolve_address_impl;
|
130
132
|
|
131
133
|
/* Callback to be passed to grpc_executor to asynch-ify
|
132
134
|
* grpc_blocking_resolve_address */
|
133
|
-
static void do_request_thread(grpc_exec_ctx
|
134
|
-
grpc_error
|
135
|
-
request
|
135
|
+
static void do_request_thread(grpc_exec_ctx* exec_ctx, void* rp,
|
136
|
+
grpc_error* error) {
|
137
|
+
request* r = (request*)rp;
|
136
138
|
if (error == GRPC_ERROR_NONE) {
|
137
139
|
error =
|
138
140
|
grpc_blocking_resolve_address(r->name, r->default_port, r->addresses);
|
@@ -145,19 +147,19 @@ static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp,
|
|
145
147
|
gpr_free(r);
|
146
148
|
}
|
147
149
|
|
148
|
-
void grpc_resolved_addresses_destroy(grpc_resolved_addresses
|
150
|
+
void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addrs) {
|
149
151
|
if (addrs != NULL) {
|
150
152
|
gpr_free(addrs->addrs);
|
151
153
|
}
|
152
154
|
gpr_free(addrs);
|
153
155
|
}
|
154
156
|
|
155
|
-
static void resolve_address_impl(grpc_exec_ctx
|
156
|
-
const char
|
157
|
-
grpc_pollset_set
|
158
|
-
grpc_closure
|
159
|
-
grpc_resolved_addresses
|
160
|
-
request
|
157
|
+
static void resolve_address_impl(grpc_exec_ctx* exec_ctx, const char* name,
|
158
|
+
const char* default_port,
|
159
|
+
grpc_pollset_set* interested_parties,
|
160
|
+
grpc_closure* on_done,
|
161
|
+
grpc_resolved_addresses** addresses) {
|
162
|
+
request* r = (request*)gpr_malloc(sizeof(request));
|
161
163
|
GRPC_CLOSURE_INIT(&r->request_closure, do_request_thread, r,
|
162
164
|
grpc_executor_scheduler(GRPC_EXECUTOR_SHORT));
|
163
165
|
r->name = gpr_strdup(name);
|
@@ -168,8 +170,8 @@ static void resolve_address_impl(grpc_exec_ctx *exec_ctx, const char *name,
|
|
168
170
|
}
|
169
171
|
|
170
172
|
void (*grpc_resolve_address)(
|
171
|
-
grpc_exec_ctx
|
172
|
-
grpc_pollset_set
|
173
|
-
grpc_resolved_addresses
|
173
|
+
grpc_exec_ctx* exec_ctx, const char* name, const char* default_port,
|
174
|
+
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
175
|
+
grpc_resolved_addresses** addresses) = resolve_address_impl;
|
174
176
|
|
175
177
|
#endif
|
@@ -18,6 +18,7 @@
|
|
18
18
|
|
19
19
|
#include "src/core/lib/iomgr/resource_quota.h"
|
20
20
|
|
21
|
+
#include <inttypes.h>
|
21
22
|
#include <limits.h>
|
22
23
|
#include <stdint.h>
|
23
24
|
#include <string.h>
|
@@ -30,15 +31,14 @@
|
|
30
31
|
|
31
32
|
#include "src/core/lib/iomgr/combiner.h"
|
32
33
|
|
33
|
-
|
34
|
-
GRPC_TRACER_INITIALIZER(false, "resource_quota");
|
34
|
+
grpc_core::TraceFlag grpc_resource_quota_trace(false, "resource_quota");
|
35
35
|
|
36
36
|
#define MEMORY_USAGE_ESTIMATION_MAX 65536
|
37
37
|
|
38
38
|
/* Internal linked list pointers for a resource user */
|
39
39
|
typedef struct {
|
40
|
-
grpc_resource_user
|
41
|
-
grpc_resource_user
|
40
|
+
grpc_resource_user* next;
|
41
|
+
grpc_resource_user* prev;
|
42
42
|
} grpc_resource_user_link;
|
43
43
|
|
44
44
|
/* Resource users are kept in (potentially) several intrusive linked lists
|
@@ -59,7 +59,7 @@ typedef enum {
|
|
59
59
|
|
60
60
|
struct grpc_resource_user {
|
61
61
|
/* The quota this resource user consumes from */
|
62
|
-
grpc_resource_quota
|
62
|
+
grpc_resource_quota* resource_quota;
|
63
63
|
|
64
64
|
/* Closure to schedule an allocation under the resource quota combiner lock */
|
65
65
|
grpc_closure allocate_closure;
|
@@ -88,16 +88,18 @@ struct grpc_resource_user {
|
|
88
88
|
grpc_closure_list on_allocated;
|
89
89
|
/* True if we are currently trying to allocate from the quota, false if not */
|
90
90
|
bool allocating;
|
91
|
+
/* How many bytes of allocations are outstanding */
|
92
|
+
int64_t outstanding_allocations;
|
91
93
|
/* True if we are currently trying to add ourselves to the non-free quota
|
92
94
|
list, false otherwise */
|
93
95
|
bool added_to_free_pool;
|
94
96
|
|
95
97
|
/* Reclaimers: index 0 is the benign reclaimer, 1 is the destructive reclaimer
|
96
98
|
*/
|
97
|
-
grpc_closure
|
99
|
+
grpc_closure* reclaimers[2];
|
98
100
|
/* Reclaimers just posted: once we're in the combiner lock, we'll move them
|
99
101
|
to the array above */
|
100
|
-
grpc_closure
|
102
|
+
grpc_closure* new_reclaimers[2];
|
101
103
|
/* Trampoline closures to finish reclamation and re-enter the quota combiner
|
102
104
|
lock */
|
103
105
|
grpc_closure post_reclaimer_closure[2];
|
@@ -110,7 +112,7 @@ struct grpc_resource_user {
|
|
110
112
|
grpc_resource_user_link links[GRPC_RULIST_COUNT];
|
111
113
|
|
112
114
|
/* The name of this resource user, for debugging/tracing */
|
113
|
-
char
|
115
|
+
char* name;
|
114
116
|
};
|
115
117
|
|
116
118
|
struct grpc_resource_quota {
|
@@ -123,7 +125,7 @@ struct grpc_resource_quota {
|
|
123
125
|
|
124
126
|
/* Master combiner lock: all activity on a quota executes under this combiner
|
125
127
|
* (so no mutex is needed for this data structure) */
|
126
|
-
grpc_combiner
|
128
|
+
grpc_combiner* combiner;
|
127
129
|
/* Size of the resource quota */
|
128
130
|
int64_t size;
|
129
131
|
/* Amount of free memory in the resource quota */
|
@@ -143,24 +145,27 @@ struct grpc_resource_quota {
|
|
143
145
|
/* This is only really usable for debugging: it's always a stale pointer, but
|
144
146
|
a stale pointer that might just be fresh enough to guide us to where the
|
145
147
|
reclamation system is stuck */
|
146
|
-
grpc_closure
|
147
|
-
grpc_resource_user
|
148
|
+
grpc_closure* debug_only_last_initiated_reclaimer;
|
149
|
+
grpc_resource_user* debug_only_last_reclaimer_resource_user;
|
148
150
|
|
149
151
|
/* Roots of all resource user lists */
|
150
|
-
grpc_resource_user
|
152
|
+
grpc_resource_user* roots[GRPC_RULIST_COUNT];
|
151
153
|
|
152
|
-
char
|
154
|
+
char* name;
|
153
155
|
};
|
154
156
|
|
157
|
+
static void ru_unref_by(grpc_exec_ctx* exec_ctx,
|
158
|
+
grpc_resource_user* resource_user, gpr_atm amount);
|
159
|
+
|
155
160
|
/*******************************************************************************
|
156
161
|
* list management
|
157
162
|
*/
|
158
163
|
|
159
|
-
static void rulist_add_head(grpc_resource_user
|
164
|
+
static void rulist_add_head(grpc_resource_user* resource_user,
|
160
165
|
grpc_rulist list) {
|
161
|
-
grpc_resource_quota
|
162
|
-
grpc_resource_user
|
163
|
-
if (*root ==
|
166
|
+
grpc_resource_quota* resource_quota = resource_user->resource_quota;
|
167
|
+
grpc_resource_user** root = &resource_quota->roots[list];
|
168
|
+
if (*root == nullptr) {
|
164
169
|
*root = resource_user;
|
165
170
|
resource_user->links[list].next = resource_user->links[list].prev =
|
166
171
|
resource_user;
|
@@ -173,11 +178,11 @@ static void rulist_add_head(grpc_resource_user *resource_user,
|
|
173
178
|
}
|
174
179
|
}
|
175
180
|
|
176
|
-
static void rulist_add_tail(grpc_resource_user
|
181
|
+
static void rulist_add_tail(grpc_resource_user* resource_user,
|
177
182
|
grpc_rulist list) {
|
178
|
-
grpc_resource_quota
|
179
|
-
grpc_resource_user
|
180
|
-
if (*root ==
|
183
|
+
grpc_resource_quota* resource_quota = resource_user->resource_quota;
|
184
|
+
grpc_resource_user** root = &resource_quota->roots[list];
|
185
|
+
if (*root == nullptr) {
|
181
186
|
*root = resource_user;
|
182
187
|
resource_user->links[list].next = resource_user->links[list].prev =
|
183
188
|
resource_user;
|
@@ -189,20 +194,20 @@ static void rulist_add_tail(grpc_resource_user *resource_user,
|
|
189
194
|
}
|
190
195
|
}
|
191
196
|
|
192
|
-
static bool rulist_empty(grpc_resource_quota
|
197
|
+
static bool rulist_empty(grpc_resource_quota* resource_quota,
|
193
198
|
grpc_rulist list) {
|
194
|
-
return resource_quota->roots[list] ==
|
199
|
+
return resource_quota->roots[list] == nullptr;
|
195
200
|
}
|
196
201
|
|
197
|
-
static grpc_resource_user
|
202
|
+
static grpc_resource_user* rulist_pop_head(grpc_resource_quota* resource_quota,
|
198
203
|
grpc_rulist list) {
|
199
|
-
grpc_resource_user
|
200
|
-
grpc_resource_user
|
201
|
-
if (resource_user ==
|
202
|
-
return
|
204
|
+
grpc_resource_user** root = &resource_quota->roots[list];
|
205
|
+
grpc_resource_user* resource_user = *root;
|
206
|
+
if (resource_user == nullptr) {
|
207
|
+
return nullptr;
|
203
208
|
}
|
204
209
|
if (resource_user->links[list].next == resource_user) {
|
205
|
-
*root =
|
210
|
+
*root = nullptr;
|
206
211
|
} else {
|
207
212
|
resource_user->links[list].next->links[list].prev =
|
208
213
|
resource_user->links[list].prev;
|
@@ -210,39 +215,39 @@ static grpc_resource_user *rulist_pop_head(grpc_resource_quota *resource_quota,
|
|
210
215
|
resource_user->links[list].next;
|
211
216
|
*root = resource_user->links[list].next;
|
212
217
|
}
|
213
|
-
resource_user->links[list].next = resource_user->links[list].prev =
|
218
|
+
resource_user->links[list].next = resource_user->links[list].prev = nullptr;
|
214
219
|
return resource_user;
|
215
220
|
}
|
216
221
|
|
217
|
-
static void rulist_remove(grpc_resource_user
|
218
|
-
if (resource_user->links[list].next ==
|
219
|
-
grpc_resource_quota
|
222
|
+
static void rulist_remove(grpc_resource_user* resource_user, grpc_rulist list) {
|
223
|
+
if (resource_user->links[list].next == nullptr) return;
|
224
|
+
grpc_resource_quota* resource_quota = resource_user->resource_quota;
|
220
225
|
if (resource_quota->roots[list] == resource_user) {
|
221
226
|
resource_quota->roots[list] = resource_user->links[list].next;
|
222
227
|
if (resource_quota->roots[list] == resource_user) {
|
223
|
-
resource_quota->roots[list] =
|
228
|
+
resource_quota->roots[list] = nullptr;
|
224
229
|
}
|
225
230
|
}
|
226
231
|
resource_user->links[list].next->links[list].prev =
|
227
232
|
resource_user->links[list].prev;
|
228
233
|
resource_user->links[list].prev->links[list].next =
|
229
234
|
resource_user->links[list].next;
|
230
|
-
resource_user->links[list].next = resource_user->links[list].prev =
|
235
|
+
resource_user->links[list].next = resource_user->links[list].prev = nullptr;
|
231
236
|
}
|
232
237
|
|
233
238
|
/*******************************************************************************
|
234
239
|
* resource quota state machine
|
235
240
|
*/
|
236
241
|
|
237
|
-
static bool rq_alloc(grpc_exec_ctx
|
238
|
-
grpc_resource_quota
|
242
|
+
static bool rq_alloc(grpc_exec_ctx* exec_ctx,
|
243
|
+
grpc_resource_quota* resource_quota);
|
239
244
|
static bool rq_reclaim_from_per_user_free_pool(
|
240
|
-
grpc_exec_ctx
|
241
|
-
static bool rq_reclaim(grpc_exec_ctx
|
242
|
-
grpc_resource_quota
|
245
|
+
grpc_exec_ctx* exec_ctx, grpc_resource_quota* resource_quota);
|
246
|
+
static bool rq_reclaim(grpc_exec_ctx* exec_ctx,
|
247
|
+
grpc_resource_quota* resource_quota, bool destructive);
|
243
248
|
|
244
|
-
static void rq_step(grpc_exec_ctx
|
245
|
-
grpc_resource_quota
|
249
|
+
static void rq_step(grpc_exec_ctx* exec_ctx, void* rq, grpc_error* error) {
|
250
|
+
grpc_resource_quota* resource_quota = (grpc_resource_quota*)rq;
|
246
251
|
resource_quota->step_scheduled = false;
|
247
252
|
do {
|
248
253
|
if (rq_alloc(exec_ctx, resource_quota)) goto done;
|
@@ -256,8 +261,8 @@ done:
|
|
256
261
|
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
257
262
|
}
|
258
263
|
|
259
|
-
static void rq_step_sched(grpc_exec_ctx
|
260
|
-
grpc_resource_quota
|
264
|
+
static void rq_step_sched(grpc_exec_ctx* exec_ctx,
|
265
|
+
grpc_resource_quota* resource_quota) {
|
261
266
|
if (resource_quota->step_scheduled) return;
|
262
267
|
resource_quota->step_scheduled = true;
|
263
268
|
grpc_resource_quota_ref_internal(resource_quota);
|
@@ -267,13 +272,12 @@ static void rq_step_sched(grpc_exec_ctx *exec_ctx,
|
|
267
272
|
|
268
273
|
/* update the atomically available resource estimate - use no barriers since
|
269
274
|
timeliness of delivery really doesn't matter much */
|
270
|
-
static void rq_update_estimate(grpc_resource_quota
|
275
|
+
static void rq_update_estimate(grpc_resource_quota* resource_quota) {
|
271
276
|
gpr_atm memory_usage_estimation = MEMORY_USAGE_ESTIMATION_MAX;
|
272
277
|
if (resource_quota->size != 0) {
|
273
278
|
memory_usage_estimation =
|
274
|
-
GPR_CLAMP((gpr_atm)((1.0 -
|
275
|
-
|
276
|
-
((double)resource_quota->size)) *
|
279
|
+
GPR_CLAMP((gpr_atm)((1.0 - ((double)resource_quota->free_pool) /
|
280
|
+
((double)resource_quota->size)) *
|
277
281
|
MEMORY_USAGE_ESTIMATION_MAX),
|
278
282
|
0, MEMORY_USAGE_ESTIMATION_MAX);
|
279
283
|
}
|
@@ -282,31 +286,53 @@ static void rq_update_estimate(grpc_resource_quota *resource_quota) {
|
|
282
286
|
}
|
283
287
|
|
284
288
|
/* returns true if all allocations are completed */
|
285
|
-
static bool rq_alloc(grpc_exec_ctx
|
286
|
-
grpc_resource_quota
|
287
|
-
grpc_resource_user
|
289
|
+
static bool rq_alloc(grpc_exec_ctx* exec_ctx,
|
290
|
+
grpc_resource_quota* resource_quota) {
|
291
|
+
grpc_resource_user* resource_user;
|
288
292
|
while ((resource_user = rulist_pop_head(resource_quota,
|
289
293
|
GRPC_RULIST_AWAITING_ALLOCATION))) {
|
290
294
|
gpr_mu_lock(&resource_user->mu);
|
295
|
+
if (grpc_resource_quota_trace.enabled()) {
|
296
|
+
gpr_log(GPR_DEBUG,
|
297
|
+
"RQ: check allocation for user %p shutdown=%" PRIdPTR
|
298
|
+
" free_pool=%" PRId64,
|
299
|
+
resource_user, gpr_atm_no_barrier_load(&resource_user->shutdown),
|
300
|
+
resource_user->free_pool);
|
301
|
+
}
|
302
|
+
if (gpr_atm_no_barrier_load(&resource_user->shutdown)) {
|
303
|
+
resource_user->allocating = false;
|
304
|
+
grpc_closure_list_fail_all(
|
305
|
+
&resource_user->on_allocated,
|
306
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource user shutdown"));
|
307
|
+
int64_t aborted_allocations = resource_user->outstanding_allocations;
|
308
|
+
resource_user->outstanding_allocations = 0;
|
309
|
+
resource_user->free_pool += aborted_allocations;
|
310
|
+
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &resource_user->on_allocated);
|
311
|
+
gpr_mu_unlock(&resource_user->mu);
|
312
|
+
ru_unref_by(exec_ctx, resource_user, (gpr_atm)aborted_allocations);
|
313
|
+
continue;
|
314
|
+
}
|
291
315
|
if (resource_user->free_pool < 0 &&
|
292
316
|
-resource_user->free_pool <= resource_quota->free_pool) {
|
293
317
|
int64_t amt = -resource_user->free_pool;
|
294
318
|
resource_user->free_pool = 0;
|
295
319
|
resource_quota->free_pool -= amt;
|
296
320
|
rq_update_estimate(resource_quota);
|
297
|
-
if (
|
298
|
-
gpr_log(GPR_DEBUG,
|
299
|
-
|
321
|
+
if (grpc_resource_quota_trace.enabled()) {
|
322
|
+
gpr_log(GPR_DEBUG,
|
323
|
+
"RQ %s %s: grant alloc %" PRId64
|
324
|
+
" bytes; rq_free_pool -> %" PRId64,
|
300
325
|
resource_quota->name, resource_user->name, amt,
|
301
326
|
resource_quota->free_pool);
|
302
327
|
}
|
303
|
-
} else if (
|
328
|
+
} else if (grpc_resource_quota_trace.enabled() &&
|
304
329
|
resource_user->free_pool >= 0) {
|
305
330
|
gpr_log(GPR_DEBUG, "RQ %s %s: discard already satisfied alloc request",
|
306
331
|
resource_quota->name, resource_user->name);
|
307
332
|
}
|
308
333
|
if (resource_user->free_pool >= 0) {
|
309
334
|
resource_user->allocating = false;
|
335
|
+
resource_user->outstanding_allocations = 0;
|
310
336
|
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &resource_user->on_allocated);
|
311
337
|
gpr_mu_unlock(&resource_user->mu);
|
312
338
|
} else {
|
@@ -320,8 +346,8 @@ static bool rq_alloc(grpc_exec_ctx *exec_ctx,
|
|
320
346
|
|
321
347
|
/* returns true if any memory could be reclaimed from buffers */
|
322
348
|
static bool rq_reclaim_from_per_user_free_pool(
|
323
|
-
grpc_exec_ctx
|
324
|
-
grpc_resource_user
|
349
|
+
grpc_exec_ctx* exec_ctx, grpc_resource_quota* resource_quota) {
|
350
|
+
grpc_resource_user* resource_user;
|
325
351
|
while ((resource_user = rulist_pop_head(resource_quota,
|
326
352
|
GRPC_RULIST_NON_EMPTY_FREE_POOL))) {
|
327
353
|
gpr_mu_lock(&resource_user->mu);
|
@@ -330,9 +356,10 @@ static bool rq_reclaim_from_per_user_free_pool(
|
|
330
356
|
resource_user->free_pool = 0;
|
331
357
|
resource_quota->free_pool += amt;
|
332
358
|
rq_update_estimate(resource_quota);
|
333
|
-
if (
|
334
|
-
gpr_log(GPR_DEBUG,
|
335
|
-
|
359
|
+
if (grpc_resource_quota_trace.enabled()) {
|
360
|
+
gpr_log(GPR_DEBUG,
|
361
|
+
"RQ %s %s: reclaim_from_per_user_free_pool %" PRId64
|
362
|
+
" bytes; rq_free_pool -> %" PRId64,
|
336
363
|
resource_quota->name, resource_user->name, amt,
|
337
364
|
resource_quota->free_pool);
|
338
365
|
}
|
@@ -346,25 +373,25 @@ static bool rq_reclaim_from_per_user_free_pool(
|
|
346
373
|
}
|
347
374
|
|
348
375
|
/* returns true if reclamation is proceeding */
|
349
|
-
static bool rq_reclaim(grpc_exec_ctx
|
350
|
-
grpc_resource_quota
|
376
|
+
static bool rq_reclaim(grpc_exec_ctx* exec_ctx,
|
377
|
+
grpc_resource_quota* resource_quota, bool destructive) {
|
351
378
|
if (resource_quota->reclaiming) return true;
|
352
379
|
grpc_rulist list = destructive ? GRPC_RULIST_RECLAIMER_DESTRUCTIVE
|
353
380
|
: GRPC_RULIST_RECLAIMER_BENIGN;
|
354
|
-
grpc_resource_user
|
355
|
-
if (resource_user ==
|
356
|
-
if (
|
381
|
+
grpc_resource_user* resource_user = rulist_pop_head(resource_quota, list);
|
382
|
+
if (resource_user == nullptr) return false;
|
383
|
+
if (grpc_resource_quota_trace.enabled()) {
|
357
384
|
gpr_log(GPR_DEBUG, "RQ %s %s: initiate %s reclamation",
|
358
385
|
resource_quota->name, resource_user->name,
|
359
386
|
destructive ? "destructive" : "benign");
|
360
387
|
}
|
361
388
|
resource_quota->reclaiming = true;
|
362
389
|
grpc_resource_quota_ref_internal(resource_quota);
|
363
|
-
grpc_closure
|
390
|
+
grpc_closure* c = resource_user->reclaimers[destructive];
|
364
391
|
GPR_ASSERT(c);
|
365
392
|
resource_quota->debug_only_last_reclaimer_resource_user = resource_user;
|
366
393
|
resource_quota->debug_only_last_initiated_reclaimer = c;
|
367
|
-
resource_user->reclaimers[destructive] =
|
394
|
+
resource_user->reclaimers[destructive] = nullptr;
|
368
395
|
GRPC_CLOSURE_RUN(exec_ctx, c, GRPC_ERROR_NONE);
|
369
396
|
return true;
|
370
397
|
}
|
@@ -376,17 +403,17 @@ static bool rq_reclaim(grpc_exec_ctx *exec_ctx,
|
|
376
403
|
typedef struct {
|
377
404
|
grpc_slice_refcount base;
|
378
405
|
gpr_refcount refs;
|
379
|
-
grpc_resource_user
|
406
|
+
grpc_resource_user* resource_user;
|
380
407
|
size_t size;
|
381
408
|
} ru_slice_refcount;
|
382
409
|
|
383
|
-
static void ru_slice_ref(void
|
384
|
-
ru_slice_refcount
|
410
|
+
static void ru_slice_ref(void* p) {
|
411
|
+
ru_slice_refcount* rc = (ru_slice_refcount*)p;
|
385
412
|
gpr_ref(&rc->refs);
|
386
413
|
}
|
387
414
|
|
388
|
-
static void ru_slice_unref(grpc_exec_ctx
|
389
|
-
ru_slice_refcount
|
415
|
+
static void ru_slice_unref(grpc_exec_ctx* exec_ctx, void* p) {
|
416
|
+
ru_slice_refcount* rc = (ru_slice_refcount*)p;
|
390
417
|
if (gpr_unref(&rc->refs)) {
|
391
418
|
grpc_resource_user_free(exec_ctx, rc->resource_user, rc->size);
|
392
419
|
gpr_free(rc);
|
@@ -397,10 +424,10 @@ static const grpc_slice_refcount_vtable ru_slice_vtable = {
|
|
397
424
|
ru_slice_ref, ru_slice_unref, grpc_slice_default_eq_impl,
|
398
425
|
grpc_slice_default_hash_impl};
|
399
426
|
|
400
|
-
static grpc_slice ru_slice_create(grpc_resource_user
|
427
|
+
static grpc_slice ru_slice_create(grpc_resource_user* resource_user,
|
401
428
|
size_t size) {
|
402
|
-
ru_slice_refcount
|
403
|
-
(ru_slice_refcount
|
429
|
+
ru_slice_refcount* rc =
|
430
|
+
(ru_slice_refcount*)gpr_malloc(sizeof(ru_slice_refcount) + size);
|
404
431
|
rc->base.vtable = &ru_slice_vtable;
|
405
432
|
rc->base.sub_refcount = &rc->base;
|
406
433
|
gpr_ref_init(&rc->refs, 1);
|
@@ -408,7 +435,7 @@ static grpc_slice ru_slice_create(grpc_resource_user *resource_user,
|
|
408
435
|
rc->size = size;
|
409
436
|
grpc_slice slice;
|
410
437
|
slice.refcount = &rc->base;
|
411
|
-
slice.data.refcounted.bytes = (uint8_t
|
438
|
+
slice.data.refcounted.bytes = (uint8_t*)(rc + 1);
|
412
439
|
slice.data.refcounted.length = size;
|
413
440
|
return slice;
|
414
441
|
}
|
@@ -418,8 +445,8 @@ static grpc_slice ru_slice_create(grpc_resource_user *resource_user,
|
|
418
445
|
* the combiner
|
419
446
|
*/
|
420
447
|
|
421
|
-
static void ru_allocate(grpc_exec_ctx
|
422
|
-
grpc_resource_user
|
448
|
+
static void ru_allocate(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) {
|
449
|
+
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
423
450
|
if (rulist_empty(resource_user->resource_quota,
|
424
451
|
GRPC_RULIST_AWAITING_ALLOCATION)) {
|
425
452
|
rq_step_sched(exec_ctx, resource_user->resource_quota);
|
@@ -427,9 +454,9 @@ static void ru_allocate(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) {
|
|
427
454
|
rulist_add_tail(resource_user, GRPC_RULIST_AWAITING_ALLOCATION);
|
428
455
|
}
|
429
456
|
|
430
|
-
static void ru_add_to_free_pool(grpc_exec_ctx
|
431
|
-
grpc_error
|
432
|
-
grpc_resource_user
|
457
|
+
static void ru_add_to_free_pool(grpc_exec_ctx* exec_ctx, void* ru,
|
458
|
+
grpc_error* error) {
|
459
|
+
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
433
460
|
if (!rulist_empty(resource_user->resource_quota,
|
434
461
|
GRPC_RULIST_AWAITING_ALLOCATION) &&
|
435
462
|
rulist_empty(resource_user->resource_quota,
|
@@ -439,13 +466,13 @@ static void ru_add_to_free_pool(grpc_exec_ctx *exec_ctx, void *ru,
|
|
439
466
|
rulist_add_tail(resource_user, GRPC_RULIST_NON_EMPTY_FREE_POOL);
|
440
467
|
}
|
441
468
|
|
442
|
-
static bool ru_post_reclaimer(grpc_exec_ctx
|
443
|
-
grpc_resource_user
|
469
|
+
static bool ru_post_reclaimer(grpc_exec_ctx* exec_ctx,
|
470
|
+
grpc_resource_user* resource_user,
|
444
471
|
bool destructive) {
|
445
|
-
grpc_closure
|
446
|
-
GPR_ASSERT(closure !=
|
447
|
-
resource_user->new_reclaimers[destructive] =
|
448
|
-
GPR_ASSERT(resource_user->reclaimers[destructive] ==
|
472
|
+
grpc_closure* closure = resource_user->new_reclaimers[destructive];
|
473
|
+
GPR_ASSERT(closure != nullptr);
|
474
|
+
resource_user->new_reclaimers[destructive] = nullptr;
|
475
|
+
GPR_ASSERT(resource_user->reclaimers[destructive] == nullptr);
|
449
476
|
if (gpr_atm_acq_load(&resource_user->shutdown) > 0) {
|
450
477
|
GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CANCELLED);
|
451
478
|
return false;
|
@@ -454,9 +481,9 @@ static bool ru_post_reclaimer(grpc_exec_ctx *exec_ctx,
|
|
454
481
|
return true;
|
455
482
|
}
|
456
483
|
|
457
|
-
static void ru_post_benign_reclaimer(grpc_exec_ctx
|
458
|
-
grpc_error
|
459
|
-
grpc_resource_user
|
484
|
+
static void ru_post_benign_reclaimer(grpc_exec_ctx* exec_ctx, void* ru,
|
485
|
+
grpc_error* error) {
|
486
|
+
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
460
487
|
if (!ru_post_reclaimer(exec_ctx, resource_user, false)) return;
|
461
488
|
if (!rulist_empty(resource_user->resource_quota,
|
462
489
|
GRPC_RULIST_AWAITING_ALLOCATION) &&
|
@@ -469,9 +496,9 @@ static void ru_post_benign_reclaimer(grpc_exec_ctx *exec_ctx, void *ru,
|
|
469
496
|
rulist_add_tail(resource_user, GRPC_RULIST_RECLAIMER_BENIGN);
|
470
497
|
}
|
471
498
|
|
472
|
-
static void ru_post_destructive_reclaimer(grpc_exec_ctx
|
473
|
-
grpc_error
|
474
|
-
grpc_resource_user
|
499
|
+
static void ru_post_destructive_reclaimer(grpc_exec_ctx* exec_ctx, void* ru,
|
500
|
+
grpc_error* error) {
|
501
|
+
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
475
502
|
if (!ru_post_reclaimer(exec_ctx, resource_user, true)) return;
|
476
503
|
if (!rulist_empty(resource_user->resource_quota,
|
477
504
|
GRPC_RULIST_AWAITING_ALLOCATION) &&
|
@@ -486,20 +513,26 @@ static void ru_post_destructive_reclaimer(grpc_exec_ctx *exec_ctx, void *ru,
|
|
486
513
|
rulist_add_tail(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE);
|
487
514
|
}
|
488
515
|
|
489
|
-
static void ru_shutdown(grpc_exec_ctx
|
490
|
-
|
516
|
+
static void ru_shutdown(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) {
|
517
|
+
if (grpc_resource_quota_trace.enabled()) {
|
518
|
+
gpr_log(GPR_DEBUG, "RU shutdown %p", ru);
|
519
|
+
}
|
520
|
+
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
491
521
|
GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[0],
|
492
522
|
GRPC_ERROR_CANCELLED);
|
493
523
|
GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[1],
|
494
524
|
GRPC_ERROR_CANCELLED);
|
495
|
-
resource_user->reclaimers[0] =
|
496
|
-
resource_user->reclaimers[1] =
|
525
|
+
resource_user->reclaimers[0] = nullptr;
|
526
|
+
resource_user->reclaimers[1] = nullptr;
|
497
527
|
rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_BENIGN);
|
498
528
|
rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE);
|
529
|
+
if (resource_user->allocating) {
|
530
|
+
rq_step_sched(exec_ctx, resource_user->resource_quota);
|
531
|
+
}
|
499
532
|
}
|
500
533
|
|
501
|
-
static void ru_destroy(grpc_exec_ctx
|
502
|
-
grpc_resource_user
|
534
|
+
static void ru_destroy(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) {
|
535
|
+
grpc_resource_user* resource_user = (grpc_resource_user*)ru;
|
503
536
|
GPR_ASSERT(gpr_atm_no_barrier_load(&resource_user->refs) == 0);
|
504
537
|
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
|
505
538
|
rulist_remove(resource_user, (grpc_rulist)i);
|
@@ -518,10 +551,10 @@ static void ru_destroy(grpc_exec_ctx *exec_ctx, void *ru, grpc_error *error) {
|
|
518
551
|
gpr_free(resource_user);
|
519
552
|
}
|
520
553
|
|
521
|
-
static void ru_allocated_slices(grpc_exec_ctx
|
522
|
-
grpc_error
|
523
|
-
grpc_resource_user_slice_allocator
|
524
|
-
(grpc_resource_user_slice_allocator
|
554
|
+
static void ru_allocated_slices(grpc_exec_ctx* exec_ctx, void* arg,
|
555
|
+
grpc_error* error) {
|
556
|
+
grpc_resource_user_slice_allocator* slice_allocator =
|
557
|
+
(grpc_resource_user_slice_allocator*)arg;
|
525
558
|
if (error == GRPC_ERROR_NONE) {
|
526
559
|
for (size_t i = 0; i < slice_allocator->count; i++) {
|
527
560
|
grpc_slice_buffer_add_indexed(
|
@@ -539,12 +572,12 @@ static void ru_allocated_slices(grpc_exec_ctx *exec_ctx, void *arg,
|
|
539
572
|
|
540
573
|
typedef struct {
|
541
574
|
int64_t size;
|
542
|
-
grpc_resource_quota
|
575
|
+
grpc_resource_quota* resource_quota;
|
543
576
|
grpc_closure closure;
|
544
577
|
} rq_resize_args;
|
545
578
|
|
546
|
-
static void rq_resize(grpc_exec_ctx
|
547
|
-
rq_resize_args
|
579
|
+
static void rq_resize(grpc_exec_ctx* exec_ctx, void* args, grpc_error* error) {
|
580
|
+
rq_resize_args* a = (rq_resize_args*)args;
|
548
581
|
int64_t delta = a->size - a->resource_quota->size;
|
549
582
|
a->resource_quota->size += delta;
|
550
583
|
a->resource_quota->free_pool += delta;
|
@@ -554,9 +587,9 @@ static void rq_resize(grpc_exec_ctx *exec_ctx, void *args, grpc_error *error) {
|
|
554
587
|
gpr_free(a);
|
555
588
|
}
|
556
589
|
|
557
|
-
static void rq_reclamation_done(grpc_exec_ctx
|
558
|
-
grpc_error
|
559
|
-
grpc_resource_quota
|
590
|
+
static void rq_reclamation_done(grpc_exec_ctx* exec_ctx, void* rq,
|
591
|
+
grpc_error* error) {
|
592
|
+
grpc_resource_quota* resource_quota = (grpc_resource_quota*)rq;
|
560
593
|
resource_quota->reclaiming = false;
|
561
594
|
rq_step_sched(exec_ctx, resource_quota);
|
562
595
|
grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
|
@@ -567,9 +600,9 @@ static void rq_reclamation_done(grpc_exec_ctx *exec_ctx, void *rq,
|
|
567
600
|
*/
|
568
601
|
|
569
602
|
/* Public API */
|
570
|
-
grpc_resource_quota
|
571
|
-
grpc_resource_quota
|
572
|
-
(grpc_resource_quota
|
603
|
+
grpc_resource_quota* grpc_resource_quota_create(const char* name) {
|
604
|
+
grpc_resource_quota* resource_quota =
|
605
|
+
(grpc_resource_quota*)gpr_malloc(sizeof(*resource_quota));
|
573
606
|
gpr_ref_init(&resource_quota->refs, 1);
|
574
607
|
resource_quota->combiner = grpc_combiner_create();
|
575
608
|
resource_quota->free_pool = INT64_MAX;
|
@@ -578,7 +611,7 @@ grpc_resource_quota *grpc_resource_quota_create(const char *name) {
|
|
578
611
|
resource_quota->step_scheduled = false;
|
579
612
|
resource_quota->reclaiming = false;
|
580
613
|
gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation, 0);
|
581
|
-
if (name !=
|
614
|
+
if (name != nullptr) {
|
582
615
|
resource_quota->name = gpr_strdup(name);
|
583
616
|
} else {
|
584
617
|
gpr_asprintf(&resource_quota->name, "anonymous_pool_%" PRIxPTR,
|
@@ -590,13 +623,13 @@ grpc_resource_quota *grpc_resource_quota_create(const char *name) {
|
|
590
623
|
rq_reclamation_done, resource_quota,
|
591
624
|
grpc_combiner_scheduler(resource_quota->combiner));
|
592
625
|
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
|
593
|
-
resource_quota->roots[i] =
|
626
|
+
resource_quota->roots[i] = nullptr;
|
594
627
|
}
|
595
628
|
return resource_quota;
|
596
629
|
}
|
597
630
|
|
598
|
-
void grpc_resource_quota_unref_internal(grpc_exec_ctx
|
599
|
-
grpc_resource_quota
|
631
|
+
void grpc_resource_quota_unref_internal(grpc_exec_ctx* exec_ctx,
|
632
|
+
grpc_resource_quota* resource_quota) {
|
600
633
|
if (gpr_unref(&resource_quota->refs)) {
|
601
634
|
GRPC_COMBINER_UNREF(exec_ctx, resource_quota->combiner, "resource_quota");
|
602
635
|
gpr_free(resource_quota->name);
|
@@ -605,35 +638,35 @@ void grpc_resource_quota_unref_internal(grpc_exec_ctx *exec_ctx,
|
|
605
638
|
}
|
606
639
|
|
607
640
|
/* Public API */
|
608
|
-
void grpc_resource_quota_unref(grpc_resource_quota
|
641
|
+
void grpc_resource_quota_unref(grpc_resource_quota* resource_quota) {
|
609
642
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
610
643
|
grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
|
611
644
|
grpc_exec_ctx_finish(&exec_ctx);
|
612
645
|
}
|
613
646
|
|
614
|
-
grpc_resource_quota
|
615
|
-
grpc_resource_quota
|
647
|
+
grpc_resource_quota* grpc_resource_quota_ref_internal(
|
648
|
+
grpc_resource_quota* resource_quota) {
|
616
649
|
gpr_ref(&resource_quota->refs);
|
617
650
|
return resource_quota;
|
618
651
|
}
|
619
652
|
|
620
653
|
/* Public API */
|
621
|
-
void grpc_resource_quota_ref(grpc_resource_quota
|
654
|
+
void grpc_resource_quota_ref(grpc_resource_quota* resource_quota) {
|
622
655
|
grpc_resource_quota_ref_internal(resource_quota);
|
623
656
|
}
|
624
657
|
|
625
658
|
double grpc_resource_quota_get_memory_pressure(
|
626
|
-
grpc_resource_quota
|
659
|
+
grpc_resource_quota* resource_quota) {
|
627
660
|
return ((double)(gpr_atm_no_barrier_load(
|
628
661
|
&resource_quota->memory_usage_estimation))) /
|
629
662
|
((double)MEMORY_USAGE_ESTIMATION_MAX);
|
630
663
|
}
|
631
664
|
|
632
665
|
/* Public API */
|
633
|
-
void grpc_resource_quota_resize(grpc_resource_quota
|
666
|
+
void grpc_resource_quota_resize(grpc_resource_quota* resource_quota,
|
634
667
|
size_t size) {
|
635
668
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
636
|
-
rq_resize_args
|
669
|
+
rq_resize_args* a = (rq_resize_args*)gpr_malloc(sizeof(*a));
|
637
670
|
a->resource_quota = grpc_resource_quota_ref_internal(resource_quota);
|
638
671
|
a->size = (int64_t)size;
|
639
672
|
gpr_atm_no_barrier_store(&resource_quota->last_size,
|
@@ -643,7 +676,7 @@ void grpc_resource_quota_resize(grpc_resource_quota *resource_quota,
|
|
643
676
|
grpc_exec_ctx_finish(&exec_ctx);
|
644
677
|
}
|
645
678
|
|
646
|
-
size_t grpc_resource_quota_peek_size(grpc_resource_quota
|
679
|
+
size_t grpc_resource_quota_peek_size(grpc_resource_quota* resource_quota) {
|
647
680
|
return (size_t)gpr_atm_no_barrier_load(&resource_quota->last_size);
|
648
681
|
}
|
649
682
|
|
@@ -651,33 +684,33 @@ size_t grpc_resource_quota_peek_size(grpc_resource_quota *resource_quota) {
|
|
651
684
|
* grpc_resource_user channel args api
|
652
685
|
*/
|
653
686
|
|
654
|
-
grpc_resource_quota
|
655
|
-
const grpc_channel_args
|
687
|
+
grpc_resource_quota* grpc_resource_quota_from_channel_args(
|
688
|
+
const grpc_channel_args* channel_args) {
|
656
689
|
for (size_t i = 0; i < channel_args->num_args; i++) {
|
657
690
|
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
|
658
691
|
if (channel_args->args[i].type == GRPC_ARG_POINTER) {
|
659
692
|
return grpc_resource_quota_ref_internal(
|
660
|
-
(grpc_resource_quota
|
693
|
+
(grpc_resource_quota*)channel_args->args[i].value.pointer.p);
|
661
694
|
} else {
|
662
695
|
gpr_log(GPR_DEBUG, GRPC_ARG_RESOURCE_QUOTA " should be a pointer");
|
663
696
|
}
|
664
697
|
}
|
665
698
|
}
|
666
|
-
return grpc_resource_quota_create(
|
699
|
+
return grpc_resource_quota_create(nullptr);
|
667
700
|
}
|
668
701
|
|
669
|
-
static void
|
670
|
-
grpc_resource_quota_ref((grpc_resource_quota
|
702
|
+
static void* rq_copy(void* rq) {
|
703
|
+
grpc_resource_quota_ref((grpc_resource_quota*)rq);
|
671
704
|
return rq;
|
672
705
|
}
|
673
706
|
|
674
|
-
static void rq_destroy(grpc_exec_ctx
|
675
|
-
grpc_resource_quota_unref_internal(exec_ctx, (grpc_resource_quota
|
707
|
+
static void rq_destroy(grpc_exec_ctx* exec_ctx, void* rq) {
|
708
|
+
grpc_resource_quota_unref_internal(exec_ctx, (grpc_resource_quota*)rq);
|
676
709
|
}
|
677
710
|
|
678
|
-
static int rq_cmp(void
|
711
|
+
static int rq_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
|
679
712
|
|
680
|
-
const grpc_arg_pointer_vtable
|
713
|
+
const grpc_arg_pointer_vtable* grpc_resource_quota_arg_vtable(void) {
|
681
714
|
static const grpc_arg_pointer_vtable vtable = {rq_copy, rq_destroy, rq_cmp};
|
682
715
|
return &vtable;
|
683
716
|
}
|
@@ -686,10 +719,10 @@ const grpc_arg_pointer_vtable *grpc_resource_quota_arg_vtable(void) {
|
|
686
719
|
* grpc_resource_user api
|
687
720
|
*/
|
688
721
|
|
689
|
-
grpc_resource_user
|
690
|
-
grpc_resource_quota
|
691
|
-
grpc_resource_user
|
692
|
-
(grpc_resource_user
|
722
|
+
grpc_resource_user* grpc_resource_user_create(
|
723
|
+
grpc_resource_quota* resource_quota, const char* name) {
|
724
|
+
grpc_resource_user* resource_user =
|
725
|
+
(grpc_resource_user*)gpr_malloc(sizeof(*resource_user));
|
693
726
|
resource_user->resource_quota =
|
694
727
|
grpc_resource_quota_ref_internal(resource_quota);
|
695
728
|
GRPC_CLOSURE_INIT(&resource_user->allocate_closure, &ru_allocate,
|
@@ -713,14 +746,15 @@ grpc_resource_user *grpc_resource_user_create(
|
|
713
746
|
grpc_closure_list_init(&resource_user->on_allocated);
|
714
747
|
resource_user->allocating = false;
|
715
748
|
resource_user->added_to_free_pool = false;
|
716
|
-
resource_user->reclaimers[0] =
|
717
|
-
resource_user->reclaimers[1] =
|
718
|
-
resource_user->new_reclaimers[0] =
|
719
|
-
resource_user->new_reclaimers[1] =
|
749
|
+
resource_user->reclaimers[0] = nullptr;
|
750
|
+
resource_user->reclaimers[1] = nullptr;
|
751
|
+
resource_user->new_reclaimers[0] = nullptr;
|
752
|
+
resource_user->new_reclaimers[1] = nullptr;
|
753
|
+
resource_user->outstanding_allocations = 0;
|
720
754
|
for (int i = 0; i < GRPC_RULIST_COUNT; i++) {
|
721
|
-
resource_user->links[i].next = resource_user->links[i].prev =
|
755
|
+
resource_user->links[i].next = resource_user->links[i].prev = nullptr;
|
722
756
|
}
|
723
|
-
if (name !=
|
757
|
+
if (name != nullptr) {
|
724
758
|
resource_user->name = gpr_strdup(name);
|
725
759
|
} else {
|
726
760
|
gpr_asprintf(&resource_user->name, "anonymous_resource_user_%" PRIxPTR,
|
@@ -729,18 +763,18 @@ grpc_resource_user *grpc_resource_user_create(
|
|
729
763
|
return resource_user;
|
730
764
|
}
|
731
765
|
|
732
|
-
grpc_resource_quota
|
733
|
-
grpc_resource_user
|
766
|
+
grpc_resource_quota* grpc_resource_user_quota(
|
767
|
+
grpc_resource_user* resource_user) {
|
734
768
|
return resource_user->resource_quota;
|
735
769
|
}
|
736
770
|
|
737
|
-
static void ru_ref_by(grpc_resource_user
|
771
|
+
static void ru_ref_by(grpc_resource_user* resource_user, gpr_atm amount) {
|
738
772
|
GPR_ASSERT(amount > 0);
|
739
773
|
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&resource_user->refs, amount) != 0);
|
740
774
|
}
|
741
775
|
|
742
|
-
static void ru_unref_by(grpc_exec_ctx
|
743
|
-
grpc_resource_user
|
776
|
+
static void ru_unref_by(grpc_exec_ctx* exec_ctx,
|
777
|
+
grpc_resource_user* resource_user, gpr_atm amount) {
|
744
778
|
GPR_ASSERT(amount > 0);
|
745
779
|
gpr_atm old = gpr_atm_full_fetch_add(&resource_user->refs, -amount);
|
746
780
|
GPR_ASSERT(old >= amount);
|
@@ -750,17 +784,17 @@ static void ru_unref_by(grpc_exec_ctx *exec_ctx,
|
|
750
784
|
}
|
751
785
|
}
|
752
786
|
|
753
|
-
void grpc_resource_user_ref(grpc_resource_user
|
787
|
+
void grpc_resource_user_ref(grpc_resource_user* resource_user) {
|
754
788
|
ru_ref_by(resource_user, 1);
|
755
789
|
}
|
756
790
|
|
757
|
-
void grpc_resource_user_unref(grpc_exec_ctx
|
758
|
-
grpc_resource_user
|
791
|
+
void grpc_resource_user_unref(grpc_exec_ctx* exec_ctx,
|
792
|
+
grpc_resource_user* resource_user) {
|
759
793
|
ru_unref_by(exec_ctx, resource_user, 1);
|
760
794
|
}
|
761
795
|
|
762
|
-
void grpc_resource_user_shutdown(grpc_exec_ctx
|
763
|
-
grpc_resource_user
|
796
|
+
void grpc_resource_user_shutdown(grpc_exec_ctx* exec_ctx,
|
797
|
+
grpc_resource_user* resource_user) {
|
764
798
|
if (gpr_atm_full_fetch_add(&resource_user->shutdown, 1) == 0) {
|
765
799
|
GRPC_CLOSURE_SCHED(
|
766
800
|
exec_ctx,
|
@@ -771,13 +805,14 @@ void grpc_resource_user_shutdown(grpc_exec_ctx *exec_ctx,
|
|
771
805
|
}
|
772
806
|
}
|
773
807
|
|
774
|
-
void grpc_resource_user_alloc(grpc_exec_ctx
|
775
|
-
grpc_resource_user
|
776
|
-
grpc_closure
|
808
|
+
void grpc_resource_user_alloc(grpc_exec_ctx* exec_ctx,
|
809
|
+
grpc_resource_user* resource_user, size_t size,
|
810
|
+
grpc_closure* optional_on_done) {
|
777
811
|
gpr_mu_lock(&resource_user->mu);
|
778
812
|
ru_ref_by(resource_user, (gpr_atm)size);
|
779
813
|
resource_user->free_pool -= (int64_t)size;
|
780
|
-
|
814
|
+
resource_user->outstanding_allocations += (int64_t)size;
|
815
|
+
if (grpc_resource_quota_trace.enabled()) {
|
781
816
|
gpr_log(GPR_DEBUG, "RQ %s %s: alloc %" PRIdPTR "; free_pool -> %" PRId64,
|
782
817
|
resource_user->resource_quota->name, resource_user->name, size,
|
783
818
|
resource_user->free_pool);
|
@@ -791,17 +826,18 @@ void grpc_resource_user_alloc(grpc_exec_ctx *exec_ctx,
|
|
791
826
|
GRPC_ERROR_NONE);
|
792
827
|
}
|
793
828
|
} else {
|
829
|
+
resource_user->outstanding_allocations -= (int64_t)size;
|
794
830
|
GRPC_CLOSURE_SCHED(exec_ctx, optional_on_done, GRPC_ERROR_NONE);
|
795
831
|
}
|
796
832
|
gpr_mu_unlock(&resource_user->mu);
|
797
833
|
}
|
798
834
|
|
799
|
-
void grpc_resource_user_free(grpc_exec_ctx
|
800
|
-
grpc_resource_user
|
835
|
+
void grpc_resource_user_free(grpc_exec_ctx* exec_ctx,
|
836
|
+
grpc_resource_user* resource_user, size_t size) {
|
801
837
|
gpr_mu_lock(&resource_user->mu);
|
802
838
|
bool was_zero_or_negative = resource_user->free_pool <= 0;
|
803
839
|
resource_user->free_pool += (int64_t)size;
|
804
|
-
if (
|
840
|
+
if (grpc_resource_quota_trace.enabled()) {
|
805
841
|
gpr_log(GPR_DEBUG, "RQ %s %s: free %" PRIdPTR "; free_pool -> %" PRId64,
|
806
842
|
resource_user->resource_quota->name, resource_user->name, size,
|
807
843
|
resource_user->free_pool);
|
@@ -817,20 +853,20 @@ void grpc_resource_user_free(grpc_exec_ctx *exec_ctx,
|
|
817
853
|
ru_unref_by(exec_ctx, resource_user, (gpr_atm)size);
|
818
854
|
}
|
819
855
|
|
820
|
-
void grpc_resource_user_post_reclaimer(grpc_exec_ctx
|
821
|
-
grpc_resource_user
|
856
|
+
void grpc_resource_user_post_reclaimer(grpc_exec_ctx* exec_ctx,
|
857
|
+
grpc_resource_user* resource_user,
|
822
858
|
bool destructive,
|
823
|
-
grpc_closure
|
824
|
-
GPR_ASSERT(resource_user->new_reclaimers[destructive] ==
|
859
|
+
grpc_closure* closure) {
|
860
|
+
GPR_ASSERT(resource_user->new_reclaimers[destructive] == nullptr);
|
825
861
|
resource_user->new_reclaimers[destructive] = closure;
|
826
862
|
GRPC_CLOSURE_SCHED(exec_ctx,
|
827
863
|
&resource_user->post_reclaimer_closure[destructive],
|
828
864
|
GRPC_ERROR_NONE);
|
829
865
|
}
|
830
866
|
|
831
|
-
void grpc_resource_user_finish_reclamation(grpc_exec_ctx
|
832
|
-
grpc_resource_user
|
833
|
-
if (
|
867
|
+
void grpc_resource_user_finish_reclamation(grpc_exec_ctx* exec_ctx,
|
868
|
+
grpc_resource_user* resource_user) {
|
869
|
+
if (grpc_resource_quota_trace.enabled()) {
|
834
870
|
gpr_log(GPR_DEBUG, "RQ %s %s: reclamation complete",
|
835
871
|
resource_user->resource_quota->name, resource_user->name);
|
836
872
|
}
|
@@ -840,8 +876,8 @@ void grpc_resource_user_finish_reclamation(grpc_exec_ctx *exec_ctx,
|
|
840
876
|
}
|
841
877
|
|
842
878
|
void grpc_resource_user_slice_allocator_init(
|
843
|
-
grpc_resource_user_slice_allocator
|
844
|
-
grpc_resource_user
|
879
|
+
grpc_resource_user_slice_allocator* slice_allocator,
|
880
|
+
grpc_resource_user* resource_user, grpc_iomgr_cb_func cb, void* p) {
|
845
881
|
GRPC_CLOSURE_INIT(&slice_allocator->on_allocated, ru_allocated_slices,
|
846
882
|
slice_allocator, grpc_schedule_on_exec_ctx);
|
847
883
|
GRPC_CLOSURE_INIT(&slice_allocator->on_done, cb, p,
|
@@ -850,19 +886,12 @@ void grpc_resource_user_slice_allocator_init(
|
|
850
886
|
}
|
851
887
|
|
852
888
|
void grpc_resource_user_alloc_slices(
|
853
|
-
grpc_exec_ctx
|
854
|
-
grpc_resource_user_slice_allocator
|
855
|
-
size_t count, grpc_slice_buffer
|
889
|
+
grpc_exec_ctx* exec_ctx,
|
890
|
+
grpc_resource_user_slice_allocator* slice_allocator, size_t length,
|
891
|
+
size_t count, grpc_slice_buffer* dest) {
|
856
892
|
slice_allocator->length = length;
|
857
893
|
slice_allocator->count = count;
|
858
894
|
slice_allocator->dest = dest;
|
859
895
|
grpc_resource_user_alloc(exec_ctx, slice_allocator->resource_user,
|
860
896
|
count * length, &slice_allocator->on_allocated);
|
861
897
|
}
|
862
|
-
|
863
|
-
grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx *exec_ctx,
|
864
|
-
grpc_resource_user *resource_user,
|
865
|
-
size_t size) {
|
866
|
-
grpc_resource_user_alloc(exec_ctx, resource_user, size, NULL);
|
867
|
-
return ru_slice_create(resource_user, size);
|
868
|
-
}
|