grpc 1.4.5 → 1.6.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +1235 -1100
- data/etc/roots.pem +0 -412
- data/include/grpc/byte_buffer.h +10 -25
- data/include/grpc/byte_buffer_reader.h +10 -25
- data/include/grpc/census.h +10 -25
- data/include/grpc/compression.h +10 -25
- data/include/grpc/grpc.h +15 -26
- data/include/grpc/grpc_cronet.h +10 -25
- data/include/grpc/grpc_posix.h +10 -25
- data/include/grpc/grpc_security.h +10 -25
- data/include/grpc/grpc_security_constants.h +10 -25
- data/include/grpc/impl/codegen/atm.h +11 -25
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +10 -25
- data/include/grpc/impl/codegen/atm_gcc_sync.h +10 -25
- data/include/grpc/impl/codegen/atm_windows.h +10 -25
- data/include/grpc/impl/codegen/byte_buffer_reader.h +11 -26
- data/include/grpc/impl/codegen/compression_types.h +12 -27
- data/include/grpc/impl/codegen/connectivity_state.h +10 -25
- data/include/grpc/impl/codegen/exec_ctx_fwd.h +10 -25
- data/include/grpc/impl/codegen/gpr_slice.h +10 -25
- data/include/grpc/impl/codegen/gpr_types.h +10 -25
- data/include/grpc/impl/codegen/grpc_types.h +42 -43
- data/include/grpc/impl/codegen/port_platform.h +10 -25
- data/include/grpc/impl/codegen/propagation_bits.h +10 -25
- data/include/grpc/impl/codegen/slice.h +13 -28
- data/include/grpc/impl/codegen/status.h +10 -25
- data/include/grpc/impl/codegen/sync.h +10 -25
- data/include/grpc/impl/codegen/sync_generic.h +10 -25
- data/include/grpc/impl/codegen/sync_posix.h +10 -25
- data/include/grpc/impl/codegen/sync_windows.h +10 -25
- data/include/grpc/load_reporting.h +10 -25
- data/include/grpc/slice.h +10 -25
- data/include/grpc/slice_buffer.h +10 -25
- data/include/grpc/status.h +10 -25
- data/include/grpc/support/alloc.h +10 -25
- data/include/grpc/support/atm.h +10 -25
- data/include/grpc/support/atm_gcc_atomic.h +10 -25
- data/include/grpc/support/atm_gcc_sync.h +10 -25
- data/include/grpc/support/atm_windows.h +10 -25
- data/include/grpc/support/avl.h +46 -49
- data/include/grpc/support/cmdline.h +10 -25
- data/include/grpc/support/cpu.h +10 -25
- data/include/grpc/support/histogram.h +10 -25
- data/include/grpc/support/host_port.h +10 -25
- data/include/grpc/support/log.h +10 -25
- data/include/grpc/support/log_windows.h +10 -25
- data/include/grpc/support/port_platform.h +10 -25
- data/include/grpc/support/string_util.h +10 -25
- data/include/grpc/support/subprocess.h +10 -25
- data/include/grpc/support/sync.h +10 -25
- data/include/grpc/support/sync_generic.h +10 -25
- data/include/grpc/support/sync_posix.h +10 -25
- data/include/grpc/support/sync_windows.h +10 -25
- data/include/grpc/support/thd.h +10 -25
- data/include/grpc/support/time.h +10 -25
- data/include/grpc/support/tls.h +10 -25
- data/include/grpc/support/tls_gcc.h +10 -25
- data/include/grpc/support/tls_msvc.h +10 -25
- data/include/grpc/support/tls_pthread.h +10 -25
- data/include/grpc/support/useful.h +10 -25
- data/include/grpc/support/workaround_list.h +11 -26
- data/src/boringssl/err_data.c +277 -259
- data/src/core/ext/census/aggregation.h +10 -25
- data/src/core/ext/census/base_resources.c +10 -25
- data/src/core/ext/census/base_resources.h +10 -25
- data/src/core/ext/census/census_interface.h +10 -25
- data/src/core/ext/census/census_rpc_stats.h +10 -25
- data/src/core/ext/census/context.c +10 -25
- data/src/core/ext/census/gen/census.pb.c +10 -25
- data/src/core/ext/census/gen/census.pb.h +10 -25
- data/src/core/ext/census/gen/trace_context.pb.c +10 -25
- data/src/core/ext/census/gen/trace_context.pb.h +10 -25
- data/src/core/ext/census/grpc_context.c +10 -25
- data/src/core/ext/census/grpc_filter.c +11 -26
- data/src/core/ext/census/grpc_filter.h +10 -25
- data/src/core/ext/census/grpc_plugin.c +10 -25
- data/src/core/ext/census/initialize.c +10 -25
- data/src/core/ext/census/intrusive_hash_map.c +10 -25
- data/src/core/ext/census/intrusive_hash_map.h +10 -25
- data/src/core/ext/census/intrusive_hash_map_internal.h +10 -25
- data/src/core/ext/census/mlog.c +10 -25
- data/src/core/ext/census/mlog.h +10 -25
- data/src/core/ext/census/operation.c +10 -25
- data/src/core/ext/census/placeholders.c +10 -25
- data/src/core/ext/census/resource.c +10 -25
- data/src/core/ext/census/resource.h +10 -25
- data/src/core/ext/census/rpc_metric_id.h +10 -25
- data/src/core/ext/census/trace_context.c +10 -25
- data/src/core/ext/census/trace_context.h +10 -25
- data/src/core/ext/census/trace_label.h +10 -25
- data/src/core/ext/census/trace_propagation.h +10 -25
- data/src/core/ext/census/trace_status.h +10 -25
- data/src/core/ext/census/trace_string.h +10 -25
- data/src/core/ext/census/tracing.c +10 -26
- data/src/core/ext/census/tracing.h +10 -25
- data/src/core/ext/filters/client_channel/channel_connectivity.c +20 -33
- data/src/core/ext/filters/client_channel/client_channel.c +617 -520
- data/src/core/ext/filters/client_channel/client_channel.h +15 -28
- data/src/core/ext/filters/client_channel/client_channel_factory.c +13 -31
- data/src/core/ext/filters/client_channel/client_channel_factory.h +10 -25
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +16 -29
- data/src/core/ext/filters/client_channel/connector.c +10 -25
- data/src/core/ext/filters/client_channel/connector.h +10 -25
- data/src/core/ext/filters/client_channel/http_connect_handshaker.c +15 -30
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +10 -25
- data/src/core/ext/filters/client_channel/http_proxy.c +112 -38
- data/src/core/ext/filters/client_channel/http_proxy.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy.c +32 -36
- data/src/core/ext/filters/client_channel/lb_policy.h +24 -27
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +14 -30
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +464 -279
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +10 -25
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +15 -28
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c +40 -48
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +65 -49
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +31 -31
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +47 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +11 -26
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +13 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +27 -21
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +373 -136
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +504 -279
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +12 -31
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +12 -27
- data/src/core/ext/filters/client_channel/lb_policy_registry.c +10 -25
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -25
- data/src/core/ext/filters/client_channel/parse_address.c +10 -25
- data/src/core/ext/filters/client_channel/parse_address.h +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper.c +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper.h +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +10 -25
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +10 -25
- data/src/core/ext/filters/client_channel/resolver.c +33 -38
- data/src/core/ext/filters/client_channel/resolver.h +19 -30
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +153 -50
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +14 -27
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +33 -30
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +326 -116
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +35 -36
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +60 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +19 -34
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +254 -0
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +60 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c +16 -28
- data/src/core/ext/filters/client_channel/resolver_factory.c +10 -25
- data/src/core/ext/filters/client_channel/resolver_factory.h +10 -25
- data/src/core/ext/filters/client_channel/resolver_registry.c +10 -25
- data/src/core/ext/filters/client_channel/resolver_registry.h +10 -25
- data/src/core/ext/filters/client_channel/retry_throttle.c +23 -34
- data/src/core/ext/filters/client_channel/retry_throttle.h +10 -25
- data/src/core/ext/filters/client_channel/subchannel.c +33 -55
- data/src/core/ext/filters/client_channel/subchannel.h +16 -26
- data/src/core/ext/filters/client_channel/subchannel_index.c +55 -92
- data/src/core/ext/filters/client_channel/subchannel_index.h +26 -29
- data/src/core/ext/filters/client_channel/uri_parser.c +10 -25
- data/src/core/ext/filters/client_channel/uri_parser.h +10 -25
- data/src/core/ext/filters/deadline/deadline_filter.c +30 -45
- data/src/core/ext/filters/deadline/deadline_filter.h +10 -25
- data/src/core/ext/filters/http/client/http_client_filter.c +255 -294
- data/src/core/ext/filters/http/client/http_client_filter.h +10 -25
- data/src/core/ext/filters/http/http_filters_plugin.c +11 -26
- data/src/core/ext/filters/http/message_compress/message_compress_filter.c +133 -105
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +10 -25
- data/src/core/ext/filters/http/server/http_server_filter.c +17 -32
- data/src/core/ext/filters/http/server/http_server_filter.h +10 -25
- data/src/core/ext/filters/load_reporting/load_reporting.c +11 -30
- data/src/core/ext/filters/load_reporting/load_reporting.h +10 -25
- data/src/core/ext/filters/load_reporting/load_reporting_filter.c +11 -26
- data/src/core/ext/filters/load_reporting/load_reporting_filter.h +10 -25
- data/src/core/ext/filters/max_age/max_age_filter.c +28 -43
- data/src/core/ext/filters/max_age/max_age_filter.h +10 -25
- data/src/core/ext/filters/message_size/message_size_filter.c +24 -37
- data/src/core/ext/filters/message_size/message_size_filter.h +10 -25
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +16 -31
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +10 -25
- data/src/core/ext/filters/workarounds/workaround_utils.c +12 -26
- data/src/core/ext/filters/workarounds/workaround_utils.h +11 -26
- data/src/core/ext/transport/chttp2/alpn/alpn.c +10 -25
- data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -25
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +13 -28
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +10 -25
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +13 -30
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +12 -29
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +13 -30
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +11 -26
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +10 -25
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +10 -25
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +10 -25
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +11 -25
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +10 -25
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +10 -25
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +15 -27
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +421 -443
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -25
- data/src/core/ext/transport/chttp2/transport/flow_control.c +500 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_data.c +20 -28
- data/src/core/ext/transport/chttp2/transport/frame_data.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +11 -26
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +11 -26
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +16 -29
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +10 -25
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -33
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +18 -31
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +12 -25
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +15 -30
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +10 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -25
- data/src/core/ext/transport/chttp2/transport/http2_settings.c +10 -25
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -25
- data/src/core/ext/transport/chttp2/transport/huffsyms.c +10 -25
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +10 -25
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +10 -25
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +10 -25
- data/src/core/ext/transport/chttp2/transport/internal.h +191 -179
- data/src/core/ext/transport/chttp2/transport/parsing.c +33 -102
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +26 -28
- data/src/core/ext/transport/chttp2/transport/stream_map.c +10 -25
- data/src/core/ext/transport/chttp2/transport/stream_map.h +10 -25
- data/src/core/ext/transport/chttp2/transport/varint.c +14 -25
- data/src/core/ext/transport/chttp2/transport/varint.h +10 -25
- data/src/core/ext/transport/chttp2/transport/writing.c +164 -106
- data/src/core/ext/transport/inproc/inproc_plugin.c +29 -0
- data/src/core/ext/transport/inproc/inproc_transport.c +1303 -0
- data/src/core/ext/transport/inproc/inproc_transport.h +41 -0
- data/src/core/lib/channel/channel_args.c +52 -27
- data/src/core/lib/channel/channel_args.h +18 -27
- data/src/core/lib/channel/channel_stack.c +11 -26
- data/src/core/lib/channel/channel_stack.h +12 -27
- data/src/core/lib/channel/channel_stack_builder.c +11 -26
- data/src/core/lib/channel/channel_stack_builder.h +10 -25
- data/src/core/lib/channel/connected_channel.c +10 -25
- data/src/core/lib/channel/connected_channel.h +10 -25
- data/src/core/lib/channel/context.h +10 -25
- data/src/core/lib/channel/handshaker.c +14 -29
- data/src/core/lib/channel/handshaker.h +10 -25
- data/src/core/lib/channel/handshaker_factory.c +10 -25
- data/src/core/lib/channel/handshaker_factory.h +10 -25
- data/src/core/lib/channel/handshaker_registry.c +10 -25
- data/src/core/lib/channel/handshaker_registry.h +10 -25
- data/src/core/lib/compression/algorithm_metadata.h +10 -25
- data/src/core/lib/compression/compression.c +10 -25
- data/src/core/lib/compression/message_compress.c +10 -25
- data/src/core/lib/compression/message_compress.h +10 -25
- data/src/core/lib/compression/stream_compression.c +191 -0
- data/src/core/lib/compression/stream_compression.h +90 -0
- data/src/core/lib/debug/trace.c +28 -29
- data/src/core/lib/debug/trace.h +16 -30
- data/src/core/lib/http/format_request.c +10 -25
- data/src/core/lib/http/format_request.h +10 -25
- data/src/core/lib/http/httpcli.c +19 -35
- data/src/core/lib/http/httpcli.h +10 -25
- data/src/core/lib/http/httpcli_security_connector.c +17 -30
- data/src/core/lib/http/parser.c +11 -26
- data/src/core/lib/http/parser.h +10 -25
- data/src/core/lib/iomgr/closure.c +62 -25
- data/src/core/lib/iomgr/closure.h +81 -26
- data/src/core/lib/iomgr/combiner.c +103 -200
- data/src/core/lib/iomgr/combiner.h +14 -32
- data/src/core/lib/iomgr/endpoint.c +10 -29
- data/src/core/lib/iomgr/endpoint.h +10 -29
- data/src/core/lib/iomgr/endpoint_pair.h +10 -25
- data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -25
- data/src/core/lib/iomgr/endpoint_pair_uv.c +10 -25
- data/src/core/lib/iomgr/endpoint_pair_windows.c +10 -25
- data/src/core/lib/iomgr/error.c +45 -46
- data/src/core/lib/iomgr/error.h +21 -34
- data/src/core/lib/iomgr/error_internal.h +10 -25
- data/src/core/lib/iomgr/ev_epoll1_linux.c +279 -179
- data/src/core/lib/iomgr/ev_epoll1_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +75 -264
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +44 -199
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epollex_linux.c +184 -247
- data/src/core/lib/iomgr/ev_epollex_linux.h +10 -25
- data/src/core/lib/iomgr/ev_epollsig_linux.c +116 -323
- data/src/core/lib/iomgr/ev_epollsig_linux.h +10 -25
- data/src/core/lib/iomgr/ev_poll_posix.c +328 -184
- data/src/core/lib/iomgr/ev_poll_posix.h +10 -25
- data/src/core/lib/iomgr/ev_posix.c +25 -56
- data/src/core/lib/iomgr/ev_posix.h +15 -44
- data/src/core/lib/iomgr/ev_windows.c +11 -26
- data/src/core/lib/iomgr/exec_ctx.c +36 -45
- data/src/core/lib/iomgr/exec_ctx.h +10 -25
- data/src/core/lib/iomgr/executor.c +152 -127
- data/src/core/lib/iomgr/executor.h +18 -26
- data/src/core/lib/iomgr/gethostname.h +26 -0
- data/src/core/lib/iomgr/gethostname_fallback.c +27 -0
- data/src/core/lib/iomgr/gethostname_host_name_max.c +37 -0
- data/src/core/lib/iomgr/gethostname_sysconf.c +37 -0
- data/src/core/lib/iomgr/iocp_windows.c +10 -25
- data/src/core/lib/iomgr/iocp_windows.h +10 -25
- data/src/core/lib/iomgr/iomgr.c +17 -28
- data/src/core/lib/iomgr/iomgr.h +12 -27
- data/src/core/lib/iomgr/iomgr_internal.h +10 -25
- data/src/core/lib/iomgr/iomgr_posix.c +11 -26
- data/src/core/lib/iomgr/iomgr_posix.h +10 -25
- data/src/core/lib/iomgr/iomgr_uv.c +19 -26
- data/src/core/lib/iomgr/iomgr_uv.h +37 -0
- data/src/core/lib/iomgr/iomgr_windows.c +10 -25
- data/src/core/lib/iomgr/is_epollexclusive_available.c +10 -25
- data/src/core/lib/iomgr/is_epollexclusive_available.h +10 -25
- data/src/core/lib/iomgr/load_file.c +10 -25
- data/src/core/lib/iomgr/load_file.h +10 -25
- data/src/core/lib/iomgr/lockfree_event.c +22 -35
- data/src/core/lib/iomgr/lockfree_event.h +13 -27
- data/src/core/lib/iomgr/nameser.h +104 -0
- data/src/core/lib/iomgr/network_status_tracker.c +10 -25
- data/src/core/lib/iomgr/network_status_tracker.h +10 -25
- data/src/core/lib/iomgr/polling_entity.c +10 -25
- data/src/core/lib/iomgr/polling_entity.h +14 -34
- data/src/core/lib/iomgr/pollset.h +14 -25
- data/src/core/lib/iomgr/pollset_set.h +10 -25
- data/src/core/lib/iomgr/pollset_set_uv.c +10 -25
- data/src/core/lib/iomgr/pollset_set_windows.c +10 -25
- data/src/core/lib/iomgr/pollset_set_windows.h +10 -25
- data/src/core/lib/iomgr/pollset_uv.c +25 -26
- data/src/core/lib/iomgr/pollset_uv.h +10 -25
- data/src/core/lib/iomgr/pollset_windows.c +17 -27
- data/src/core/lib/iomgr/pollset_windows.h +10 -25
- data/src/core/lib/iomgr/port.h +24 -25
- data/src/core/lib/iomgr/resolve_address.h +10 -25
- data/src/core/lib/iomgr/resolve_address_posix.c +13 -28
- data/src/core/lib/iomgr/resolve_address_uv.c +31 -35
- data/src/core/lib/iomgr/resolve_address_windows.c +13 -28
- data/src/core/lib/iomgr/resource_quota.c +52 -67
- data/src/core/lib/iomgr/resource_quota.h +10 -25
- data/src/core/lib/iomgr/sockaddr.h +10 -25
- data/src/core/lib/iomgr/sockaddr_posix.h +10 -25
- data/src/core/lib/iomgr/sockaddr_utils.c +15 -25
- data/src/core/lib/iomgr/sockaddr_utils.h +12 -25
- data/src/core/lib/iomgr/sockaddr_windows.h +10 -25
- data/src/core/lib/iomgr/socket_factory_posix.c +13 -31
- data/src/core/lib/iomgr/socket_factory_posix.h +10 -25
- data/src/core/lib/iomgr/socket_mutator.c +14 -31
- data/src/core/lib/iomgr/socket_mutator.h +10 -25
- data/src/core/lib/iomgr/socket_utils.h +10 -25
- data/src/core/lib/iomgr/socket_utils_common_posix.c +10 -25
- data/src/core/lib/iomgr/socket_utils_linux.c +10 -25
- data/src/core/lib/iomgr/socket_utils_posix.c +10 -25
- data/src/core/lib/iomgr/socket_utils_posix.h +10 -25
- data/src/core/lib/iomgr/socket_utils_uv.c +10 -25
- data/src/core/lib/iomgr/socket_utils_windows.c +10 -25
- data/src/core/lib/iomgr/socket_windows.c +12 -27
- data/src/core/lib/iomgr/socket_windows.h +10 -25
- data/src/core/lib/iomgr/sys_epoll_wrapper.h +10 -25
- data/src/core/lib/iomgr/tcp_client.h +10 -25
- data/src/core/lib/iomgr/tcp_client_posix.c +21 -34
- data/src/core/lib/iomgr/tcp_client_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_client_uv.c +18 -27
- data/src/core/lib/iomgr/tcp_client_windows.c +14 -29
- data/src/core/lib/iomgr/tcp_posix.c +36 -55
- data/src/core/lib/iomgr/tcp_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_server.h +10 -25
- data/src/core/lib/iomgr/tcp_server_posix.c +16 -31
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +10 -25
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +11 -26
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +10 -25
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +10 -25
- data/src/core/lib/iomgr/tcp_server_uv.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +14 -29
- data/src/core/lib/iomgr/tcp_uv.c +41 -45
- data/src/core/lib/iomgr/tcp_uv.h +10 -25
- data/src/core/lib/iomgr/tcp_windows.c +39 -53
- data/src/core/lib/iomgr/tcp_windows.h +10 -25
- data/src/core/lib/iomgr/time_averaged_stats.c +10 -25
- data/src/core/lib/iomgr/time_averaged_stats.h +10 -25
- data/src/core/lib/iomgr/timer.h +18 -27
- data/src/core/lib/iomgr/timer_generic.c +91 -87
- data/src/core/lib/iomgr/timer_generic.h +10 -25
- data/src/core/lib/iomgr/timer_heap.c +10 -25
- data/src/core/lib/iomgr/timer_heap.h +10 -25
- data/src/core/lib/iomgr/timer_manager.c +178 -100
- data/src/core/lib/iomgr/timer_manager.h +10 -25
- data/src/core/lib/iomgr/timer_uv.c +23 -33
- data/src/core/lib/iomgr/timer_uv.h +10 -25
- data/src/core/lib/iomgr/udp_server.c +17 -32
- data/src/core/lib/iomgr/udp_server.h +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix.c +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix.h +10 -25
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_cv.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_cv.h +13 -28
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_nospecial.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +10 -25
- data/src/core/lib/iomgr/wakeup_fd_posix.c +10 -25
- data/src/core/lib/iomgr/wakeup_fd_posix.h +10 -25
- data/src/core/lib/json/json.c +10 -25
- data/src/core/lib/json/json.h +10 -25
- data/src/core/lib/json/json_common.h +10 -25
- data/src/core/lib/json/json_reader.c +11 -25
- data/src/core/lib/json/json_reader.h +10 -25
- data/src/core/lib/json/json_string.c +10 -25
- data/src/core/lib/json/json_writer.c +10 -25
- data/src/core/lib/json/json_writer.h +10 -25
- data/src/core/lib/profiling/basic_timers.c +10 -25
- data/src/core/lib/profiling/stap_timers.c +10 -25
- data/src/core/lib/profiling/timers.h +10 -25
- data/src/core/lib/security/context/security_context.c +32 -40
- data/src/core/lib/security/context/security_context.h +15 -26
- data/src/core/lib/security/credentials/composite/composite_credentials.c +76 -81
- data/src/core/lib/security/credentials/composite/composite_credentials.h +10 -25
- data/src/core/lib/security/credentials/credentials.c +29 -49
- data/src/core/lib/security/credentials/credentials.h +48 -61
- data/src/core/lib/security/credentials/credentials_metadata.c +34 -78
- data/src/core/lib/security/credentials/fake/fake_credentials.c +33 -56
- data/src/core/lib/security/credentials/fake/fake_credentials.h +12 -27
- data/src/core/lib/security/credentials/google_default/credentials_generic.c +10 -25
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +12 -27
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +10 -25
- data/src/core/lib/security/credentials/iam/iam_credentials.c +40 -40
- data/src/core/lib/security/credentials/iam/iam_credentials.h +11 -26
- data/src/core/lib/security/credentials/jwt/json_token.c +10 -25
- data/src/core/lib/security/credentials/jwt/json_token.h +10 -25
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +45 -48
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -26
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +53 -33
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +10 -25
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +155 -87
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +24 -28
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +118 -82
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +24 -27
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +13 -32
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +10 -25
- data/src/core/lib/security/transport/auth_filters.h +10 -25
- data/src/core/lib/security/transport/client_auth_filter.c +217 -112
- data/src/core/lib/security/transport/lb_targets_info.c +16 -32
- data/src/core/lib/security/transport/lb_targets_info.h +10 -25
- data/src/core/lib/security/transport/secure_endpoint.c +29 -43
- data/src/core/lib/security/transport/secure_endpoint.h +10 -25
- data/src/core/lib/security/transport/security_connector.c +80 -61
- data/src/core/lib/security/transport/security_connector.h +35 -35
- data/src/core/lib/security/transport/security_handshaker.c +18 -33
- data/src/core/lib/security/transport/security_handshaker.h +10 -25
- data/src/core/lib/security/transport/server_auth_filter.c +62 -116
- data/src/core/lib/security/transport/tsi_error.c +10 -25
- data/src/core/lib/security/transport/tsi_error.h +10 -25
- data/src/core/lib/security/util/json_util.c +10 -25
- data/src/core/lib/security/util/json_util.h +10 -25
- data/src/core/lib/slice/b64.c +10 -25
- data/src/core/lib/slice/b64.h +10 -25
- data/src/core/lib/slice/percent_encoding.c +10 -25
- data/src/core/lib/slice/percent_encoding.h +10 -25
- data/src/core/lib/slice/slice.c +10 -25
- data/src/core/lib/slice/slice_buffer.c +10 -25
- data/src/core/lib/slice/slice_hash_table.c +48 -26
- data/src/core/lib/slice/slice_hash_table.h +26 -28
- data/src/core/lib/slice/slice_intern.c +10 -25
- data/src/core/lib/slice/slice_internal.h +10 -25
- data/src/core/lib/slice/slice_string_helpers.c +10 -25
- data/src/core/lib/slice/slice_string_helpers.h +10 -25
- data/src/core/lib/support/alloc.c +10 -25
- data/src/core/lib/support/arena.c +12 -27
- data/src/core/lib/support/arena.h +10 -25
- data/src/core/lib/support/atm.c +17 -32
- data/src/core/lib/support/atomic.h +10 -25
- data/src/core/lib/support/atomic_with_atm.h +10 -25
- data/src/core/lib/support/atomic_with_std.h +10 -25
- data/src/core/lib/support/avl.c +101 -101
- data/src/core/lib/support/backoff.c +10 -25
- data/src/core/lib/support/backoff.h +10 -25
- data/src/core/lib/support/block_annotate.h +10 -25
- data/src/core/lib/support/cmdline.c +10 -25
- data/src/core/lib/support/cpu_iphone.c +10 -25
- data/src/core/lib/support/cpu_linux.c +10 -25
- data/src/core/lib/support/cpu_posix.c +10 -25
- data/src/core/lib/support/cpu_windows.c +10 -25
- data/src/core/lib/support/env.h +16 -25
- data/src/core/lib/support/env_linux.c +30 -37
- data/src/core/lib/support/env_posix.c +15 -25
- data/src/core/lib/support/env_windows.c +15 -25
- data/src/core/lib/support/histogram.c +10 -25
- data/src/core/lib/support/host_port.c +10 -25
- data/src/core/lib/support/log.c +20 -29
- data/src/core/lib/support/log_android.c +10 -25
- data/src/core/lib/support/log_linux.c +13 -26
- data/src/core/lib/support/log_posix.c +10 -25
- data/src/core/lib/support/log_windows.c +10 -25
- data/src/core/lib/support/memory.h +10 -25
- data/src/core/lib/support/mpscq.c +11 -49
- data/src/core/lib/support/mpscq.h +11 -50
- data/src/core/lib/support/murmur_hash.c +12 -25
- data/src/core/lib/support/murmur_hash.h +10 -25
- data/src/core/lib/support/spinlock.h +10 -25
- data/src/core/lib/support/stack_lockfree.c +10 -25
- data/src/core/lib/support/stack_lockfree.h +10 -25
- data/src/core/lib/support/string.c +10 -25
- data/src/core/lib/support/string.h +10 -25
- data/src/core/lib/support/string_posix.c +10 -25
- data/src/core/lib/support/string_util_windows.c +10 -25
- data/src/core/lib/support/string_windows.c +10 -25
- data/src/core/lib/support/string_windows.h +10 -25
- data/src/core/lib/support/subprocess_posix.c +10 -25
- data/src/core/lib/support/subprocess_windows.c +10 -25
- data/src/core/lib/support/sync.c +10 -25
- data/src/core/lib/support/sync_posix.c +10 -25
- data/src/core/lib/support/sync_windows.c +10 -25
- data/src/core/lib/support/thd.c +10 -25
- data/src/core/lib/support/thd_internal.h +10 -25
- data/src/core/lib/support/thd_posix.c +10 -25
- data/src/core/lib/support/thd_windows.c +10 -25
- data/src/core/lib/support/time.c +10 -25
- data/src/core/lib/support/time_posix.c +10 -25
- data/src/core/lib/support/time_precise.c +18 -33
- data/src/core/lib/support/time_precise.h +10 -25
- data/src/core/lib/support/time_windows.c +10 -25
- data/src/core/lib/support/tls_pthread.c +10 -25
- data/src/core/lib/support/tmpfile.h +10 -25
- data/src/core/lib/support/tmpfile_msys.c +10 -25
- data/src/core/lib/support/tmpfile_posix.c +10 -25
- data/src/core/lib/support/tmpfile_windows.c +10 -25
- data/src/core/lib/support/wrap_memcpy.c +10 -25
- data/src/core/lib/surface/alarm.c +78 -35
- data/src/core/lib/surface/alarm_internal.h +40 -0
- data/src/core/lib/surface/api_trace.c +11 -26
- data/src/core/lib/surface/api_trace.h +10 -25
- data/src/core/lib/surface/byte_buffer.c +10 -25
- data/src/core/lib/surface/byte_buffer_reader.c +10 -25
- data/src/core/lib/surface/call.c +64 -84
- data/src/core/lib/surface/call.h +11 -26
- data/src/core/lib/surface/call_details.c +10 -25
- data/src/core/lib/surface/call_log_batch.c +10 -25
- data/src/core/lib/surface/call_test_only.h +10 -25
- data/src/core/lib/surface/channel.c +11 -26
- data/src/core/lib/surface/channel.h +11 -26
- data/src/core/lib/surface/channel_init.c +10 -25
- data/src/core/lib/surface/channel_init.h +10 -25
- data/src/core/lib/surface/channel_ping.c +12 -27
- data/src/core/lib/surface/channel_stack_type.c +10 -25
- data/src/core/lib/surface/channel_stack_type.h +10 -25
- data/src/core/lib/surface/completion_queue.c +442 -331
- data/src/core/lib/surface/completion_queue.h +16 -33
- data/src/core/lib/surface/completion_queue_factory.c +10 -25
- data/src/core/lib/surface/completion_queue_factory.h +10 -25
- data/src/core/lib/surface/event_string.c +10 -25
- data/src/core/lib/surface/event_string.h +10 -25
- data/src/core/lib/surface/init.c +38 -47
- data/src/core/lib/surface/init.h +10 -25
- data/src/core/lib/surface/init_secure.c +20 -27
- data/src/core/lib/surface/lame_client.cc +14 -29
- data/src/core/lib/surface/lame_client.h +10 -25
- data/src/core/lib/surface/metadata_array.c +10 -25
- data/src/core/lib/surface/server.c +128 -81
- data/src/core/lib/surface/server.h +10 -25
- data/src/core/lib/surface/validate_metadata.c +10 -25
- data/src/core/lib/surface/validate_metadata.h +10 -25
- data/src/core/lib/surface/version.c +11 -26
- data/src/core/lib/transport/bdp_estimator.c +19 -29
- data/src/core/lib/transport/bdp_estimator.h +16 -29
- data/src/core/lib/transport/byte_stream.c +127 -36
- data/src/core/lib/transport/byte_stream.h +88 -46
- data/src/core/lib/transport/connectivity_state.c +17 -31
- data/src/core/lib/transport/connectivity_state.h +10 -25
- data/src/core/lib/transport/error_utils.c +10 -25
- data/src/core/lib/transport/error_utils.h +10 -25
- data/src/core/lib/transport/http2_errors.h +10 -25
- data/src/core/lib/transport/metadata.c +87 -85
- data/src/core/lib/transport/metadata.h +15 -28
- data/src/core/lib/transport/metadata_batch.c +10 -25
- data/src/core/lib/transport/metadata_batch.h +10 -25
- data/src/core/lib/transport/pid_controller.c +10 -25
- data/src/core/lib/transport/pid_controller.h +10 -25
- data/src/core/lib/transport/service_config.c +11 -26
- data/src/core/lib/transport/service_config.h +10 -25
- data/src/core/lib/transport/static_metadata.c +12 -26
- data/src/core/lib/transport/static_metadata.h +10 -25
- data/src/core/lib/transport/status_conversion.c +10 -25
- data/src/core/lib/transport/status_conversion.h +10 -25
- data/src/core/lib/transport/timeout_encoding.c +10 -25
- data/src/core/lib/transport/timeout_encoding.h +10 -25
- data/src/core/lib/transport/transport.c +60 -53
- data/src/core/lib/transport/transport.h +36 -34
- data/src/core/lib/transport/transport_impl.h +10 -25
- data/src/core/lib/transport/transport_op_string.c +10 -28
- data/src/core/plugin_registry/grpc_plugin_registry.c +22 -25
- data/src/core/tsi/fake_transport_security.c +199 -94
- data/src/core/tsi/fake_transport_security.h +11 -26
- data/src/core/tsi/gts_transport_security.c +40 -0
- data/src/core/tsi/gts_transport_security.h +37 -0
- data/src/core/tsi/ssl_transport_security.c +13 -32
- data/src/core/tsi/ssl_transport_security.h +10 -25
- data/src/core/tsi/ssl_types.h +10 -25
- data/src/core/tsi/transport_security.c +48 -78
- data/src/core/tsi/transport_security.h +18 -27
- data/src/core/tsi/transport_security_adapter.c +17 -29
- data/src/core/tsi/transport_security_adapter.h +10 -25
- data/src/core/tsi/transport_security_grpc.c +64 -0
- data/src/core/tsi/transport_security_grpc.h +80 -0
- data/src/core/tsi/transport_security_interface.h +21 -27
- data/src/ruby/bin/apis/google/protobuf/empty.rb +10 -25
- data/src/ruby/bin/apis/pubsub_demo.rb +10 -25
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +10 -25
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +10 -25
- data/src/ruby/bin/math_client.rb +10 -25
- data/src/ruby/bin/math_server.rb +10 -25
- data/src/ruby/bin/math_services_pb.rb +10 -25
- data/src/ruby/bin/noproto_client.rb +10 -25
- data/src/ruby/bin/noproto_server.rb +10 -25
- data/src/ruby/ext/grpc/extconf.rb +10 -25
- data/src/ruby/ext/grpc/rb_byte_buffer.c +10 -25
- data/src/ruby/ext/grpc/rb_byte_buffer.h +10 -25
- data/src/ruby/ext/grpc/rb_call.c +44 -25
- data/src/ruby/ext/grpc/rb_call.h +10 -25
- data/src/ruby/ext/grpc/rb_call_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_call_credentials.h +10 -25
- data/src/ruby/ext/grpc/rb_channel.c +10 -25
- data/src/ruby/ext/grpc/rb_channel.h +10 -25
- data/src/ruby/ext/grpc/rb_channel_args.c +10 -25
- data/src/ruby/ext/grpc/rb_channel_args.h +10 -25
- data/src/ruby/ext/grpc/rb_channel_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_channel_credentials.h +10 -25
- data/src/ruby/ext/grpc/rb_completion_queue.c +10 -25
- data/src/ruby/ext/grpc/rb_completion_queue.h +10 -25
- data/src/ruby/ext/grpc/rb_compression_options.c +10 -25
- data/src/ruby/ext/grpc/rb_compression_options.h +10 -25
- data/src/ruby/ext/grpc/rb_event_thread.c +10 -25
- data/src/ruby/ext/grpc/rb_event_thread.h +10 -25
- data/src/ruby/ext/grpc/rb_grpc.c +10 -25
- data/src/ruby/ext/grpc/rb_grpc.h +10 -25
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -25
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +16 -31
- data/src/ruby/ext/grpc/rb_loader.c +10 -25
- data/src/ruby/ext/grpc/rb_loader.h +10 -25
- data/src/ruby/ext/grpc/rb_server.c +10 -25
- data/src/ruby/ext/grpc/rb_server.h +10 -25
- data/src/ruby/ext/grpc/rb_server_credentials.c +10 -25
- data/src/ruby/ext/grpc/rb_server_credentials.h +10 -25
- data/src/ruby/lib/grpc.rb +10 -25
- data/src/ruby/lib/grpc/core/time_consts.rb +10 -25
- data/src/ruby/lib/grpc/errors.rb +16 -30
- data/src/ruby/lib/grpc/generic/active_call.rb +25 -27
- data/src/ruby/lib/grpc/generic/bidi_call.rb +17 -27
- data/src/ruby/lib/grpc/generic/client_stub.rb +10 -25
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +10 -25
- data/src/ruby/lib/grpc/generic/rpc_server.rb +10 -25
- data/src/ruby/lib/grpc/generic/service.rb +10 -25
- data/src/ruby/lib/grpc/grpc.rb +10 -25
- data/src/ruby/lib/grpc/logconfig.rb +10 -25
- data/src/ruby/lib/grpc/notifier.rb +10 -25
- data/src/ruby/lib/grpc/version.rb +11 -26
- data/src/ruby/pb/generate_proto_ruby.sh +10 -25
- data/src/ruby/pb/grpc/health/checker.rb +10 -25
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +10 -25
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +10 -25
- data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +10 -25
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +10 -25
- data/src/ruby/pb/test/client.rb +10 -25
- data/src/ruby/pb/test/server.rb +10 -25
- data/src/ruby/spec/call_credentials_spec.rb +10 -25
- data/src/ruby/spec/call_spec.rb +43 -25
- data/src/ruby/spec/channel_connection_spec.rb +10 -25
- data/src/ruby/spec/channel_credentials_spec.rb +11 -26
- data/src/ruby/spec/channel_spec.rb +10 -25
- data/src/ruby/spec/client_auth_spec.rb +10 -25
- data/src/ruby/spec/client_server_spec.rb +66 -25
- data/src/ruby/spec/compression_options_spec.rb +10 -25
- data/src/ruby/spec/error_sanity_spec.rb +10 -25
- data/src/ruby/spec/generic/active_call_spec.rb +10 -25
- data/src/ruby/spec/generic/client_stub_spec.rb +146 -35
- data/src/ruby/spec/generic/rpc_desc_spec.rb +10 -25
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +10 -25
- data/src/ruby/spec/generic/rpc_server_spec.rb +124 -34
- data/src/ruby/spec/generic/service_spec.rb +10 -25
- data/src/ruby/spec/pb/duplicate/codegen_spec.rb +10 -25
- data/src/ruby/spec/pb/health/checker_spec.rb +10 -25
- data/src/ruby/spec/server_credentials_spec.rb +10 -25
- data/src/ruby/spec/server_spec.rb +10 -25
- data/src/ruby/spec/spec_helper.rb +10 -25
- data/src/ruby/spec/time_consts_spec.rb +10 -25
- data/third_party/boringssl/crypto/aes/key_wrap.c +138 -0
- data/third_party/boringssl/crypto/asn1/a_bitstr.c +6 -3
- data/third_party/boringssl/crypto/asn1/a_enum.c +4 -1
- data/third_party/boringssl/crypto/asn1/a_gentm.c +20 -15
- data/third_party/boringssl/crypto/asn1/a_int.c +7 -4
- data/third_party/boringssl/crypto/asn1/a_object.c +5 -2
- data/third_party/boringssl/crypto/asn1/a_time.c +0 -1
- data/third_party/boringssl/crypto/asn1/a_utctm.c +1 -2
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -2
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +35 -0
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +3 -1
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +6 -3
- data/third_party/boringssl/crypto/asn1/tasn_new.c +12 -7
- data/third_party/boringssl/crypto/asn1/tasn_utl.c +22 -8
- data/third_party/boringssl/crypto/{time_support.c → asn1/time_support.c} +1 -1
- data/third_party/boringssl/crypto/asn1/x_long.c +5 -2
- data/third_party/boringssl/crypto/base64/base64.c +7 -5
- data/third_party/boringssl/crypto/bio/bio.c +24 -10
- data/third_party/boringssl/crypto/bio/bio_mem.c +12 -10
- data/third_party/boringssl/crypto/bio/connect.c +7 -18
- data/third_party/boringssl/crypto/bio/fd.c +3 -6
- data/third_party/boringssl/crypto/bio/file.c +6 -6
- data/third_party/boringssl/crypto/bio/hexdump.c +4 -2
- data/third_party/boringssl/crypto/bio/pair.c +30 -344
- data/third_party/boringssl/crypto/bio/socket.c +6 -7
- data/third_party/boringssl/crypto/bio/socket_helper.c +4 -3
- data/third_party/boringssl/crypto/bn/add.c +1 -1
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +11 -10
- data/third_party/boringssl/crypto/bn/bn.c +6 -20
- data/third_party/boringssl/crypto/bn/cmp.c +14 -0
- data/third_party/boringssl/crypto/bn/convert.c +73 -2
- data/third_party/boringssl/crypto/bn/ctx.c +3 -1
- data/third_party/boringssl/crypto/bn/div.c +108 -51
- data/third_party/boringssl/crypto/bn/exponentiation.c +15 -33
- data/third_party/boringssl/crypto/bn/gcd.c +29 -22
- data/third_party/boringssl/crypto/bn/generic.c +71 -67
- data/third_party/boringssl/crypto/bn/internal.h +19 -6
- data/third_party/boringssl/crypto/bn/kronecker.c +1 -0
- data/third_party/boringssl/crypto/bn/montgomery.c +9 -10
- data/third_party/boringssl/crypto/bn/montgomery_inv.c +47 -0
- data/third_party/boringssl/crypto/bn/mul.c +11 -9
- data/third_party/boringssl/crypto/bn/random.c +6 -3
- data/third_party/boringssl/crypto/bn/rsaz_exp.c +0 -65
- data/third_party/boringssl/crypto/bn/rsaz_exp.h +0 -3
- data/third_party/boringssl/crypto/bn/shift.c +9 -1
- data/third_party/boringssl/crypto/bn/sqrt.c +3 -1
- data/third_party/boringssl/crypto/buf/buf.c +6 -4
- data/third_party/boringssl/crypto/bytestring/asn1_compat.c +2 -1
- data/third_party/boringssl/crypto/bytestring/ber.c +2 -1
- data/third_party/boringssl/crypto/bytestring/cbb.c +9 -7
- data/third_party/boringssl/crypto/bytestring/cbs.c +54 -2
- data/third_party/boringssl/crypto/chacha/chacha.c +1 -1
- data/third_party/boringssl/crypto/cipher/aead.c +3 -3
- data/third_party/boringssl/crypto/cipher/cipher.c +18 -13
- data/third_party/boringssl/crypto/cipher/e_aes.c +335 -281
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +113 -137
- data/third_party/boringssl/crypto/cipher/e_null.c +2 -1
- data/third_party/boringssl/crypto/cipher/e_rc2.c +54 -49
- data/third_party/boringssl/crypto/cipher/e_ssl3.c +4 -3
- data/third_party/boringssl/crypto/cipher/e_tls.c +5 -5
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +41 -112
- data/third_party/boringssl/crypto/cmac/cmac.c +6 -4
- data/third_party/boringssl/crypto/conf/conf.c +6 -3
- data/third_party/boringssl/crypto/cpu-arm-linux.c +2 -2
- data/third_party/boringssl/crypto/curve25519/curve25519.c +28 -34
- data/third_party/boringssl/crypto/curve25519/spake25519.c +7 -6
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +2 -1
- data/third_party/boringssl/crypto/des/des.c +1 -1
- data/third_party/boringssl/crypto/des/internal.h +58 -46
- data/third_party/boringssl/crypto/dh/dh.c +4 -8
- data/third_party/boringssl/crypto/digest/digest.c +5 -2
- data/third_party/boringssl/crypto/digest/digests.c +70 -33
- data/third_party/boringssl/crypto/digest/md32_common.h +39 -27
- data/third_party/boringssl/crypto/dsa/dsa.c +11 -19
- data/third_party/boringssl/crypto/ec/ec.c +1 -1
- data/third_party/boringssl/crypto/ec/ec_asn1.c +3 -2
- data/third_party/boringssl/crypto/ec/ec_key.c +1 -1
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +6 -11
- data/third_party/boringssl/crypto/ec/oct.c +2 -14
- data/third_party/boringssl/crypto/ec/p224-64.c +78 -122
- data/third_party/boringssl/crypto/ec/p256-64.c +93 -133
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +48 -61
- data/third_party/boringssl/crypto/ec/p256-x86_64.h +113 -0
- data/third_party/boringssl/crypto/ec/simple.c +2 -1
- data/third_party/boringssl/crypto/ec/wnaf.c +52 -43
- data/third_party/boringssl/crypto/ecdh/ecdh.c +4 -2
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +17 -16
- data/third_party/boringssl/crypto/engine/engine.c +3 -1
- data/third_party/boringssl/crypto/err/err.c +5 -5
- data/third_party/boringssl/crypto/evp/evp.c +1 -1
- data/third_party/boringssl/crypto/evp/evp_asn1.c +1 -1
- data/third_party/boringssl/crypto/evp/evp_ctx.c +23 -29
- data/third_party/boringssl/crypto/evp/p_ec.c +2 -1
- data/third_party/boringssl/crypto/evp/p_rsa.c +9 -3
- data/third_party/boringssl/crypto/evp/pbkdf.c +3 -1
- data/third_party/boringssl/crypto/hkdf/hkdf.c +3 -1
- data/third_party/boringssl/crypto/hmac/hmac.c +4 -2
- data/third_party/boringssl/crypto/internal.h +81 -0
- data/third_party/boringssl/crypto/lhash/lhash.c +7 -13
- data/third_party/boringssl/crypto/md4/md4.c +20 -18
- data/third_party/boringssl/crypto/md5/md5.c +31 -21
- data/third_party/boringssl/crypto/mem.c +4 -10
- data/third_party/boringssl/crypto/modes/cbc.c +2 -6
- data/third_party/boringssl/crypto/modes/cfb.c +2 -2
- data/third_party/boringssl/crypto/modes/ctr.c +1 -1
- data/third_party/boringssl/crypto/modes/gcm.c +117 -334
- data/third_party/boringssl/crypto/modes/internal.h +107 -84
- data/third_party/boringssl/crypto/modes/ofb.c +3 -3
- data/third_party/boringssl/crypto/modes/polyval.c +94 -0
- data/third_party/boringssl/crypto/obj/obj.c +13 -8
- data/third_party/boringssl/crypto/obj/obj_dat.h +6109 -5187
- data/third_party/boringssl/crypto/obj/obj_xref.c +55 -57
- data/third_party/boringssl/crypto/pem/pem_lib.c +6 -3
- data/third_party/boringssl/crypto/pkcs8/internal.h +27 -8
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +137 -352
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +371 -364
- data/third_party/boringssl/crypto/poly1305/poly1305.c +12 -18
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +2 -2
- data/third_party/boringssl/crypto/{newhope/reduce.c → pool/internal.h} +24 -21
- data/third_party/boringssl/crypto/pool/pool.c +200 -0
- data/third_party/boringssl/crypto/rand/deterministic.c +6 -5
- data/third_party/boringssl/crypto/rand/fuchsia.c +43 -0
- data/third_party/boringssl/crypto/rand/rand.c +7 -7
- data/third_party/boringssl/crypto/rand/urandom.c +136 -22
- data/third_party/boringssl/crypto/rand/windows.c +2 -2
- data/third_party/boringssl/crypto/rsa/blinding.c +2 -1
- data/third_party/boringssl/crypto/rsa/padding.c +11 -11
- data/third_party/boringssl/crypto/rsa/rsa.c +4 -4
- data/third_party/boringssl/crypto/rsa/rsa_asn1.c +7 -1
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +41 -80
- data/third_party/boringssl/crypto/sha/sha1-altivec.c +346 -0
- data/third_party/boringssl/crypto/sha/sha1.c +60 -42
- data/third_party/boringssl/crypto/sha/sha256.c +4 -2
- data/third_party/boringssl/crypto/sha/sha512.c +9 -7
- data/third_party/boringssl/crypto/stack/stack.c +10 -7
- data/third_party/boringssl/crypto/thread_pthread.c +2 -2
- data/third_party/boringssl/crypto/thread_win.c +2 -2
- data/third_party/boringssl/crypto/x509/a_verify.c +1 -1
- data/third_party/boringssl/crypto/x509/asn1_gen.c +1 -1
- data/third_party/boringssl/crypto/x509/by_dir.c +1 -1
- data/third_party/boringssl/crypto/x509/t_x509.c +78 -38
- data/third_party/boringssl/crypto/x509/x509_cmp.c +8 -5
- data/third_party/boringssl/crypto/x509/x509_lu.c +6 -1
- data/third_party/boringssl/crypto/x509/x509_obj.c +4 -1
- data/third_party/boringssl/crypto/x509/x509_vfy.c +42 -8
- data/third_party/boringssl/crypto/x509/x509_vpm.c +8 -6
- data/third_party/boringssl/crypto/x509/x509name.c +4 -1
- data/third_party/boringssl/crypto/x509/x_crl.c +4 -2
- data/third_party/boringssl/crypto/x509/x_name.c +23 -13
- data/third_party/boringssl/crypto/x509/x_pkey.c +4 -1
- data/third_party/boringssl/crypto/x509/x_x509.c +42 -3
- data/third_party/boringssl/crypto/x509v3/pcy_int.h +2 -2
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +2 -1
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +1 -1
- data/third_party/boringssl/crypto/x509v3/v3_ia5.c +4 -1
- data/third_party/boringssl/crypto/x509v3/v3_ncons.c +4 -1
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +6 -3
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +13 -21
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +19 -33
- data/third_party/boringssl/include/openssl/aead.h +9 -20
- data/third_party/boringssl/include/openssl/aes.h +21 -9
- data/third_party/boringssl/include/openssl/asn1.h +9 -1
- data/third_party/boringssl/include/openssl/base.h +33 -6
- data/third_party/boringssl/include/openssl/bio.h +10 -103
- data/third_party/boringssl/include/openssl/bn.h +58 -42
- data/third_party/boringssl/include/openssl/bytestring.h +17 -0
- data/third_party/boringssl/include/openssl/cipher.h +4 -3
- data/third_party/boringssl/include/openssl/conf.h +4 -1
- data/third_party/boringssl/include/openssl/curve25519.h +13 -0
- data/third_party/boringssl/include/openssl/digest.h +5 -3
- data/third_party/boringssl/include/openssl/dsa.h +5 -5
- data/third_party/boringssl/include/openssl/ec.h +2 -2
- data/third_party/boringssl/include/openssl/ecdh.h +3 -4
- data/third_party/boringssl/include/openssl/ecdsa.h +10 -10
- data/third_party/boringssl/include/openssl/err.h +5 -5
- data/third_party/boringssl/include/openssl/evp.h +11 -7
- data/third_party/boringssl/include/openssl/lhash.h +2 -3
- data/third_party/boringssl/include/openssl/lhash_macros.h +56 -14
- data/third_party/boringssl/include/openssl/nid.h +2949 -2916
- data/third_party/boringssl/include/openssl/obj.h +1 -1
- data/third_party/boringssl/include/openssl/pkcs8.h +21 -42
- data/third_party/boringssl/include/openssl/pool.h +87 -0
- data/third_party/boringssl/include/openssl/rand.h +1 -1
- data/third_party/boringssl/include/openssl/rsa.h +4 -2
- data/third_party/boringssl/include/openssl/sha.h +0 -4
- data/third_party/boringssl/include/openssl/ssl.h +327 -662
- data/third_party/boringssl/include/openssl/ssl3.h +1 -21
- data/third_party/boringssl/include/openssl/stack.h +1 -0
- data/third_party/boringssl/include/openssl/stack_macros.h +85 -0
- data/third_party/boringssl/include/openssl/tls1.h +23 -52
- data/third_party/boringssl/include/openssl/type_check.h +4 -0
- data/third_party/boringssl/include/openssl/x509.h +10 -59
- data/third_party/boringssl/include/openssl/x509_vfy.h +7 -1
- data/third_party/boringssl/include/openssl/x509v3.h +4 -4
- data/third_party/boringssl/ssl/bio_ssl.c +175 -0
- data/third_party/boringssl/ssl/custom_extensions.c +24 -21
- data/third_party/boringssl/ssl/d1_both.c +259 -289
- data/third_party/boringssl/ssl/d1_lib.c +8 -20
- data/third_party/boringssl/ssl/d1_pkt.c +6 -15
- data/third_party/boringssl/ssl/dtls_method.c +22 -8
- data/third_party/boringssl/ssl/dtls_record.c +27 -2
- data/third_party/boringssl/ssl/handshake_client.c +460 -579
- data/third_party/boringssl/ssl/handshake_server.c +662 -644
- data/third_party/boringssl/ssl/internal.h +1009 -375
- data/third_party/boringssl/ssl/s3_both.c +312 -162
- data/third_party/boringssl/ssl/s3_lib.c +12 -128
- data/third_party/boringssl/ssl/s3_pkt.c +22 -30
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +28 -22
- data/third_party/boringssl/ssl/ssl_asn1.c +210 -114
- data/third_party/boringssl/ssl/ssl_buffer.c +2 -1
- data/third_party/boringssl/ssl/ssl_cert.c +417 -219
- data/third_party/boringssl/ssl/ssl_cipher.c +191 -393
- data/third_party/boringssl/ssl/ssl_ecdh.c +19 -164
- data/third_party/boringssl/ssl/ssl_file.c +0 -11
- data/third_party/boringssl/ssl/ssl_lib.c +325 -652
- data/third_party/boringssl/ssl/{ssl_rsa.c → ssl_privkey.c} +21 -131
- data/third_party/boringssl/ssl/ssl_privkey_cc.cc +76 -0
- data/third_party/boringssl/ssl/ssl_session.c +206 -95
- data/third_party/boringssl/ssl/ssl_stat.c +18 -84
- data/third_party/boringssl/ssl/{s3_enc.c → ssl_transcript.c} +150 -157
- data/third_party/boringssl/ssl/ssl_x509.c +815 -0
- data/third_party/boringssl/ssl/t1_enc.c +188 -174
- data/third_party/boringssl/ssl/t1_lib.c +1064 -764
- data/third_party/boringssl/ssl/tls13_both.c +290 -96
- data/third_party/boringssl/ssl/tls13_client.c +344 -314
- data/third_party/boringssl/ssl/tls13_enc.c +239 -200
- data/third_party/boringssl/ssl/tls13_server.c +374 -366
- data/third_party/boringssl/ssl/tls_method.c +40 -5
- data/third_party/boringssl/ssl/tls_record.c +166 -71
- metadata +39 -25
- data/src/core/lib/iomgr/workqueue.h +0 -87
- data/src/core/lib/iomgr/workqueue_uv.c +0 -65
- data/src/core/lib/iomgr/workqueue_uv.h +0 -37
- data/src/core/lib/iomgr/workqueue_windows.c +0 -63
- data/src/core/lib/iomgr/workqueue_windows.h +0 -37
- data/third_party/boringssl/crypto/bio/buffer.c +0 -496
- data/third_party/boringssl/crypto/newhope/error_correction.c +0 -131
- data/third_party/boringssl/crypto/newhope/internal.h +0 -71
- data/third_party/boringssl/crypto/newhope/newhope.c +0 -174
- data/third_party/boringssl/crypto/newhope/ntt.c +0 -148
- data/third_party/boringssl/crypto/newhope/poly.c +0 -183
- data/third_party/boringssl/crypto/newhope/precomp.c +0 -306
- data/third_party/boringssl/crypto/obj/obj_xref.h +0 -96
- data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +0 -151
- data/third_party/boringssl/include/openssl/newhope.h +0 -158
- data/third_party/boringssl/include/openssl/time_support.h +0 -91
@@ -1,33 +1,18 @@
|
|
1
1
|
/*
|
2
2
|
*
|
3
|
-
* Copyright 2015
|
4
|
-
* All rights reserved.
|
3
|
+
* Copyright 2015 gRPC authors.
|
5
4
|
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
9
8
|
*
|
10
|
-
*
|
11
|
-
* notice, this list of conditions and the following disclaimer.
|
12
|
-
* * Redistributions in binary form must reproduce the above
|
13
|
-
* copyright notice, this list of conditions and the following disclaimer
|
14
|
-
* in the documentation and/or other materials provided with the
|
15
|
-
* distribution.
|
16
|
-
* * Neither the name of Google Inc. nor the names of its
|
17
|
-
* contributors may be used to endorse or promote products derived from
|
18
|
-
* this software without specific prior written permission.
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
19
10
|
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
27
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
31
16
|
*
|
32
17
|
*/
|
33
18
|
|
@@ -126,7 +111,7 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx,
|
|
126
111
|
}
|
127
112
|
pq->inflight_id = t->ping_ctr * GRPC_CHTTP2_PING_TYPE_COUNT + ping_type;
|
128
113
|
t->ping_ctr++;
|
129
|
-
|
114
|
+
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INITIATE]);
|
130
115
|
grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT],
|
131
116
|
&pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]);
|
132
117
|
grpc_slice_buffer_add(&t->outbuf,
|
@@ -163,20 +148,25 @@ static bool stream_ref_if_not_destroyed(gpr_refcount *r) {
|
|
163
148
|
return true;
|
164
149
|
}
|
165
150
|
|
166
|
-
/* How many bytes of incoming flow control would we like to advertise */
|
167
|
-
uint32_t grpc_chttp2_target_incoming_window(grpc_chttp2_transport *t) {
|
168
|
-
return (uint32_t)GPR_MIN(
|
169
|
-
(int64_t)((1u << 31) - 1),
|
170
|
-
t->stream_total_over_incoming_window +
|
171
|
-
t->settings[GRPC_SENT_SETTINGS]
|
172
|
-
[GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
|
173
|
-
}
|
174
|
-
|
175
151
|
/* How many bytes would we like to put on the wire during a single syscall */
|
176
152
|
static uint32_t target_write_size(grpc_chttp2_transport *t) {
|
177
153
|
return 1024 * 1024;
|
178
154
|
}
|
179
155
|
|
156
|
+
// Returns true if initial_metadata contains only default headers.
|
157
|
+
//
|
158
|
+
// TODO(roth): The fact that we hard-code these particular headers here
|
159
|
+
// is fairly ugly. Need some better way to know which headers are
|
160
|
+
// default, maybe via a bit in the static metadata table?
|
161
|
+
static bool is_default_initial_metadata(grpc_metadata_batch *initial_metadata) {
|
162
|
+
int num_default_fields =
|
163
|
+
(initial_metadata->idx.named.status != NULL) +
|
164
|
+
(initial_metadata->idx.named.content_type != NULL) +
|
165
|
+
(initial_metadata->idx.named.grpc_encoding != NULL) +
|
166
|
+
(initial_metadata->idx.named.grpc_accept_encoding != NULL);
|
167
|
+
return (size_t)num_default_fields == initial_metadata->list.count;
|
168
|
+
}
|
169
|
+
|
180
170
|
grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
181
171
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) {
|
182
172
|
grpc_chttp2_stream *s;
|
@@ -202,12 +192,11 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
|
202
192
|
&t->hpack_compressor,
|
203
193
|
t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE]);
|
204
194
|
|
205
|
-
if (t->
|
195
|
+
if (t->flow_control.remote_window > 0) {
|
206
196
|
while (grpc_chttp2_list_pop_stalled_by_transport(t, &s)) {
|
207
197
|
if (!t->closed && grpc_chttp2_list_add_writable_stream(t, s) &&
|
208
198
|
stream_ref_if_not_destroyed(&s->refcount->refs)) {
|
209
|
-
grpc_chttp2_initiate_write(exec_ctx, t,
|
210
|
-
"transport.read_flow_control");
|
199
|
+
grpc_chttp2_initiate_write(exec_ctx, t, "transport.read_flow_control");
|
211
200
|
}
|
212
201
|
}
|
213
202
|
}
|
@@ -229,43 +218,74 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
|
229
218
|
bool sent_initial_metadata = s->sent_initial_metadata;
|
230
219
|
bool now_writing = false;
|
231
220
|
|
232
|
-
GRPC_CHTTP2_IF_TRACING(
|
233
|
-
GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t,
|
234
|
-
|
235
|
-
|
221
|
+
GRPC_CHTTP2_IF_TRACING(
|
222
|
+
gpr_log(GPR_DEBUG, "W:%p %s[%d] im-(sent,send)=(%d,%d) announce=%d", t,
|
223
|
+
t->is_client ? "CLIENT" : "SERVER", s->id,
|
224
|
+
sent_initial_metadata, s->send_initial_metadata != NULL,
|
225
|
+
(int)(s->flow_control.local_window_delta -
|
226
|
+
s->flow_control.announced_window_delta)));
|
227
|
+
|
228
|
+
grpc_mdelem *extra_headers_for_trailing_metadata[2];
|
229
|
+
size_t num_extra_headers_for_trailing_metadata = 0;
|
236
230
|
|
237
231
|
/* send initial metadata if it's available */
|
238
|
-
if (!sent_initial_metadata && s->send_initial_metadata) {
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
232
|
+
if (!sent_initial_metadata && s->send_initial_metadata != NULL) {
|
233
|
+
// We skip this on the server side if there is no custom initial
|
234
|
+
// metadata, there are no messages to send, and we are also sending
|
235
|
+
// trailing metadata. This results in a Trailers-Only response,
|
236
|
+
// which is required for retries, as per:
|
237
|
+
// https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid
|
238
|
+
if (t->is_client || s->fetching_send_message != NULL ||
|
239
|
+
s->flow_controlled_buffer.length != 0 ||
|
240
|
+
s->send_trailing_metadata == NULL ||
|
241
|
+
!is_default_initial_metadata(s->send_initial_metadata)) {
|
242
|
+
grpc_encode_header_options hopt = {
|
243
|
+
.stream_id = s->id,
|
244
|
+
.is_eof = false,
|
245
|
+
.use_true_binary_metadata =
|
246
|
+
t->settings
|
247
|
+
[GRPC_PEER_SETTINGS]
|
248
|
+
[GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != 0,
|
249
|
+
.max_frame_size = t->settings[GRPC_PEER_SETTINGS]
|
250
|
+
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
|
251
|
+
.stats = &s->stats.outgoing};
|
252
|
+
grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, NULL, 0,
|
253
|
+
s->send_initial_metadata, &hopt, &t->outbuf);
|
254
|
+
now_writing = true;
|
255
|
+
t->ping_state.pings_before_data_required =
|
256
|
+
t->ping_policy.max_pings_without_data;
|
257
|
+
if (!t->is_client) {
|
258
|
+
t->ping_recv_state.last_ping_recv_time =
|
259
|
+
gpr_inf_past(GPR_CLOCK_MONOTONIC);
|
260
|
+
t->ping_recv_state.ping_strikes = 0;
|
261
|
+
}
|
262
|
+
} else {
|
263
|
+
GRPC_CHTTP2_IF_TRACING(
|
264
|
+
gpr_log(GPR_INFO, "not sending initial_metadata (Trailers-Only)"));
|
265
|
+
// When sending Trailers-Only, we need to move the :status and
|
266
|
+
// content-type headers to the trailers.
|
267
|
+
if (s->send_initial_metadata->idx.named.status != NULL) {
|
268
|
+
extra_headers_for_trailing_metadata
|
269
|
+
[num_extra_headers_for_trailing_metadata++] =
|
270
|
+
&s->send_initial_metadata->idx.named.status->md;
|
271
|
+
}
|
272
|
+
if (s->send_initial_metadata->idx.named.content_type != NULL) {
|
273
|
+
extra_headers_for_trailing_metadata
|
274
|
+
[num_extra_headers_for_trailing_metadata++] =
|
275
|
+
&s->send_initial_metadata->idx.named.content_type->md;
|
276
|
+
}
|
277
|
+
}
|
251
278
|
s->send_initial_metadata = NULL;
|
252
279
|
s->sent_initial_metadata = true;
|
253
280
|
sent_initial_metadata = true;
|
254
|
-
now_writing = true;
|
255
|
-
t->ping_state.pings_before_data_required =
|
256
|
-
t->ping_policy.max_pings_without_data;
|
257
|
-
if (!t->is_client) {
|
258
|
-
t->ping_recv_state.last_ping_recv_time =
|
259
|
-
gpr_inf_past(GPR_CLOCK_MONOTONIC);
|
260
|
-
t->ping_recv_state.ping_strikes = 0;
|
261
|
-
}
|
262
281
|
}
|
263
282
|
/* send any window updates */
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
283
|
+
uint32_t stream_announce = grpc_chttp2_flowctl_maybe_send_stream_update(
|
284
|
+
&t->flow_control, &s->flow_control);
|
285
|
+
if (stream_announce > 0) {
|
286
|
+
grpc_slice_buffer_add(
|
287
|
+
&t->outbuf, grpc_chttp2_window_update_create(s->id, stream_announce,
|
288
|
+
&s->stats.outgoing));
|
269
289
|
t->ping_state.pings_before_data_required =
|
270
290
|
t->ping_policy.max_pings_without_data;
|
271
291
|
if (!t->is_client) {
|
@@ -273,36 +293,75 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
|
273
293
|
gpr_inf_past(GPR_CLOCK_MONOTONIC);
|
274
294
|
t->ping_recv_state.ping_strikes = 0;
|
275
295
|
}
|
276
|
-
GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", t, s, announce_window, announce);
|
277
296
|
}
|
278
297
|
if (sent_initial_metadata) {
|
279
298
|
/* send any body bytes, if allowed by flow control */
|
280
|
-
if (s->flow_controlled_buffer.length > 0
|
281
|
-
|
299
|
+
if (s->flow_controlled_buffer.length > 0 ||
|
300
|
+
(s->stream_compression_send_enabled &&
|
301
|
+
s->compressed_data_buffer->length > 0)) {
|
302
|
+
uint32_t stream_remote_window = (uint32_t)GPR_MAX(
|
282
303
|
0,
|
283
|
-
s->
|
304
|
+
s->flow_control.remote_window_delta +
|
284
305
|
(int64_t)t->settings[GRPC_PEER_SETTINGS]
|
285
306
|
[GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
|
286
307
|
uint32_t max_outgoing = (uint32_t)GPR_MIN(
|
287
308
|
t->settings[GRPC_PEER_SETTINGS]
|
288
309
|
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
|
289
|
-
GPR_MIN(
|
310
|
+
GPR_MIN(stream_remote_window, t->flow_control.remote_window));
|
290
311
|
if (max_outgoing > 0) {
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
312
|
+
bool is_last_data_frame = false;
|
313
|
+
bool is_last_frame = false;
|
314
|
+
if (s->stream_compression_send_enabled) {
|
315
|
+
while ((s->flow_controlled_buffer.length > 0 ||
|
316
|
+
s->compressed_data_buffer->length > 0) &&
|
317
|
+
max_outgoing > 0) {
|
318
|
+
if (s->compressed_data_buffer->length > 0) {
|
319
|
+
uint32_t send_bytes = (uint32_t)GPR_MIN(
|
320
|
+
max_outgoing, s->compressed_data_buffer->length);
|
321
|
+
is_last_data_frame =
|
322
|
+
(send_bytes == s->compressed_data_buffer->length &&
|
323
|
+
s->flow_controlled_buffer.length == 0 &&
|
324
|
+
s->fetching_send_message == NULL);
|
325
|
+
is_last_frame =
|
326
|
+
is_last_data_frame && s->send_trailing_metadata != NULL &&
|
327
|
+
grpc_metadata_batch_is_empty(s->send_trailing_metadata);
|
328
|
+
grpc_chttp2_encode_data(s->id, s->compressed_data_buffer,
|
329
|
+
send_bytes, is_last_frame,
|
330
|
+
&s->stats.outgoing, &t->outbuf);
|
331
|
+
grpc_chttp2_flowctl_sent_data(&t->flow_control,
|
332
|
+
&s->flow_control, send_bytes);
|
333
|
+
max_outgoing -= send_bytes;
|
334
|
+
if (s->compressed_data_buffer->length == 0) {
|
335
|
+
s->sending_bytes += s->uncompressed_data_size;
|
336
|
+
}
|
337
|
+
} else {
|
338
|
+
if (s->stream_compression_ctx == NULL) {
|
339
|
+
s->stream_compression_ctx =
|
340
|
+
grpc_stream_compression_context_create(
|
341
|
+
GRPC_STREAM_COMPRESSION_COMPRESS);
|
342
|
+
}
|
343
|
+
s->uncompressed_data_size = s->flow_controlled_buffer.length;
|
344
|
+
GPR_ASSERT(grpc_stream_compress(
|
345
|
+
s->stream_compression_ctx, &s->flow_controlled_buffer,
|
346
|
+
s->compressed_data_buffer, NULL, MAX_SIZE_T,
|
347
|
+
GRPC_STREAM_COMPRESSION_FLUSH_SYNC));
|
348
|
+
}
|
349
|
+
}
|
350
|
+
} else {
|
351
|
+
uint32_t send_bytes = (uint32_t)GPR_MIN(
|
352
|
+
max_outgoing, s->flow_controlled_buffer.length);
|
353
|
+
is_last_data_frame = s->fetching_send_message == NULL &&
|
354
|
+
send_bytes == s->flow_controlled_buffer.length;
|
355
|
+
is_last_frame =
|
356
|
+
is_last_data_frame && s->send_trailing_metadata != NULL &&
|
357
|
+
grpc_metadata_batch_is_empty(s->send_trailing_metadata);
|
358
|
+
grpc_chttp2_encode_data(s->id, &s->flow_controlled_buffer,
|
359
|
+
send_bytes, is_last_frame,
|
360
|
+
&s->stats.outgoing, &t->outbuf);
|
361
|
+
grpc_chttp2_flowctl_sent_data(&t->flow_control, &s->flow_control,
|
362
|
+
send_bytes);
|
363
|
+
s->sending_bytes += send_bytes;
|
364
|
+
}
|
306
365
|
t->ping_state.pings_before_data_required =
|
307
366
|
t->ping_policy.max_pings_without_data;
|
308
367
|
if (!t->is_client) {
|
@@ -319,23 +378,27 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
|
319
378
|
&s->stats.outgoing));
|
320
379
|
}
|
321
380
|
}
|
322
|
-
s->sending_bytes += send_bytes;
|
323
381
|
now_writing = true;
|
324
|
-
if (s->flow_controlled_buffer.length > 0
|
382
|
+
if (s->flow_controlled_buffer.length > 0 ||
|
383
|
+
(s->stream_compression_send_enabled &&
|
384
|
+
s->compressed_data_buffer->length > 0)) {
|
325
385
|
GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:fork");
|
326
386
|
grpc_chttp2_list_add_writable_stream(t, s);
|
327
387
|
}
|
328
|
-
} else if (t->
|
388
|
+
} else if (t->flow_control.remote_window == 0) {
|
329
389
|
grpc_chttp2_list_add_stalled_by_transport(t, s);
|
330
390
|
now_writing = true;
|
331
|
-
} else if (
|
391
|
+
} else if (stream_remote_window == 0) {
|
332
392
|
grpc_chttp2_list_add_stalled_by_stream(t, s);
|
333
393
|
now_writing = true;
|
334
394
|
}
|
335
395
|
}
|
336
396
|
if (s->send_trailing_metadata != NULL &&
|
337
397
|
s->fetching_send_message == NULL &&
|
338
|
-
s->flow_controlled_buffer.length == 0
|
398
|
+
s->flow_controlled_buffer.length == 0 &&
|
399
|
+
(!s->stream_compression_send_enabled ||
|
400
|
+
s->compressed_data_buffer->length == 0)) {
|
401
|
+
GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "sending trailing_metadata"));
|
339
402
|
if (grpc_metadata_batch_is_empty(s->send_trailing_metadata)) {
|
340
403
|
grpc_chttp2_encode_data(s->id, &s->flow_controlled_buffer, 0, true,
|
341
404
|
&s->stats.outgoing, &t->outbuf);
|
@@ -353,6 +416,8 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
|
353
416
|
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
|
354
417
|
.stats = &s->stats.outgoing};
|
355
418
|
grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor,
|
419
|
+
extra_headers_for_trailing_metadata,
|
420
|
+
num_extra_headers_for_trailing_metadata,
|
356
421
|
s->send_trailing_metadata, &hopt,
|
357
422
|
&t->outbuf);
|
358
423
|
}
|
@@ -377,22 +442,15 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write(
|
|
377
442
|
}
|
378
443
|
}
|
379
444
|
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
uint32_t threshold_to_send_transport_window_update =
|
384
|
-
t->outbuf.count > 0 ? 3 * target_incoming_window / 4
|
385
|
-
: target_incoming_window / 2;
|
386
|
-
if (t->incoming_window <= threshold_to_send_transport_window_update &&
|
387
|
-
t->incoming_window != target_incoming_window) {
|
445
|
+
uint32_t transport_announce =
|
446
|
+
grpc_chttp2_flowctl_maybe_send_transport_update(&t->flow_control);
|
447
|
+
if (transport_announce) {
|
388
448
|
maybe_initiate_ping(exec_ctx, t,
|
389
449
|
GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE);
|
390
|
-
uint32_t announced = (uint32_t)GPR_CLAMP(
|
391
|
-
target_incoming_window - t->incoming_window, 0, UINT32_MAX);
|
392
|
-
GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("write", t, incoming_window, announced);
|
393
450
|
grpc_transport_one_way_stats throwaway_stats;
|
394
|
-
grpc_slice_buffer_add(
|
395
|
-
|
451
|
+
grpc_slice_buffer_add(
|
452
|
+
&t->outbuf, grpc_chttp2_window_update_create(0, transport_announce,
|
453
|
+
&throwaway_stats));
|
396
454
|
t->ping_state.pings_before_data_required =
|
397
455
|
t->ping_policy.max_pings_without_data;
|
398
456
|
if (!t->is_client) {
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2017 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "src/core/ext/transport/inproc/inproc_transport.h"
|
20
|
+
#include "src/core/lib/debug/trace.h"
|
21
|
+
|
22
|
+
grpc_tracer_flag grpc_inproc_trace = GRPC_TRACER_INITIALIZER(false, "inproc");
|
23
|
+
|
24
|
+
void grpc_inproc_plugin_init(void) {
|
25
|
+
grpc_register_tracer(&grpc_inproc_trace);
|
26
|
+
grpc_inproc_transport_init();
|
27
|
+
}
|
28
|
+
|
29
|
+
void grpc_inproc_plugin_shutdown(void) { grpc_inproc_transport_shutdown(); }
|
@@ -0,0 +1,1303 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2017 gRPC authors.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include "src/core/ext/transport/inproc/inproc_transport.h"
|
20
|
+
#include <grpc/support/alloc.h>
|
21
|
+
#include <grpc/support/string_util.h>
|
22
|
+
#include <grpc/support/sync.h>
|
23
|
+
#include <grpc/support/time.h>
|
24
|
+
#include <string.h>
|
25
|
+
#include "src/core/lib/channel/channel_args.h"
|
26
|
+
#include "src/core/lib/slice/slice_internal.h"
|
27
|
+
#include "src/core/lib/surface/api_trace.h"
|
28
|
+
#include "src/core/lib/surface/channel.h"
|
29
|
+
#include "src/core/lib/surface/channel_stack_type.h"
|
30
|
+
#include "src/core/lib/surface/server.h"
|
31
|
+
#include "src/core/lib/transport/connectivity_state.h"
|
32
|
+
#include "src/core/lib/transport/error_utils.h"
|
33
|
+
#include "src/core/lib/transport/transport_impl.h"
|
34
|
+
|
35
|
+
#define INPROC_LOG(...) \
|
36
|
+
do { \
|
37
|
+
if (GRPC_TRACER_ON(grpc_inproc_trace)) gpr_log(__VA_ARGS__); \
|
38
|
+
} while (0)
|
39
|
+
|
40
|
+
static const grpc_transport_vtable inproc_vtable;
|
41
|
+
static grpc_slice g_empty_slice;
|
42
|
+
static grpc_slice g_fake_path_key;
|
43
|
+
static grpc_slice g_fake_path_value;
|
44
|
+
static grpc_slice g_fake_auth_key;
|
45
|
+
static grpc_slice g_fake_auth_value;
|
46
|
+
|
47
|
+
typedef struct {
|
48
|
+
gpr_mu mu;
|
49
|
+
gpr_refcount refs;
|
50
|
+
} shared_mu;
|
51
|
+
|
52
|
+
typedef struct inproc_transport {
|
53
|
+
grpc_transport base;
|
54
|
+
shared_mu *mu;
|
55
|
+
gpr_refcount refs;
|
56
|
+
bool is_client;
|
57
|
+
grpc_connectivity_state_tracker connectivity;
|
58
|
+
void (*accept_stream_cb)(grpc_exec_ctx *exec_ctx, void *user_data,
|
59
|
+
grpc_transport *transport, const void *server_data);
|
60
|
+
void *accept_stream_data;
|
61
|
+
bool is_closed;
|
62
|
+
struct inproc_transport *other_side;
|
63
|
+
struct inproc_stream *stream_list;
|
64
|
+
} inproc_transport;
|
65
|
+
|
66
|
+
typedef struct sb_list_entry {
|
67
|
+
grpc_slice_buffer sb;
|
68
|
+
struct sb_list_entry *next;
|
69
|
+
} sb_list_entry;
|
70
|
+
|
71
|
+
// Specialize grpc_byte_stream for our use case
|
72
|
+
typedef struct {
|
73
|
+
grpc_byte_stream base;
|
74
|
+
sb_list_entry *le;
|
75
|
+
grpc_error *shutdown_error;
|
76
|
+
} inproc_slice_byte_stream;
|
77
|
+
|
78
|
+
typedef struct {
|
79
|
+
// TODO (vjpai): Add some inlined elements to avoid alloc in simple cases
|
80
|
+
sb_list_entry *head;
|
81
|
+
sb_list_entry *tail;
|
82
|
+
} slice_buffer_list;
|
83
|
+
|
84
|
+
static void slice_buffer_list_init(slice_buffer_list *l) {
|
85
|
+
l->head = NULL;
|
86
|
+
l->tail = NULL;
|
87
|
+
}
|
88
|
+
|
89
|
+
static void sb_list_entry_destroy(grpc_exec_ctx *exec_ctx, sb_list_entry *le) {
|
90
|
+
grpc_slice_buffer_destroy_internal(exec_ctx, &le->sb);
|
91
|
+
gpr_free(le);
|
92
|
+
}
|
93
|
+
|
94
|
+
static void slice_buffer_list_destroy(grpc_exec_ctx *exec_ctx,
|
95
|
+
slice_buffer_list *l) {
|
96
|
+
sb_list_entry *curr = l->head;
|
97
|
+
while (curr != NULL) {
|
98
|
+
sb_list_entry *le = curr;
|
99
|
+
curr = curr->next;
|
100
|
+
sb_list_entry_destroy(exec_ctx, le);
|
101
|
+
}
|
102
|
+
l->head = NULL;
|
103
|
+
l->tail = NULL;
|
104
|
+
}
|
105
|
+
|
106
|
+
static bool slice_buffer_list_empty(slice_buffer_list *l) {
|
107
|
+
return l->head == NULL;
|
108
|
+
}
|
109
|
+
|
110
|
+
static void slice_buffer_list_append_entry(slice_buffer_list *l,
|
111
|
+
sb_list_entry *next) {
|
112
|
+
next->next = NULL;
|
113
|
+
if (l->tail) {
|
114
|
+
l->tail->next = next;
|
115
|
+
l->tail = next;
|
116
|
+
} else {
|
117
|
+
l->head = next;
|
118
|
+
l->tail = next;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
static grpc_slice_buffer *slice_buffer_list_append(slice_buffer_list *l) {
|
123
|
+
sb_list_entry *next = gpr_malloc(sizeof(*next));
|
124
|
+
grpc_slice_buffer_init(&next->sb);
|
125
|
+
slice_buffer_list_append_entry(l, next);
|
126
|
+
return &next->sb;
|
127
|
+
}
|
128
|
+
|
129
|
+
static sb_list_entry *slice_buffer_list_pophead(slice_buffer_list *l) {
|
130
|
+
sb_list_entry *ret = l->head;
|
131
|
+
l->head = l->head->next;
|
132
|
+
if (l->head == NULL) {
|
133
|
+
l->tail = NULL;
|
134
|
+
}
|
135
|
+
return ret;
|
136
|
+
}
|
137
|
+
|
138
|
+
typedef struct inproc_stream {
|
139
|
+
inproc_transport *t;
|
140
|
+
grpc_metadata_batch to_read_initial_md;
|
141
|
+
uint32_t to_read_initial_md_flags;
|
142
|
+
bool to_read_initial_md_filled;
|
143
|
+
slice_buffer_list to_read_message;
|
144
|
+
grpc_metadata_batch to_read_trailing_md;
|
145
|
+
bool to_read_trailing_md_filled;
|
146
|
+
bool reads_needed;
|
147
|
+
bool read_closure_scheduled;
|
148
|
+
grpc_closure read_closure;
|
149
|
+
// Write buffer used only during gap at init time when client-side
|
150
|
+
// stream is set up but server side stream is not yet set up
|
151
|
+
grpc_metadata_batch write_buffer_initial_md;
|
152
|
+
bool write_buffer_initial_md_filled;
|
153
|
+
uint32_t write_buffer_initial_md_flags;
|
154
|
+
gpr_timespec write_buffer_deadline;
|
155
|
+
slice_buffer_list write_buffer_message;
|
156
|
+
grpc_metadata_batch write_buffer_trailing_md;
|
157
|
+
bool write_buffer_trailing_md_filled;
|
158
|
+
grpc_error *write_buffer_cancel_error;
|
159
|
+
|
160
|
+
struct inproc_stream *other_side;
|
161
|
+
bool other_side_closed; // won't talk anymore
|
162
|
+
bool write_buffer_other_side_closed; // on hold
|
163
|
+
grpc_stream_refcount *refs;
|
164
|
+
grpc_closure *closure_at_destroy;
|
165
|
+
|
166
|
+
gpr_arena *arena;
|
167
|
+
|
168
|
+
grpc_transport_stream_op_batch *recv_initial_md_op;
|
169
|
+
grpc_transport_stream_op_batch *recv_message_op;
|
170
|
+
grpc_transport_stream_op_batch *recv_trailing_md_op;
|
171
|
+
|
172
|
+
inproc_slice_byte_stream recv_message_stream;
|
173
|
+
|
174
|
+
bool initial_md_sent;
|
175
|
+
bool trailing_md_sent;
|
176
|
+
bool initial_md_recvd;
|
177
|
+
bool trailing_md_recvd;
|
178
|
+
|
179
|
+
bool closed;
|
180
|
+
|
181
|
+
grpc_error *cancel_self_error;
|
182
|
+
grpc_error *cancel_other_error;
|
183
|
+
|
184
|
+
gpr_timespec deadline;
|
185
|
+
|
186
|
+
bool listed;
|
187
|
+
struct inproc_stream *stream_list_prev;
|
188
|
+
struct inproc_stream *stream_list_next;
|
189
|
+
} inproc_stream;
|
190
|
+
|
191
|
+
static bool inproc_slice_byte_stream_next(grpc_exec_ctx *exec_ctx,
|
192
|
+
grpc_byte_stream *bs, size_t max,
|
193
|
+
grpc_closure *on_complete) {
|
194
|
+
// Because inproc transport always provides the entire message atomically,
|
195
|
+
// the byte stream always has data available when this function is called.
|
196
|
+
// Thus, this function always returns true (unlike other transports) and
|
197
|
+
// there is never any need to schedule a closure
|
198
|
+
return true;
|
199
|
+
}
|
200
|
+
|
201
|
+
static grpc_error *inproc_slice_byte_stream_pull(grpc_exec_ctx *exec_ctx,
|
202
|
+
grpc_byte_stream *bs,
|
203
|
+
grpc_slice *slice) {
|
204
|
+
inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs;
|
205
|
+
if (stream->shutdown_error != GRPC_ERROR_NONE) {
|
206
|
+
return GRPC_ERROR_REF(stream->shutdown_error);
|
207
|
+
}
|
208
|
+
*slice = grpc_slice_buffer_take_first(&stream->le->sb);
|
209
|
+
return GRPC_ERROR_NONE;
|
210
|
+
}
|
211
|
+
|
212
|
+
static void inproc_slice_byte_stream_shutdown(grpc_exec_ctx *exec_ctx,
|
213
|
+
grpc_byte_stream *bs,
|
214
|
+
grpc_error *error) {
|
215
|
+
inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs;
|
216
|
+
GRPC_ERROR_UNREF(stream->shutdown_error);
|
217
|
+
stream->shutdown_error = error;
|
218
|
+
}
|
219
|
+
|
220
|
+
static void inproc_slice_byte_stream_destroy(grpc_exec_ctx *exec_ctx,
|
221
|
+
grpc_byte_stream *bs) {
|
222
|
+
inproc_slice_byte_stream *stream = (inproc_slice_byte_stream *)bs;
|
223
|
+
sb_list_entry_destroy(exec_ctx, stream->le);
|
224
|
+
GRPC_ERROR_UNREF(stream->shutdown_error);
|
225
|
+
}
|
226
|
+
|
227
|
+
static const grpc_byte_stream_vtable inproc_slice_byte_stream_vtable = {
|
228
|
+
inproc_slice_byte_stream_next, inproc_slice_byte_stream_pull,
|
229
|
+
inproc_slice_byte_stream_shutdown, inproc_slice_byte_stream_destroy};
|
230
|
+
|
231
|
+
void inproc_slice_byte_stream_init(inproc_slice_byte_stream *s,
|
232
|
+
sb_list_entry *le) {
|
233
|
+
s->base.length = (uint32_t)le->sb.length;
|
234
|
+
s->base.flags = 0;
|
235
|
+
s->base.vtable = &inproc_slice_byte_stream_vtable;
|
236
|
+
s->le = le;
|
237
|
+
s->shutdown_error = GRPC_ERROR_NONE;
|
238
|
+
}
|
239
|
+
|
240
|
+
static void ref_transport(inproc_transport *t) {
|
241
|
+
INPROC_LOG(GPR_DEBUG, "ref_transport %p", t);
|
242
|
+
gpr_ref(&t->refs);
|
243
|
+
}
|
244
|
+
|
245
|
+
static void really_destroy_transport(grpc_exec_ctx *exec_ctx,
|
246
|
+
inproc_transport *t) {
|
247
|
+
INPROC_LOG(GPR_DEBUG, "really_destroy_transport %p", t);
|
248
|
+
grpc_connectivity_state_destroy(exec_ctx, &t->connectivity);
|
249
|
+
if (gpr_unref(&t->mu->refs)) {
|
250
|
+
gpr_free(t->mu);
|
251
|
+
}
|
252
|
+
gpr_free(t);
|
253
|
+
}
|
254
|
+
|
255
|
+
static void unref_transport(grpc_exec_ctx *exec_ctx, inproc_transport *t) {
|
256
|
+
INPROC_LOG(GPR_DEBUG, "unref_transport %p", t);
|
257
|
+
if (gpr_unref(&t->refs)) {
|
258
|
+
really_destroy_transport(exec_ctx, t);
|
259
|
+
}
|
260
|
+
}
|
261
|
+
|
262
|
+
#ifndef NDEBUG
|
263
|
+
#define STREAM_REF(refs, reason) grpc_stream_ref(refs, reason)
|
264
|
+
#define STREAM_UNREF(e, refs, reason) grpc_stream_unref(e, refs, reason)
|
265
|
+
#else
|
266
|
+
#define STREAM_REF(refs, reason) grpc_stream_ref(refs)
|
267
|
+
#define STREAM_UNREF(e, refs, reason) grpc_stream_unref(e, refs)
|
268
|
+
#endif
|
269
|
+
|
270
|
+
static void ref_stream(inproc_stream *s, const char *reason) {
|
271
|
+
INPROC_LOG(GPR_DEBUG, "ref_stream %p %s", s, reason);
|
272
|
+
STREAM_REF(s->refs, reason);
|
273
|
+
}
|
274
|
+
|
275
|
+
static void unref_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s,
|
276
|
+
const char *reason) {
|
277
|
+
INPROC_LOG(GPR_DEBUG, "unref_stream %p %s", s, reason);
|
278
|
+
STREAM_UNREF(exec_ctx, s->refs, reason);
|
279
|
+
}
|
280
|
+
|
281
|
+
static void really_destroy_stream(grpc_exec_ctx *exec_ctx, inproc_stream *s) {
|
282
|
+
INPROC_LOG(GPR_DEBUG, "really_destroy_stream %p", s);
|
283
|
+
|
284
|
+
slice_buffer_list_destroy(exec_ctx, &s->to_read_message);
|
285
|
+
slice_buffer_list_destroy(exec_ctx, &s->write_buffer_message);
|
286
|
+
GRPC_ERROR_UNREF(s->write_buffer_cancel_error);
|
287
|
+
GRPC_ERROR_UNREF(s->cancel_self_error);
|
288
|
+
GRPC_ERROR_UNREF(s->cancel_other_error);
|
289
|
+
|
290
|
+
unref_transport(exec_ctx, s->t);
|
291
|
+
|
292
|
+
if (s->closure_at_destroy) {
|
293
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->closure_at_destroy, GRPC_ERROR_NONE);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg,
|
298
|
+
grpc_error *error);
|
299
|
+
|
300
|
+
static void log_metadata(const grpc_metadata_batch *md_batch, bool is_client,
|
301
|
+
bool is_initial) {
|
302
|
+
for (grpc_linked_mdelem *md = md_batch->list.head; md != NULL;
|
303
|
+
md = md->next) {
|
304
|
+
char *key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
|
305
|
+
char *value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
|
306
|
+
gpr_log(GPR_INFO, "INPROC:%s:%s: %s: %s", is_initial ? "HDR" : "TRL",
|
307
|
+
is_client ? "CLI" : "SVR", key, value);
|
308
|
+
gpr_free(key);
|
309
|
+
gpr_free(value);
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
static grpc_error *fill_in_metadata(grpc_exec_ctx *exec_ctx, inproc_stream *s,
|
314
|
+
const grpc_metadata_batch *metadata,
|
315
|
+
uint32_t flags, grpc_metadata_batch *out_md,
|
316
|
+
uint32_t *outflags, bool *markfilled) {
|
317
|
+
if (GRPC_TRACER_ON(grpc_inproc_trace)) {
|
318
|
+
log_metadata(metadata, s->t->is_client, outflags != NULL);
|
319
|
+
}
|
320
|
+
|
321
|
+
if (outflags != NULL) {
|
322
|
+
*outflags = flags;
|
323
|
+
}
|
324
|
+
if (markfilled != NULL) {
|
325
|
+
*markfilled = true;
|
326
|
+
}
|
327
|
+
grpc_error *error = GRPC_ERROR_NONE;
|
328
|
+
for (grpc_linked_mdelem *elem = metadata->list.head;
|
329
|
+
(elem != NULL) && (error == GRPC_ERROR_NONE); elem = elem->next) {
|
330
|
+
grpc_linked_mdelem *nelem = gpr_arena_alloc(s->arena, sizeof(*nelem));
|
331
|
+
nelem->md = grpc_mdelem_from_slices(
|
332
|
+
exec_ctx, grpc_slice_intern(GRPC_MDKEY(elem->md)),
|
333
|
+
grpc_slice_intern(GRPC_MDVALUE(elem->md)));
|
334
|
+
|
335
|
+
error = grpc_metadata_batch_link_tail(exec_ctx, out_md, nelem);
|
336
|
+
}
|
337
|
+
return error;
|
338
|
+
}
|
339
|
+
|
340
|
+
static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
341
|
+
grpc_stream *gs, grpc_stream_refcount *refcount,
|
342
|
+
const void *server_data, gpr_arena *arena) {
|
343
|
+
INPROC_LOG(GPR_DEBUG, "init_stream %p %p %p", gt, gs, server_data);
|
344
|
+
inproc_transport *t = (inproc_transport *)gt;
|
345
|
+
inproc_stream *s = (inproc_stream *)gs;
|
346
|
+
s->arena = arena;
|
347
|
+
|
348
|
+
s->refs = refcount;
|
349
|
+
// Ref this stream right now
|
350
|
+
ref_stream(s, "inproc_init_stream:init");
|
351
|
+
|
352
|
+
grpc_metadata_batch_init(&s->to_read_initial_md);
|
353
|
+
s->to_read_initial_md_flags = 0;
|
354
|
+
s->to_read_initial_md_filled = false;
|
355
|
+
grpc_metadata_batch_init(&s->to_read_trailing_md);
|
356
|
+
s->to_read_trailing_md_filled = false;
|
357
|
+
grpc_metadata_batch_init(&s->write_buffer_initial_md);
|
358
|
+
s->write_buffer_initial_md_flags = 0;
|
359
|
+
s->write_buffer_initial_md_filled = false;
|
360
|
+
grpc_metadata_batch_init(&s->write_buffer_trailing_md);
|
361
|
+
s->write_buffer_trailing_md_filled = false;
|
362
|
+
slice_buffer_list_init(&s->to_read_message);
|
363
|
+
slice_buffer_list_init(&s->write_buffer_message);
|
364
|
+
s->reads_needed = false;
|
365
|
+
s->read_closure_scheduled = false;
|
366
|
+
GRPC_CLOSURE_INIT(&s->read_closure, read_state_machine, s,
|
367
|
+
grpc_schedule_on_exec_ctx);
|
368
|
+
s->t = t;
|
369
|
+
s->closure_at_destroy = NULL;
|
370
|
+
s->other_side_closed = false;
|
371
|
+
|
372
|
+
s->initial_md_sent = s->trailing_md_sent = s->initial_md_recvd =
|
373
|
+
s->trailing_md_recvd = false;
|
374
|
+
|
375
|
+
s->closed = false;
|
376
|
+
|
377
|
+
s->cancel_self_error = GRPC_ERROR_NONE;
|
378
|
+
s->cancel_other_error = GRPC_ERROR_NONE;
|
379
|
+
s->write_buffer_cancel_error = GRPC_ERROR_NONE;
|
380
|
+
s->deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
|
381
|
+
s->write_buffer_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
|
382
|
+
|
383
|
+
s->stream_list_prev = NULL;
|
384
|
+
gpr_mu_lock(&t->mu->mu);
|
385
|
+
s->listed = true;
|
386
|
+
ref_stream(s, "inproc_init_stream:list");
|
387
|
+
s->stream_list_next = t->stream_list;
|
388
|
+
if (t->stream_list) {
|
389
|
+
t->stream_list->stream_list_prev = s;
|
390
|
+
}
|
391
|
+
t->stream_list = s;
|
392
|
+
gpr_mu_unlock(&t->mu->mu);
|
393
|
+
|
394
|
+
if (!server_data) {
|
395
|
+
ref_transport(t);
|
396
|
+
inproc_transport *st = t->other_side;
|
397
|
+
ref_transport(st);
|
398
|
+
s->other_side = NULL; // will get filled in soon
|
399
|
+
// Pass the client-side stream address to the server-side for a ref
|
400
|
+
ref_stream(s, "inproc_init_stream:clt"); // ref it now on behalf of server
|
401
|
+
// side to avoid destruction
|
402
|
+
INPROC_LOG(GPR_DEBUG, "calling accept stream cb %p %p",
|
403
|
+
st->accept_stream_cb, st->accept_stream_data);
|
404
|
+
(*st->accept_stream_cb)(exec_ctx, st->accept_stream_data, &st->base,
|
405
|
+
(void *)s);
|
406
|
+
} else {
|
407
|
+
// This is the server-side and is being called through accept_stream_cb
|
408
|
+
inproc_stream *cs = (inproc_stream *)server_data;
|
409
|
+
s->other_side = cs;
|
410
|
+
// Ref the server-side stream on behalf of the client now
|
411
|
+
ref_stream(s, "inproc_init_stream:srv");
|
412
|
+
|
413
|
+
// Now we are about to affect the other side, so lock the transport
|
414
|
+
// to make sure that it doesn't get destroyed
|
415
|
+
gpr_mu_lock(&s->t->mu->mu);
|
416
|
+
cs->other_side = s;
|
417
|
+
// Now transfer from the other side's write_buffer if any to the to_read
|
418
|
+
// buffer
|
419
|
+
if (cs->write_buffer_initial_md_filled) {
|
420
|
+
fill_in_metadata(exec_ctx, s, &cs->write_buffer_initial_md,
|
421
|
+
cs->write_buffer_initial_md_flags,
|
422
|
+
&s->to_read_initial_md, &s->to_read_initial_md_flags,
|
423
|
+
&s->to_read_initial_md_filled);
|
424
|
+
s->deadline = gpr_time_min(s->deadline, cs->write_buffer_deadline);
|
425
|
+
grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_initial_md);
|
426
|
+
cs->write_buffer_initial_md_filled = false;
|
427
|
+
}
|
428
|
+
while (!slice_buffer_list_empty(&cs->write_buffer_message)) {
|
429
|
+
slice_buffer_list_append_entry(
|
430
|
+
&s->to_read_message,
|
431
|
+
slice_buffer_list_pophead(&cs->write_buffer_message));
|
432
|
+
}
|
433
|
+
if (cs->write_buffer_trailing_md_filled) {
|
434
|
+
fill_in_metadata(exec_ctx, s, &cs->write_buffer_trailing_md, 0,
|
435
|
+
&s->to_read_trailing_md, NULL,
|
436
|
+
&s->to_read_trailing_md_filled);
|
437
|
+
grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_trailing_md);
|
438
|
+
cs->write_buffer_trailing_md_filled = false;
|
439
|
+
}
|
440
|
+
if (cs->write_buffer_cancel_error != GRPC_ERROR_NONE) {
|
441
|
+
s->cancel_other_error = cs->write_buffer_cancel_error;
|
442
|
+
cs->write_buffer_cancel_error = GRPC_ERROR_NONE;
|
443
|
+
}
|
444
|
+
|
445
|
+
gpr_mu_unlock(&s->t->mu->mu);
|
446
|
+
}
|
447
|
+
return 0; // return value is not important
|
448
|
+
}
|
449
|
+
|
450
|
+
static void close_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s) {
|
451
|
+
if (!s->closed) {
|
452
|
+
// Release the metadata that we would have written out
|
453
|
+
grpc_metadata_batch_destroy(exec_ctx, &s->write_buffer_initial_md);
|
454
|
+
grpc_metadata_batch_destroy(exec_ctx, &s->write_buffer_trailing_md);
|
455
|
+
|
456
|
+
if (s->listed) {
|
457
|
+
inproc_stream *p = s->stream_list_prev;
|
458
|
+
inproc_stream *n = s->stream_list_next;
|
459
|
+
if (p != NULL) {
|
460
|
+
p->stream_list_next = n;
|
461
|
+
} else {
|
462
|
+
s->t->stream_list = n;
|
463
|
+
}
|
464
|
+
if (n != NULL) {
|
465
|
+
n->stream_list_prev = p;
|
466
|
+
}
|
467
|
+
s->listed = false;
|
468
|
+
unref_stream(exec_ctx, s, "close_stream:list");
|
469
|
+
}
|
470
|
+
s->closed = true;
|
471
|
+
unref_stream(exec_ctx, s, "close_stream:closing");
|
472
|
+
}
|
473
|
+
}
|
474
|
+
|
475
|
+
// This function means that we are done talking/listening to the other side
|
476
|
+
static void close_other_side_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
|
477
|
+
const char *reason) {
|
478
|
+
if (s->other_side != NULL) {
|
479
|
+
// First release the metadata that came from the other side's arena
|
480
|
+
grpc_metadata_batch_destroy(exec_ctx, &s->to_read_initial_md);
|
481
|
+
grpc_metadata_batch_destroy(exec_ctx, &s->to_read_trailing_md);
|
482
|
+
|
483
|
+
unref_stream(exec_ctx, s->other_side, reason);
|
484
|
+
s->other_side_closed = true;
|
485
|
+
s->other_side = NULL;
|
486
|
+
} else if (!s->other_side_closed) {
|
487
|
+
s->write_buffer_other_side_closed = true;
|
488
|
+
}
|
489
|
+
}
|
490
|
+
|
491
|
+
static void fail_helper_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
|
492
|
+
grpc_error *error) {
|
493
|
+
INPROC_LOG(GPR_DEBUG, "read_state_machine %p fail_helper", s);
|
494
|
+
// If we're failing this side, we need to make sure that
|
495
|
+
// we also send or have already sent trailing metadata
|
496
|
+
if (!s->trailing_md_sent) {
|
497
|
+
// Send trailing md to the other side indicating cancellation
|
498
|
+
s->trailing_md_sent = true;
|
499
|
+
|
500
|
+
grpc_metadata_batch fake_md;
|
501
|
+
grpc_metadata_batch_init(&fake_md);
|
502
|
+
|
503
|
+
inproc_stream *other = s->other_side;
|
504
|
+
grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
|
505
|
+
: &other->to_read_trailing_md;
|
506
|
+
bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
|
507
|
+
: &other->to_read_trailing_md_filled;
|
508
|
+
fill_in_metadata(exec_ctx, s, &fake_md, 0, dest, NULL, destfilled);
|
509
|
+
grpc_metadata_batch_destroy(exec_ctx, &fake_md);
|
510
|
+
|
511
|
+
if (other != NULL) {
|
512
|
+
if (other->cancel_other_error == GRPC_ERROR_NONE) {
|
513
|
+
other->cancel_other_error = GRPC_ERROR_REF(error);
|
514
|
+
}
|
515
|
+
if (other->reads_needed) {
|
516
|
+
if (!other->read_closure_scheduled) {
|
517
|
+
GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure,
|
518
|
+
GRPC_ERROR_REF(error));
|
519
|
+
other->read_closure_scheduled = true;
|
520
|
+
}
|
521
|
+
other->reads_needed = false;
|
522
|
+
}
|
523
|
+
} else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
|
524
|
+
s->write_buffer_cancel_error = GRPC_ERROR_REF(error);
|
525
|
+
}
|
526
|
+
}
|
527
|
+
if (s->recv_initial_md_op) {
|
528
|
+
grpc_error *err;
|
529
|
+
if (!s->t->is_client) {
|
530
|
+
// If this is a server, provide initial metadata with a path and authority
|
531
|
+
// since it expects that as well as no error yet
|
532
|
+
grpc_metadata_batch fake_md;
|
533
|
+
grpc_metadata_batch_init(&fake_md);
|
534
|
+
grpc_linked_mdelem *path_md = gpr_arena_alloc(s->arena, sizeof(*path_md));
|
535
|
+
path_md->md =
|
536
|
+
grpc_mdelem_from_slices(exec_ctx, g_fake_path_key, g_fake_path_value);
|
537
|
+
GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, path_md) ==
|
538
|
+
GRPC_ERROR_NONE);
|
539
|
+
grpc_linked_mdelem *auth_md = gpr_arena_alloc(s->arena, sizeof(*auth_md));
|
540
|
+
auth_md->md =
|
541
|
+
grpc_mdelem_from_slices(exec_ctx, g_fake_auth_key, g_fake_auth_value);
|
542
|
+
GPR_ASSERT(grpc_metadata_batch_link_tail(exec_ctx, &fake_md, auth_md) ==
|
543
|
+
GRPC_ERROR_NONE);
|
544
|
+
|
545
|
+
fill_in_metadata(
|
546
|
+
exec_ctx, s, &fake_md, 0,
|
547
|
+
s->recv_initial_md_op->payload->recv_initial_metadata
|
548
|
+
.recv_initial_metadata,
|
549
|
+
s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags,
|
550
|
+
NULL);
|
551
|
+
grpc_metadata_batch_destroy(exec_ctx, &fake_md);
|
552
|
+
err = GRPC_ERROR_NONE;
|
553
|
+
} else {
|
554
|
+
err = GRPC_ERROR_REF(error);
|
555
|
+
}
|
556
|
+
INPROC_LOG(GPR_DEBUG,
|
557
|
+
"fail_helper %p scheduling initial-metadata-ready %p %p", s,
|
558
|
+
error, err);
|
559
|
+
GRPC_CLOSURE_SCHED(exec_ctx,
|
560
|
+
s->recv_initial_md_op->payload->recv_initial_metadata
|
561
|
+
.recv_initial_metadata_ready,
|
562
|
+
err);
|
563
|
+
// Last use of err so no need to REF and then UNREF it
|
564
|
+
|
565
|
+
if ((s->recv_initial_md_op != s->recv_message_op) &&
|
566
|
+
(s->recv_initial_md_op != s->recv_trailing_md_op)) {
|
567
|
+
INPROC_LOG(GPR_DEBUG,
|
568
|
+
"fail_helper %p scheduling initial-metadata-on-complete %p",
|
569
|
+
error, s);
|
570
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_initial_md_op->on_complete,
|
571
|
+
GRPC_ERROR_REF(error));
|
572
|
+
}
|
573
|
+
s->recv_initial_md_op = NULL;
|
574
|
+
}
|
575
|
+
if (s->recv_message_op) {
|
576
|
+
INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-ready %p", s,
|
577
|
+
error);
|
578
|
+
GRPC_CLOSURE_SCHED(
|
579
|
+
exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready,
|
580
|
+
GRPC_ERROR_REF(error));
|
581
|
+
if (s->recv_message_op != s->recv_trailing_md_op) {
|
582
|
+
INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-on-complete %p",
|
583
|
+
s, error);
|
584
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete,
|
585
|
+
GRPC_ERROR_REF(error));
|
586
|
+
}
|
587
|
+
s->recv_message_op = NULL;
|
588
|
+
}
|
589
|
+
if (s->recv_trailing_md_op) {
|
590
|
+
INPROC_LOG(GPR_DEBUG,
|
591
|
+
"fail_helper %p scheduling trailing-md-on-complete %p", s,
|
592
|
+
error);
|
593
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
|
594
|
+
GRPC_ERROR_REF(error));
|
595
|
+
s->recv_trailing_md_op = NULL;
|
596
|
+
}
|
597
|
+
close_other_side_locked(exec_ctx, s, "fail_helper:other_side");
|
598
|
+
close_stream_locked(exec_ctx, s);
|
599
|
+
|
600
|
+
GRPC_ERROR_UNREF(error);
|
601
|
+
}
|
602
|
+
|
603
|
+
static void read_state_machine(grpc_exec_ctx *exec_ctx, void *arg,
|
604
|
+
grpc_error *error) {
|
605
|
+
// This function gets called when we have contents in the unprocessed reads
|
606
|
+
// Get what we want based on our ops wanted
|
607
|
+
// Schedule our appropriate closures
|
608
|
+
// and then return to reads_needed state if still needed
|
609
|
+
|
610
|
+
// Since this is a closure directly invoked by the combiner, it should not
|
611
|
+
// unref the error parameter explicitly; the combiner will do that implicitly
|
612
|
+
grpc_error *new_err = GRPC_ERROR_NONE;
|
613
|
+
|
614
|
+
bool needs_close = false;
|
615
|
+
|
616
|
+
INPROC_LOG(GPR_DEBUG, "read_state_machine %p", arg);
|
617
|
+
inproc_stream *s = (inproc_stream *)arg;
|
618
|
+
gpr_mu *mu = &s->t->mu->mu; // keep aside in case s gets closed
|
619
|
+
gpr_mu_lock(mu);
|
620
|
+
s->read_closure_scheduled = false;
|
621
|
+
// cancellation takes precedence
|
622
|
+
if (s->cancel_self_error != GRPC_ERROR_NONE) {
|
623
|
+
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(s->cancel_self_error));
|
624
|
+
goto done;
|
625
|
+
} else if (s->cancel_other_error != GRPC_ERROR_NONE) {
|
626
|
+
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(s->cancel_other_error));
|
627
|
+
goto done;
|
628
|
+
} else if (error != GRPC_ERROR_NONE) {
|
629
|
+
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(error));
|
630
|
+
goto done;
|
631
|
+
}
|
632
|
+
|
633
|
+
if (s->recv_initial_md_op) {
|
634
|
+
if (!s->to_read_initial_md_filled) {
|
635
|
+
// We entered the state machine on some other kind of read even though
|
636
|
+
// we still haven't satisfied initial md . That's an error.
|
637
|
+
new_err =
|
638
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unexpected frame sequencing");
|
639
|
+
INPROC_LOG(GPR_DEBUG,
|
640
|
+
"read_state_machine %p scheduling on_complete errors for no "
|
641
|
+
"initial md %p",
|
642
|
+
s, new_err);
|
643
|
+
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
|
644
|
+
goto done;
|
645
|
+
} else if (s->initial_md_recvd) {
|
646
|
+
new_err =
|
647
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd initial md");
|
648
|
+
INPROC_LOG(
|
649
|
+
GPR_DEBUG,
|
650
|
+
"read_state_machine %p scheduling on_complete errors for already "
|
651
|
+
"recvd initial md %p",
|
652
|
+
s, new_err);
|
653
|
+
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
|
654
|
+
goto done;
|
655
|
+
}
|
656
|
+
|
657
|
+
s->initial_md_recvd = true;
|
658
|
+
new_err = fill_in_metadata(
|
659
|
+
exec_ctx, s, &s->to_read_initial_md, s->to_read_initial_md_flags,
|
660
|
+
s->recv_initial_md_op->payload->recv_initial_metadata
|
661
|
+
.recv_initial_metadata,
|
662
|
+
s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags, NULL);
|
663
|
+
s->recv_initial_md_op->payload->recv_initial_metadata.recv_initial_metadata
|
664
|
+
->deadline = s->deadline;
|
665
|
+
grpc_metadata_batch_clear(exec_ctx, &s->to_read_initial_md);
|
666
|
+
s->to_read_initial_md_filled = false;
|
667
|
+
INPROC_LOG(GPR_DEBUG,
|
668
|
+
"read_state_machine %p scheduling initial-metadata-ready %p", s,
|
669
|
+
new_err);
|
670
|
+
GRPC_CLOSURE_SCHED(exec_ctx,
|
671
|
+
s->recv_initial_md_op->payload->recv_initial_metadata
|
672
|
+
.recv_initial_metadata_ready,
|
673
|
+
GRPC_ERROR_REF(new_err));
|
674
|
+
if ((s->recv_initial_md_op != s->recv_message_op) &&
|
675
|
+
(s->recv_initial_md_op != s->recv_trailing_md_op)) {
|
676
|
+
INPROC_LOG(
|
677
|
+
GPR_DEBUG,
|
678
|
+
"read_state_machine %p scheduling initial-metadata-on-complete %p", s,
|
679
|
+
new_err);
|
680
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_initial_md_op->on_complete,
|
681
|
+
GRPC_ERROR_REF(new_err));
|
682
|
+
}
|
683
|
+
s->recv_initial_md_op = NULL;
|
684
|
+
|
685
|
+
if (new_err != GRPC_ERROR_NONE) {
|
686
|
+
INPROC_LOG(GPR_DEBUG,
|
687
|
+
"read_state_machine %p scheduling on_complete errors2 %p", s,
|
688
|
+
new_err);
|
689
|
+
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
|
690
|
+
goto done;
|
691
|
+
}
|
692
|
+
}
|
693
|
+
if (s->to_read_initial_md_filled) {
|
694
|
+
new_err = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unexpected recv frame");
|
695
|
+
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
|
696
|
+
goto done;
|
697
|
+
}
|
698
|
+
if (!slice_buffer_list_empty(&s->to_read_message) && s->recv_message_op) {
|
699
|
+
inproc_slice_byte_stream_init(
|
700
|
+
&s->recv_message_stream,
|
701
|
+
slice_buffer_list_pophead(&s->to_read_message));
|
702
|
+
*s->recv_message_op->payload->recv_message.recv_message =
|
703
|
+
&s->recv_message_stream.base;
|
704
|
+
INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready", s);
|
705
|
+
GRPC_CLOSURE_SCHED(
|
706
|
+
exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready,
|
707
|
+
GRPC_ERROR_NONE);
|
708
|
+
if (s->recv_message_op != s->recv_trailing_md_op) {
|
709
|
+
INPROC_LOG(GPR_DEBUG,
|
710
|
+
"read_state_machine %p scheduling message-on-complete %p", s,
|
711
|
+
new_err);
|
712
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete,
|
713
|
+
GRPC_ERROR_REF(new_err));
|
714
|
+
}
|
715
|
+
s->recv_message_op = NULL;
|
716
|
+
}
|
717
|
+
if (s->to_read_trailing_md_filled) {
|
718
|
+
if (s->trailing_md_recvd) {
|
719
|
+
new_err =
|
720
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Already recvd trailing md");
|
721
|
+
INPROC_LOG(
|
722
|
+
GPR_DEBUG,
|
723
|
+
"read_state_machine %p scheduling on_complete errors for already "
|
724
|
+
"recvd trailing md %p",
|
725
|
+
s, new_err);
|
726
|
+
fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err));
|
727
|
+
goto done;
|
728
|
+
}
|
729
|
+
if (s->recv_message_op != NULL) {
|
730
|
+
// This message needs to be wrapped up because it will never be
|
731
|
+
// satisfied
|
732
|
+
INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready",
|
733
|
+
s);
|
734
|
+
GRPC_CLOSURE_SCHED(
|
735
|
+
exec_ctx,
|
736
|
+
s->recv_message_op->payload->recv_message.recv_message_ready,
|
737
|
+
GRPC_ERROR_NONE);
|
738
|
+
if (s->recv_message_op != s->recv_trailing_md_op) {
|
739
|
+
INPROC_LOG(GPR_DEBUG,
|
740
|
+
"read_state_machine %p scheduling message-on-complete %p", s,
|
741
|
+
new_err);
|
742
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete,
|
743
|
+
GRPC_ERROR_REF(new_err));
|
744
|
+
}
|
745
|
+
s->recv_message_op = NULL;
|
746
|
+
}
|
747
|
+
if (s->recv_trailing_md_op != NULL) {
|
748
|
+
// We wanted trailing metadata and we got it
|
749
|
+
s->trailing_md_recvd = true;
|
750
|
+
new_err =
|
751
|
+
fill_in_metadata(exec_ctx, s, &s->to_read_trailing_md, 0,
|
752
|
+
s->recv_trailing_md_op->payload
|
753
|
+
->recv_trailing_metadata.recv_trailing_metadata,
|
754
|
+
NULL, NULL);
|
755
|
+
grpc_metadata_batch_clear(exec_ctx, &s->to_read_trailing_md);
|
756
|
+
s->to_read_trailing_md_filled = false;
|
757
|
+
|
758
|
+
// We should schedule the recv_trailing_md_op completion if
|
759
|
+
// 1. this stream is the client-side
|
760
|
+
// 2. this stream is the server-side AND has already sent its trailing md
|
761
|
+
// (If the server hasn't already sent its trailing md, it doesn't have
|
762
|
+
// a final status, so don't mark this op complete)
|
763
|
+
if (s->t->is_client || s->trailing_md_sent) {
|
764
|
+
INPROC_LOG(
|
765
|
+
GPR_DEBUG,
|
766
|
+
"read_state_machine %p scheduling trailing-md-on-complete %p", s,
|
767
|
+
new_err);
|
768
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
|
769
|
+
GRPC_ERROR_REF(new_err));
|
770
|
+
s->recv_trailing_md_op = NULL;
|
771
|
+
needs_close = true;
|
772
|
+
} else {
|
773
|
+
INPROC_LOG(GPR_DEBUG,
|
774
|
+
"read_state_machine %p server needs to delay handling "
|
775
|
+
"trailing-md-on-complete %p",
|
776
|
+
s, new_err);
|
777
|
+
}
|
778
|
+
} else {
|
779
|
+
INPROC_LOG(
|
780
|
+
GPR_DEBUG,
|
781
|
+
"read_state_machine %p has trailing md but not yet waiting for it",
|
782
|
+
s);
|
783
|
+
}
|
784
|
+
}
|
785
|
+
if (s->trailing_md_recvd && s->recv_message_op) {
|
786
|
+
// No further message will come on this stream, so finish off the
|
787
|
+
// recv_message_op
|
788
|
+
INPROC_LOG(GPR_DEBUG, "read_state_machine %p scheduling message-ready", s);
|
789
|
+
GRPC_CLOSURE_SCHED(
|
790
|
+
exec_ctx, s->recv_message_op->payload->recv_message.recv_message_ready,
|
791
|
+
GRPC_ERROR_NONE);
|
792
|
+
if (s->recv_message_op != s->recv_trailing_md_op) {
|
793
|
+
INPROC_LOG(GPR_DEBUG,
|
794
|
+
"read_state_machine %p scheduling message-on-complete %p", s,
|
795
|
+
new_err);
|
796
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_message_op->on_complete,
|
797
|
+
GRPC_ERROR_REF(new_err));
|
798
|
+
}
|
799
|
+
s->recv_message_op = NULL;
|
800
|
+
}
|
801
|
+
if (s->recv_message_op || s->recv_trailing_md_op) {
|
802
|
+
// Didn't get the item we wanted so we still need to get
|
803
|
+
// rescheduled
|
804
|
+
INPROC_LOG(GPR_DEBUG, "read_state_machine %p still needs closure %p %p", s,
|
805
|
+
s->recv_message_op, s->recv_trailing_md_op);
|
806
|
+
s->reads_needed = true;
|
807
|
+
}
|
808
|
+
done:
|
809
|
+
if (needs_close) {
|
810
|
+
close_other_side_locked(exec_ctx, s, "read_state_machine");
|
811
|
+
close_stream_locked(exec_ctx, s);
|
812
|
+
}
|
813
|
+
gpr_mu_unlock(mu);
|
814
|
+
GRPC_ERROR_UNREF(new_err);
|
815
|
+
}
|
816
|
+
|
817
|
+
static grpc_closure do_nothing_closure;
|
818
|
+
|
819
|
+
static bool cancel_stream_locked(grpc_exec_ctx *exec_ctx, inproc_stream *s,
|
820
|
+
grpc_error *error) {
|
821
|
+
bool ret = false; // was the cancel accepted
|
822
|
+
INPROC_LOG(GPR_DEBUG, "cancel_stream %p with %s", s,
|
823
|
+
grpc_error_string(error));
|
824
|
+
if (s->cancel_self_error == GRPC_ERROR_NONE) {
|
825
|
+
ret = true;
|
826
|
+
s->cancel_self_error = GRPC_ERROR_REF(error);
|
827
|
+
if (s->reads_needed) {
|
828
|
+
if (!s->read_closure_scheduled) {
|
829
|
+
GRPC_CLOSURE_SCHED(exec_ctx, &s->read_closure,
|
830
|
+
GRPC_ERROR_REF(s->cancel_self_error));
|
831
|
+
s->read_closure_scheduled = true;
|
832
|
+
}
|
833
|
+
s->reads_needed = false;
|
834
|
+
}
|
835
|
+
// Send trailing md to the other side indicating cancellation, even if we
|
836
|
+
// already have
|
837
|
+
s->trailing_md_sent = true;
|
838
|
+
|
839
|
+
grpc_metadata_batch cancel_md;
|
840
|
+
grpc_metadata_batch_init(&cancel_md);
|
841
|
+
|
842
|
+
inproc_stream *other = s->other_side;
|
843
|
+
grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
|
844
|
+
: &other->to_read_trailing_md;
|
845
|
+
bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
|
846
|
+
: &other->to_read_trailing_md_filled;
|
847
|
+
fill_in_metadata(exec_ctx, s, &cancel_md, 0, dest, NULL, destfilled);
|
848
|
+
grpc_metadata_batch_destroy(exec_ctx, &cancel_md);
|
849
|
+
|
850
|
+
if (other != NULL) {
|
851
|
+
if (other->cancel_other_error == GRPC_ERROR_NONE) {
|
852
|
+
other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error);
|
853
|
+
}
|
854
|
+
if (other->reads_needed) {
|
855
|
+
if (!other->read_closure_scheduled) {
|
856
|
+
GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure,
|
857
|
+
GRPC_ERROR_REF(other->cancel_other_error));
|
858
|
+
other->read_closure_scheduled = true;
|
859
|
+
}
|
860
|
+
other->reads_needed = false;
|
861
|
+
}
|
862
|
+
} else if (s->write_buffer_cancel_error == GRPC_ERROR_NONE) {
|
863
|
+
s->write_buffer_cancel_error = GRPC_ERROR_REF(s->cancel_self_error);
|
864
|
+
}
|
865
|
+
|
866
|
+
// if we are a server and already received trailing md but
|
867
|
+
// couldn't complete that because we hadn't yet sent out trailing
|
868
|
+
// md, now's the chance
|
869
|
+
if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) {
|
870
|
+
INPROC_LOG(GPR_DEBUG,
|
871
|
+
"cancel_stream %p scheduling trailing-md-on-complete %p", s,
|
872
|
+
s->cancel_self_error);
|
873
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
|
874
|
+
GRPC_ERROR_REF(s->cancel_self_error));
|
875
|
+
s->recv_trailing_md_op = NULL;
|
876
|
+
}
|
877
|
+
}
|
878
|
+
|
879
|
+
close_other_side_locked(exec_ctx, s, "cancel_stream:other_side");
|
880
|
+
close_stream_locked(exec_ctx, s);
|
881
|
+
|
882
|
+
GRPC_ERROR_UNREF(error);
|
883
|
+
return ret;
|
884
|
+
}
|
885
|
+
|
886
|
+
static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
887
|
+
grpc_stream *gs,
|
888
|
+
grpc_transport_stream_op_batch *op) {
|
889
|
+
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %p %p", gt, gs, op);
|
890
|
+
inproc_stream *s = (inproc_stream *)gs;
|
891
|
+
gpr_mu *mu = &s->t->mu->mu; // save aside in case s gets closed
|
892
|
+
gpr_mu_lock(mu);
|
893
|
+
|
894
|
+
if (GRPC_TRACER_ON(grpc_inproc_trace)) {
|
895
|
+
if (op->send_initial_metadata) {
|
896
|
+
log_metadata(op->payload->send_initial_metadata.send_initial_metadata,
|
897
|
+
s->t->is_client, true);
|
898
|
+
}
|
899
|
+
if (op->send_trailing_metadata) {
|
900
|
+
log_metadata(op->payload->send_trailing_metadata.send_trailing_metadata,
|
901
|
+
s->t->is_client, false);
|
902
|
+
}
|
903
|
+
}
|
904
|
+
grpc_error *error = GRPC_ERROR_NONE;
|
905
|
+
grpc_closure *on_complete = op->on_complete;
|
906
|
+
if (on_complete == NULL) {
|
907
|
+
on_complete = &do_nothing_closure;
|
908
|
+
}
|
909
|
+
|
910
|
+
if (op->cancel_stream) {
|
911
|
+
// Call cancel_stream_locked without ref'ing the cancel_error because
|
912
|
+
// this function is responsible to make sure that that field gets unref'ed
|
913
|
+
cancel_stream_locked(exec_ctx, s, op->payload->cancel_stream.cancel_error);
|
914
|
+
// this op can complete without an error
|
915
|
+
} else if (s->cancel_self_error != GRPC_ERROR_NONE) {
|
916
|
+
// already self-canceled so still give it an error
|
917
|
+
error = GRPC_ERROR_REF(s->cancel_self_error);
|
918
|
+
} else {
|
919
|
+
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p%s%s%s%s%s%s", s,
|
920
|
+
op->send_initial_metadata ? " send_initial_metadata" : "",
|
921
|
+
op->send_message ? " send_message" : "",
|
922
|
+
op->send_trailing_metadata ? " send_trailing_metadata" : "",
|
923
|
+
op->recv_initial_metadata ? " recv_initial_metadata" : "",
|
924
|
+
op->recv_message ? " recv_message" : "",
|
925
|
+
op->recv_trailing_metadata ? " recv_trailing_metadata" : "");
|
926
|
+
}
|
927
|
+
|
928
|
+
bool needs_close = false;
|
929
|
+
|
930
|
+
if (error == GRPC_ERROR_NONE &&
|
931
|
+
(op->send_initial_metadata || op->send_message ||
|
932
|
+
op->send_trailing_metadata)) {
|
933
|
+
inproc_stream *other = s->other_side;
|
934
|
+
if (s->t->is_closed) {
|
935
|
+
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown");
|
936
|
+
}
|
937
|
+
if (error == GRPC_ERROR_NONE && op->send_initial_metadata) {
|
938
|
+
grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_initial_md
|
939
|
+
: &other->to_read_initial_md;
|
940
|
+
uint32_t *destflags = (other == NULL) ? &s->write_buffer_initial_md_flags
|
941
|
+
: &other->to_read_initial_md_flags;
|
942
|
+
bool *destfilled = (other == NULL) ? &s->write_buffer_initial_md_filled
|
943
|
+
: &other->to_read_initial_md_filled;
|
944
|
+
if (*destfilled || s->initial_md_sent) {
|
945
|
+
// The buffer is already in use; that's an error!
|
946
|
+
INPROC_LOG(GPR_DEBUG, "Extra initial metadata %p", s);
|
947
|
+
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra initial metadata");
|
948
|
+
} else {
|
949
|
+
if (!other->closed) {
|
950
|
+
fill_in_metadata(
|
951
|
+
exec_ctx, s,
|
952
|
+
op->payload->send_initial_metadata.send_initial_metadata,
|
953
|
+
op->payload->send_initial_metadata.send_initial_metadata_flags,
|
954
|
+
dest, destflags, destfilled);
|
955
|
+
}
|
956
|
+
if (s->t->is_client) {
|
957
|
+
gpr_timespec *dl =
|
958
|
+
(other == NULL) ? &s->write_buffer_deadline : &other->deadline;
|
959
|
+
*dl = gpr_time_min(*dl, op->payload->send_initial_metadata
|
960
|
+
.send_initial_metadata->deadline);
|
961
|
+
s->initial_md_sent = true;
|
962
|
+
}
|
963
|
+
}
|
964
|
+
}
|
965
|
+
if (error == GRPC_ERROR_NONE && op->send_message) {
|
966
|
+
size_t remaining = op->payload->send_message.send_message->length;
|
967
|
+
grpc_slice_buffer *dest = slice_buffer_list_append(
|
968
|
+
(other == NULL) ? &s->write_buffer_message : &other->to_read_message);
|
969
|
+
do {
|
970
|
+
grpc_slice message_slice;
|
971
|
+
grpc_closure unused;
|
972
|
+
GPR_ASSERT(grpc_byte_stream_next(exec_ctx,
|
973
|
+
op->payload->send_message.send_message,
|
974
|
+
SIZE_MAX, &unused));
|
975
|
+
error = grpc_byte_stream_pull(
|
976
|
+
exec_ctx, op->payload->send_message.send_message, &message_slice);
|
977
|
+
if (error != GRPC_ERROR_NONE) {
|
978
|
+
cancel_stream_locked(exec_ctx, s, GRPC_ERROR_REF(error));
|
979
|
+
break;
|
980
|
+
}
|
981
|
+
GPR_ASSERT(error == GRPC_ERROR_NONE);
|
982
|
+
remaining -= GRPC_SLICE_LENGTH(message_slice);
|
983
|
+
grpc_slice_buffer_add(dest, message_slice);
|
984
|
+
} while (remaining != 0);
|
985
|
+
grpc_byte_stream_destroy(exec_ctx,
|
986
|
+
op->payload->send_message.send_message);
|
987
|
+
}
|
988
|
+
if (error == GRPC_ERROR_NONE && op->send_trailing_metadata) {
|
989
|
+
grpc_metadata_batch *dest = (other == NULL) ? &s->write_buffer_trailing_md
|
990
|
+
: &other->to_read_trailing_md;
|
991
|
+
bool *destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled
|
992
|
+
: &other->to_read_trailing_md_filled;
|
993
|
+
if (*destfilled || s->trailing_md_sent) {
|
994
|
+
// The buffer is already in use; that's an error!
|
995
|
+
INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s);
|
996
|
+
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Extra trailing metadata");
|
997
|
+
} else {
|
998
|
+
if (!other->closed) {
|
999
|
+
fill_in_metadata(
|
1000
|
+
exec_ctx, s,
|
1001
|
+
op->payload->send_trailing_metadata.send_trailing_metadata, 0,
|
1002
|
+
dest, NULL, destfilled);
|
1003
|
+
}
|
1004
|
+
s->trailing_md_sent = true;
|
1005
|
+
if (!s->t->is_client && s->trailing_md_recvd &&
|
1006
|
+
s->recv_trailing_md_op) {
|
1007
|
+
INPROC_LOG(GPR_DEBUG,
|
1008
|
+
"perform_stream_op %p scheduling trailing-md-on-complete",
|
1009
|
+
s);
|
1010
|
+
GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete,
|
1011
|
+
GRPC_ERROR_NONE);
|
1012
|
+
s->recv_trailing_md_op = NULL;
|
1013
|
+
needs_close = true;
|
1014
|
+
}
|
1015
|
+
}
|
1016
|
+
}
|
1017
|
+
if (other != NULL && other->reads_needed) {
|
1018
|
+
if (!other->read_closure_scheduled) {
|
1019
|
+
GRPC_CLOSURE_SCHED(exec_ctx, &other->read_closure, error);
|
1020
|
+
other->read_closure_scheduled = true;
|
1021
|
+
}
|
1022
|
+
other->reads_needed = false;
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
if (error == GRPC_ERROR_NONE &&
|
1026
|
+
(op->recv_initial_metadata || op->recv_message ||
|
1027
|
+
op->recv_trailing_metadata)) {
|
1028
|
+
// If there are any reads, mark it so that the read closure will react to
|
1029
|
+
// them
|
1030
|
+
if (op->recv_initial_metadata) {
|
1031
|
+
s->recv_initial_md_op = op;
|
1032
|
+
}
|
1033
|
+
if (op->recv_message) {
|
1034
|
+
s->recv_message_op = op;
|
1035
|
+
}
|
1036
|
+
if (op->recv_trailing_metadata) {
|
1037
|
+
s->recv_trailing_md_op = op;
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
// We want to initiate the closure if:
|
1041
|
+
// 1. There is initial metadata and something ready to take that
|
1042
|
+
// 2. There is a message and something ready to take it
|
1043
|
+
// 3. There is trailing metadata, even if nothing specifically wants
|
1044
|
+
// that because that can shut down the message as well
|
1045
|
+
if ((s->to_read_initial_md_filled && op->recv_initial_metadata) ||
|
1046
|
+
((!slice_buffer_list_empty(&s->to_read_message) ||
|
1047
|
+
s->trailing_md_recvd) &&
|
1048
|
+
op->recv_message) ||
|
1049
|
+
(s->to_read_trailing_md_filled)) {
|
1050
|
+
if (!s->read_closure_scheduled) {
|
1051
|
+
GRPC_CLOSURE_SCHED(exec_ctx, &s->read_closure, GRPC_ERROR_NONE);
|
1052
|
+
s->read_closure_scheduled = true;
|
1053
|
+
}
|
1054
|
+
} else {
|
1055
|
+
s->reads_needed = true;
|
1056
|
+
}
|
1057
|
+
} else {
|
1058
|
+
if (error != GRPC_ERROR_NONE) {
|
1059
|
+
// Schedule op's read closures that we didn't push to read state machine
|
1060
|
+
if (op->recv_initial_metadata) {
|
1061
|
+
INPROC_LOG(
|
1062
|
+
GPR_DEBUG,
|
1063
|
+
"perform_stream_op error %p scheduling initial-metadata-ready %p",
|
1064
|
+
s, error);
|
1065
|
+
GRPC_CLOSURE_SCHED(
|
1066
|
+
exec_ctx,
|
1067
|
+
op->payload->recv_initial_metadata.recv_initial_metadata_ready,
|
1068
|
+
GRPC_ERROR_REF(error));
|
1069
|
+
}
|
1070
|
+
if (op->recv_message) {
|
1071
|
+
INPROC_LOG(
|
1072
|
+
GPR_DEBUG,
|
1073
|
+
"perform_stream_op error %p scheduling recv message-ready %p", s,
|
1074
|
+
error);
|
1075
|
+
GRPC_CLOSURE_SCHED(exec_ctx,
|
1076
|
+
op->payload->recv_message.recv_message_ready,
|
1077
|
+
GRPC_ERROR_REF(error));
|
1078
|
+
}
|
1079
|
+
}
|
1080
|
+
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p scheduling on_complete %p", s,
|
1081
|
+
error);
|
1082
|
+
GRPC_CLOSURE_SCHED(exec_ctx, on_complete, GRPC_ERROR_REF(error));
|
1083
|
+
}
|
1084
|
+
if (needs_close) {
|
1085
|
+
close_other_side_locked(exec_ctx, s, "perform_stream_op:other_side");
|
1086
|
+
close_stream_locked(exec_ctx, s);
|
1087
|
+
}
|
1088
|
+
gpr_mu_unlock(mu);
|
1089
|
+
GRPC_ERROR_UNREF(error);
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
static void close_transport_locked(grpc_exec_ctx *exec_ctx,
|
1093
|
+
inproc_transport *t) {
|
1094
|
+
INPROC_LOG(GPR_DEBUG, "close_transport %p %d", t, t->is_closed);
|
1095
|
+
grpc_connectivity_state_set(
|
1096
|
+
exec_ctx, &t->connectivity, GRPC_CHANNEL_SHUTDOWN,
|
1097
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Closing transport."),
|
1098
|
+
"close transport");
|
1099
|
+
if (!t->is_closed) {
|
1100
|
+
t->is_closed = true;
|
1101
|
+
/* Also end all streams on this transport */
|
1102
|
+
while (t->stream_list != NULL) {
|
1103
|
+
// cancel_stream_locked also adjusts stream list
|
1104
|
+
cancel_stream_locked(
|
1105
|
+
exec_ctx, t->stream_list,
|
1106
|
+
grpc_error_set_int(
|
1107
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport closed"),
|
1108
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
|
1109
|
+
}
|
1110
|
+
}
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
1114
|
+
grpc_transport_op *op) {
|
1115
|
+
inproc_transport *t = (inproc_transport *)gt;
|
1116
|
+
INPROC_LOG(GPR_DEBUG, "perform_transport_op %p %p", t, op);
|
1117
|
+
gpr_mu_lock(&t->mu->mu);
|
1118
|
+
if (op->on_connectivity_state_change) {
|
1119
|
+
grpc_connectivity_state_notify_on_state_change(
|
1120
|
+
exec_ctx, &t->connectivity, op->connectivity_state,
|
1121
|
+
op->on_connectivity_state_change);
|
1122
|
+
}
|
1123
|
+
if (op->set_accept_stream) {
|
1124
|
+
t->accept_stream_cb = op->set_accept_stream_fn;
|
1125
|
+
t->accept_stream_data = op->set_accept_stream_user_data;
|
1126
|
+
}
|
1127
|
+
if (op->on_consumed) {
|
1128
|
+
GRPC_CLOSURE_SCHED(exec_ctx, op->on_consumed, GRPC_ERROR_NONE);
|
1129
|
+
}
|
1130
|
+
|
1131
|
+
bool do_close = false;
|
1132
|
+
if (op->goaway_error != GRPC_ERROR_NONE) {
|
1133
|
+
do_close = true;
|
1134
|
+
GRPC_ERROR_UNREF(op->goaway_error);
|
1135
|
+
}
|
1136
|
+
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
|
1137
|
+
do_close = true;
|
1138
|
+
GRPC_ERROR_UNREF(op->disconnect_with_error);
|
1139
|
+
}
|
1140
|
+
|
1141
|
+
if (do_close) {
|
1142
|
+
close_transport_locked(exec_ctx, t);
|
1143
|
+
}
|
1144
|
+
gpr_mu_unlock(&t->mu->mu);
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
static void destroy_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
1148
|
+
grpc_stream *gs,
|
1149
|
+
grpc_closure *then_schedule_closure) {
|
1150
|
+
INPROC_LOG(GPR_DEBUG, "destroy_stream %p %p", gs, then_schedule_closure);
|
1151
|
+
inproc_stream *s = (inproc_stream *)gs;
|
1152
|
+
s->closure_at_destroy = then_schedule_closure;
|
1153
|
+
really_destroy_stream(exec_ctx, s);
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
static void destroy_transport(grpc_exec_ctx *exec_ctx, grpc_transport *gt) {
|
1157
|
+
inproc_transport *t = (inproc_transport *)gt;
|
1158
|
+
INPROC_LOG(GPR_DEBUG, "destroy_transport %p", t);
|
1159
|
+
gpr_mu_lock(&t->mu->mu);
|
1160
|
+
close_transport_locked(exec_ctx, t);
|
1161
|
+
gpr_mu_unlock(&t->mu->mu);
|
1162
|
+
unref_transport(exec_ctx, t->other_side);
|
1163
|
+
unref_transport(exec_ctx, t);
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
/*******************************************************************************
|
1167
|
+
* Main inproc transport functions
|
1168
|
+
*/
|
1169
|
+
static void inproc_transports_create(grpc_exec_ctx *exec_ctx,
|
1170
|
+
grpc_transport **server_transport,
|
1171
|
+
const grpc_channel_args *server_args,
|
1172
|
+
grpc_transport **client_transport,
|
1173
|
+
const grpc_channel_args *client_args) {
|
1174
|
+
INPROC_LOG(GPR_DEBUG, "inproc_transports_create");
|
1175
|
+
inproc_transport *st = gpr_zalloc(sizeof(*st));
|
1176
|
+
inproc_transport *ct = gpr_zalloc(sizeof(*ct));
|
1177
|
+
// Share one lock between both sides since both sides get affected
|
1178
|
+
st->mu = ct->mu = gpr_malloc(sizeof(*st->mu));
|
1179
|
+
gpr_mu_init(&st->mu->mu);
|
1180
|
+
gpr_ref_init(&st->mu->refs, 2);
|
1181
|
+
st->base.vtable = &inproc_vtable;
|
1182
|
+
ct->base.vtable = &inproc_vtable;
|
1183
|
+
// Start each side of transport with 2 refs since they each have a ref
|
1184
|
+
// to the other
|
1185
|
+
gpr_ref_init(&st->refs, 2);
|
1186
|
+
gpr_ref_init(&ct->refs, 2);
|
1187
|
+
st->is_client = false;
|
1188
|
+
ct->is_client = true;
|
1189
|
+
grpc_connectivity_state_init(&st->connectivity, GRPC_CHANNEL_READY,
|
1190
|
+
"inproc_server");
|
1191
|
+
grpc_connectivity_state_init(&ct->connectivity, GRPC_CHANNEL_READY,
|
1192
|
+
"inproc_client");
|
1193
|
+
st->other_side = ct;
|
1194
|
+
ct->other_side = st;
|
1195
|
+
st->stream_list = NULL;
|
1196
|
+
ct->stream_list = NULL;
|
1197
|
+
*server_transport = (grpc_transport *)st;
|
1198
|
+
*client_transport = (grpc_transport *)ct;
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
grpc_channel *grpc_inproc_channel_create(grpc_server *server,
|
1202
|
+
grpc_channel_args *args,
|
1203
|
+
void *reserved) {
|
1204
|
+
GRPC_API_TRACE("grpc_inproc_channel_create(server=%p, args=%p)", 2,
|
1205
|
+
(server, args));
|
1206
|
+
|
1207
|
+
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1208
|
+
|
1209
|
+
const grpc_channel_args *server_args = grpc_server_get_channel_args(server);
|
1210
|
+
|
1211
|
+
// Add a default authority channel argument for the client
|
1212
|
+
|
1213
|
+
grpc_arg default_authority_arg;
|
1214
|
+
default_authority_arg.type = GRPC_ARG_STRING;
|
1215
|
+
default_authority_arg.key = GRPC_ARG_DEFAULT_AUTHORITY;
|
1216
|
+
default_authority_arg.value.string = "inproc.authority";
|
1217
|
+
grpc_channel_args *client_args =
|
1218
|
+
grpc_channel_args_copy_and_add(args, &default_authority_arg, 1);
|
1219
|
+
|
1220
|
+
grpc_transport *server_transport;
|
1221
|
+
grpc_transport *client_transport;
|
1222
|
+
inproc_transports_create(&exec_ctx, &server_transport, server_args,
|
1223
|
+
&client_transport, client_args);
|
1224
|
+
|
1225
|
+
grpc_server_setup_transport(&exec_ctx, server, server_transport, NULL,
|
1226
|
+
server_args);
|
1227
|
+
grpc_channel *channel =
|
1228
|
+
grpc_channel_create(&exec_ctx, "inproc", client_args,
|
1229
|
+
GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
|
1230
|
+
|
1231
|
+
// Free up created channel args
|
1232
|
+
grpc_channel_args_destroy(&exec_ctx, client_args);
|
1233
|
+
|
1234
|
+
// Now finish scheduled operations
|
1235
|
+
grpc_exec_ctx_finish(&exec_ctx);
|
1236
|
+
|
1237
|
+
return channel;
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
/*******************************************************************************
|
1241
|
+
* INTEGRATION GLUE
|
1242
|
+
*/
|
1243
|
+
|
1244
|
+
static void set_pollset(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
1245
|
+
grpc_stream *gs, grpc_pollset *pollset) {
|
1246
|
+
// Nothing to do here
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
1250
|
+
grpc_stream *gs, grpc_pollset_set *pollset_set) {
|
1251
|
+
// Nothing to do here
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
static char *get_peer(grpc_exec_ctx *exec_ctx, grpc_transport *t) {
|
1255
|
+
return gpr_strdup("inproc");
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
static grpc_endpoint *get_endpoint(grpc_exec_ctx *exec_ctx, grpc_transport *t) {
|
1259
|
+
return NULL;
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
static const grpc_transport_vtable inproc_vtable = {
|
1263
|
+
sizeof(inproc_stream), "inproc",
|
1264
|
+
init_stream, set_pollset,
|
1265
|
+
set_pollset_set, perform_stream_op,
|
1266
|
+
perform_transport_op, destroy_stream,
|
1267
|
+
destroy_transport, get_peer,
|
1268
|
+
get_endpoint};
|
1269
|
+
|
1270
|
+
/*******************************************************************************
|
1271
|
+
* GLOBAL INIT AND DESTROY
|
1272
|
+
*/
|
1273
|
+
static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
|
1274
|
+
|
1275
|
+
void grpc_inproc_transport_init(void) {
|
1276
|
+
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1277
|
+
GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, NULL,
|
1278
|
+
grpc_schedule_on_exec_ctx);
|
1279
|
+
g_empty_slice = grpc_slice_from_static_buffer(NULL, 0);
|
1280
|
+
|
1281
|
+
grpc_slice key_tmp = grpc_slice_from_static_string(":path");
|
1282
|
+
g_fake_path_key = grpc_slice_intern(key_tmp);
|
1283
|
+
grpc_slice_unref_internal(&exec_ctx, key_tmp);
|
1284
|
+
|
1285
|
+
g_fake_path_value = grpc_slice_from_static_string("/");
|
1286
|
+
|
1287
|
+
grpc_slice auth_tmp = grpc_slice_from_static_string(":authority");
|
1288
|
+
g_fake_auth_key = grpc_slice_intern(auth_tmp);
|
1289
|
+
grpc_slice_unref_internal(&exec_ctx, auth_tmp);
|
1290
|
+
|
1291
|
+
g_fake_auth_value = grpc_slice_from_static_string("inproc-fail");
|
1292
|
+
grpc_exec_ctx_finish(&exec_ctx);
|
1293
|
+
}
|
1294
|
+
|
1295
|
+
void grpc_inproc_transport_shutdown(void) {
|
1296
|
+
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
1297
|
+
grpc_slice_unref_internal(&exec_ctx, g_empty_slice);
|
1298
|
+
grpc_slice_unref_internal(&exec_ctx, g_fake_path_key);
|
1299
|
+
grpc_slice_unref_internal(&exec_ctx, g_fake_path_value);
|
1300
|
+
grpc_slice_unref_internal(&exec_ctx, g_fake_auth_key);
|
1301
|
+
grpc_slice_unref_internal(&exec_ctx, g_fake_auth_value);
|
1302
|
+
grpc_exec_ctx_finish(&exec_ctx);
|
1303
|
+
}
|