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
@@ -23,16 +23,44 @@
|
|
23
23
|
#include "src/core/lib/iomgr/ev_posix.h"
|
24
24
|
#include "src/core/lib/iomgr/tcp_client.h"
|
25
25
|
|
26
|
-
|
27
|
-
extern "C" {
|
28
|
-
#endif
|
26
|
+
/* Create an endpoint from a connected grpc_fd.
|
29
27
|
|
28
|
+
fd: a connected FD. Ownership is taken.
|
29
|
+
channel_args: may contain custom settings for the endpoint
|
30
|
+
addr_str: destination address in printable format
|
31
|
+
Returns: a new endpoint
|
32
|
+
*/
|
30
33
|
grpc_endpoint* grpc_tcp_client_create_from_fd(
|
31
|
-
|
32
|
-
const char* addr_str);
|
34
|
+
grpc_fd* fd, const grpc_channel_args* channel_args, const char* addr_str);
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
/* Return a configured, unbound, unconnected TCP client grpc_fd.
|
37
|
+
|
38
|
+
channel_args: may contain custom settings for the fd
|
39
|
+
addr: the destination address
|
40
|
+
mapped_addr: out parameter. addr mapped to an address appropriate to the
|
41
|
+
type of socket FD created. For example, if addr is IPv4 and dual stack
|
42
|
+
sockets are available, mapped_addr will be an IPv4-mapped IPv6 address
|
43
|
+
fdobj: out parameter. The new FD
|
44
|
+
Returns: error, if any. Out parameters are not set on error
|
45
|
+
*/
|
46
|
+
grpc_error* grpc_tcp_client_prepare_fd(const grpc_channel_args* channel_args,
|
47
|
+
const grpc_resolved_address* addr,
|
48
|
+
grpc_resolved_address* mapped_addr,
|
49
|
+
grpc_fd** fdobj);
|
50
|
+
|
51
|
+
/* Connect a configured TCP client grpc_fd.
|
52
|
+
|
53
|
+
interested_parties: a set of pollsets that would be interested in this
|
54
|
+
connection being established (in order to continue their work
|
55
|
+
closure: called when complete. On success, *ep will be set.
|
56
|
+
fdobj: an FD returned from grpc_tcp_client_prepare_fd(). Ownership is taken
|
57
|
+
channel_args: may contain custom settings for the endpoint
|
58
|
+
deadline: connection deadline
|
59
|
+
ep: out parameter. Set before closure is called if successful
|
60
|
+
*/
|
61
|
+
void grpc_tcp_client_create_from_prepared_fd(
|
62
|
+
grpc_pollset_set* interested_parties, grpc_closure* closure, grpc_fd* fdobj,
|
63
|
+
const grpc_channel_args* channel_args, const grpc_resolved_address* addr,
|
64
|
+
grpc_millis deadline, grpc_endpoint** ep);
|
37
65
|
|
38
66
|
#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */
|
@@ -46,17 +46,15 @@ typedef struct grpc_uv_tcp_connect {
|
|
46
46
|
grpc_resource_quota* resource_quota;
|
47
47
|
} grpc_uv_tcp_connect;
|
48
48
|
|
49
|
-
static void uv_tcp_connect_cleanup(
|
50
|
-
|
51
|
-
grpc_resource_quota_unref_internal(exec_ctx, connect->resource_quota);
|
49
|
+
static void uv_tcp_connect_cleanup(grpc_uv_tcp_connect* connect) {
|
50
|
+
grpc_resource_quota_unref_internal(connect->resource_quota);
|
52
51
|
gpr_free(connect->addr_name);
|
53
52
|
gpr_free(connect);
|
54
53
|
}
|
55
54
|
|
56
55
|
static void tcp_close_callback(uv_handle_t* handle) { gpr_free(handle); }
|
57
56
|
|
58
|
-
static void uv_tc_on_alarm(
|
59
|
-
grpc_error* error) {
|
57
|
+
static void uv_tc_on_alarm(void* acp, grpc_error* error) {
|
60
58
|
int done;
|
61
59
|
grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)acp;
|
62
60
|
if (grpc_tcp_trace.enabled()) {
|
@@ -72,17 +70,17 @@ static void uv_tc_on_alarm(grpc_exec_ctx* exec_ctx, void* acp,
|
|
72
70
|
}
|
73
71
|
done = (--connect->refs == 0);
|
74
72
|
if (done) {
|
75
|
-
uv_tcp_connect_cleanup(
|
73
|
+
uv_tcp_connect_cleanup(connect);
|
76
74
|
}
|
77
75
|
}
|
78
76
|
|
79
77
|
static void uv_tc_on_connect(uv_connect_t* req, int status) {
|
80
78
|
grpc_uv_tcp_connect* connect = (grpc_uv_tcp_connect*)req->data;
|
81
|
-
|
79
|
+
grpc_core::ExecCtx exec_ctx;
|
82
80
|
grpc_error* error = GRPC_ERROR_NONE;
|
83
81
|
int done;
|
84
82
|
grpc_closure* closure = connect->closure;
|
85
|
-
grpc_timer_cancel(&
|
83
|
+
grpc_timer_cancel(&connect->alarm);
|
86
84
|
if (status == 0) {
|
87
85
|
*connect->endpoint = grpc_tcp_create(
|
88
86
|
connect->tcp_handle, connect->resource_quota, connect->addr_name);
|
@@ -107,15 +105,13 @@ static void uv_tc_on_connect(uv_connect_t* req, int status) {
|
|
107
105
|
}
|
108
106
|
done = (--connect->refs == 0);
|
109
107
|
if (done) {
|
110
|
-
|
111
|
-
uv_tcp_connect_cleanup(
|
108
|
+
grpc_core::ExecCtx::Get()->Flush();
|
109
|
+
uv_tcp_connect_cleanup(connect);
|
112
110
|
}
|
113
|
-
GRPC_CLOSURE_SCHED(
|
114
|
-
grpc_exec_ctx_finish(&exec_ctx);
|
111
|
+
GRPC_CLOSURE_SCHED(closure, error);
|
115
112
|
}
|
116
113
|
|
117
|
-
static void tcp_client_connect_impl(
|
118
|
-
grpc_closure* closure, grpc_endpoint** ep,
|
114
|
+
static void tcp_client_connect_impl(grpc_closure* closure, grpc_endpoint** ep,
|
119
115
|
grpc_pollset_set* interested_parties,
|
120
116
|
const grpc_channel_args* channel_args,
|
121
117
|
const grpc_resolved_address* resolved_addr,
|
@@ -130,7 +126,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
|
|
130
126
|
if (channel_args != NULL) {
|
131
127
|
for (size_t i = 0; i < channel_args->num_args; i++) {
|
132
128
|
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
|
133
|
-
grpc_resource_quota_unref_internal(
|
129
|
+
grpc_resource_quota_unref_internal(resource_quota);
|
134
130
|
resource_quota = grpc_resource_quota_ref_internal(
|
135
131
|
(grpc_resource_quota*)channel_args->args[i].value.pointer.p);
|
136
132
|
}
|
@@ -157,26 +153,23 @@ static void tcp_client_connect_impl(grpc_exec_ctx* exec_ctx,
|
|
157
153
|
(const struct sockaddr*)resolved_addr->addr, uv_tc_on_connect);
|
158
154
|
GRPC_CLOSURE_INIT(&connect->on_alarm, uv_tc_on_alarm, connect,
|
159
155
|
grpc_schedule_on_exec_ctx);
|
160
|
-
grpc_timer_init(
|
156
|
+
grpc_timer_init(&connect->alarm, deadline, &connect->on_alarm);
|
161
157
|
}
|
162
158
|
|
163
159
|
// overridden by api_fuzzer.c
|
164
|
-
extern "C" {
|
165
160
|
void (*grpc_tcp_client_connect_impl)(
|
166
|
-
|
161
|
+
grpc_closure* closure, grpc_endpoint** ep,
|
167
162
|
grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
|
168
163
|
const grpc_resolved_address* addr,
|
169
164
|
grpc_millis deadline) = tcp_client_connect_impl;
|
170
|
-
}
|
171
165
|
|
172
|
-
void grpc_tcp_client_connect(
|
173
|
-
grpc_endpoint** ep,
|
166
|
+
void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
|
174
167
|
grpc_pollset_set* interested_parties,
|
175
168
|
const grpc_channel_args* channel_args,
|
176
169
|
const grpc_resolved_address* addr,
|
177
170
|
grpc_millis deadline) {
|
178
|
-
grpc_tcp_client_connect_impl(
|
179
|
-
|
171
|
+
grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
|
172
|
+
addr, deadline);
|
180
173
|
}
|
181
174
|
|
182
175
|
#endif /* GRPC_UV */
|
@@ -52,13 +52,12 @@ typedef struct {
|
|
52
52
|
grpc_channel_args* channel_args;
|
53
53
|
} async_connect;
|
54
54
|
|
55
|
-
static void async_connect_unlock_and_cleanup(
|
56
|
-
async_connect* ac,
|
55
|
+
static void async_connect_unlock_and_cleanup(async_connect* ac,
|
57
56
|
grpc_winsocket* socket) {
|
58
57
|
int done = (--ac->refs == 0);
|
59
58
|
gpr_mu_unlock(&ac->mu);
|
60
59
|
if (done) {
|
61
|
-
grpc_channel_args_destroy(
|
60
|
+
grpc_channel_args_destroy(ac->channel_args);
|
62
61
|
gpr_mu_destroy(&ac->mu);
|
63
62
|
gpr_free(ac->addr_name);
|
64
63
|
gpr_free(ac);
|
@@ -66,7 +65,7 @@ static void async_connect_unlock_and_cleanup(grpc_exec_ctx* exec_ctx,
|
|
66
65
|
if (socket != NULL) grpc_winsocket_destroy(socket);
|
67
66
|
}
|
68
67
|
|
69
|
-
static void on_alarm(
|
68
|
+
static void on_alarm(void* acp, grpc_error* error) {
|
70
69
|
async_connect* ac = (async_connect*)acp;
|
71
70
|
gpr_mu_lock(&ac->mu);
|
72
71
|
grpc_winsocket* socket = ac->socket;
|
@@ -74,10 +73,10 @@ static void on_alarm(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
|
|
74
73
|
if (socket != NULL) {
|
75
74
|
grpc_winsocket_shutdown(socket);
|
76
75
|
}
|
77
|
-
async_connect_unlock_and_cleanup(
|
76
|
+
async_connect_unlock_and_cleanup(ac, socket);
|
78
77
|
}
|
79
78
|
|
80
|
-
static void on_connect(
|
79
|
+
static void on_connect(void* acp, grpc_error* error) {
|
81
80
|
async_connect* ac = (async_connect*)acp;
|
82
81
|
grpc_endpoint** ep = ac->endpoint;
|
83
82
|
GPR_ASSERT(*ep == NULL);
|
@@ -90,7 +89,7 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
|
|
90
89
|
ac->socket = NULL;
|
91
90
|
gpr_mu_unlock(&ac->mu);
|
92
91
|
|
93
|
-
grpc_timer_cancel(
|
92
|
+
grpc_timer_cancel(&ac->alarm);
|
94
93
|
|
95
94
|
gpr_mu_lock(&ac->mu);
|
96
95
|
|
@@ -106,8 +105,7 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
|
|
106
105
|
error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx");
|
107
106
|
closesocket(socket->socket);
|
108
107
|
} else {
|
109
|
-
*ep =
|
110
|
-
grpc_tcp_create(exec_ctx, socket, ac->channel_args, ac->addr_name);
|
108
|
+
*ep = grpc_tcp_create(socket, ac->channel_args, ac->addr_name);
|
111
109
|
socket = NULL;
|
112
110
|
}
|
113
111
|
} else {
|
@@ -115,18 +113,20 @@ static void on_connect(grpc_exec_ctx* exec_ctx, void* acp, grpc_error* error) {
|
|
115
113
|
}
|
116
114
|
}
|
117
115
|
|
118
|
-
async_connect_unlock_and_cleanup(
|
116
|
+
async_connect_unlock_and_cleanup(ac, socket);
|
119
117
|
/* If the connection was aborted, the callback was already called when
|
120
118
|
the deadline was met. */
|
121
|
-
GRPC_CLOSURE_SCHED(
|
119
|
+
GRPC_CLOSURE_SCHED(on_done, error);
|
122
120
|
}
|
123
121
|
|
124
122
|
/* Tries to issue one async connection, then schedules both an IOCP
|
125
123
|
notification request for the connection, and one timeout alert. */
|
126
|
-
static void tcp_client_connect_impl(
|
127
|
-
|
128
|
-
|
129
|
-
|
124
|
+
static void tcp_client_connect_impl(grpc_closure* on_done,
|
125
|
+
grpc_endpoint** endpoint,
|
126
|
+
grpc_pollset_set* interested_parties,
|
127
|
+
const grpc_channel_args* channel_args,
|
128
|
+
const grpc_resolved_address* addr,
|
129
|
+
grpc_millis deadline) {
|
130
130
|
SOCKET sock = INVALID_SOCKET;
|
131
131
|
BOOL success;
|
132
132
|
int status;
|
@@ -206,8 +206,8 @@ static void tcp_client_connect_impl(
|
|
206
206
|
GRPC_CLOSURE_INIT(&ac->on_connect, on_connect, ac, grpc_schedule_on_exec_ctx);
|
207
207
|
|
208
208
|
GRPC_CLOSURE_INIT(&ac->on_alarm, on_alarm, ac, grpc_schedule_on_exec_ctx);
|
209
|
-
grpc_timer_init(
|
210
|
-
grpc_socket_notify_on_write(
|
209
|
+
grpc_timer_init(&ac->alarm, deadline, &ac->on_alarm);
|
210
|
+
grpc_socket_notify_on_write(socket, &ac->on_connect);
|
211
211
|
return;
|
212
212
|
|
213
213
|
failure:
|
@@ -223,26 +223,23 @@ failure:
|
|
223
223
|
} else if (sock != INVALID_SOCKET) {
|
224
224
|
closesocket(sock);
|
225
225
|
}
|
226
|
-
GRPC_CLOSURE_SCHED(
|
226
|
+
GRPC_CLOSURE_SCHED(on_done, final_error);
|
227
227
|
}
|
228
228
|
|
229
229
|
// overridden by api_fuzzer.c
|
230
|
-
extern "C" {
|
231
230
|
void (*grpc_tcp_client_connect_impl)(
|
232
|
-
|
231
|
+
grpc_closure* closure, grpc_endpoint** ep,
|
233
232
|
grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args,
|
234
233
|
const grpc_resolved_address* addr,
|
235
234
|
grpc_millis deadline) = tcp_client_connect_impl;
|
236
|
-
}
|
237
235
|
|
238
|
-
void grpc_tcp_client_connect(
|
239
|
-
grpc_endpoint** ep,
|
236
|
+
void grpc_tcp_client_connect(grpc_closure* closure, grpc_endpoint** ep,
|
240
237
|
grpc_pollset_set* interested_parties,
|
241
238
|
const grpc_channel_args* channel_args,
|
242
239
|
const grpc_resolved_address* addr,
|
243
240
|
grpc_millis deadline) {
|
244
|
-
grpc_tcp_client_connect_impl(
|
245
|
-
|
241
|
+
grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
|
242
|
+
addr, deadline);
|
246
243
|
}
|
247
244
|
|
248
245
|
#endif /* GRPC_WINSOCK_SOCKET */
|
@@ -42,12 +42,12 @@
|
|
42
42
|
#include "src/core/lib/channel/channel_args.h"
|
43
43
|
#include "src/core/lib/debug/stats.h"
|
44
44
|
#include "src/core/lib/debug/trace.h"
|
45
|
+
#include "src/core/lib/gpr/string.h"
|
45
46
|
#include "src/core/lib/iomgr/ev_posix.h"
|
46
47
|
#include "src/core/lib/iomgr/executor.h"
|
47
48
|
#include "src/core/lib/profiling/timers.h"
|
48
49
|
#include "src/core/lib/slice/slice_internal.h"
|
49
50
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
50
|
-
#include "src/core/lib/support/string.h"
|
51
51
|
|
52
52
|
#ifdef GRPC_HAVE_MSG_NOSIGNAL
|
53
53
|
#define SENDMSG_FLAGS MSG_NOSIGNAL
|
@@ -63,7 +63,8 @@ typedef size_t msg_iovlen_type;
|
|
63
63
|
|
64
64
|
grpc_core::TraceFlag grpc_tcp_trace(false, "tcp");
|
65
65
|
|
66
|
-
|
66
|
+
namespace {
|
67
|
+
struct grpc_tcp {
|
67
68
|
grpc_endpoint base;
|
68
69
|
grpc_fd* em_fd;
|
69
70
|
int fd;
|
@@ -96,48 +97,44 @@ typedef struct {
|
|
96
97
|
|
97
98
|
grpc_resource_user* resource_user;
|
98
99
|
grpc_resource_user_slice_allocator slice_allocator;
|
99
|
-
}
|
100
|
+
};
|
100
101
|
|
101
|
-
|
102
|
+
struct backup_poller {
|
102
103
|
gpr_mu* pollset_mu;
|
103
104
|
grpc_closure run_poller;
|
104
|
-
}
|
105
|
+
};
|
106
|
+
} // namespace
|
105
107
|
|
106
108
|
#define BACKUP_POLLER_POLLSET(b) ((grpc_pollset*)((b) + 1))
|
107
109
|
|
108
110
|
static gpr_atm g_uncovered_notifications_pending;
|
109
111
|
static gpr_atm g_backup_poller; /* backup_poller* */
|
110
112
|
|
111
|
-
static void tcp_handle_read(
|
112
|
-
|
113
|
-
static void
|
114
|
-
grpc_error* error);
|
115
|
-
static void tcp_drop_uncovered_then_handle_write(grpc_exec_ctx* exec_ctx,
|
116
|
-
void* arg /* grpc_tcp */,
|
113
|
+
static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
|
114
|
+
static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
|
115
|
+
static void tcp_drop_uncovered_then_handle_write(void* arg /* grpc_tcp */,
|
117
116
|
grpc_error* error);
|
118
117
|
|
119
|
-
static void done_poller(
|
120
|
-
grpc_error* error_ignored) {
|
118
|
+
static void done_poller(void* bp, grpc_error* error_ignored) {
|
121
119
|
backup_poller* p = (backup_poller*)bp;
|
122
120
|
if (grpc_tcp_trace.enabled()) {
|
123
121
|
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p destroy", p);
|
124
122
|
}
|
125
|
-
grpc_pollset_destroy(
|
123
|
+
grpc_pollset_destroy(BACKUP_POLLER_POLLSET(p));
|
126
124
|
gpr_free(p);
|
127
125
|
}
|
128
126
|
|
129
|
-
static void run_poller(
|
130
|
-
grpc_error* error_ignored) {
|
127
|
+
static void run_poller(void* bp, grpc_error* error_ignored) {
|
131
128
|
backup_poller* p = (backup_poller*)bp;
|
132
129
|
if (grpc_tcp_trace.enabled()) {
|
133
130
|
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p);
|
134
131
|
}
|
135
132
|
gpr_mu_lock(p->pollset_mu);
|
136
|
-
grpc_millis deadline =
|
137
|
-
GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(
|
133
|
+
grpc_millis deadline = grpc_core::ExecCtx::Get()->Now() + 13 * GPR_MS_PER_SEC;
|
134
|
+
GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS();
|
138
135
|
GRPC_LOG_IF_ERROR(
|
139
136
|
"backup_poller:pollset_work",
|
140
|
-
grpc_pollset_work(
|
137
|
+
grpc_pollset_work(BACKUP_POLLER_POLLSET(p), nullptr, deadline));
|
141
138
|
gpr_mu_unlock(p->pollset_mu);
|
142
139
|
/* last "uncovered" notification is the ref that keeps us polling, if we get
|
143
140
|
* there try a cas to release it */
|
@@ -152,18 +149,18 @@ static void run_poller(grpc_exec_ctx* exec_ctx, void* bp,
|
|
152
149
|
if (grpc_tcp_trace.enabled()) {
|
153
150
|
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p shutdown", p);
|
154
151
|
}
|
155
|
-
grpc_pollset_shutdown(
|
152
|
+
grpc_pollset_shutdown(BACKUP_POLLER_POLLSET(p),
|
156
153
|
GRPC_CLOSURE_INIT(&p->run_poller, done_poller, p,
|
157
154
|
grpc_schedule_on_exec_ctx));
|
158
155
|
} else {
|
159
156
|
if (grpc_tcp_trace.enabled()) {
|
160
157
|
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p reschedule", p);
|
161
158
|
}
|
162
|
-
GRPC_CLOSURE_SCHED(
|
159
|
+
GRPC_CLOSURE_SCHED(&p->run_poller, GRPC_ERROR_NONE);
|
163
160
|
}
|
164
161
|
}
|
165
162
|
|
166
|
-
static void drop_uncovered(
|
163
|
+
static void drop_uncovered(grpc_tcp* tcp) {
|
167
164
|
backup_poller* p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller);
|
168
165
|
gpr_atm old_count =
|
169
166
|
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1);
|
@@ -174,7 +171,7 @@ static void drop_uncovered(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
|
|
174
171
|
GPR_ASSERT(old_count != 1);
|
175
172
|
}
|
176
173
|
|
177
|
-
static void cover_self(
|
174
|
+
static void cover_self(grpc_tcp* tcp) {
|
178
175
|
backup_poller* p;
|
179
176
|
gpr_atm old_count =
|
180
177
|
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, 2);
|
@@ -183,7 +180,7 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
|
|
183
180
|
2 + (int)old_count);
|
184
181
|
}
|
185
182
|
if (old_count == 0) {
|
186
|
-
GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(
|
183
|
+
GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED();
|
187
184
|
p = (backup_poller*)gpr_zalloc(sizeof(*p) + grpc_pollset_size());
|
188
185
|
if (grpc_tcp_trace.enabled()) {
|
189
186
|
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p);
|
@@ -191,7 +188,6 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
|
|
191
188
|
grpc_pollset_init(BACKUP_POLLER_POLLSET(p), &p->pollset_mu);
|
192
189
|
gpr_atm_rel_store(&g_backup_poller, (gpr_atm)p);
|
193
190
|
GRPC_CLOSURE_SCHED(
|
194
|
-
exec_ctx,
|
195
191
|
GRPC_CLOSURE_INIT(&p->run_poller, run_poller, p,
|
196
192
|
grpc_executor_scheduler(GRPC_EXECUTOR_LONG)),
|
197
193
|
GRPC_ERROR_NONE);
|
@@ -204,39 +200,38 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
|
|
204
200
|
if (grpc_tcp_trace.enabled()) {
|
205
201
|
gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p add %p", p, tcp);
|
206
202
|
}
|
207
|
-
grpc_pollset_add_fd(
|
203
|
+
grpc_pollset_add_fd(BACKUP_POLLER_POLLSET(p), tcp->em_fd);
|
208
204
|
if (old_count != 0) {
|
209
|
-
drop_uncovered(
|
205
|
+
drop_uncovered(tcp);
|
210
206
|
}
|
211
207
|
}
|
212
208
|
|
213
|
-
static void notify_on_read(
|
209
|
+
static void notify_on_read(grpc_tcp* tcp) {
|
214
210
|
if (grpc_tcp_trace.enabled()) {
|
215
211
|
gpr_log(GPR_DEBUG, "TCP:%p notify_on_read", tcp);
|
216
212
|
}
|
217
213
|
GRPC_CLOSURE_INIT(&tcp->read_done_closure, tcp_handle_read, tcp,
|
218
214
|
grpc_schedule_on_exec_ctx);
|
219
|
-
grpc_fd_notify_on_read(
|
215
|
+
grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_done_closure);
|
220
216
|
}
|
221
217
|
|
222
|
-
static void notify_on_write(
|
218
|
+
static void notify_on_write(grpc_tcp* tcp) {
|
223
219
|
if (grpc_tcp_trace.enabled()) {
|
224
220
|
gpr_log(GPR_DEBUG, "TCP:%p notify_on_write", tcp);
|
225
221
|
}
|
226
|
-
cover_self(
|
222
|
+
cover_self(tcp);
|
227
223
|
GRPC_CLOSURE_INIT(&tcp->write_done_closure,
|
228
224
|
tcp_drop_uncovered_then_handle_write, tcp,
|
229
225
|
grpc_schedule_on_exec_ctx);
|
230
|
-
grpc_fd_notify_on_write(
|
226
|
+
grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_done_closure);
|
231
227
|
}
|
232
228
|
|
233
|
-
static void tcp_drop_uncovered_then_handle_write(
|
234
|
-
void* arg, grpc_error* error) {
|
229
|
+
static void tcp_drop_uncovered_then_handle_write(void* arg, grpc_error* error) {
|
235
230
|
if (grpc_tcp_trace.enabled()) {
|
236
231
|
gpr_log(GPR_DEBUG, "TCP:%p got_write: %s", arg, grpc_error_string(error));
|
237
232
|
}
|
238
|
-
drop_uncovered(
|
239
|
-
tcp_handle_write(
|
233
|
+
drop_uncovered((grpc_tcp*)arg);
|
234
|
+
tcp_handle_write(arg, error);
|
240
235
|
}
|
241
236
|
|
242
237
|
static void add_to_estimate(grpc_tcp* tcp, size_t bytes) {
|
@@ -277,38 +272,38 @@ static size_t get_target_read_size(grpc_tcp* tcp) {
|
|
277
272
|
|
278
273
|
static grpc_error* tcp_annotate_error(grpc_error* src_error, grpc_tcp* tcp) {
|
279
274
|
return grpc_error_set_str(
|
280
|
-
grpc_error_set_int(
|
275
|
+
grpc_error_set_int(
|
276
|
+
grpc_error_set_int(src_error, GRPC_ERROR_INT_FD, tcp->fd),
|
277
|
+
/* All tcp errors are marked with UNAVAILABLE so that application may
|
278
|
+
* choose to retry. */
|
279
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE),
|
281
280
|
GRPC_ERROR_STR_TARGET_ADDRESS,
|
282
281
|
grpc_slice_from_copied_string(tcp->peer_string));
|
283
282
|
}
|
284
283
|
|
285
|
-
static void tcp_handle_read(
|
286
|
-
|
287
|
-
static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
|
288
|
-
grpc_error* error);
|
284
|
+
static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error);
|
285
|
+
static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error);
|
289
286
|
|
290
|
-
static void tcp_shutdown(
|
291
|
-
grpc_error* why) {
|
287
|
+
static void tcp_shutdown(grpc_endpoint* ep, grpc_error* why) {
|
292
288
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
293
|
-
grpc_fd_shutdown(
|
294
|
-
grpc_resource_user_shutdown(
|
289
|
+
grpc_fd_shutdown(tcp->em_fd, why);
|
290
|
+
grpc_resource_user_shutdown(tcp->resource_user);
|
295
291
|
}
|
296
292
|
|
297
|
-
static void tcp_free(
|
298
|
-
grpc_fd_orphan(
|
293
|
+
static void tcp_free(grpc_tcp* tcp) {
|
294
|
+
grpc_fd_orphan(tcp->em_fd, tcp->release_fd_cb, tcp->release_fd,
|
299
295
|
false /* already_closed */, "tcp_unref_orphan");
|
300
|
-
grpc_slice_buffer_destroy_internal(
|
301
|
-
grpc_resource_user_unref(
|
296
|
+
grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer);
|
297
|
+
grpc_resource_user_unref(tcp->resource_user);
|
302
298
|
gpr_free(tcp->peer_string);
|
303
299
|
gpr_free(tcp);
|
304
300
|
}
|
305
301
|
|
306
302
|
#ifndef NDEBUG
|
307
|
-
#define TCP_UNREF(
|
308
|
-
tcp_unref((cl), (tcp), (reason), __FILE__, __LINE__)
|
303
|
+
#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
|
309
304
|
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
|
310
|
-
static void tcp_unref(
|
311
|
-
|
305
|
+
static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file,
|
306
|
+
int line) {
|
312
307
|
if (grpc_tcp_trace.enabled()) {
|
313
308
|
gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count);
|
314
309
|
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
|
@@ -316,7 +311,7 @@ static void tcp_unref(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
|
|
316
311
|
val - 1);
|
317
312
|
}
|
318
313
|
if (gpr_unref(&tcp->refcount)) {
|
319
|
-
tcp_free(
|
314
|
+
tcp_free(tcp);
|
320
315
|
}
|
321
316
|
}
|
322
317
|
|
@@ -331,26 +326,25 @@ static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file,
|
|
331
326
|
gpr_ref(&tcp->refcount);
|
332
327
|
}
|
333
328
|
#else
|
334
|
-
#define TCP_UNREF(
|
329
|
+
#define TCP_UNREF(tcp, reason) tcp_unref((tcp))
|
335
330
|
#define TCP_REF(tcp, reason) tcp_ref((tcp))
|
336
|
-
static void tcp_unref(
|
331
|
+
static void tcp_unref(grpc_tcp* tcp) {
|
337
332
|
if (gpr_unref(&tcp->refcount)) {
|
338
|
-
tcp_free(
|
333
|
+
tcp_free(tcp);
|
339
334
|
}
|
340
335
|
}
|
341
336
|
|
342
337
|
static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); }
|
343
338
|
#endif
|
344
339
|
|
345
|
-
static void tcp_destroy(
|
340
|
+
static void tcp_destroy(grpc_endpoint* ep) {
|
346
341
|
grpc_network_status_unregister_endpoint(ep);
|
347
342
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
348
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
349
|
-
TCP_UNREF(
|
343
|
+
grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
|
344
|
+
TCP_UNREF(tcp, "destroy");
|
350
345
|
}
|
351
346
|
|
352
|
-
static void call_read_cb(
|
353
|
-
grpc_error* error) {
|
347
|
+
static void call_read_cb(grpc_tcp* tcp, grpc_error* error) {
|
354
348
|
grpc_closure* cb = tcp->read_cb;
|
355
349
|
|
356
350
|
if (grpc_tcp_trace.enabled()) {
|
@@ -369,11 +363,11 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
|
|
369
363
|
|
370
364
|
tcp->read_cb = nullptr;
|
371
365
|
tcp->incoming_buffer = nullptr;
|
372
|
-
GRPC_CLOSURE_RUN(
|
366
|
+
GRPC_CLOSURE_RUN(cb, error);
|
373
367
|
}
|
374
368
|
|
375
369
|
#define MAX_READ_IOVEC 4
|
376
|
-
static void tcp_do_read(
|
370
|
+
static void tcp_do_read(grpc_tcp* tcp) {
|
377
371
|
struct msghdr msg;
|
378
372
|
struct iovec iov[MAX_READ_IOVEC];
|
379
373
|
ssize_t read_bytes;
|
@@ -396,12 +390,12 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
|
|
396
390
|
msg.msg_controllen = 0;
|
397
391
|
msg.msg_flags = 0;
|
398
392
|
|
399
|
-
GRPC_STATS_INC_TCP_READ_OFFER(
|
400
|
-
GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(
|
393
|
+
GRPC_STATS_INC_TCP_READ_OFFER(tcp->incoming_buffer->length);
|
394
|
+
GRPC_STATS_INC_TCP_READ_OFFER_IOV_SIZE(tcp->incoming_buffer->count);
|
401
395
|
|
402
396
|
GPR_TIMER_BEGIN("recvmsg", 0);
|
403
397
|
do {
|
404
|
-
GRPC_STATS_INC_SYSCALL_READ(
|
398
|
+
GRPC_STATS_INC_SYSCALL_READ();
|
405
399
|
read_bytes = recvmsg(tcp->fd, &msg, 0);
|
406
400
|
} while (read_bytes < 0 && errno == EINTR);
|
407
401
|
GPR_TIMER_END("recvmsg", read_bytes >= 0);
|
@@ -412,24 +406,22 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
|
|
412
406
|
if (errno == EAGAIN) {
|
413
407
|
finish_estimate(tcp);
|
414
408
|
/* We've consumed the edge, request a new one */
|
415
|
-
notify_on_read(
|
409
|
+
notify_on_read(tcp);
|
416
410
|
} else {
|
417
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
418
|
-
|
419
|
-
call_read_cb(exec_ctx, tcp,
|
411
|
+
grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
|
412
|
+
call_read_cb(tcp,
|
420
413
|
tcp_annotate_error(GRPC_OS_ERROR(errno, "recvmsg"), tcp));
|
421
|
-
TCP_UNREF(
|
414
|
+
TCP_UNREF(tcp, "read");
|
422
415
|
}
|
423
416
|
} else if (read_bytes == 0) {
|
424
417
|
/* 0 read size ==> end of stream */
|
425
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
418
|
+
grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
|
426
419
|
call_read_cb(
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
TCP_UNREF(exec_ctx, tcp, "read");
|
420
|
+
tcp, tcp_annotate_error(
|
421
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), tcp));
|
422
|
+
TCP_UNREF(tcp, "read");
|
431
423
|
} else {
|
432
|
-
GRPC_STATS_INC_TCP_READ_SIZE(
|
424
|
+
GRPC_STATS_INC_TCP_READ_SIZE(read_bytes);
|
433
425
|
add_to_estimate(tcp, (size_t)read_bytes);
|
434
426
|
GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length);
|
435
427
|
if ((size_t)read_bytes < tcp->incoming_buffer->length) {
|
@@ -439,50 +431,47 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) {
|
|
439
431
|
&tcp->last_read_buffer);
|
440
432
|
}
|
441
433
|
GPR_ASSERT((size_t)read_bytes == tcp->incoming_buffer->length);
|
442
|
-
call_read_cb(
|
443
|
-
TCP_UNREF(
|
434
|
+
call_read_cb(tcp, GRPC_ERROR_NONE);
|
435
|
+
TCP_UNREF(tcp, "read");
|
444
436
|
}
|
445
437
|
|
446
438
|
GPR_TIMER_END("tcp_continue_read", 0);
|
447
439
|
}
|
448
440
|
|
449
|
-
static void tcp_read_allocation_done(
|
450
|
-
grpc_error* error) {
|
441
|
+
static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
|
451
442
|
grpc_tcp* tcp = (grpc_tcp*)tcpp;
|
452
443
|
if (grpc_tcp_trace.enabled()) {
|
453
444
|
gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp,
|
454
445
|
grpc_error_string(error));
|
455
446
|
}
|
456
447
|
if (error != GRPC_ERROR_NONE) {
|
457
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
458
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
459
|
-
|
460
|
-
|
461
|
-
TCP_UNREF(exec_ctx, tcp, "read");
|
448
|
+
grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
|
449
|
+
grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
|
450
|
+
call_read_cb(tcp, GRPC_ERROR_REF(error));
|
451
|
+
TCP_UNREF(tcp, "read");
|
462
452
|
} else {
|
463
|
-
tcp_do_read(
|
453
|
+
tcp_do_read(tcp);
|
464
454
|
}
|
465
455
|
}
|
466
456
|
|
467
|
-
static void tcp_continue_read(
|
457
|
+
static void tcp_continue_read(grpc_tcp* tcp) {
|
468
458
|
size_t target_read_size = get_target_read_size(tcp);
|
469
459
|
if (tcp->incoming_buffer->length < target_read_size &&
|
470
460
|
tcp->incoming_buffer->count < MAX_READ_IOVEC) {
|
471
461
|
if (grpc_tcp_trace.enabled()) {
|
472
462
|
gpr_log(GPR_DEBUG, "TCP:%p alloc_slices", tcp);
|
473
463
|
}
|
474
|
-
grpc_resource_user_alloc_slices(
|
475
|
-
|
464
|
+
grpc_resource_user_alloc_slices(&tcp->slice_allocator, target_read_size, 1,
|
465
|
+
tcp->incoming_buffer);
|
476
466
|
} else {
|
477
467
|
if (grpc_tcp_trace.enabled()) {
|
478
468
|
gpr_log(GPR_DEBUG, "TCP:%p do_read", tcp);
|
479
469
|
}
|
480
|
-
tcp_do_read(
|
470
|
+
tcp_do_read(tcp);
|
481
471
|
}
|
482
472
|
}
|
483
473
|
|
484
|
-
static void tcp_handle_read(
|
485
|
-
grpc_error* error) {
|
474
|
+
static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) {
|
486
475
|
grpc_tcp* tcp = (grpc_tcp*)arg;
|
487
476
|
GPR_ASSERT(!tcp->finished_edge);
|
488
477
|
if (grpc_tcp_trace.enabled()) {
|
@@ -490,37 +479,35 @@ static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
|
|
490
479
|
}
|
491
480
|
|
492
481
|
if (error != GRPC_ERROR_NONE) {
|
493
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
494
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
495
|
-
|
496
|
-
|
497
|
-
TCP_UNREF(exec_ctx, tcp, "read");
|
482
|
+
grpc_slice_buffer_reset_and_unref_internal(tcp->incoming_buffer);
|
483
|
+
grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
|
484
|
+
call_read_cb(tcp, GRPC_ERROR_REF(error));
|
485
|
+
TCP_UNREF(tcp, "read");
|
498
486
|
} else {
|
499
|
-
tcp_continue_read(
|
487
|
+
tcp_continue_read(tcp);
|
500
488
|
}
|
501
489
|
}
|
502
490
|
|
503
|
-
static void tcp_read(
|
504
|
-
|
491
|
+
static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer,
|
492
|
+
grpc_closure* cb) {
|
505
493
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
506
494
|
GPR_ASSERT(tcp->read_cb == nullptr);
|
507
495
|
tcp->read_cb = cb;
|
508
496
|
tcp->incoming_buffer = incoming_buffer;
|
509
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
497
|
+
grpc_slice_buffer_reset_and_unref_internal(incoming_buffer);
|
510
498
|
grpc_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer);
|
511
499
|
TCP_REF(tcp, "read");
|
512
500
|
if (tcp->finished_edge) {
|
513
501
|
tcp->finished_edge = false;
|
514
|
-
notify_on_read(
|
502
|
+
notify_on_read(tcp);
|
515
503
|
} else {
|
516
|
-
GRPC_CLOSURE_SCHED(
|
504
|
+
GRPC_CLOSURE_SCHED(&tcp->read_done_closure, GRPC_ERROR_NONE);
|
517
505
|
}
|
518
506
|
}
|
519
507
|
|
520
508
|
/* returns true if done, false if pending; if returning true, *error is set */
|
521
509
|
#define MAX_WRITE_IOVEC 1000
|
522
|
-
static bool tcp_flush(
|
523
|
-
grpc_error** error) {
|
510
|
+
static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) {
|
524
511
|
struct msghdr msg;
|
525
512
|
struct iovec iov[MAX_WRITE_IOVEC];
|
526
513
|
msg_iovlen_type iov_size;
|
@@ -562,13 +549,13 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
|
|
562
549
|
msg.msg_controllen = 0;
|
563
550
|
msg.msg_flags = 0;
|
564
551
|
|
565
|
-
GRPC_STATS_INC_TCP_WRITE_SIZE(
|
566
|
-
GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(
|
552
|
+
GRPC_STATS_INC_TCP_WRITE_SIZE(sending_length);
|
553
|
+
GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(iov_size);
|
567
554
|
|
568
555
|
GPR_TIMER_BEGIN("sendmsg", 1);
|
569
556
|
do {
|
570
557
|
/* TODO(klempner): Cork if this is a partial write */
|
571
|
-
GRPC_STATS_INC_SYSCALL_WRITE(
|
558
|
+
GRPC_STATS_INC_SYSCALL_WRITE();
|
572
559
|
sent_length = sendmsg(tcp->fd, &msg, SENDMSG_FLAGS);
|
573
560
|
} while (sent_length < 0 && errno == EINTR);
|
574
561
|
GPR_TIMER_END("sendmsg", 0);
|
@@ -580,20 +567,16 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
|
|
580
567
|
// point
|
581
568
|
for (size_t idx = 0; idx < unwind_slice_idx; ++idx) {
|
582
569
|
grpc_slice_unref_internal(
|
583
|
-
|
570
|
+
grpc_slice_buffer_take_first(tcp->outgoing_buffer));
|
584
571
|
}
|
585
572
|
return false;
|
586
573
|
} else if (errno == EPIPE) {
|
587
|
-
*error =
|
588
|
-
|
589
|
-
GRPC_STATUS_UNAVAILABLE);
|
590
|
-
grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
|
591
|
-
tcp->outgoing_buffer);
|
574
|
+
*error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
|
575
|
+
grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
|
592
576
|
return true;
|
593
577
|
} else {
|
594
578
|
*error = tcp_annotate_error(GRPC_OS_ERROR(errno, "sendmsg"), tcp);
|
595
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
596
|
-
tcp->outgoing_buffer);
|
579
|
+
grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
|
597
580
|
return true;
|
598
581
|
}
|
599
582
|
}
|
@@ -616,31 +599,29 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp,
|
|
616
599
|
|
617
600
|
if (outgoing_slice_idx == tcp->outgoing_buffer->count) {
|
618
601
|
*error = GRPC_ERROR_NONE;
|
619
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
620
|
-
tcp->outgoing_buffer);
|
602
|
+
grpc_slice_buffer_reset_and_unref_internal(tcp->outgoing_buffer);
|
621
603
|
return true;
|
622
604
|
}
|
623
605
|
}
|
624
606
|
}
|
625
607
|
|
626
|
-
static void tcp_handle_write(
|
627
|
-
grpc_error* error) {
|
608
|
+
static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) {
|
628
609
|
grpc_tcp* tcp = (grpc_tcp*)arg;
|
629
610
|
grpc_closure* cb;
|
630
611
|
|
631
612
|
if (error != GRPC_ERROR_NONE) {
|
632
613
|
cb = tcp->write_cb;
|
633
614
|
tcp->write_cb = nullptr;
|
634
|
-
cb->cb(
|
635
|
-
TCP_UNREF(
|
615
|
+
cb->cb(cb->cb_arg, error);
|
616
|
+
TCP_UNREF(tcp, "write");
|
636
617
|
return;
|
637
618
|
}
|
638
619
|
|
639
|
-
if (!tcp_flush(
|
620
|
+
if (!tcp_flush(tcp, &error)) {
|
640
621
|
if (grpc_tcp_trace.enabled()) {
|
641
622
|
gpr_log(GPR_DEBUG, "write: delayed");
|
642
623
|
}
|
643
|
-
notify_on_write(
|
624
|
+
notify_on_write(tcp);
|
644
625
|
} else {
|
645
626
|
cb = tcp->write_cb;
|
646
627
|
tcp->write_cb = nullptr;
|
@@ -649,13 +630,13 @@ static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */,
|
|
649
630
|
gpr_log(GPR_DEBUG, "write: %s", str);
|
650
631
|
}
|
651
632
|
|
652
|
-
GRPC_CLOSURE_RUN(
|
653
|
-
TCP_UNREF(
|
633
|
+
GRPC_CLOSURE_RUN(cb, error);
|
634
|
+
TCP_UNREF(tcp, "write");
|
654
635
|
}
|
655
636
|
}
|
656
637
|
|
657
|
-
static void tcp_write(
|
658
|
-
|
638
|
+
static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf,
|
639
|
+
grpc_closure* cb) {
|
659
640
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
660
641
|
grpc_error* error = GRPC_ERROR_NONE;
|
661
642
|
|
@@ -676,51 +657,48 @@ static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep,
|
|
676
657
|
if (buf->length == 0) {
|
677
658
|
GPR_TIMER_END("tcp_write", 0);
|
678
659
|
GRPC_CLOSURE_SCHED(
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
: GRPC_ERROR_NONE);
|
660
|
+
cb, grpc_fd_is_shutdown(tcp->em_fd)
|
661
|
+
? tcp_annotate_error(
|
662
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("EOF"), tcp)
|
663
|
+
: GRPC_ERROR_NONE);
|
684
664
|
return;
|
685
665
|
}
|
686
666
|
tcp->outgoing_buffer = buf;
|
687
667
|
tcp->outgoing_byte_idx = 0;
|
688
668
|
|
689
|
-
if (!tcp_flush(
|
669
|
+
if (!tcp_flush(tcp, &error)) {
|
690
670
|
TCP_REF(tcp, "write");
|
691
671
|
tcp->write_cb = cb;
|
692
672
|
if (grpc_tcp_trace.enabled()) {
|
693
673
|
gpr_log(GPR_DEBUG, "write: delayed");
|
694
674
|
}
|
695
|
-
notify_on_write(
|
675
|
+
notify_on_write(tcp);
|
696
676
|
} else {
|
697
677
|
if (grpc_tcp_trace.enabled()) {
|
698
678
|
const char* str = grpc_error_string(error);
|
699
679
|
gpr_log(GPR_DEBUG, "write: %s", str);
|
700
680
|
}
|
701
|
-
GRPC_CLOSURE_SCHED(
|
681
|
+
GRPC_CLOSURE_SCHED(cb, error);
|
702
682
|
}
|
703
683
|
|
704
684
|
GPR_TIMER_END("tcp_write", 0);
|
705
685
|
}
|
706
686
|
|
707
|
-
static void tcp_add_to_pollset(
|
708
|
-
grpc_pollset* pollset) {
|
687
|
+
static void tcp_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
|
709
688
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
710
|
-
grpc_pollset_add_fd(
|
689
|
+
grpc_pollset_add_fd(pollset, tcp->em_fd);
|
711
690
|
}
|
712
691
|
|
713
|
-
static void tcp_add_to_pollset_set(
|
692
|
+
static void tcp_add_to_pollset_set(grpc_endpoint* ep,
|
714
693
|
grpc_pollset_set* pollset_set) {
|
715
694
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
716
|
-
grpc_pollset_set_add_fd(
|
695
|
+
grpc_pollset_set_add_fd(pollset_set, tcp->em_fd);
|
717
696
|
}
|
718
697
|
|
719
|
-
static void tcp_delete_from_pollset_set(
|
720
|
-
grpc_endpoint* ep,
|
698
|
+
static void tcp_delete_from_pollset_set(grpc_endpoint* ep,
|
721
699
|
grpc_pollset_set* pollset_set) {
|
722
700
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
723
|
-
grpc_pollset_set_del_fd(
|
701
|
+
grpc_pollset_set_del_fd(pollset_set, tcp->em_fd);
|
724
702
|
}
|
725
703
|
|
726
704
|
static char* tcp_get_peer(grpc_endpoint* ep) {
|
@@ -751,7 +729,7 @@ static const grpc_endpoint_vtable vtable = {tcp_read,
|
|
751
729
|
|
752
730
|
#define MAX_CHUNK_SIZE 32 * 1024 * 1024
|
753
731
|
|
754
|
-
grpc_endpoint* grpc_tcp_create(
|
732
|
+
grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd,
|
755
733
|
const grpc_channel_args* channel_args,
|
756
734
|
const char* peer_string) {
|
757
735
|
int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
|
@@ -780,7 +758,7 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
|
|
780
758
|
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
781
759
|
} else if (0 ==
|
782
760
|
strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) {
|
783
|
-
grpc_resource_quota_unref_internal(
|
761
|
+
grpc_resource_quota_unref_internal(resource_quota);
|
784
762
|
resource_quota = grpc_resource_quota_ref_internal(
|
785
763
|
(grpc_resource_quota*)channel_args->args[i].value.pointer.p);
|
786
764
|
}
|
@@ -817,7 +795,7 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd,
|
|
817
795
|
&tcp->slice_allocator, tcp->resource_user, tcp_read_allocation_done, tcp);
|
818
796
|
/* Tell network status tracker about new endpoint */
|
819
797
|
grpc_network_status_register_endpoint(&tcp->base);
|
820
|
-
grpc_resource_quota_unref_internal(
|
798
|
+
grpc_resource_quota_unref_internal(resource_quota);
|
821
799
|
|
822
800
|
return &tcp->base;
|
823
801
|
}
|
@@ -828,15 +806,15 @@ int grpc_tcp_fd(grpc_endpoint* ep) {
|
|
828
806
|
return grpc_fd_wrapped_fd(tcp->em_fd);
|
829
807
|
}
|
830
808
|
|
831
|
-
void grpc_tcp_destroy_and_release_fd(
|
832
|
-
|
809
|
+
void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd,
|
810
|
+
grpc_closure* done) {
|
833
811
|
grpc_network_status_unregister_endpoint(ep);
|
834
812
|
grpc_tcp* tcp = (grpc_tcp*)ep;
|
835
813
|
GPR_ASSERT(ep->vtable == &vtable);
|
836
814
|
tcp->release_fd = fd;
|
837
815
|
tcp->release_fd_cb = done;
|
838
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
839
|
-
TCP_UNREF(
|
816
|
+
grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
|
817
|
+
TCP_UNREF(tcp, "destroy");
|
840
818
|
}
|
841
819
|
|
842
820
|
#endif
|