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
@@ -183,6 +183,7 @@ void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport* t,
|
|
183
183
|
|
184
184
|
void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t,
|
185
185
|
grpc_chttp2_stream* s) {
|
186
|
+
GPR_ASSERT(t->flow_control->flow_control_enabled());
|
186
187
|
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
|
187
188
|
}
|
188
189
|
|
@@ -198,6 +199,7 @@ void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport* t,
|
|
198
199
|
|
199
200
|
void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t,
|
200
201
|
grpc_chttp2_stream* s) {
|
202
|
+
GPR_ASSERT(t->flow_control->flow_control_enabled());
|
201
203
|
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM);
|
202
204
|
}
|
203
205
|
|
@@ -23,10 +23,6 @@
|
|
23
23
|
|
24
24
|
#include <stddef.h>
|
25
25
|
|
26
|
-
#ifdef __cplusplus
|
27
|
-
extern "C" {
|
28
|
-
#endif
|
29
|
-
|
30
26
|
/* Data structure to map a uint32_t to a data object (represented by a void*)
|
31
27
|
|
32
28
|
Represented as a sorted array of keys, and a corresponding array of values.
|
@@ -69,8 +65,4 @@ void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map,
|
|
69
65
|
void* value),
|
70
66
|
void* user_data);
|
71
67
|
|
72
|
-
#ifdef __cplusplus
|
73
|
-
}
|
74
|
-
#endif
|
75
|
-
|
76
68
|
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */
|
@@ -21,10 +21,6 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
-
#ifdef __cplusplus
|
25
|
-
extern "C" {
|
26
|
-
#endif
|
27
|
-
|
28
24
|
/* Helpers for hpack varint encoding */
|
29
25
|
|
30
26
|
/* length of a value that needs varint tail encoding (it's bigger than can be
|
@@ -61,8 +57,4 @@ void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target,
|
|
61
57
|
} \
|
62
58
|
} while (0)
|
63
59
|
|
64
|
-
#ifdef __cplusplus
|
65
|
-
}
|
66
|
-
#endif
|
67
|
-
|
68
60
|
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H */
|
@@ -33,17 +33,15 @@ static void add_to_write_list(grpc_chttp2_write_cb** list,
|
|
33
33
|
*list = cb;
|
34
34
|
}
|
35
35
|
|
36
|
-
static void finish_write_cb(
|
37
|
-
|
38
|
-
|
39
|
-
grpc_chttp2_complete_closure_step(exec_ctx, t, s, &cb->closure, error,
|
36
|
+
static void finish_write_cb(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
37
|
+
grpc_chttp2_write_cb* cb, grpc_error* error) {
|
38
|
+
grpc_chttp2_complete_closure_step(t, s, &cb->closure, error,
|
40
39
|
"finish_write_cb");
|
41
40
|
cb->next = t->write_cb_pool;
|
42
41
|
t->write_cb_pool = cb;
|
43
42
|
}
|
44
43
|
|
45
|
-
static void maybe_initiate_ping(
|
46
|
-
grpc_chttp2_transport* t) {
|
44
|
+
static void maybe_initiate_ping(grpc_chttp2_transport* t) {
|
47
45
|
grpc_chttp2_ping_queue* pq = &t->ping_queue;
|
48
46
|
if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) {
|
49
47
|
/* no ping needed: wait */
|
@@ -68,7 +66,7 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
|
|
68
66
|
}
|
69
67
|
return;
|
70
68
|
}
|
71
|
-
grpc_millis now =
|
69
|
+
grpc_millis now = grpc_core::ExecCtx::Get()->Now();
|
72
70
|
|
73
71
|
grpc_millis next_allowed_ping_interval =
|
74
72
|
(t->keepalive_permit_without_calls == 0 &&
|
@@ -90,20 +88,20 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
|
|
90
88
|
}
|
91
89
|
if (!t->ping_state.is_delayed_ping_timer_set) {
|
92
90
|
t->ping_state.is_delayed_ping_timer_set = true;
|
93
|
-
grpc_timer_init(
|
94
|
-
|
91
|
+
grpc_timer_init(&t->ping_state.delayed_ping_timer, next_allowed_ping,
|
92
|
+
&t->retry_initiate_ping_locked);
|
95
93
|
}
|
96
94
|
return;
|
97
95
|
}
|
98
96
|
|
99
97
|
pq->inflight_id = t->ping_ctr;
|
100
98
|
t->ping_ctr++;
|
101
|
-
GRPC_CLOSURE_LIST_SCHED(
|
99
|
+
GRPC_CLOSURE_LIST_SCHED(&pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
|
102
100
|
grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT],
|
103
101
|
&pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
|
104
102
|
grpc_slice_buffer_add(&t->outbuf,
|
105
103
|
grpc_chttp2_ping_create(false, pq->inflight_id));
|
106
|
-
GRPC_STATS_INC_HTTP2_PINGS_SENT(
|
104
|
+
GRPC_STATS_INC_HTTP2_PINGS_SENT();
|
107
105
|
t->ping_state.last_ping_sent_time = now;
|
108
106
|
if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) {
|
109
107
|
gpr_log(GPR_DEBUG, "%s: Ping sent [%p]: %d/%d",
|
@@ -115,10 +113,9 @@ static void maybe_initiate_ping(grpc_exec_ctx* exec_ctx,
|
|
115
113
|
(t->ping_state.pings_before_data_required != 0);
|
116
114
|
}
|
117
115
|
|
118
|
-
static bool update_list(
|
119
|
-
|
120
|
-
|
121
|
-
grpc_error* error) {
|
116
|
+
static bool update_list(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
117
|
+
int64_t send_bytes, grpc_chttp2_write_cb** list,
|
118
|
+
int64_t* ctr, grpc_error* error) {
|
122
119
|
bool sched_any = false;
|
123
120
|
grpc_chttp2_write_cb* cb = *list;
|
124
121
|
*list = nullptr;
|
@@ -127,7 +124,7 @@ static bool update_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
|
127
124
|
grpc_chttp2_write_cb* next = cb->next;
|
128
125
|
if (cb->call_at_byte <= *ctr) {
|
129
126
|
sched_any = true;
|
130
|
-
finish_write_cb(
|
127
|
+
finish_write_cb(t, s, cb, GRPC_ERROR_REF(error));
|
131
128
|
} else {
|
132
129
|
add_to_write_list(list, cb);
|
133
130
|
}
|
@@ -141,10 +138,11 @@ static void report_stall(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
|
141
138
|
const char* staller) {
|
142
139
|
gpr_log(
|
143
140
|
GPR_DEBUG,
|
144
|
-
"%s:%p stream %d stalled by %s [fc:pending=%" PRIdPTR
|
141
|
+
"%s:%p stream %d stalled by %s [fc:pending=%" PRIdPTR
|
142
|
+
":pending-compressed=%" PRIdPTR ":flowed=%" PRId64
|
145
143
|
":peer_initwin=%d:t_win=%" PRId64 ":s_win=%d:s_delta=%" PRId64 "]",
|
146
144
|
t->peer_string, t, s->id, staller, s->flow_controlled_buffer.length,
|
147
|
-
s->flow_controlled_bytes_flowed,
|
145
|
+
s->compressed_data_buffer.length, s->flow_controlled_bytes_flowed,
|
148
146
|
t->settings[GRPC_ACKED_SETTINGS]
|
149
147
|
[GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE],
|
150
148
|
t->flow_control->remote_window(),
|
@@ -180,22 +178,22 @@ class StreamWriteContext;
|
|
180
178
|
|
181
179
|
class WriteContext {
|
182
180
|
public:
|
183
|
-
WriteContext(
|
184
|
-
GRPC_STATS_INC_HTTP2_WRITES_BEGUN(
|
181
|
+
WriteContext(grpc_chttp2_transport* t) : t_(t) {
|
182
|
+
GRPC_STATS_INC_HTTP2_WRITES_BEGUN();
|
185
183
|
GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0);
|
186
184
|
}
|
187
185
|
|
188
186
|
// TODO(ctiller): make this the destructor
|
189
|
-
void FlushStats(
|
187
|
+
void FlushStats() {
|
190
188
|
GRPC_STATS_INC_HTTP2_SEND_INITIAL_METADATA_PER_WRITE(
|
191
|
-
|
192
|
-
GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(
|
189
|
+
initial_metadata_writes_);
|
190
|
+
GRPC_STATS_INC_HTTP2_SEND_MESSAGE_PER_WRITE(message_writes_);
|
193
191
|
GRPC_STATS_INC_HTTP2_SEND_TRAILING_METADATA_PER_WRITE(
|
194
|
-
|
195
|
-
GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(
|
192
|
+
trailing_metadata_writes_);
|
193
|
+
GRPC_STATS_INC_HTTP2_SEND_FLOWCTL_PER_WRITE(flow_control_writes_);
|
196
194
|
}
|
197
195
|
|
198
|
-
void FlushSettings(
|
196
|
+
void FlushSettings() {
|
199
197
|
if (t_->dirtied_local_settings && !t_->sent_local_settings) {
|
200
198
|
grpc_slice_buffer_add(
|
201
199
|
&t_->outbuf, grpc_chttp2_settings_create(
|
@@ -205,17 +203,17 @@ class WriteContext {
|
|
205
203
|
t_->force_send_settings = false;
|
206
204
|
t_->dirtied_local_settings = false;
|
207
205
|
t_->sent_local_settings = true;
|
208
|
-
GRPC_STATS_INC_HTTP2_SETTINGS_WRITES(
|
206
|
+
GRPC_STATS_INC_HTTP2_SETTINGS_WRITES();
|
209
207
|
}
|
210
208
|
}
|
211
209
|
|
212
|
-
void FlushQueuedBuffers(
|
210
|
+
void FlushQueuedBuffers() {
|
213
211
|
/* simple writes are queued to qbuf, and flushed here */
|
214
212
|
grpc_slice_buffer_move_into(&t_->qbuf, &t_->outbuf);
|
215
213
|
GPR_ASSERT(t_->qbuf.count == 0);
|
216
214
|
}
|
217
215
|
|
218
|
-
void FlushWindowUpdates(
|
216
|
+
void FlushWindowUpdates() {
|
219
217
|
uint32_t transport_announce =
|
220
218
|
t_->flow_control->MaybeSendUpdate(t_->outbuf.count > 0);
|
221
219
|
if (transport_announce) {
|
@@ -235,7 +233,7 @@ class WriteContext {
|
|
235
233
|
t_->ping_ack_count = 0;
|
236
234
|
}
|
237
235
|
|
238
|
-
void EnactHpackSettings(
|
236
|
+
void EnactHpackSettings() {
|
239
237
|
grpc_chttp2_hpack_compressor_set_max_table_size(
|
240
238
|
&t_->hpack_compressor,
|
241
239
|
t_->settings[GRPC_PEER_SETTINGS]
|
@@ -375,8 +373,8 @@ class DataSendContext {
|
|
375
373
|
|
376
374
|
bool is_last_frame() const { return is_last_frame_; }
|
377
375
|
|
378
|
-
void CallCallbacks(
|
379
|
-
if (update_list(
|
376
|
+
void CallCallbacks() {
|
377
|
+
if (update_list(t_, s_,
|
380
378
|
(int64_t)(s_->sending_bytes - sending_bytes_before_),
|
381
379
|
&s_->on_flow_controlled_cbs,
|
382
380
|
&s_->flow_controlled_bytes_flowed, GRPC_ERROR_NONE)) {
|
@@ -404,7 +402,7 @@ class StreamWriteContext {
|
|
404
402
|
s->flow_control->announced_window_delta())));
|
405
403
|
}
|
406
404
|
|
407
|
-
void FlushInitialMetadata(
|
405
|
+
void FlushInitialMetadata() {
|
408
406
|
/* send initial metadata if it's available */
|
409
407
|
if (s_->sent_initial_metadata) return;
|
410
408
|
if (s_->send_initial_metadata == nullptr) return;
|
@@ -431,7 +429,7 @@ class StreamWriteContext {
|
|
431
429
|
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], // max_frame_size
|
432
430
|
&s_->stats.outgoing // stats
|
433
431
|
};
|
434
|
-
grpc_chttp2_encode_header(
|
432
|
+
grpc_chttp2_encode_header(&t_->hpack_compressor, nullptr, 0,
|
435
433
|
s_->send_initial_metadata, &hopt, &t_->outbuf);
|
436
434
|
write_context_->ResetPingRecvClock();
|
437
435
|
write_context_->IncInitialMetadataWrites();
|
@@ -441,11 +439,11 @@ class StreamWriteContext {
|
|
441
439
|
s_->sent_initial_metadata = true;
|
442
440
|
write_context_->NoteScheduledResults();
|
443
441
|
grpc_chttp2_complete_closure_step(
|
444
|
-
|
442
|
+
t_, s_, &s_->send_initial_metadata_finished, GRPC_ERROR_NONE,
|
445
443
|
"send_initial_metadata_finished");
|
446
444
|
}
|
447
445
|
|
448
|
-
void FlushWindowUpdates(
|
446
|
+
void FlushWindowUpdates() {
|
449
447
|
/* send any window updates */
|
450
448
|
const uint32_t stream_announce = s_->flow_control->MaybeSendUpdate();
|
451
449
|
if (stream_announce == 0) return;
|
@@ -457,7 +455,7 @@ class StreamWriteContext {
|
|
457
455
|
write_context_->IncWindowUpdateWrites();
|
458
456
|
}
|
459
457
|
|
460
|
-
void FlushData(
|
458
|
+
void FlushData() {
|
461
459
|
if (!s_->sent_initial_metadata) return;
|
462
460
|
|
463
461
|
if (s_->flow_controlled_buffer.length == 0 &&
|
@@ -489,9 +487,9 @@ class StreamWriteContext {
|
|
489
487
|
}
|
490
488
|
write_context_->ResetPingRecvClock();
|
491
489
|
if (data_send_context.is_last_frame()) {
|
492
|
-
SentLastFrame(
|
490
|
+
SentLastFrame();
|
493
491
|
}
|
494
|
-
data_send_context.CallCallbacks(
|
492
|
+
data_send_context.CallCallbacks();
|
495
493
|
stream_became_writable_ = true;
|
496
494
|
if (s_->flow_controlled_buffer.length > 0 ||
|
497
495
|
s_->compressed_data_buffer.length > 0) {
|
@@ -501,7 +499,7 @@ class StreamWriteContext {
|
|
501
499
|
write_context_->IncMessageWrites();
|
502
500
|
}
|
503
501
|
|
504
|
-
void FlushTrailingMetadata(
|
502
|
+
void FlushTrailingMetadata() {
|
505
503
|
if (!s_->sent_initial_metadata) return;
|
506
504
|
|
507
505
|
if (s_->send_trailing_metadata == nullptr) return;
|
@@ -522,18 +520,18 @@ class StreamWriteContext {
|
|
522
520
|
|
523
521
|
t_->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
|
524
522
|
&s_->stats.outgoing};
|
525
|
-
grpc_chttp2_encode_header(
|
523
|
+
grpc_chttp2_encode_header(&t_->hpack_compressor,
|
526
524
|
extra_headers_for_trailing_metadata_,
|
527
525
|
num_extra_headers_for_trailing_metadata_,
|
528
526
|
s_->send_trailing_metadata, &hopt, &t_->outbuf);
|
529
527
|
}
|
530
528
|
write_context_->IncTrailingMetadataWrites();
|
531
529
|
write_context_->ResetPingRecvClock();
|
532
|
-
SentLastFrame(
|
530
|
+
SentLastFrame();
|
533
531
|
|
534
532
|
write_context_->NoteScheduledResults();
|
535
533
|
grpc_chttp2_complete_closure_step(
|
536
|
-
|
534
|
+
t_, s_, &s_->send_trailing_metadata_finished, GRPC_ERROR_NONE,
|
537
535
|
"send_trailing_metadata_finished");
|
538
536
|
}
|
539
537
|
|
@@ -557,7 +555,7 @@ class StreamWriteContext {
|
|
557
555
|
}
|
558
556
|
}
|
559
557
|
|
560
|
-
void SentLastFrame(
|
558
|
+
void SentLastFrame() {
|
561
559
|
s_->send_trailing_metadata = nullptr;
|
562
560
|
s_->sent_trailing_metadata = true;
|
563
561
|
|
@@ -566,7 +564,7 @@ class StreamWriteContext {
|
|
566
564
|
&t_->outbuf, grpc_chttp2_rst_stream_create(
|
567
565
|
s_->id, GRPC_HTTP2_NO_ERROR, &s_->stats.outgoing));
|
568
566
|
}
|
569
|
-
grpc_chttp2_mark_stream_closed(
|
567
|
+
grpc_chttp2_mark_stream_closed(t_, s_, !t_->is_client, true,
|
570
568
|
GRPC_ERROR_NONE);
|
571
569
|
}
|
572
570
|
|
@@ -580,12 +578,12 @@ class StreamWriteContext {
|
|
580
578
|
} // namespace
|
581
579
|
|
582
580
|
grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
583
|
-
|
584
|
-
WriteContext ctx(
|
585
|
-
ctx.FlushSettings(
|
581
|
+
grpc_chttp2_transport* t) {
|
582
|
+
WriteContext ctx(t);
|
583
|
+
ctx.FlushSettings();
|
586
584
|
ctx.FlushPingAcks();
|
587
|
-
ctx.FlushQueuedBuffers(
|
588
|
-
ctx.EnactHpackSettings(
|
585
|
+
ctx.FlushQueuedBuffers();
|
586
|
+
ctx.EnactHpackSettings();
|
589
587
|
|
590
588
|
if (t->flow_control->remote_window() > 0) {
|
591
589
|
ctx.UpdateStreamsNoLongerStalled();
|
@@ -595,47 +593,45 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
|
595
593
|
(according to available window sizes) and add to the output buffer */
|
596
594
|
while (grpc_chttp2_stream* s = ctx.NextStream()) {
|
597
595
|
StreamWriteContext stream_ctx(&ctx, s);
|
598
|
-
stream_ctx.FlushInitialMetadata(
|
599
|
-
stream_ctx.FlushWindowUpdates(
|
600
|
-
stream_ctx.FlushData(
|
601
|
-
stream_ctx.FlushTrailingMetadata(
|
596
|
+
stream_ctx.FlushInitialMetadata();
|
597
|
+
stream_ctx.FlushWindowUpdates();
|
598
|
+
stream_ctx.FlushData();
|
599
|
+
stream_ctx.FlushTrailingMetadata();
|
602
600
|
|
603
601
|
if (stream_ctx.stream_became_writable()) {
|
604
602
|
if (!grpc_chttp2_list_add_writing_stream(t, s)) {
|
605
603
|
/* already in writing list: drop ref */
|
606
|
-
GRPC_CHTTP2_STREAM_UNREF(
|
604
|
+
GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:already_writing");
|
607
605
|
} else {
|
608
606
|
/* ref will be dropped at end of write */
|
609
607
|
}
|
610
608
|
} else {
|
611
|
-
GRPC_CHTTP2_STREAM_UNREF(
|
609
|
+
GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:no_write");
|
612
610
|
}
|
613
611
|
}
|
614
612
|
|
615
|
-
ctx.FlushWindowUpdates(
|
613
|
+
ctx.FlushWindowUpdates();
|
616
614
|
|
617
|
-
maybe_initiate_ping(
|
615
|
+
maybe_initiate_ping(t);
|
618
616
|
|
619
617
|
GPR_TIMER_END("grpc_chttp2_begin_write", 0);
|
620
618
|
|
621
619
|
return ctx.Result();
|
622
620
|
}
|
623
621
|
|
624
|
-
void grpc_chttp2_end_write(
|
625
|
-
grpc_error* error) {
|
622
|
+
void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error* error) {
|
626
623
|
GPR_TIMER_BEGIN("grpc_chttp2_end_write", 0);
|
627
624
|
grpc_chttp2_stream* s;
|
628
625
|
|
629
626
|
while (grpc_chttp2_list_pop_writing_stream(t, &s)) {
|
630
627
|
if (s->sending_bytes != 0) {
|
631
|
-
update_list(
|
632
|
-
&s->
|
633
|
-
GRPC_ERROR_REF(error));
|
628
|
+
update_list(t, s, (int64_t)s->sending_bytes, &s->on_write_finished_cbs,
|
629
|
+
&s->flow_controlled_bytes_written, GRPC_ERROR_REF(error));
|
634
630
|
s->sending_bytes = 0;
|
635
631
|
}
|
636
|
-
GRPC_CHTTP2_STREAM_UNREF(
|
632
|
+
GRPC_CHTTP2_STREAM_UNREF(s, "chttp2_writing:end");
|
637
633
|
}
|
638
|
-
grpc_slice_buffer_reset_and_unref_internal(
|
634
|
+
grpc_slice_buffer_reset_and_unref_internal(&t->outbuf);
|
639
635
|
GRPC_ERROR_UNREF(error);
|
640
636
|
GPR_TIMER_END("grpc_chttp2_end_write", 0);
|
641
637
|
}
|
@@ -21,8 +21,6 @@
|
|
21
21
|
|
22
22
|
grpc_core::TraceFlag grpc_inproc_trace(false, "inproc");
|
23
23
|
|
24
|
-
|
24
|
+
void grpc_inproc_plugin_init(void) { grpc_inproc_transport_init(); }
|
25
25
|
|
26
|
-
|
27
|
-
grpc_inproc_transport_shutdown();
|
28
|
-
}
|
26
|
+
void grpc_inproc_plugin_shutdown(void) { grpc_inproc_transport_shutdown(); }
|
@@ -54,8 +54,8 @@ typedef struct inproc_transport {
|
|
54
54
|
gpr_refcount refs;
|
55
55
|
bool is_client;
|
56
56
|
grpc_connectivity_state_tracker connectivity;
|
57
|
-
void (*accept_stream_cb)(
|
58
|
-
|
57
|
+
void (*accept_stream_cb)(void* user_data, grpc_transport* transport,
|
58
|
+
const void* server_data);
|
59
59
|
void* accept_stream_data;
|
60
60
|
bool is_closed;
|
61
61
|
struct inproc_transport* other_side;
|
@@ -118,39 +118,36 @@ typedef struct inproc_stream {
|
|
118
118
|
} inproc_stream;
|
119
119
|
|
120
120
|
static grpc_closure do_nothing_closure;
|
121
|
-
static bool cancel_stream_locked(
|
122
|
-
|
123
|
-
static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
124
|
-
grpc_error* error);
|
121
|
+
static bool cancel_stream_locked(inproc_stream* s, grpc_error* error);
|
122
|
+
static void op_state_machine(void* arg, grpc_error* error);
|
125
123
|
|
126
124
|
static void ref_transport(inproc_transport* t) {
|
127
125
|
INPROC_LOG(GPR_DEBUG, "ref_transport %p", t);
|
128
126
|
gpr_ref(&t->refs);
|
129
127
|
}
|
130
128
|
|
131
|
-
static void really_destroy_transport(
|
132
|
-
inproc_transport* t) {
|
129
|
+
static void really_destroy_transport(inproc_transport* t) {
|
133
130
|
INPROC_LOG(GPR_DEBUG, "really_destroy_transport %p", t);
|
134
|
-
grpc_connectivity_state_destroy(
|
131
|
+
grpc_connectivity_state_destroy(&t->connectivity);
|
135
132
|
if (gpr_unref(&t->mu->refs)) {
|
136
133
|
gpr_free(t->mu);
|
137
134
|
}
|
138
135
|
gpr_free(t);
|
139
136
|
}
|
140
137
|
|
141
|
-
static void unref_transport(
|
138
|
+
static void unref_transport(inproc_transport* t) {
|
142
139
|
INPROC_LOG(GPR_DEBUG, "unref_transport %p", t);
|
143
140
|
if (gpr_unref(&t->refs)) {
|
144
|
-
really_destroy_transport(
|
141
|
+
really_destroy_transport(t);
|
145
142
|
}
|
146
143
|
}
|
147
144
|
|
148
145
|
#ifndef NDEBUG
|
149
146
|
#define STREAM_REF(refs, reason) grpc_stream_ref(refs, reason)
|
150
|
-
#define STREAM_UNREF(
|
147
|
+
#define STREAM_UNREF(refs, reason) grpc_stream_unref(refs, reason)
|
151
148
|
#else
|
152
149
|
#define STREAM_REF(refs, reason) grpc_stream_ref(refs)
|
153
|
-
#define STREAM_UNREF(
|
150
|
+
#define STREAM_UNREF(refs, reason) grpc_stream_unref(refs)
|
154
151
|
#endif
|
155
152
|
|
156
153
|
static void ref_stream(inproc_stream* s, const char* reason) {
|
@@ -158,13 +155,12 @@ static void ref_stream(inproc_stream* s, const char* reason) {
|
|
158
155
|
STREAM_REF(s->refs, reason);
|
159
156
|
}
|
160
157
|
|
161
|
-
static void unref_stream(
|
162
|
-
const char* reason) {
|
158
|
+
static void unref_stream(inproc_stream* s, const char* reason) {
|
163
159
|
INPROC_LOG(GPR_DEBUG, "unref_stream %p %s", s, reason);
|
164
|
-
STREAM_UNREF(
|
160
|
+
STREAM_UNREF(s->refs, reason);
|
165
161
|
}
|
166
162
|
|
167
|
-
static void really_destroy_stream(
|
163
|
+
static void really_destroy_stream(inproc_stream* s) {
|
168
164
|
INPROC_LOG(GPR_DEBUG, "really_destroy_stream %p", s);
|
169
165
|
|
170
166
|
GRPC_ERROR_UNREF(s->write_buffer_cancel_error);
|
@@ -172,13 +168,13 @@ static void really_destroy_stream(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
|
|
172
168
|
GRPC_ERROR_UNREF(s->cancel_other_error);
|
173
169
|
|
174
170
|
if (s->recv_inited) {
|
175
|
-
grpc_slice_buffer_destroy_internal(
|
171
|
+
grpc_slice_buffer_destroy_internal(&s->recv_message);
|
176
172
|
}
|
177
173
|
|
178
|
-
unref_transport(
|
174
|
+
unref_transport(s->t);
|
179
175
|
|
180
176
|
if (s->closure_at_destroy) {
|
181
|
-
GRPC_CLOSURE_SCHED(
|
177
|
+
GRPC_CLOSURE_SCHED(s->closure_at_destroy, GRPC_ERROR_NONE);
|
182
178
|
}
|
183
179
|
}
|
184
180
|
|
@@ -195,7 +191,7 @@ static void log_metadata(const grpc_metadata_batch* md_batch, bool is_client,
|
|
195
191
|
}
|
196
192
|
}
|
197
193
|
|
198
|
-
static grpc_error* fill_in_metadata(
|
194
|
+
static grpc_error* fill_in_metadata(inproc_stream* s,
|
199
195
|
const grpc_metadata_batch* metadata,
|
200
196
|
uint32_t flags, grpc_metadata_batch* out_md,
|
201
197
|
uint32_t* outflags, bool* markfilled) {
|
@@ -214,18 +210,18 @@ static grpc_error* fill_in_metadata(grpc_exec_ctx* exec_ctx, inproc_stream* s,
|
|
214
210
|
(elem != nullptr) && (error == GRPC_ERROR_NONE); elem = elem->next) {
|
215
211
|
grpc_linked_mdelem* nelem =
|
216
212
|
(grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*nelem));
|
217
|
-
nelem->md =
|
218
|
-
|
219
|
-
|
213
|
+
nelem->md =
|
214
|
+
grpc_mdelem_from_slices(grpc_slice_intern(GRPC_MDKEY(elem->md)),
|
215
|
+
grpc_slice_intern(GRPC_MDVALUE(elem->md)));
|
220
216
|
|
221
|
-
error = grpc_metadata_batch_link_tail(
|
217
|
+
error = grpc_metadata_batch_link_tail(out_md, nelem);
|
222
218
|
}
|
223
219
|
return error;
|
224
220
|
}
|
225
221
|
|
226
|
-
static int init_stream(
|
227
|
-
|
228
|
-
|
222
|
+
static int init_stream(grpc_transport* gt, grpc_stream* gs,
|
223
|
+
grpc_stream_refcount* refcount, const void* server_data,
|
224
|
+
gpr_arena* arena) {
|
229
225
|
INPROC_LOG(GPR_DEBUG, "init_stream %p %p %p", gt, gs, server_data);
|
230
226
|
inproc_transport* t = (inproc_transport*)gt;
|
231
227
|
inproc_stream* s = (inproc_stream*)gs;
|
@@ -285,8 +281,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
285
281
|
// side to avoid destruction
|
286
282
|
INPROC_LOG(GPR_DEBUG, "calling accept stream cb %p %p",
|
287
283
|
st->accept_stream_cb, st->accept_stream_data);
|
288
|
-
(*st->accept_stream_cb)(
|
289
|
-
(void*)s);
|
284
|
+
(*st->accept_stream_cb)(st->accept_stream_data, &st->base, (void*)s);
|
290
285
|
} else {
|
291
286
|
// This is the server-side and is being called through accept_stream_cb
|
292
287
|
inproc_stream* cs = (inproc_stream*)server_data;
|
@@ -301,19 +296,19 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
301
296
|
// Now transfer from the other side's write_buffer if any to the to_read
|
302
297
|
// buffer
|
303
298
|
if (cs->write_buffer_initial_md_filled) {
|
304
|
-
fill_in_metadata(
|
299
|
+
fill_in_metadata(s, &cs->write_buffer_initial_md,
|
305
300
|
cs->write_buffer_initial_md_flags,
|
306
301
|
&s->to_read_initial_md, &s->to_read_initial_md_flags,
|
307
302
|
&s->to_read_initial_md_filled);
|
308
303
|
s->deadline = GPR_MIN(s->deadline, cs->write_buffer_deadline);
|
309
|
-
grpc_metadata_batch_clear(
|
304
|
+
grpc_metadata_batch_clear(&cs->write_buffer_initial_md);
|
310
305
|
cs->write_buffer_initial_md_filled = false;
|
311
306
|
}
|
312
307
|
if (cs->write_buffer_trailing_md_filled) {
|
313
|
-
fill_in_metadata(
|
308
|
+
fill_in_metadata(s, &cs->write_buffer_trailing_md, 0,
|
314
309
|
&s->to_read_trailing_md, nullptr,
|
315
310
|
&s->to_read_trailing_md_filled);
|
316
|
-
grpc_metadata_batch_clear(
|
311
|
+
grpc_metadata_batch_clear(&cs->write_buffer_trailing_md);
|
317
312
|
cs->write_buffer_trailing_md_filled = false;
|
318
313
|
}
|
319
314
|
if (cs->write_buffer_cancel_error != GRPC_ERROR_NONE) {
|
@@ -326,11 +321,11 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
326
321
|
return 0; // return value is not important
|
327
322
|
}
|
328
323
|
|
329
|
-
static void close_stream_locked(
|
324
|
+
static void close_stream_locked(inproc_stream* s) {
|
330
325
|
if (!s->closed) {
|
331
326
|
// Release the metadata that we would have written out
|
332
|
-
grpc_metadata_batch_destroy(
|
333
|
-
grpc_metadata_batch_destroy(
|
327
|
+
grpc_metadata_batch_destroy(&s->write_buffer_initial_md);
|
328
|
+
grpc_metadata_batch_destroy(&s->write_buffer_trailing_md);
|
334
329
|
|
335
330
|
if (s->listed) {
|
336
331
|
inproc_stream* p = s->stream_list_prev;
|
@@ -344,22 +339,21 @@ static void close_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s) {
|
|
344
339
|
n->stream_list_prev = p;
|
345
340
|
}
|
346
341
|
s->listed = false;
|
347
|
-
unref_stream(
|
342
|
+
unref_stream(s, "close_stream:list");
|
348
343
|
}
|
349
344
|
s->closed = true;
|
350
|
-
unref_stream(
|
345
|
+
unref_stream(s, "close_stream:closing");
|
351
346
|
}
|
352
347
|
}
|
353
348
|
|
354
349
|
// This function means that we are done talking/listening to the other side
|
355
|
-
static void close_other_side_locked(
|
356
|
-
const char* reason) {
|
350
|
+
static void close_other_side_locked(inproc_stream* s, const char* reason) {
|
357
351
|
if (s->other_side != nullptr) {
|
358
352
|
// First release the metadata that came from the other side's arena
|
359
|
-
grpc_metadata_batch_destroy(
|
360
|
-
grpc_metadata_batch_destroy(
|
353
|
+
grpc_metadata_batch_destroy(&s->to_read_initial_md);
|
354
|
+
grpc_metadata_batch_destroy(&s->to_read_trailing_md);
|
361
355
|
|
362
|
-
unref_stream(
|
356
|
+
unref_stream(s->other_side, reason);
|
363
357
|
s->other_side_closed = true;
|
364
358
|
s->other_side = nullptr;
|
365
359
|
} else if (!s->other_side_closed) {
|
@@ -371,8 +365,7 @@ static void close_other_side_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
|
|
371
365
|
// this stream_op_batch is only one of the pending operations for this
|
372
366
|
// stream. This is called when one of the pending operations for the stream
|
373
367
|
// is done and about to be NULLed out
|
374
|
-
static void complete_if_batch_end_locked(
|
375
|
-
inproc_stream* s, grpc_error* error,
|
368
|
+
static void complete_if_batch_end_locked(inproc_stream* s, grpc_error* error,
|
376
369
|
grpc_transport_stream_op_batch* op,
|
377
370
|
const char* msg) {
|
378
371
|
int is_sm = (int)(op == s->send_message_op);
|
@@ -383,22 +376,20 @@ static void complete_if_batch_end_locked(grpc_exec_ctx* exec_ctx,
|
|
383
376
|
|
384
377
|
if ((is_sm + is_stm + is_rim + is_rm + is_rtm) == 1) {
|
385
378
|
INPROC_LOG(GPR_DEBUG, "%s %p %p %p", msg, s, op, error);
|
386
|
-
GRPC_CLOSURE_SCHED(
|
379
|
+
GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_REF(error));
|
387
380
|
}
|
388
381
|
}
|
389
382
|
|
390
|
-
static void maybe_schedule_op_closure_locked(
|
391
|
-
inproc_stream* s,
|
383
|
+
static void maybe_schedule_op_closure_locked(inproc_stream* s,
|
392
384
|
grpc_error* error) {
|
393
385
|
if (s && s->ops_needed && !s->op_closure_scheduled) {
|
394
|
-
GRPC_CLOSURE_SCHED(
|
386
|
+
GRPC_CLOSURE_SCHED(&s->op_closure, GRPC_ERROR_REF(error));
|
395
387
|
s->op_closure_scheduled = true;
|
396
388
|
s->ops_needed = false;
|
397
389
|
}
|
398
390
|
}
|
399
391
|
|
400
|
-
static void fail_helper_locked(
|
401
|
-
grpc_error* error) {
|
392
|
+
static void fail_helper_locked(inproc_stream* s, grpc_error* error) {
|
402
393
|
INPROC_LOG(GPR_DEBUG, "op_state_machine %p fail_helper", s);
|
403
394
|
// If we're failing this side, we need to make sure that
|
404
395
|
// we also send or have already sent trailing metadata
|
@@ -415,14 +406,14 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
|
|
415
406
|
: &other->to_read_trailing_md;
|
416
407
|
bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled
|
417
408
|
: &other->to_read_trailing_md_filled;
|
418
|
-
fill_in_metadata(
|
419
|
-
grpc_metadata_batch_destroy(
|
409
|
+
fill_in_metadata(s, &fake_md, 0, dest, nullptr, destfilled);
|
410
|
+
grpc_metadata_batch_destroy(&fake_md);
|
420
411
|
|
421
412
|
if (other != nullptr) {
|
422
413
|
if (other->cancel_other_error == GRPC_ERROR_NONE) {
|
423
414
|
other->cancel_other_error = GRPC_ERROR_REF(error);
|
424
415
|
}
|
425
|
-
maybe_schedule_op_closure_locked(
|
416
|
+
maybe_schedule_op_closure_locked(other, error);
|
426
417
|
} else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
|
427
418
|
s->write_buffer_cancel_error = GRPC_ERROR_REF(error);
|
428
419
|
}
|
@@ -436,39 +427,44 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
|
|
436
427
|
grpc_metadata_batch_init(&fake_md);
|
437
428
|
grpc_linked_mdelem* path_md =
|
438
429
|
(grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*path_md));
|
439
|
-
path_md->md =
|
440
|
-
|
441
|
-
GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, path_md) ==
|
430
|
+
path_md->md = grpc_mdelem_from_slices(g_fake_path_key, g_fake_path_value);
|
431
|
+
GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, path_md) ==
|
442
432
|
GRPC_ERROR_NONE);
|
443
433
|
grpc_linked_mdelem* auth_md =
|
444
434
|
(grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*auth_md));
|
445
|
-
auth_md->md =
|
446
|
-
|
447
|
-
GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, auth_md) ==
|
435
|
+
auth_md->md = grpc_mdelem_from_slices(g_fake_auth_key, g_fake_auth_value);
|
436
|
+
GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, auth_md) ==
|
448
437
|
GRPC_ERROR_NONE);
|
449
438
|
|
450
439
|
fill_in_metadata(
|
451
|
-
|
440
|
+
s, &fake_md, 0,
|
452
441
|
s->recv_initial_md_op->payload->recv_initial_metadata
|
453
442
|
.recv_initial_metadata,
|
454
443
|
s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
|
455
444
|
nullptr);
|
456
|
-
grpc_metadata_batch_destroy(
|
445
|
+
grpc_metadata_batch_destroy(&fake_md);
|
457
446
|
err = GRPC_ERROR_NONE;
|
458
447
|
} else {
|
459
448
|
err = GRPC_ERROR_REF(error);
|
460
449
|
}
|
450
|
+
if (s->recv_initial_md_op->payload->recv_initial_metadata
|
451
|
+
.trailing_metadata_available != nullptr) {
|
452
|
+
// Set to true unconditionally, because we're failing the call, so even
|
453
|
+
// if we haven't actually seen the send_trailing_metadata op from the
|
454
|
+
// other side, we're going to return trailing metadata anyway.
|
455
|
+
*s->recv_initial_md_op->payload->recv_initial_metadata
|
456
|
+
.trailing_metadata_available = true;
|
457
|
+
}
|
461
458
|
INPROC_LOG(GPR_DEBUG,
|
462
459
|
"fail_helper %p scheduling initial-metadata-ready %p %p", s,
|
463
460
|
error, err);
|
464
|
-
GRPC_CLOSURE_SCHED(
|
465
|
-
s->recv_initial_md_op->payload->recv_initial_metadata
|
461
|
+
GRPC_CLOSURE_SCHED(s->recv_initial_md_op->payload->recv_initial_metadata
|
466
462
|
.recv_initial_metadata_ready,
|
467
463
|
err);
|
468
464
|
// Last use of err so no need to REF and then UNREF it
|
469
465
|
|
470
466
|
complete_if_batch_end_locked(
|
471
|
-
|
467
|
+
s, error, s->recv_initial_md_op,
|
472
468
|
"fail_helper scheduling recv-initial-metadata-on-complete");
|
473
469
|
s->recv_initial_md_op = nullptr;
|
474
470
|
}
|
@@ -476,22 +472,22 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
|
|
476
472
|
INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-ready %p", s,
|
477
473
|
error);
|
478
474
|
GRPC_CLOSURE_SCHED(
|
479
|
-
|
475
|
+
s->recv_message_op->payload->recv_message.recv_message_ready,
|
480
476
|
GRPC_ERROR_REF(error));
|
481
477
|
complete_if_batch_end_locked(
|
482
|
-
|
478
|
+
s, error, s->recv_message_op,
|
483
479
|
"fail_helper scheduling recv-message-on-complete");
|
484
480
|
s->recv_message_op = nullptr;
|
485
481
|
}
|
486
482
|
if (s->send_message_op) {
|
487
483
|
complete_if_batch_end_locked(
|
488
|
-
|
484
|
+
s, error, s->send_message_op,
|
489
485
|
"fail_helper scheduling send-message-on-complete");
|
490
486
|
s->send_message_op = nullptr;
|
491
487
|
}
|
492
488
|
if (s->send_trailing_md_op) {
|
493
489
|
complete_if_batch_end_locked(
|
494
|
-
|
490
|
+
s, error, s->send_trailing_md_op,
|
495
491
|
"fail_helper scheduling send-trailng-md-on-complete");
|
496
492
|
s->send_trailing_md_op = nullptr;
|
497
493
|
}
|
@@ -500,23 +496,22 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
|
|
500
496
|
"fail_helper %p scheduling trailing-md-on-complete %p", s,
|
501
497
|
error);
|
502
498
|
complete_if_batch_end_locked(
|
503
|
-
|
499
|
+
s, error, s->recv_trailing_md_op,
|
504
500
|
"fail_helper scheduling recv-trailing-metadata-on-complete");
|
505
501
|
s->recv_trailing_md_op = nullptr;
|
506
502
|
}
|
507
|
-
close_other_side_locked(
|
508
|
-
close_stream_locked(
|
503
|
+
close_other_side_locked(s, "fail_helper:other_side");
|
504
|
+
close_stream_locked(s);
|
509
505
|
|
510
506
|
GRPC_ERROR_UNREF(error);
|
511
507
|
}
|
512
508
|
|
513
|
-
static void message_transfer_locked(
|
514
|
-
inproc_stream* sender,
|
509
|
+
static void message_transfer_locked(inproc_stream* sender,
|
515
510
|
inproc_stream* receiver) {
|
516
511
|
size_t remaining =
|
517
512
|
sender->send_message_op->payload->send_message.send_message->length;
|
518
513
|
if (receiver->recv_inited) {
|
519
|
-
grpc_slice_buffer_destroy_internal(
|
514
|
+
grpc_slice_buffer_destroy_internal(&receiver->recv_message);
|
520
515
|
}
|
521
516
|
grpc_slice_buffer_init(&receiver->recv_message);
|
522
517
|
receiver->recv_inited = true;
|
@@ -524,13 +519,13 @@ static void message_transfer_locked(grpc_exec_ctx* exec_ctx,
|
|
524
519
|
grpc_slice message_slice;
|
525
520
|
grpc_closure unused;
|
526
521
|
GPR_ASSERT(grpc_byte_stream_next(
|
527
|
-
|
528
|
-
|
522
|
+
sender->send_message_op->payload->send_message.send_message, SIZE_MAX,
|
523
|
+
&unused));
|
529
524
|
grpc_error* error = grpc_byte_stream_pull(
|
530
|
-
|
525
|
+
sender->send_message_op->payload->send_message.send_message,
|
531
526
|
&message_slice);
|
532
527
|
if (error != GRPC_ERROR_NONE) {
|
533
|
-
cancel_stream_locked(
|
528
|
+
cancel_stream_locked(sender, GRPC_ERROR_REF(error));
|
534
529
|
break;
|
535
530
|
}
|
536
531
|
GPR_ASSERT(error == GRPC_ERROR_NONE);
|
@@ -545,22 +540,20 @@ static void message_transfer_locked(grpc_exec_ctx* exec_ctx,
|
|
545
540
|
INPROC_LOG(GPR_DEBUG, "message_transfer_locked %p scheduling message-ready",
|
546
541
|
receiver);
|
547
542
|
GRPC_CLOSURE_SCHED(
|
548
|
-
exec_ctx,
|
549
543
|
receiver->recv_message_op->payload->recv_message.recv_message_ready,
|
550
544
|
GRPC_ERROR_NONE);
|
551
545
|
complete_if_batch_end_locked(
|
552
|
-
|
546
|
+
sender, GRPC_ERROR_NONE, sender->send_message_op,
|
553
547
|
"message_transfer scheduling sender on_complete");
|
554
548
|
complete_if_batch_end_locked(
|
555
|
-
|
549
|
+
receiver, GRPC_ERROR_NONE, receiver->recv_message_op,
|
556
550
|
"message_transfer scheduling receiver on_complete");
|
557
551
|
|
558
552
|
receiver->recv_message_op = nullptr;
|
559
553
|
sender->send_message_op = nullptr;
|
560
554
|
}
|
561
555
|
|
562
|
-
static void op_state_machine(
|
563
|
-
grpc_error* error) {
|
556
|
+
static void op_state_machine(void* arg, grpc_error* error) {
|
564
557
|
// This function gets called when we have contents in the unprocessed reads
|
565
558
|
// Get what we want based on our ops wanted
|
566
559
|
// Schedule our appropriate closures
|
@@ -581,26 +574,26 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
581
574
|
inproc_stream* other = s->other_side;
|
582
575
|
|
583
576
|
if (s->cancel_self_error != GRPC_ERROR_NONE) {
|
584
|
-
fail_helper_locked(
|
577
|
+
fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_self_error));
|
585
578
|
goto done;
|
586
579
|
} else if (s->cancel_other_error != GRPC_ERROR_NONE) {
|
587
|
-
fail_helper_locked(
|
580
|
+
fail_helper_locked(s, GRPC_ERROR_REF(s->cancel_other_error));
|
588
581
|
goto done;
|
589
582
|
} else if (error != GRPC_ERROR_NONE) {
|
590
|
-
fail_helper_locked(
|
583
|
+
fail_helper_locked(s, GRPC_ERROR_REF(error));
|
591
584
|
goto done;
|
592
585
|
}
|
593
586
|
|
594
587
|
if (s->send_message_op && other) {
|
595
588
|
if (other->recv_message_op) {
|
596
|
-
message_transfer_locked(
|
597
|
-
maybe_schedule_op_closure_locked(
|
589
|
+
message_transfer_locked(s, other);
|
590
|
+
maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
|
598
591
|
} else if (!s->t->is_client &&
|
599
592
|
(s->trailing_md_sent || other->recv_trailing_md_op)) {
|
600
593
|
// A server send will never be matched if the client is waiting
|
601
594
|
// for trailing metadata already
|
602
595
|
complete_if_batch_end_locked(
|
603
|
-
|
596
|
+
s, GRPC_ERROR_NONE, s->send_message_op,
|
604
597
|
"op_state_machine scheduling send-message-on-complete");
|
605
598
|
s->send_message_op = nullptr;
|
606
599
|
}
|
@@ -622,11 +615,11 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
622
615
|
// The buffer is already in use; that's an error!
|
623
616
|
INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s);
|
624
617
|
new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra trailing metadata");
|
625
|
-
fail_helper_locked(
|
618
|
+
fail_helper_locked(s, GRPC_ERROR_REF(new_err));
|
626
619
|
goto done;
|
627
620
|
} else {
|
628
621
|
if (!other || !other->closed) {
|
629
|
-
fill_in_metadata(
|
622
|
+
fill_in_metadata(s,
|
630
623
|
s->send_trailing_md_op->payload->send_trailing_metadata
|
631
624
|
.send_trailing_metadata,
|
632
625
|
0, dest, nullptr, destfilled);
|
@@ -635,15 +628,15 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
635
628
|
if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
|
636
629
|
INPROC_LOG(GPR_DEBUG,
|
637
630
|
"op_state_machine %p scheduling trailing-md-on-complete", s);
|
638
|
-
GRPC_CLOSURE_SCHED(
|
631
|
+
GRPC_CLOSURE_SCHED(s->recv_trailing_md_op->on_complete,
|
639
632
|
GRPC_ERROR_NONE);
|
640
633
|
s->recv_trailing_md_op = nullptr;
|
641
634
|
needs_close = true;
|
642
635
|
}
|
643
636
|
}
|
644
|
-
maybe_schedule_op_closure_locked(
|
637
|
+
maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
|
645
638
|
complete_if_batch_end_locked(
|
646
|
-
|
639
|
+
s, GRPC_ERROR_NONE, s->send_trailing_md_op,
|
647
640
|
"op_state_machine scheduling send-trailing-metadata-on-complete");
|
648
641
|
s->send_trailing_md_op = nullptr;
|
649
642
|
}
|
@@ -656,31 +649,36 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
656
649
|
"op_state_machine %p scheduling on_complete errors for already "
|
657
650
|
"recvd initial md %p",
|
658
651
|
s, new_err);
|
659
|
-
fail_helper_locked(
|
652
|
+
fail_helper_locked(s, GRPC_ERROR_REF(new_err));
|
660
653
|
goto done;
|
661
654
|
}
|
662
655
|
|
663
656
|
if (s->to_read_initial_md_filled) {
|
664
657
|
s->initial_md_recvd = true;
|
665
658
|
new_err = fill_in_metadata(
|
666
|
-
|
659
|
+
s, &s->to_read_initial_md, s->to_read_initial_md_flags,
|
667
660
|
s->recv_initial_md_op->payload->recv_initial_metadata
|
668
661
|
.recv_initial_metadata,
|
669
662
|
s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
|
670
663
|
nullptr);
|
671
664
|
s->recv_initial_md_op->payload->recv_initial_metadata
|
672
665
|
.recv_initial_metadata->deadline = s->deadline;
|
673
|
-
|
666
|
+
if (s->recv_initial_md_op->payload->recv_initial_metadata
|
667
|
+
.trailing_metadata_available != nullptr) {
|
668
|
+
*s->recv_initial_md_op->payload->recv_initial_metadata
|
669
|
+
.trailing_metadata_available =
|
670
|
+
(other != nullptr && other->send_trailing_md_op != nullptr);
|
671
|
+
}
|
672
|
+
grpc_metadata_batch_clear(&s->to_read_initial_md);
|
674
673
|
s->to_read_initial_md_filled = false;
|
675
674
|
INPROC_LOG(GPR_DEBUG,
|
676
675
|
"op_state_machine %p scheduling initial-metadata-ready %p", s,
|
677
676
|
new_err);
|
678
|
-
GRPC_CLOSURE_SCHED(
|
679
|
-
s->recv_initial_md_op->payload->recv_initial_metadata
|
677
|
+
GRPC_CLOSURE_SCHED(s->recv_initial_md_op->payload->recv_initial_metadata
|
680
678
|
.recv_initial_metadata_ready,
|
681
679
|
GRPC_ERROR_REF(new_err));
|
682
680
|
complete_if_batch_end_locked(
|
683
|
-
|
681
|
+
s, new_err, s->recv_initial_md_op,
|
684
682
|
"op_state_machine scheduling recv-initial-metadata-on-complete");
|
685
683
|
s->recv_initial_md_op = nullptr;
|
686
684
|
|
@@ -688,20 +686,20 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
688
686
|
INPROC_LOG(GPR_DEBUG,
|
689
687
|
"op_state_machine %p scheduling on_complete errors2 %p", s,
|
690
688
|
new_err);
|
691
|
-
fail_helper_locked(
|
689
|
+
fail_helper_locked(s, GRPC_ERROR_REF(new_err));
|
692
690
|
goto done;
|
693
691
|
}
|
694
692
|
}
|
695
693
|
}
|
696
694
|
if (s->recv_message_op) {
|
697
695
|
if (other && other->send_message_op) {
|
698
|
-
message_transfer_locked(
|
699
|
-
maybe_schedule_op_closure_locked(
|
696
|
+
message_transfer_locked(other, s);
|
697
|
+
maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
|
700
698
|
}
|
701
699
|
}
|
702
700
|
if (s->recv_trailing_md_op && s->t->is_client && other &&
|
703
701
|
other->send_message_op) {
|
704
|
-
maybe_schedule_op_closure_locked(
|
702
|
+
maybe_schedule_op_closure_locked(other, GRPC_ERROR_NONE);
|
705
703
|
}
|
706
704
|
if (s->to_read_trailing_md_filled) {
|
707
705
|
if (s->trailing_md_recvd) {
|
@@ -712,7 +710,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
712
710
|
"op_state_machine %p scheduling on_complete errors for already "
|
713
711
|
"recvd trailing md %p",
|
714
712
|
s, new_err);
|
715
|
-
fail_helper_locked(
|
713
|
+
fail_helper_locked(s, GRPC_ERROR_REF(new_err));
|
716
714
|
goto done;
|
717
715
|
}
|
718
716
|
if (s->recv_message_op != nullptr) {
|
@@ -720,11 +718,10 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
720
718
|
// satisfied
|
721
719
|
INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s);
|
722
720
|
GRPC_CLOSURE_SCHED(
|
723
|
-
exec_ctx,
|
724
721
|
s->recv_message_op->payload->recv_message.recv_message_ready,
|
725
722
|
GRPC_ERROR_NONE);
|
726
723
|
complete_if_batch_end_locked(
|
727
|
-
|
724
|
+
s, new_err, s->recv_message_op,
|
728
725
|
"op_state_machine scheduling recv-message-on-complete");
|
729
726
|
s->recv_message_op = nullptr;
|
730
727
|
}
|
@@ -732,7 +729,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
732
729
|
// Nothing further will try to receive from this stream, so finish off
|
733
730
|
// any outstanding send_message op
|
734
731
|
complete_if_batch_end_locked(
|
735
|
-
|
732
|
+
s, new_err, s->send_message_op,
|
736
733
|
"op_state_machine scheduling send-message-on-complete");
|
737
734
|
s->send_message_op = nullptr;
|
738
735
|
}
|
@@ -740,11 +737,11 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
740
737
|
// We wanted trailing metadata and we got it
|
741
738
|
s->trailing_md_recvd = true;
|
742
739
|
new_err =
|
743
|
-
fill_in_metadata(
|
740
|
+
fill_in_metadata(s, &s->to_read_trailing_md, 0,
|
744
741
|
s->recv_trailing_md_op->payload
|
745
742
|
->recv_trailing_metadata.recv_trailing_metadata,
|
746
743
|
nullptr, nullptr);
|
747
|
-
grpc_metadata_batch_clear(
|
744
|
+
grpc_metadata_batch_clear(&s->to_read_trailing_md);
|
748
745
|
s->to_read_trailing_md_filled = false;
|
749
746
|
|
750
747
|
// We should schedule the recv_trailing_md_op completion if
|
@@ -756,7 +753,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
756
753
|
INPROC_LOG(GPR_DEBUG,
|
757
754
|
"op_state_machine %p scheduling trailing-md-on-complete %p",
|
758
755
|
s, new_err);
|
759
|
-
GRPC_CLOSURE_SCHED(
|
756
|
+
GRPC_CLOSURE_SCHED(s->recv_trailing_md_op->on_complete,
|
760
757
|
GRPC_ERROR_REF(new_err));
|
761
758
|
s->recv_trailing_md_op = nullptr;
|
762
759
|
needs_close = true;
|
@@ -777,10 +774,10 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
777
774
|
// recv_message_op
|
778
775
|
INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s);
|
779
776
|
GRPC_CLOSURE_SCHED(
|
780
|
-
|
777
|
+
s->recv_message_op->payload->recv_message.recv_message_ready,
|
781
778
|
GRPC_ERROR_NONE);
|
782
779
|
complete_if_batch_end_locked(
|
783
|
-
|
780
|
+
s, new_err, s->recv_message_op,
|
784
781
|
"op_state_machine scheduling recv-message-on-complete");
|
785
782
|
s->recv_message_op = nullptr;
|
786
783
|
}
|
@@ -789,7 +786,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
789
786
|
// Nothing further will try to receive from this stream, so finish off
|
790
787
|
// any outstanding send_message op
|
791
788
|
complete_if_batch_end_locked(
|
792
|
-
|
789
|
+
s, new_err, s->send_message_op,
|
793
790
|
"op_state_machine scheduling send-message-on-complete");
|
794
791
|
s->send_message_op = nullptr;
|
795
792
|
}
|
@@ -805,22 +802,21 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg,
|
|
805
802
|
}
|
806
803
|
done:
|
807
804
|
if (needs_close) {
|
808
|
-
close_other_side_locked(
|
809
|
-
close_stream_locked(
|
805
|
+
close_other_side_locked(s, "op_state_machine");
|
806
|
+
close_stream_locked(s);
|
810
807
|
}
|
811
808
|
gpr_mu_unlock(mu);
|
812
809
|
GRPC_ERROR_UNREF(new_err);
|
813
810
|
}
|
814
811
|
|
815
|
-
static bool cancel_stream_locked(
|
816
|
-
grpc_error* error) {
|
812
|
+
static bool cancel_stream_locked(inproc_stream* s, grpc_error* error) {
|
817
813
|
bool ret = false; // was the cancel accepted
|
818
814
|
INPROC_LOG(GPR_DEBUG, "cancel_stream %p with %s", s,
|
819
815
|
grpc_error_string(error));
|
820
816
|
if (s->cancel_self_error == GRPC_ERROR_NONE) {
|
821
817
|
ret = true;
|
822
818
|
s->cancel_self_error = GRPC_ERROR_REF(error);
|
823
|
-
maybe_schedule_op_closure_locked(
|
819
|
+
maybe_schedule_op_closure_locked(s, s->cancel_self_error);
|
824
820
|
// Send trailing md to the other side indicating cancellation, even if we
|
825
821
|
// already have
|
826
822
|
s->trailing_md_sent = true;
|
@@ -834,15 +830,14 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
|
|
834
830
|
: &other->to_read_trailing_md;
|
835
831
|
bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled
|
836
832
|
: &other->to_read_trailing_md_filled;
|
837
|
-
fill_in_metadata(
|
838
|
-
grpc_metadata_batch_destroy(
|
833
|
+
fill_in_metadata(s, &cancel_md, 0, dest, nullptr, destfilled);
|
834
|
+
grpc_metadata_batch_destroy(&cancel_md);
|
839
835
|
|
840
836
|
if (other != nullptr) {
|
841
837
|
if (other->cancel_other_error == GRPC_ERROR_NONE) {
|
842
838
|
other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error);
|
843
839
|
}
|
844
|
-
maybe_schedule_op_closure_locked(
|
845
|
-
other->cancel_other_error);
|
840
|
+
maybe_schedule_op_closure_locked(other, other->cancel_other_error);
|
846
841
|
} else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
|
847
842
|
s->write_buffer_cancel_error = GRPC_ERROR_REF(s->cancel_self_error);
|
848
843
|
}
|
@@ -852,21 +847,20 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s,
|
|
852
847
|
// md, now's the chance
|
853
848
|
if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
|
854
849
|
complete_if_batch_end_locked(
|
855
|
-
|
850
|
+
s, s->cancel_self_error, s->recv_trailing_md_op,
|
856
851
|
"cancel_stream scheduling trailing-md-on-complete");
|
857
852
|
s->recv_trailing_md_op = nullptr;
|
858
853
|
}
|
859
854
|
}
|
860
855
|
|
861
|
-
close_other_side_locked(
|
862
|
-
close_stream_locked(
|
856
|
+
close_other_side_locked(s, "cancel_stream:other_side");
|
857
|
+
close_stream_locked(s);
|
863
858
|
|
864
859
|
GRPC_ERROR_UNREF(error);
|
865
860
|
return ret;
|
866
861
|
}
|
867
862
|
|
868
|
-
static void perform_stream_op(
|
869
|
-
grpc_stream* gs,
|
863
|
+
static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
|
870
864
|
grpc_transport_stream_op_batch* op) {
|
871
865
|
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %p %p", gt, gs, op);
|
872
866
|
inproc_stream* s = (inproc_stream*)gs;
|
@@ -892,7 +886,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
892
886
|
if (op->cancel_stream) {
|
893
887
|
// Call cancel_stream_locked without ref'ing the cancel_error because
|
894
888
|
// this function is responsible to make sure that that field gets unref'ed
|
895
|
-
cancel_stream_locked(
|
889
|
+
cancel_stream_locked(s, op->payload->cancel_stream.cancel_error);
|
896
890
|
// this op can complete without an error
|
897
891
|
} else if (s->cancel_self_error != GRPC_ERROR_NONE) {
|
898
892
|
// already self-canceled so still give it an error
|
@@ -932,8 +926,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
932
926
|
} else {
|
933
927
|
if (!other || !other->closed) {
|
934
928
|
fill_in_metadata(
|
935
|
-
|
936
|
-
op->payload->send_initial_metadata.send_initial_metadata,
|
929
|
+
s, op->payload->send_initial_metadata.send_initial_metadata,
|
937
930
|
op->payload->send_initial_metadata.send_initial_metadata_flags,
|
938
931
|
dest, destflags, destfilled);
|
939
932
|
}
|
@@ -945,7 +938,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
945
938
|
s->initial_md_sent = true;
|
946
939
|
}
|
947
940
|
}
|
948
|
-
maybe_schedule_op_closure_locked(
|
941
|
+
maybe_schedule_op_closure_locked(other, error);
|
949
942
|
}
|
950
943
|
}
|
951
944
|
|
@@ -985,7 +978,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
985
978
|
(op->recv_message && other && (other->send_message_op != nullptr)) ||
|
986
979
|
(s->to_read_trailing_md_filled || s->trailing_md_recvd)) {
|
987
980
|
if (!s->op_closure_scheduled) {
|
988
|
-
GRPC_CLOSURE_SCHED(
|
981
|
+
GRPC_CLOSURE_SCHED(&s->op_closure, GRPC_ERROR_NONE);
|
989
982
|
s->op_closure_scheduled = true;
|
990
983
|
}
|
991
984
|
} else {
|
@@ -995,12 +988,20 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
995
988
|
if (error != GRPC_ERROR_NONE) {
|
996
989
|
// Schedule op's closures that we didn't push to op state machine
|
997
990
|
if (op->recv_initial_metadata) {
|
991
|
+
if (op->payload->recv_initial_metadata.trailing_metadata_available !=
|
992
|
+
nullptr) {
|
993
|
+
// Set to true unconditionally, because we're failing the call, so
|
994
|
+
// even if we haven't actually seen the send_trailing_metadata op
|
995
|
+
// from the other side, we're going to return trailing metadata
|
996
|
+
// anyway.
|
997
|
+
*op->payload->recv_initial_metadata.trailing_metadata_available =
|
998
|
+
true;
|
999
|
+
}
|
998
1000
|
INPROC_LOG(
|
999
1001
|
GPR_DEBUG,
|
1000
1002
|
"perform_stream_op error %p scheduling initial-metadata-ready %p",
|
1001
1003
|
s, error);
|
1002
1004
|
GRPC_CLOSURE_SCHED(
|
1003
|
-
exec_ctx,
|
1004
1005
|
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
|
1005
1006
|
GRPC_ERROR_REF(error));
|
1006
1007
|
}
|
@@ -1009,28 +1010,26 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
1009
1010
|
GPR_DEBUG,
|
1010
1011
|
"perform_stream_op error %p scheduling recv message-ready %p", s,
|
1011
1012
|
error);
|
1012
|
-
GRPC_CLOSURE_SCHED(
|
1013
|
-
op->payload->recv_message.recv_message_ready,
|
1013
|
+
GRPC_CLOSURE_SCHED(op->payload->recv_message.recv_message_ready,
|
1014
1014
|
GRPC_ERROR_REF(error));
|
1015
1015
|
}
|
1016
1016
|
}
|
1017
1017
|
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p scheduling on_complete %p", s,
|
1018
1018
|
error);
|
1019
|
-
GRPC_CLOSURE_SCHED(
|
1019
|
+
GRPC_CLOSURE_SCHED(on_complete, GRPC_ERROR_REF(error));
|
1020
1020
|
}
|
1021
1021
|
if (needs_close) {
|
1022
|
-
close_other_side_locked(
|
1023
|
-
close_stream_locked(
|
1022
|
+
close_other_side_locked(s, "perform_stream_op:other_side");
|
1023
|
+
close_stream_locked(s);
|
1024
1024
|
}
|
1025
1025
|
gpr_mu_unlock(mu);
|
1026
1026
|
GRPC_ERROR_UNREF(error);
|
1027
1027
|
}
|
1028
1028
|
|
1029
|
-
static void close_transport_locked(
|
1030
|
-
inproc_transport* t) {
|
1029
|
+
static void close_transport_locked(inproc_transport* t) {
|
1031
1030
|
INPROC_LOG(GPR_DEBUG, "close_transport %p %d", t, t->is_closed);
|
1032
1031
|
grpc_connectivity_state_set(
|
1033
|
-
|
1032
|
+
&t->connectivity, GRPC_CHANNEL_SHUTDOWN,
|
1034
1033
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Closing transport."),
|
1035
1034
|
"close transport");
|
1036
1035
|
if (!t->is_closed) {
|
@@ -1039,7 +1038,7 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
|
|
1039
1038
|
while (t->stream_list != nullptr) {
|
1040
1039
|
// cancel_stream_locked also adjusts stream list
|
1041
1040
|
cancel_stream_locked(
|
1042
|
-
|
1041
|
+
t->stream_list,
|
1043
1042
|
grpc_error_set_int(
|
1044
1043
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport closed"),
|
1045
1044
|
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
|
@@ -1047,14 +1046,13 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx,
|
|
1047
1046
|
}
|
1048
1047
|
}
|
1049
1048
|
|
1050
|
-
static void perform_transport_op(
|
1051
|
-
grpc_transport_op* op) {
|
1049
|
+
static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
|
1052
1050
|
inproc_transport* t = (inproc_transport*)gt;
|
1053
1051
|
INPROC_LOG(GPR_DEBUG, "perform_transport_op %p %p", t, op);
|
1054
1052
|
gpr_mu_lock(&t->mu->mu);
|
1055
1053
|
if (op->on_connectivity_state_change) {
|
1056
1054
|
grpc_connectivity_state_notify_on_state_change(
|
1057
|
-
|
1055
|
+
&t->connectivity, op->connectivity_state,
|
1058
1056
|
op->on_connectivity_state_change);
|
1059
1057
|
}
|
1060
1058
|
if (op->set_accept_stream) {
|
@@ -1062,7 +1060,7 @@ static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
1062
1060
|
t->accept_stream_data = op->set_accept_stream_user_data;
|
1063
1061
|
}
|
1064
1062
|
if (op->on_consumed) {
|
1065
|
-
GRPC_CLOSURE_SCHED(
|
1063
|
+
GRPC_CLOSURE_SCHED(op->on_consumed, GRPC_ERROR_NONE);
|
1066
1064
|
}
|
1067
1065
|
|
1068
1066
|
bool do_close = false;
|
@@ -1076,71 +1074,67 @@ static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
|
1076
1074
|
}
|
1077
1075
|
|
1078
1076
|
if (do_close) {
|
1079
|
-
close_transport_locked(
|
1077
|
+
close_transport_locked(t);
|
1080
1078
|
}
|
1081
1079
|
gpr_mu_unlock(&t->mu->mu);
|
1082
1080
|
}
|
1083
1081
|
|
1084
|
-
static void destroy_stream(
|
1085
|
-
grpc_stream* gs,
|
1082
|
+
static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
|
1086
1083
|
grpc_closure* then_schedule_closure) {
|
1087
1084
|
INPROC_LOG(GPR_DEBUG, "destroy_stream %p %p", gs, then_schedule_closure);
|
1088
1085
|
inproc_stream* s = (inproc_stream*)gs;
|
1089
1086
|
s->closure_at_destroy = then_schedule_closure;
|
1090
|
-
really_destroy_stream(
|
1087
|
+
really_destroy_stream(s);
|
1091
1088
|
}
|
1092
1089
|
|
1093
|
-
static void destroy_transport(
|
1090
|
+
static void destroy_transport(grpc_transport* gt) {
|
1094
1091
|
inproc_transport* t = (inproc_transport*)gt;
|
1095
1092
|
INPROC_LOG(GPR_DEBUG, "destroy_transport %p", t);
|
1096
1093
|
gpr_mu_lock(&t->mu->mu);
|
1097
|
-
close_transport_locked(
|
1094
|
+
close_transport_locked(t);
|
1098
1095
|
gpr_mu_unlock(&t->mu->mu);
|
1099
|
-
unref_transport(
|
1100
|
-
unref_transport(
|
1096
|
+
unref_transport(t->other_side);
|
1097
|
+
unref_transport(t);
|
1101
1098
|
}
|
1102
1099
|
|
1103
1100
|
/*******************************************************************************
|
1104
1101
|
* INTEGRATION GLUE
|
1105
1102
|
*/
|
1106
1103
|
|
1107
|
-
static void set_pollset(
|
1108
|
-
|
1104
|
+
static void set_pollset(grpc_transport* gt, grpc_stream* gs,
|
1105
|
+
grpc_pollset* pollset) {
|
1109
1106
|
// Nothing to do here
|
1110
1107
|
}
|
1111
1108
|
|
1112
|
-
static void set_pollset_set(
|
1113
|
-
|
1109
|
+
static void set_pollset_set(grpc_transport* gt, grpc_stream* gs,
|
1110
|
+
grpc_pollset_set* pollset_set) {
|
1114
1111
|
// Nothing to do here
|
1115
1112
|
}
|
1116
1113
|
|
1117
|
-
static grpc_endpoint* get_endpoint(
|
1118
|
-
return nullptr;
|
1119
|
-
}
|
1114
|
+
static grpc_endpoint* get_endpoint(grpc_transport* t) { return nullptr; }
|
1120
1115
|
|
1121
1116
|
/*******************************************************************************
|
1122
1117
|
* GLOBAL INIT AND DESTROY
|
1123
1118
|
*/
|
1124
|
-
static void do_nothing(
|
1119
|
+
static void do_nothing(void* arg, grpc_error* error) {}
|
1125
1120
|
|
1126
1121
|
void grpc_inproc_transport_init(void) {
|
1127
|
-
|
1122
|
+
grpc_core::ExecCtx exec_ctx;
|
1128
1123
|
GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, nullptr,
|
1129
1124
|
grpc_schedule_on_exec_ctx);
|
1130
1125
|
g_empty_slice = grpc_slice_from_static_buffer(nullptr, 0);
|
1131
1126
|
|
1132
1127
|
grpc_slice key_tmp = grpc_slice_from_static_string(":path");
|
1133
1128
|
g_fake_path_key = grpc_slice_intern(key_tmp);
|
1134
|
-
grpc_slice_unref_internal(
|
1129
|
+
grpc_slice_unref_internal(key_tmp);
|
1135
1130
|
|
1136
1131
|
g_fake_path_value = grpc_slice_from_static_string("/");
|
1137
1132
|
|
1138
1133
|
grpc_slice auth_tmp = grpc_slice_from_static_string(":authority");
|
1139
1134
|
g_fake_auth_key = grpc_slice_intern(auth_tmp);
|
1140
|
-
grpc_slice_unref_internal(
|
1135
|
+
grpc_slice_unref_internal(auth_tmp);
|
1141
1136
|
|
1142
1137
|
g_fake_auth_value = grpc_slice_from_static_string("inproc-fail");
|
1143
|
-
grpc_exec_ctx_finish(&exec_ctx);
|
1144
1138
|
}
|
1145
1139
|
|
1146
1140
|
static const grpc_transport_vtable inproc_vtable = {
|
@@ -1152,8 +1146,7 @@ static const grpc_transport_vtable inproc_vtable = {
|
|
1152
1146
|
/*******************************************************************************
|
1153
1147
|
* Main inproc transport functions
|
1154
1148
|
*/
|
1155
|
-
static void inproc_transports_create(
|
1156
|
-
grpc_transport** server_transport,
|
1149
|
+
static void inproc_transports_create(grpc_transport** server_transport,
|
1157
1150
|
const grpc_channel_args* server_args,
|
1158
1151
|
grpc_transport** client_transport,
|
1159
1152
|
const grpc_channel_args* client_args) {
|
@@ -1190,7 +1183,7 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
|
|
1190
1183
|
GRPC_API_TRACE("grpc_inproc_channel_create(server=%p, args=%p)", 2,
|
1191
1184
|
(server, args));
|
1192
1185
|
|
1193
|
-
|
1186
|
+
grpc_core::ExecCtx exec_ctx;
|
1194
1187
|
|
1195
1188
|
const grpc_channel_args* server_args = grpc_server_get_channel_args(server);
|
1196
1189
|
|
@@ -1205,30 +1198,26 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server,
|
|
1205
1198
|
|
1206
1199
|
grpc_transport* server_transport;
|
1207
1200
|
grpc_transport* client_transport;
|
1208
|
-
inproc_transports_create(&
|
1209
|
-
|
1201
|
+
inproc_transports_create(&server_transport, server_args, &client_transport,
|
1202
|
+
client_args);
|
1210
1203
|
|
1211
|
-
grpc_server_setup_transport(
|
1212
|
-
|
1213
|
-
|
1214
|
-
grpc_channel_create(&exec_ctx, "inproc", client_args,
|
1215
|
-
GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
|
1204
|
+
grpc_server_setup_transport(server, server_transport, nullptr, server_args);
|
1205
|
+
grpc_channel* channel = grpc_channel_create(
|
1206
|
+
"inproc", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
|
1216
1207
|
|
1217
1208
|
// Free up created channel args
|
1218
|
-
grpc_channel_args_destroy(
|
1209
|
+
grpc_channel_args_destroy(client_args);
|
1219
1210
|
|
1220
1211
|
// Now finish scheduled operations
|
1221
|
-
grpc_exec_ctx_finish(&exec_ctx);
|
1222
1212
|
|
1223
1213
|
return channel;
|
1224
1214
|
}
|
1225
1215
|
|
1226
1216
|
void grpc_inproc_transport_shutdown(void) {
|
1227
|
-
|
1228
|
-
grpc_slice_unref_internal(
|
1229
|
-
grpc_slice_unref_internal(
|
1230
|
-
grpc_slice_unref_internal(
|
1231
|
-
grpc_slice_unref_internal(
|
1232
|
-
grpc_slice_unref_internal(
|
1233
|
-
grpc_exec_ctx_finish(&exec_ctx);
|
1217
|
+
grpc_core::ExecCtx exec_ctx;
|
1218
|
+
grpc_slice_unref_internal(g_empty_slice);
|
1219
|
+
grpc_slice_unref_internal(g_fake_path_key);
|
1220
|
+
grpc_slice_unref_internal(g_fake_path_value);
|
1221
|
+
grpc_slice_unref_internal(g_fake_auth_key);
|
1222
|
+
grpc_slice_unref_internal(g_fake_auth_value);
|
1234
1223
|
}
|