grpc 1.7.3 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +2106 -2116
- data/include/grpc/census.h +1 -432
- data/include/grpc/compression.h +9 -9
- data/include/grpc/grpc.h +115 -98
- data/include/grpc/grpc_cronet.h +3 -3
- data/include/grpc/grpc_posix.h +4 -4
- data/include/grpc/grpc_security.h +160 -88
- data/include/grpc/grpc_security_constants.h +7 -0
- data/include/grpc/impl/codegen/atm.h +9 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +13 -4
- data/include/grpc/impl/codegen/atm_gcc_sync.h +6 -5
- data/include/grpc/impl/codegen/atm_windows.h +23 -22
- data/include/grpc/impl/codegen/byte_buffer.h +14 -14
- data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -2
- data/include/grpc/impl/codegen/connectivity_state.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +32 -28
- data/include/grpc/impl/codegen/port_platform.h +48 -0
- data/include/grpc/impl/codegen/slice.h +10 -10
- data/include/grpc/impl/codegen/sync_generic.h +9 -3
- data/include/grpc/slice.h +16 -17
- data/include/grpc/slice_buffer.h +22 -22
- data/include/grpc/support/alloc.h +11 -11
- data/include/grpc/support/avl.h +28 -20
- data/include/grpc/support/cmdline.h +13 -13
- data/include/grpc/support/histogram.h +17 -17
- data/include/grpc/support/host_port.h +2 -2
- data/include/grpc/support/log.h +9 -9
- data/include/grpc/support/log_windows.h +1 -1
- data/include/grpc/support/string_util.h +2 -2
- data/include/grpc/support/subprocess.h +5 -5
- data/include/grpc/support/sync.h +43 -27
- data/include/grpc/support/thd.h +6 -6
- data/include/grpc/support/tls_gcc.h +1 -1
- data/include/grpc/support/tls_pthread.h +1 -1
- data/src/core/ext/census/{grpc_context.c → grpc_context.cc} +5 -8
- data/src/core/ext/filters/client_channel/backup_poller.cc +165 -0
- data/src/core/ext/{census/grpc_filter.h → filters/client_channel/backup_poller.h} +12 -7
- data/src/core/ext/filters/client_channel/{channel_connectivity.c → channel_connectivity.cc} +45 -42
- data/src/core/ext/filters/client_channel/{client_channel.c → client_channel.cc} +452 -417
- data/src/core/ext/filters/client_channel/client_channel.h +16 -8
- data/src/core/ext/filters/client_channel/{client_channel_factory.c → client_channel_factory.cc} +0 -0
- data/src/core/ext/filters/client_channel/client_channel_factory.h +29 -21
- data/src/core/ext/filters/client_channel/{client_channel_plugin.c → client_channel_plugin.cc} +15 -19
- data/src/core/ext/filters/client_channel/{connector.c → connector.cc} +0 -0
- data/src/core/ext/filters/client_channel/connector.h +29 -21
- data/src/core/ext/filters/client_channel/{http_connect_handshaker.c → http_connect_handshaker.cc} +10 -10
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +8 -0
- data/src/core/ext/filters/client_channel/{http_proxy.c → http_proxy.cc} +14 -14
- data/src/core/ext/filters/client_channel/http_proxy.h +8 -0
- data/src/core/ext/filters/client_channel/{lb_policy.c → lb_policy.cc} +47 -48
- data/src/core/ext/filters/client_channel/lb_policy.h +76 -70
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{client_load_reporting_filter.c → client_load_reporting_filter.cc} +28 -29
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb.c → grpclb.cc} +554 -563
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +17 -9
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_channel_secure.c → grpclb_channel_secure.cc} +17 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{grpclb_client_stats.c → grpclb_client_stats.cc} +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +9 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/{load_balancer_api.c → load_balancer_api.cc} +64 -67
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +20 -21
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +599 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +695 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +270 -0
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +153 -0
- data/src/core/ext/filters/client_channel/{lb_policy_factory.c → lb_policy_factory.cc} +10 -10
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +48 -40
- data/src/core/ext/filters/client_channel/{lb_policy_registry.c → lb_policy_registry.cc} +9 -9
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +11 -3
- data/src/core/ext/filters/client_channel/{parse_address.c → parse_address.cc} +24 -24
- data/src/core/ext/filters/client_channel/parse_address.h +14 -6
- data/src/core/ext/filters/client_channel/{proxy_mapper.c → proxy_mapper.cc} +0 -0
- data/src/core/ext/filters/client_channel/proxy_mapper.h +8 -0
- data/src/core/ext/filters/client_channel/{proxy_mapper_registry.c → proxy_mapper_registry.cc} +0 -0
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +8 -0
- data/src/core/ext/filters/client_channel/{resolver.c → resolver.cc} +21 -23
- data/src/core/ext/filters/client_channel/resolver.h +33 -27
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{dns_resolver_ares.c → dns_resolver_ares.cc} +133 -133
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +18 -9
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_ev_driver_posix.c → grpc_ares_ev_driver_posix.cc} +58 -56
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/{grpc_ares_wrapper.c → grpc_ares_wrapper.cc} +118 -115
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +23 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +60 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/{dns_resolver.c → dns_resolver.cc} +100 -94
- data/src/core/ext/filters/client_channel/resolver/fake/{fake_resolver.c → fake_resolver.cc} +14 -14
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +9 -1
- data/src/core/ext/filters/client_channel/resolver/sockaddr/{sockaddr_resolver.c → sockaddr_resolver.cc} +60 -60
- data/src/core/ext/filters/client_channel/{resolver_factory.c → resolver_factory.cc} +2 -2
- data/src/core/ext/filters/client_channel/resolver_factory.h +27 -19
- data/src/core/ext/filters/client_channel/{resolver_registry.c → resolver_registry.cc} +35 -35
- data/src/core/ext/filters/client_channel/resolver_registry.h +18 -10
- data/src/core/ext/filters/client_channel/{retry_throttle.c → retry_throttle.cc} +10 -10
- data/src/core/ext/filters/client_channel/retry_throttle.h +8 -0
- data/src/core/ext/filters/client_channel/{subchannel.c → subchannel.cc} +210 -213
- data/src/core/ext/filters/client_channel/subchannel.h +68 -60
- data/src/core/ext/filters/client_channel/{subchannel_index.c → subchannel_index.cc} +52 -52
- data/src/core/ext/filters/client_channel/subchannel_index.h +22 -14
- data/src/core/ext/filters/client_channel/{uri_parser.c → uri_parser.cc} +29 -27
- data/src/core/ext/filters/client_channel/uri_parser.h +18 -10
- data/src/core/ext/filters/deadline/{deadline_filter.c → deadline_filter.cc} +12 -15
- data/src/core/ext/filters/deadline/deadline_filter.h +11 -2
- data/src/core/ext/filters/http/client/{http_client_filter.c → http_client_filter.cc} +83 -83
- data/src/core/ext/filters/http/client/http_client_filter.h +8 -0
- data/src/core/ext/filters/http/{http_filters_plugin.c → http_filters_plugin.cc} +20 -21
- data/src/core/ext/filters/http/message_compress/{message_compress_filter.c → message_compress_filter.cc} +84 -83
- data/src/core/ext/filters/http/message_compress/message_compress_filter.h +9 -1
- data/src/core/ext/filters/http/server/{http_server_filter.c → http_server_filter.cc} +80 -78
- data/src/core/ext/filters/http/server/http_server_filter.h +8 -0
- data/src/core/ext/filters/load_reporting/{server_load_reporting_filter.c → server_load_reporting_filter.cc} +29 -29
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +9 -1
- data/src/core/ext/filters/load_reporting/{server_load_reporting_plugin.c → server_load_reporting_plugin.cc} +11 -11
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +13 -5
- data/src/core/ext/filters/max_age/{max_age_filter.c → max_age_filter.cc} +46 -56
- data/src/core/ext/filters/max_age/max_age_filter.h +8 -0
- data/src/core/ext/filters/message_size/{message_size_filter.c → message_size_filter.cc} +62 -40
- data/src/core/ext/filters/message_size/message_size_filter.h +8 -0
- data/src/core/ext/filters/workarounds/{workaround_cronet_compression_filter.c → workaround_cronet_compression_filter.cc} +11 -11
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +8 -0
- data/src/core/ext/filters/workarounds/{workaround_utils.c → workaround_utils.cc} +7 -7
- data/src/core/ext/filters/workarounds/workaround_utils.h +9 -1
- data/src/core/ext/transport/chttp2/alpn/{alpn.c → alpn.cc} +3 -3
- data/src/core/ext/transport/chttp2/alpn/alpn.h +10 -2
- data/src/core/ext/transport/chttp2/client/{chttp2_connector.c → chttp2_connector.cc} +49 -45
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +8 -0
- data/src/core/ext/transport/chttp2/client/insecure/{channel_create.c → channel_create.cc} +28 -27
- data/src/core/ext/transport/chttp2/client/insecure/{channel_create_posix.c → channel_create_posix.cc} +14 -13
- data/src/core/ext/transport/chttp2/client/secure/{secure_channel_create.c → secure_channel_create.cc} +68 -66
- data/src/core/ext/transport/chttp2/server/{chttp2_server.c → chttp2_server.cc} +76 -77
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +11 -3
- data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2.c → server_chttp2.cc} +3 -3
- data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2_posix.c → server_chttp2_posix.cc} +13 -12
- data/src/core/ext/transport/chttp2/server/secure/{server_secure_chttp2.c → server_secure_chttp2.cc} +12 -10
- data/src/core/ext/transport/chttp2/transport/{bin_decoder.c → bin_decoder.cc} +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +15 -7
- data/src/core/ext/transport/chttp2/transport/{bin_encoder.c → bin_encoder.cc} +11 -11
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{chttp2_plugin.c → chttp2_plugin.cc} +2 -9
- data/src/core/ext/transport/chttp2/transport/{chttp2_transport.c → chttp2_transport.cc} +778 -778
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +14 -10
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +385 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +337 -0
- data/src/core/ext/transport/chttp2/transport/frame.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{frame_data.c → frame_data.cc} +34 -34
- data/src/core/ext/transport/chttp2/transport/frame_data.h +25 -17
- data/src/core/ext/transport/chttp2/transport/{frame_goaway.c → frame_goaway.cc} +18 -18
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +18 -10
- data/src/core/ext/transport/chttp2/transport/{frame_ping.c → frame_ping.cc} +18 -19
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +12 -4
- data/src/core/ext/transport/chttp2/transport/{frame_rst_stream.c → frame_rst_stream.cc} +16 -16
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +16 -8
- data/src/core/ext/transport/chttp2/transport/{frame_settings.c → frame_settings.cc} +23 -24
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +17 -9
- data/src/core/ext/transport/chttp2/transport/{frame_window_update.c → frame_window_update.cc} +22 -24
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +14 -6
- data/src/core/ext/transport/chttp2/transport/{hpack_encoder.c → hpack_encoder.cc} +206 -161
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +23 -13
- data/src/core/ext/transport/chttp2/transport/{hpack_parser.c → hpack_parser.cc} +340 -334
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +30 -22
- data/src/core/ext/transport/chttp2/transport/{hpack_table.c → hpack_table.cc} +25 -25
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +19 -11
- data/src/core/ext/transport/chttp2/transport/{http2_settings.c → http2_settings.cc} +1 -1
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +10 -2
- data/src/core/ext/transport/chttp2/transport/{huffsyms.c → huffsyms.cc} +0 -0
- data/src/core/ext/transport/chttp2/transport/huffsyms.h +8 -0
- data/src/core/ext/transport/chttp2/transport/{incoming_metadata.c → incoming_metadata.cc} +14 -13
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +18 -10
- data/src/core/ext/transport/chttp2/transport/internal.h +214 -340
- data/src/core/ext/transport/chttp2/transport/{parsing.c → parsing.cc} +152 -141
- data/src/core/ext/transport/chttp2/transport/{stream_lists.c → stream_lists.cc} +53 -53
- data/src/core/ext/transport/chttp2/transport/{stream_map.c → stream_map.cc} +35 -34
- data/src/core/ext/transport/chttp2/transport/stream_map.h +22 -14
- data/src/core/ext/transport/chttp2/transport/{varint.c → varint.cc} +0 -0
- data/src/core/ext/transport/chttp2/transport/varint.h +8 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +636 -0
- data/src/core/ext/transport/inproc/{inproc_plugin.c → inproc_plugin.cc} +5 -6
- data/src/core/ext/transport/inproc/{inproc_transport.c → inproc_transport.cc} +479 -544
- data/src/core/ext/transport/inproc/inproc_transport.h +4 -4
- data/src/core/lib/backoff/backoff.cc +80 -0
- data/src/core/lib/backoff/backoff.h +83 -0
- data/src/core/lib/channel/{channel_args.c → channel_args.cc} +92 -92
- data/src/core/lib/channel/channel_args.h +45 -37
- data/src/core/lib/channel/{channel_stack.c → channel_stack.cc} +67 -68
- data/src/core/lib/channel/channel_stack.h +76 -75
- data/src/core/lib/channel/{channel_stack_builder.c → channel_stack_builder.cc} +91 -91
- data/src/core/lib/channel/channel_stack_builder.h +45 -45
- data/src/core/lib/channel/{connected_channel.c → connected_channel.cc} +70 -70
- data/src/core/lib/channel/connected_channel.h +12 -4
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/channel/{handshaker.c → handshaker.cc} +7 -9
- data/src/core/lib/channel/handshaker.h +9 -1
- data/src/core/lib/channel/{handshaker_factory.c → handshaker_factory.cc} +7 -7
- data/src/core/lib/channel/handshaker_factory.h +18 -10
- data/src/core/lib/channel/{handshaker_registry.c → handshaker_registry.cc} +0 -0
- data/src/core/lib/channel/handshaker_registry.h +8 -0
- data/src/core/lib/compression/algorithm_metadata.h +8 -0
- data/src/core/lib/compression/{compression.c → compression.cc} +9 -9
- data/src/core/lib/compression/{message_compress.c → message_compress.cc} +0 -0
- data/src/core/lib/compression/message_compress.h +8 -0
- data/src/core/lib/compression/{stream_compression.c → stream_compression.cc} +12 -12
- data/src/core/lib/compression/stream_compression.h +27 -19
- data/src/core/lib/compression/{stream_compression_gzip.c → stream_compression_gzip.cc} +35 -36
- data/src/core/lib/compression/stream_compression_gzip.h +8 -0
- data/src/core/lib/compression/{stream_compression_identity.c → stream_compression_identity.cc} +19 -20
- data/src/core/lib/compression/stream_compression_identity.h +8 -0
- data/src/core/lib/debug/{stats.c → stats.cc} +19 -19
- data/src/core/lib/debug/stats.h +17 -9
- data/src/core/lib/debug/{stats_data.c → stats_data.cc} +45 -22
- data/src/core/lib/debug/stats_data.h +58 -19
- data/src/core/lib/debug/trace.cc +142 -0
- data/src/core/lib/debug/trace.h +74 -14
- data/src/core/lib/http/{format_request.c → format_request.cc} +10 -10
- data/src/core/lib/http/format_request.h +12 -4
- data/src/core/lib/http/{httpcli.c → httpcli.cc} +80 -80
- data/src/core/lib/http/httpcli.h +41 -33
- data/src/core/lib/http/{httpcli_security_connector.c → httpcli_security_connector.cc} +69 -55
- data/src/core/lib/http/{parser.c → parser.cc} +42 -42
- data/src/core/lib/http/parser.h +28 -20
- data/src/core/lib/{support → iomgr}/block_annotate.h +17 -8
- data/src/core/lib/iomgr/{call_combiner.c → call_combiner.cc} +29 -17
- data/src/core/lib/iomgr/call_combiner.h +9 -1
- data/src/core/lib/iomgr/closure.h +220 -62
- data/src/core/lib/iomgr/{combiner.c → combiner.cc} +63 -62
- data/src/core/lib/iomgr/combiner.h +16 -8
- data/src/core/lib/iomgr/{endpoint.c → endpoint.cc} +6 -0
- data/src/core/lib/iomgr/endpoint.h +47 -32
- data/src/core/lib/iomgr/endpoint_pair.h +12 -4
- data/src/core/lib/iomgr/{endpoint_pair_posix.c → endpoint_pair_posix.cc} +3 -3
- data/src/core/lib/iomgr/{endpoint_pair_uv.c → endpoint_pair_uv.cc} +2 -2
- data/src/core/lib/iomgr/{endpoint_pair_windows.c → endpoint_pair_windows.cc} +6 -6
- data/src/core/lib/iomgr/{error.c → error.cc} +125 -124
- data/src/core/lib/iomgr/error.h +32 -27
- data/src/core/lib/iomgr/error_internal.h +11 -2
- data/src/core/lib/iomgr/{ev_epoll1_linux.c → ev_epoll1_linux.cc} +214 -215
- data/src/core/lib/iomgr/ev_epoll1_linux.h +9 -1
- data/src/core/lib/iomgr/ev_epollex_linux.cc +1488 -0
- data/src/core/lib/iomgr/ev_epollex_linux.h +9 -1
- data/src/core/lib/iomgr/{ev_epollsig_linux.c → ev_epollsig_linux.cc} +304 -305
- data/src/core/lib/iomgr/ev_epollsig_linux.h +12 -4
- data/src/core/lib/iomgr/{ev_poll_posix.c → ev_poll_posix.cc} +272 -283
- data/src/core/lib/iomgr/ev_poll_posix.h +10 -2
- data/src/core/lib/iomgr/ev_posix.cc +288 -0
- data/src/core/lib/iomgr/ev_posix.h +75 -67
- data/src/core/lib/iomgr/{ev_windows.c → ev_windows.cc} +2 -2
- data/src/core/lib/iomgr/exec_ctx.cc +177 -0
- data/src/core/lib/iomgr/exec_ctx.h +35 -13
- data/src/core/lib/iomgr/{executor.c → executor.cc} +34 -35
- data/src/core/lib/iomgr/executor.h +12 -4
- data/src/core/lib/iomgr/{fork_posix.c → fork_posix.cc} +0 -0
- data/src/core/lib/iomgr/{fork_windows.c → fork_windows.cc} +0 -0
- data/src/core/lib/iomgr/gethostname.h +9 -1
- data/src/core/lib/iomgr/{gethostname_fallback.c → gethostname_fallback.cc} +2 -1
- data/src/core/lib/iomgr/{gethostname_host_name_max.c → gethostname_host_name_max.cc} +4 -3
- data/src/core/lib/iomgr/{gethostname_sysconf.c → gethostname_sysconf.cc} +3 -2
- data/src/core/lib/iomgr/{iocp_windows.c → iocp_windows.cc} +23 -25
- data/src/core/lib/iomgr/iocp_windows.h +17 -3
- data/src/core/lib/iomgr/{iomgr.c → iomgr.cc} +25 -19
- data/src/core/lib/iomgr/iomgr.h +11 -3
- data/src/core/lib/iomgr/iomgr_internal.h +13 -5
- data/src/core/lib/iomgr/{iomgr_posix.c → iomgr_posix.cc} +0 -1
- data/src/core/lib/iomgr/{iomgr_uv.c → iomgr_uv.cc} +1 -1
- data/src/core/lib/iomgr/iomgr_uv.h +8 -0
- data/src/core/lib/iomgr/{iomgr_windows.c → iomgr_windows.cc} +0 -0
- data/src/core/lib/iomgr/{is_epollexclusive_available.c → is_epollexclusive_available.cc} +1 -1
- data/src/core/lib/iomgr/is_epollexclusive_available.h +8 -0
- data/src/core/lib/iomgr/{load_file.c → load_file.cc} +12 -12
- data/src/core/lib/iomgr/load_file.h +2 -2
- data/src/core/lib/iomgr/{lockfree_event.c → lockfree_event.cc} +76 -68
- data/src/core/lib/iomgr/lockfree_event.h +30 -11
- data/src/core/lib/iomgr/{network_status_tracker.c → network_status_tracker.cc} +3 -2
- data/src/core/lib/iomgr/network_status_tracker.h +2 -2
- data/src/core/lib/iomgr/{polling_entity.c → polling_entity.cc} +18 -18
- data/src/core/lib/iomgr/polling_entity.h +21 -13
- data/src/core/lib/iomgr/pollset.h +17 -11
- data/src/core/lib/iomgr/pollset_set.h +23 -15
- data/src/core/lib/iomgr/{pollset_set_uv.c → pollset_set_uv.cc} +0 -0
- data/src/core/lib/iomgr/{pollset_set_windows.c → pollset_set_windows.cc} +0 -0
- data/src/core/lib/iomgr/{pollset_uv.c → pollset_uv.cc} +31 -29
- data/src/core/lib/iomgr/pollset_uv.h +8 -0
- data/src/core/lib/iomgr/{pollset_windows.c → pollset_windows.cc} +24 -24
- data/src/core/lib/iomgr/pollset_windows.h +17 -4
- data/src/core/lib/iomgr/port.h +10 -0
- data/src/core/lib/iomgr/resolve_address.h +18 -10
- data/src/core/lib/iomgr/{resolve_address_posix.c → resolve_address_posix.cc} +40 -40
- data/src/core/lib/iomgr/{resolve_address_uv.c → resolve_address_uv.cc} +61 -56
- data/src/core/lib/iomgr/{resolve_address_windows.c → resolve_address_windows.cc} +36 -34
- data/src/core/lib/iomgr/{resource_quota.c → resource_quota.cc} +209 -180
- data/src/core/lib/iomgr/resource_quota.h +45 -37
- data/src/core/lib/iomgr/{sockaddr_utils.c → sockaddr_utils.cc} +61 -61
- data/src/core/lib/iomgr/sockaddr_utils.h +23 -15
- data/src/core/lib/iomgr/sockaddr_windows.h +6 -0
- data/src/core/lib/iomgr/{socket_factory_posix.c → socket_factory_posix.cc} +20 -20
- data/src/core/lib/iomgr/socket_factory_posix.h +15 -15
- data/src/core/lib/iomgr/{socket_mutator.c → socket_mutator.cc} +18 -18
- data/src/core/lib/iomgr/socket_mutator.h +11 -11
- data/src/core/lib/iomgr/socket_utils.h +9 -1
- data/src/core/lib/iomgr/{socket_utils_common_posix.c → socket_utils_common_posix.cc} +28 -28
- data/src/core/lib/iomgr/{socket_utils_linux.c → socket_utils_linux.cc} +3 -3
- data/src/core/lib/iomgr/{socket_utils_posix.c → socket_utils_posix.cc} +3 -3
- data/src/core/lib/iomgr/socket_utils_posix.h +26 -18
- data/src/core/lib/iomgr/{socket_utils_uv.c → socket_utils_uv.cc} +1 -1
- data/src/core/lib/iomgr/{socket_utils_windows.c → socket_utils_windows.cc} +2 -2
- data/src/core/lib/iomgr/{socket_windows.c → socket_windows.cc} +18 -18
- data/src/core/lib/iomgr/socket_windows.h +26 -13
- data/src/core/lib/iomgr/tcp_client.h +14 -6
- data/src/core/lib/iomgr/{tcp_client_posix.c → tcp_client_posix.cc} +69 -70
- data/src/core/lib/iomgr/tcp_client_posix.h +11 -3
- data/src/core/lib/iomgr/{tcp_client_uv.c → tcp_client_uv.cc} +47 -48
- data/src/core/lib/iomgr/{tcp_client_windows.c → tcp_client_windows.cc} +46 -44
- data/src/core/lib/iomgr/{tcp_posix.c → tcp_posix.cc} +198 -175
- data/src/core/lib/iomgr/tcp_posix.h +15 -7
- data/src/core/lib/iomgr/tcp_server.h +31 -23
- data/src/core/lib/iomgr/{tcp_server_posix.c → tcp_server_posix.cc} +78 -77
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +27 -19
- data/src/core/lib/iomgr/{tcp_server_utils_posix_common.c → tcp_server_utils_posix_common.cc} +27 -27
- data/src/core/lib/iomgr/{tcp_server_utils_posix_ifaddrs.c → tcp_server_utils_posix_ifaddrs.cc} +25 -25
- data/src/core/lib/iomgr/{tcp_server_utils_posix_noifaddrs.c → tcp_server_utils_posix_noifaddrs.cc} +2 -2
- data/src/core/lib/iomgr/{tcp_server_uv.c → tcp_server_uv.cc} +133 -105
- data/src/core/lib/iomgr/{tcp_server_windows.c → tcp_server_windows.cc} +81 -77
- data/src/core/lib/iomgr/tcp_uv.cc +420 -0
- data/src/core/lib/iomgr/tcp_uv.h +18 -4
- data/src/core/lib/iomgr/{tcp_windows.c → tcp_windows.cc} +90 -79
- data/src/core/lib/iomgr/tcp_windows.h +17 -4
- data/src/core/lib/iomgr/{time_averaged_stats.c → time_averaged_stats.cc} +0 -0
- data/src/core/lib/iomgr/time_averaged_stats.h +8 -0
- data/src/core/lib/iomgr/timer.h +16 -9
- data/src/core/lib/iomgr/{timer_generic.c → timer_generic.cc} +130 -171
- data/src/core/lib/iomgr/timer_generic.h +4 -4
- data/src/core/lib/iomgr/{timer_heap.c → timer_heap.cc} +20 -21
- data/src/core/lib/iomgr/timer_heap.h +16 -8
- data/src/core/lib/iomgr/{timer_manager.c → timer_manager.cc} +54 -52
- data/src/core/lib/iomgr/timer_manager.h +8 -0
- data/src/core/lib/iomgr/{timer_uv.c → timer_uv.cc} +22 -24
- data/src/core/lib/iomgr/timer_uv.h +2 -2
- data/src/core/lib/iomgr/{udp_server.c → udp_server.cc} +75 -75
- data/src/core/lib/iomgr/udp_server.h +25 -17
- data/src/core/lib/iomgr/{unix_sockets_posix.c → unix_sockets_posix.cc} +22 -21
- data/src/core/lib/iomgr/unix_sockets_posix.h +14 -6
- data/src/core/lib/iomgr/{unix_sockets_posix_noop.c → unix_sockets_posix_noop.cc} +5 -5
- data/src/core/lib/iomgr/{wakeup_fd_cv.c → wakeup_fd_cv.cc} +2 -2
- data/src/core/lib/iomgr/wakeup_fd_cv.h +10 -0
- data/src/core/lib/iomgr/{wakeup_fd_eventfd.c → wakeup_fd_eventfd.cc} +0 -0
- data/src/core/lib/iomgr/{wakeup_fd_nospecial.c → wakeup_fd_nospecial.cc} +0 -0
- data/src/core/lib/iomgr/{wakeup_fd_pipe.c → wakeup_fd_pipe.cc} +1 -0
- data/src/core/lib/iomgr/wakeup_fd_pipe.h +9 -1
- data/src/core/lib/iomgr/{wakeup_fd_posix.c → wakeup_fd_posix.cc} +6 -7
- data/src/core/lib/iomgr/wakeup_fd_posix.h +8 -0
- data/src/core/lib/json/{json.c → json.cc} +0 -0
- data/src/core/lib/json/json.h +8 -0
- data/src/core/lib/json/{json_reader.c → json_reader.cc} +18 -18
- data/src/core/lib/json/json_reader.h +26 -18
- data/src/core/lib/json/{json_string.c → json_string.cc} +57 -57
- data/src/core/lib/json/{json_writer.c → json_writer.cc} +20 -20
- data/src/core/lib/json/json_writer.h +23 -15
- data/src/core/lib/profiling/{basic_timers.c → basic_timers.cc} +34 -34
- data/src/core/lib/profiling/{stap_timers.c → stap_timers.cc} +5 -5
- data/src/core/lib/profiling/timers.h +6 -6
- data/src/core/lib/security/context/{security_context.c → security_context.cc} +98 -95
- data/src/core/lib/security/context/security_context.h +27 -29
- data/src/core/lib/security/credentials/composite/{composite_credentials.c → composite_credentials.cc} +79 -73
- data/src/core/lib/security/credentials/composite/composite_credentials.h +17 -9
- data/src/core/lib/security/credentials/{credentials.c → credentials.cc} +97 -92
- data/src/core/lib/security/credentials/credentials.h +83 -75
- data/src/core/lib/security/credentials/{credentials_metadata.c → credentials_metadata.cc} +7 -6
- data/src/core/lib/security/credentials/fake/{fake_credentials.c → fake_credentials.cc} +39 -36
- data/src/core/lib/security/credentials/fake/fake_credentials.h +13 -5
- data/src/core/lib/security/credentials/google_default/{credentials_generic.c → credentials_generic.cc} +5 -5
- data/src/core/lib/security/credentials/google_default/{google_default_credentials.c → google_default_credentials.cc} +55 -55
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +9 -1
- data/src/core/lib/security/credentials/iam/{iam_credentials.c → iam_credentials.cc} +19 -18
- data/src/core/lib/security/credentials/jwt/{json_token.c → json_token.cc} +80 -75
- data/src/core/lib/security/credentials/jwt/json_token.h +23 -15
- data/src/core/lib/security/credentials/jwt/{jwt_credentials.c → jwt_credentials.cc} +45 -41
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -3
- data/src/core/lib/security/credentials/jwt/{jwt_verifier.c → jwt_verifier.cc} +262 -252
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +38 -30
- data/src/core/lib/security/credentials/oauth2/{oauth2_credentials.c → oauth2_credentials.cc} +138 -141
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +30 -22
- data/src/core/lib/security/credentials/plugin/{plugin_credentials.c → plugin_credentials.cc} +52 -53
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +7 -7
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +344 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +27 -0
- data/src/core/lib/security/transport/auth_filters.h +16 -0
- data/src/core/lib/security/transport/{client_auth_filter.c → client_auth_filter.cc} +127 -115
- data/src/core/lib/security/transport/{lb_targets_info.c → lb_targets_info.cc} +16 -13
- data/src/core/lib/security/transport/lb_targets_info.h +11 -3
- data/src/core/lib/security/transport/{secure_endpoint.c → secure_endpoint.cc} +84 -76
- data/src/core/lib/security/transport/secure_endpoint.h +13 -5
- data/src/core/lib/security/transport/security_connector.cc +1121 -0
- data/src/core/lib/security/transport/security_connector.h +97 -79
- data/src/core/lib/security/transport/{security_handshaker.c → security_handshaker.cc} +139 -132
- data/src/core/lib/security/transport/security_handshaker.h +11 -3
- data/src/core/lib/security/transport/{server_auth_filter.c → server_auth_filter.cc} +68 -68
- data/src/core/lib/security/transport/{tsi_error.c → tsi_error.cc} +1 -1
- data/src/core/lib/security/transport/tsi_error.h +9 -1
- data/src/core/lib/security/util/{json_util.c → json_util.cc} +11 -11
- data/src/core/lib/security/util/json_util.h +12 -4
- data/src/core/lib/slice/{b64.c → b64.cc} +15 -15
- data/src/core/lib/slice/b64.h +12 -4
- data/src/core/lib/slice/{percent_encoding.c → percent_encoding.cc} +15 -15
- data/src/core/lib/slice/percent_encoding.h +11 -3
- data/src/core/lib/slice/{slice.c → slice.cc} +64 -64
- data/src/core/lib/slice/{slice_buffer.c → slice_buffer.cc} +38 -38
- data/src/core/lib/slice/{slice_hash_table.c → slice_hash_table.cc} +7 -7
- data/src/core/lib/slice/slice_hash_table.h +19 -11
- data/src/core/lib/slice/{slice_intern.c → slice_intern.cc} +35 -34
- data/src/core/lib/slice/slice_internal.h +17 -6
- data/src/core/lib/slice/{slice_string_helpers.c → slice_string_helpers.cc} +9 -9
- data/src/core/lib/slice/slice_string_helpers.h +3 -3
- data/src/core/lib/support/abstract.h +29 -0
- data/src/core/lib/support/{alloc.c → alloc.cc} +22 -22
- data/src/core/lib/support/{arena.c → arena.cc} +12 -12
- data/src/core/lib/support/arena.h +11 -3
- data/src/core/lib/support/{atm.c → atm.cc} +1 -1
- data/src/core/lib/support/{avl.c → avl.cc} +71 -70
- data/src/core/lib/support/{cmdline.c → cmdline.cc} +62 -62
- data/src/core/lib/support/{cpu_iphone.c → cpu_iphone.cc} +2 -0
- data/src/core/lib/support/{cpu_linux.c → cpu_linux.cc} +10 -0
- data/src/core/lib/support/{cpu_posix.c → cpu_posix.cc} +27 -4
- data/src/core/lib/support/{cpu_windows.c → cpu_windows.cc} +1 -0
- data/src/core/lib/support/env.h +3 -3
- data/src/core/lib/support/{env_linux.c → env_linux.cc} +11 -11
- data/src/core/lib/support/{env_posix.c → env_posix.cc} +4 -4
- data/src/core/lib/support/{env_windows.c → env_windows.cc} +5 -5
- data/src/core/lib/support/{fork.c → fork.cc} +2 -2
- data/src/core/lib/support/{histogram.c → histogram.cc} +25 -26
- data/src/core/lib/support/{host_port.c → host_port.cc} +16 -16
- data/src/core/lib/support/{log.c → log.cc} +8 -8
- data/src/core/lib/support/{log_android.c → log_android.cc} +7 -7
- data/src/core/lib/support/{log_linux.c → log_linux.cc} +8 -8
- data/src/core/lib/support/{log_posix.c → log_posix.cc} +9 -10
- data/src/core/lib/support/{log_windows.c → log_windows.cc} +7 -7
- data/src/core/lib/support/manual_constructor.h +211 -0
- data/src/core/lib/support/memory.h +41 -0
- data/src/core/lib/support/mpscq.cc +114 -0
- data/src/core/lib/support/mpscq.h +45 -7
- data/src/core/lib/support/{murmur_hash.c → murmur_hash.cc} +9 -12
- data/src/core/lib/support/murmur_hash.h +9 -1
- data/src/core/lib/support/spinlock.h +8 -1
- data/src/core/lib/support/{string.c → string.cc} +56 -55
- data/src/core/lib/support/string.h +21 -21
- data/src/core/lib/support/{string_posix.c → string_posix.cc} +5 -4
- data/src/core/lib/support/{string_util_windows.c → string_util_windows.cc} +9 -6
- data/src/core/lib/support/{string_windows.c → string_windows.cc} +3 -2
- data/src/core/lib/support/string_windows.h +8 -0
- data/src/core/lib/support/{subprocess_posix.c → subprocess_posix.cc} +13 -13
- data/src/core/lib/support/{subprocess_windows.c → subprocess_windows.cc} +9 -9
- data/src/core/lib/support/{sync.c → sync.cc} +22 -22
- data/src/core/lib/support/{sync_posix.c → sync_posix.cc} +6 -2
- data/src/core/lib/support/{sync_windows.c → sync_windows.cc} +14 -14
- data/src/core/lib/support/{thd.c → thd.cc} +0 -0
- data/src/core/lib/support/{thd_posix.c → thd_posix.cc} +10 -10
- data/src/core/lib/support/{thd_windows.c → thd_windows.cc} +10 -10
- data/src/core/lib/support/{time.c → time.cc} +0 -0
- data/src/core/lib/support/{time_posix.c → time_posix.cc} +5 -6
- data/src/core/lib/support/{time_precise.c → time_precise.cc} +6 -4
- data/src/core/lib/support/time_precise.h +9 -1
- data/src/core/lib/support/{time_windows.c → time_windows.cc} +2 -3
- data/src/core/lib/support/{tls_pthread.c → tls_pthread.cc} +2 -2
- data/src/core/lib/support/tmpfile.h +1 -1
- data/src/core/lib/support/{tmpfile_msys.c → tmpfile_msys.cc} +2 -2
- data/src/core/lib/support/{tmpfile_posix.c → tmpfile_posix.cc} +7 -7
- data/src/core/lib/support/{tmpfile_windows.c → tmpfile_windows.cc} +2 -2
- data/src/core/lib/support/{wrap_memcpy.c → wrap_memcpy.cc} +4 -2
- data/src/core/lib/surface/{alarm.c → alarm.cc} +32 -31
- data/src/core/lib/surface/alarm_internal.h +10 -2
- data/src/core/lib/surface/{api_trace.c → api_trace.cc} +1 -1
- data/src/core/lib/surface/api_trace.h +2 -2
- data/src/core/lib/surface/{byte_buffer.c → byte_buffer.cc} +13 -13
- data/src/core/lib/surface/{byte_buffer_reader.c → byte_buffer_reader.cc} +9 -9
- data/src/core/lib/surface/{call.c → call.cc} +379 -372
- data/src/core/lib/surface/call.h +37 -38
- data/src/core/lib/surface/{call_details.c → call_details.cc} +0 -0
- data/src/core/lib/surface/{call_log_batch.c → call_log_batch.cc} +13 -11
- data/src/core/lib/surface/call_test_only.h +5 -5
- data/src/core/lib/surface/{channel.c → channel.cc} +94 -95
- data/src/core/lib/surface/channel.h +29 -21
- data/src/core/lib/surface/{channel_init.c → channel_init.cc} +13 -13
- data/src/core/lib/surface/channel_init.h +6 -6
- data/src/core/lib/surface/{channel_ping.c → channel_ping.cc} +12 -12
- data/src/core/lib/surface/{channel_stack_type.c → channel_stack_type.cc} +1 -1
- data/src/core/lib/surface/channel_stack_type.h +9 -1
- data/src/core/lib/surface/{completion_queue.c → completion_queue.cc} +416 -379
- data/src/core/lib/surface/completion_queue.h +29 -29
- data/src/core/lib/surface/{completion_queue_factory.c → completion_queue_factory.cc} +1 -1
- data/src/core/lib/surface/completion_queue_factory.h +8 -0
- data/src/core/lib/surface/{event_string.c → event_string.cc} +9 -9
- data/src/core/lib/surface/event_string.h +9 -1
- data/src/core/lib/surface/{init.c → init.cc} +16 -39
- data/src/core/lib/surface/init.h +8 -0
- data/src/core/lib/surface/{init_secure.c → init_secure.cc} +12 -25
- data/src/core/lib/surface/lame_client.cc +38 -40
- data/src/core/lib/surface/lame_client.h +8 -0
- data/src/core/lib/surface/{metadata_array.c → metadata_array.cc} +0 -0
- data/src/core/lib/surface/{server.c → server.cc} +340 -404
- data/src/core/lib/surface/server.h +22 -14
- data/src/core/lib/surface/{validate_metadata.c → validate_metadata.cc} +10 -9
- data/src/core/lib/surface/validate_metadata.h +10 -2
- data/src/core/lib/surface/{version.c → version.cc} +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +84 -0
- data/src/core/lib/transport/bdp_estimator.h +67 -42
- data/src/core/lib/transport/{byte_stream.c → byte_stream.cc} +51 -51
- data/src/core/lib/transport/byte_stream.h +41 -33
- data/src/core/lib/transport/{connectivity_state.c → connectivity_state.cc} +36 -40
- data/src/core/lib/transport/connectivity_state.h +29 -21
- data/src/core/lib/transport/{error_utils.c → error_utils.cc} +26 -22
- data/src/core/lib/transport/error_utils.h +18 -6
- data/src/core/lib/transport/{metadata.c → metadata.cc} +92 -88
- data/src/core/lib/transport/metadata.h +22 -20
- data/src/core/lib/transport/{metadata_batch.c → metadata_batch.cc} +78 -79
- data/src/core/lib/transport/metadata_batch.h +46 -45
- data/src/core/lib/transport/pid_controller.cc +48 -0
- data/src/core/lib/transport/pid_controller.h +84 -32
- data/src/core/lib/transport/{service_config.c → service_config.cc} +66 -48
- data/src/core/lib/transport/service_config.h +11 -2
- data/src/core/lib/transport/{static_metadata.c → static_metadata.cc} +2 -2
- data/src/core/lib/transport/static_metadata.h +30 -23
- data/src/core/lib/transport/{status_conversion.c → status_conversion.cc} +4 -3
- data/src/core/lib/transport/status_conversion.h +12 -2
- data/src/core/lib/transport/{timeout_encoding.c → timeout_encoding.cc} +28 -61
- data/src/core/lib/transport/timeout_encoding.h +11 -2
- data/src/core/lib/transport/{transport.c → transport.cc} +79 -79
- data/src/core/lib/transport/transport.h +78 -80
- data/src/core/lib/transport/transport_impl.h +27 -19
- data/src/core/lib/transport/{transport_op_string.c → transport_op_string.cc} +32 -30
- data/src/core/plugin_registry/{grpc_plugin_registry.c → grpc_plugin_registry.cc} +34 -38
- data/src/core/tsi/{fake_transport_security.c → fake_transport_security.cc} +141 -132
- data/src/core/tsi/fake_transport_security.h +5 -5
- data/src/core/tsi/{gts_transport_security.c → gts_transport_security.cc} +4 -4
- data/src/core/tsi/gts_transport_security.h +11 -3
- data/src/core/tsi/{ssl_transport_security.c → ssl_transport_security.cc} +309 -300
- data/src/core/tsi/ssl_transport_security.h +25 -25
- data/src/core/tsi/ssl_types.h +8 -0
- data/src/core/tsi/{transport_security.c → transport_security.cc} +94 -87
- data/src/core/tsi/transport_security.h +55 -55
- data/src/core/tsi/{transport_security_adapter.c → transport_security_adapter.cc} +58 -55
- data/src/core/tsi/transport_security_adapter.h +2 -2
- data/src/core/tsi/{transport_security_grpc.c → transport_security_grpc.cc} +21 -21
- data/src/core/tsi/transport_security_grpc.h +19 -19
- data/src/core/tsi/transport_security_interface.h +41 -41
- data/src/ruby/ext/grpc/extconf.rb +4 -2
- data/src/ruby/ext/grpc/rb_byte_buffer.c +5 -5
- data/src/ruby/ext/grpc/rb_byte_buffer.h +2 -2
- data/src/ruby/ext/grpc/rb_call.c +41 -42
- data/src/ruby/ext/grpc/rb_call.h +6 -6
- data/src/ruby/ext/grpc/rb_call_credentials.c +30 -30
- data/src/ruby/ext/grpc/rb_channel.c +87 -87
- data/src/ruby/ext/grpc/rb_channel_credentials.c +23 -23
- data/src/ruby/ext/grpc/rb_completion_queue.c +11 -11
- data/src/ruby/ext/grpc/rb_completion_queue.h +3 -3
- data/src/ruby/ext/grpc/rb_compression_options.c +20 -20
- data/src/ruby/ext/grpc/rb_event_thread.c +14 -14
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +8 -8
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -58
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +242 -306
- data/src/ruby/ext/grpc/rb_server.c +23 -23
- data/src/ruby/ext/grpc/rb_server_credentials.c +13 -13
- data/src/ruby/lib/grpc/generic/rpc_server.rb +25 -12
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +14 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +29 -0
- data/third_party/cares/config_freebsd/ares_config.h +502 -0
- data/third_party/cares/config_openbsd/ares_config.h +502 -0
- metadata +302 -328
- data/src/core/ext/census/aggregation.h +0 -51
- data/src/core/ext/census/base_resources.c +0 -56
- data/src/core/ext/census/base_resources.h +0 -24
- data/src/core/ext/census/census_interface.h +0 -61
- data/src/core/ext/census/census_rpc_stats.h +0 -86
- data/src/core/ext/census/context.c +0 -496
- data/src/core/ext/census/gen/census.pb.c +0 -161
- data/src/core/ext/census/gen/census.pb.h +0 -280
- data/src/core/ext/census/gen/trace_context.pb.c +0 -39
- data/src/core/ext/census/gen/trace_context.pb.h +0 -78
- data/src/core/ext/census/grpc_filter.c +0 -196
- data/src/core/ext/census/grpc_plugin.c +0 -70
- data/src/core/ext/census/initialize.c +0 -51
- data/src/core/ext/census/intrusive_hash_map.c +0 -305
- data/src/core/ext/census/intrusive_hash_map.h +0 -152
- data/src/core/ext/census/intrusive_hash_map_internal.h +0 -48
- data/src/core/ext/census/mlog.c +0 -586
- data/src/core/ext/census/mlog.h +0 -80
- data/src/core/ext/census/operation.c +0 -48
- data/src/core/ext/census/placeholders.c +0 -49
- data/src/core/ext/census/resource.c +0 -303
- data/src/core/ext/census/resource.h +0 -48
- data/src/core/ext/census/rpc_metric_id.h +0 -36
- data/src/core/ext/census/trace_context.c +0 -71
- data/src/core/ext/census/trace_context.h +0 -56
- data/src/core/ext/census/trace_label.h +0 -46
- data/src/core/ext/census/trace_propagation.h +0 -48
- data/src/core/ext/census/trace_status.h +0 -30
- data/src/core/ext/census/trace_string.h +0 -35
- data/src/core/ext/census/tracing.c +0 -55
- data/src/core/ext/census/tracing.h +0 -109
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +0 -714
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +0 -924
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c +0 -60
- data/src/core/ext/transport/chttp2/transport/flow_control.c +0 -502
- data/src/core/ext/transport/chttp2/transport/writing.c +0 -534
- data/src/core/lib/debug/trace.c +0 -146
- data/src/core/lib/iomgr/closure.c +0 -219
- data/src/core/lib/iomgr/ev_epollex_linux.c +0 -1461
- data/src/core/lib/iomgr/ev_posix.c +0 -266
- data/src/core/lib/iomgr/exec_ctx.c +0 -113
- data/src/core/lib/iomgr/tcp_uv.c +0 -381
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +0 -194
- data/src/core/lib/security/transport/security_connector.c +0 -914
- data/src/core/lib/support/backoff.c +0 -72
- data/src/core/lib/support/backoff.h +0 -56
- data/src/core/lib/support/mpscq.c +0 -79
- data/src/core/lib/support/stack_lockfree.c +0 -137
- data/src/core/lib/support/stack_lockfree.h +0 -38
- data/src/core/lib/transport/bdp_estimator.c +0 -110
- data/src/core/lib/transport/pid_controller.c +0 -63
@@ -23,10 +23,18 @@
|
|
23
23
|
|
24
24
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
25
25
|
|
26
|
+
#ifdef __cplusplus
|
27
|
+
extern "C" {
|
28
|
+
#endif
|
29
|
+
|
26
30
|
/// Adds a port to \a server. Sets \a port_num to the port number.
|
27
31
|
/// Takes ownership of \a args.
|
28
|
-
grpc_error
|
29
|
-
grpc_server
|
30
|
-
grpc_channel_args
|
32
|
+
grpc_error* grpc_chttp2_server_add_port(grpc_exec_ctx* exec_ctx,
|
33
|
+
grpc_server* server, const char* addr,
|
34
|
+
grpc_channel_args* args, int* port_num);
|
35
|
+
|
36
|
+
#ifdef __cplusplus
|
37
|
+
}
|
38
|
+
#endif
|
31
39
|
|
32
40
|
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */
|
@@ -25,16 +25,16 @@
|
|
25
25
|
#include "src/core/lib/surface/api_trace.h"
|
26
26
|
#include "src/core/lib/surface/server.h"
|
27
27
|
|
28
|
-
int grpc_server_add_insecure_http2_port(grpc_server
|
28
|
+
int grpc_server_add_insecure_http2_port(grpc_server* server, const char* addr) {
|
29
29
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
30
30
|
int port_num = 0;
|
31
31
|
GRPC_API_TRACE("grpc_server_add_insecure_http2_port(server=%p, addr=%s)", 2,
|
32
32
|
(server, addr));
|
33
|
-
grpc_error
|
33
|
+
grpc_error* err = grpc_chttp2_server_add_port(
|
34
34
|
&exec_ctx, server, addr,
|
35
35
|
grpc_channel_args_copy(grpc_server_get_channel_args(server)), &port_num);
|
36
36
|
if (err != GRPC_ERROR_NONE) {
|
37
|
-
const char
|
37
|
+
const char* msg = grpc_error_string(err);
|
38
38
|
gpr_log(GPR_ERROR, "%s", msg);
|
39
39
|
|
40
40
|
GRPC_ERROR_UNREF(err);
|
data/src/core/ext/transport/chttp2/server/insecure/{server_chttp2_posix.c → server_chttp2_posix.cc}
RENAMED
@@ -34,25 +34,25 @@
|
|
34
34
|
#include "src/core/lib/surface/completion_queue.h"
|
35
35
|
#include "src/core/lib/surface/server.h"
|
36
36
|
|
37
|
-
void grpc_server_add_insecure_channel_from_fd(grpc_server
|
38
|
-
void
|
39
|
-
GPR_ASSERT(reserved ==
|
37
|
+
void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
|
38
|
+
void* reserved, int fd) {
|
39
|
+
GPR_ASSERT(reserved == nullptr);
|
40
40
|
|
41
41
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
42
|
-
char
|
42
|
+
char* name;
|
43
43
|
gpr_asprintf(&name, "fd:%d", fd);
|
44
44
|
|
45
|
-
grpc_endpoint
|
45
|
+
grpc_endpoint* server_endpoint =
|
46
46
|
grpc_tcp_create(&exec_ctx, grpc_fd_create(fd, name),
|
47
47
|
grpc_server_get_channel_args(server), name);
|
48
48
|
|
49
49
|
gpr_free(name);
|
50
50
|
|
51
|
-
const grpc_channel_args
|
52
|
-
grpc_transport
|
51
|
+
const grpc_channel_args* server_args = grpc_server_get_channel_args(server);
|
52
|
+
grpc_transport* transport = grpc_create_chttp2_transport(
|
53
53
|
&exec_ctx, server_args, server_endpoint, false /* is_client */);
|
54
54
|
|
55
|
-
grpc_pollset
|
55
|
+
grpc_pollset** pollsets;
|
56
56
|
size_t num_pollsets = 0;
|
57
57
|
grpc_server_get_pollsets(server, &pollsets, &num_pollsets);
|
58
58
|
|
@@ -60,15 +60,16 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
|
|
60
60
|
grpc_endpoint_add_to_pollset(&exec_ctx, server_endpoint, pollsets[i]);
|
61
61
|
}
|
62
62
|
|
63
|
-
grpc_server_setup_transport(&exec_ctx, server, transport,
|
64
|
-
|
63
|
+
grpc_server_setup_transport(&exec_ctx, server, transport, nullptr,
|
64
|
+
server_args);
|
65
|
+
grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr, nullptr);
|
65
66
|
grpc_exec_ctx_finish(&exec_ctx);
|
66
67
|
}
|
67
68
|
|
68
69
|
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
|
69
70
|
|
70
|
-
void grpc_server_add_insecure_channel_from_fd(grpc_server
|
71
|
-
void
|
71
|
+
void grpc_server_add_insecure_channel_from_fd(grpc_server* server,
|
72
|
+
void* reserved, int fd) {
|
72
73
|
GPR_ASSERT(0);
|
73
74
|
}
|
74
75
|
|
data/src/core/ext/transport/chttp2/server/secure/{server_secure_chttp2.c → server_secure_chttp2.cc}
RENAMED
@@ -34,26 +34,28 @@
|
|
34
34
|
#include "src/core/lib/surface/api_trace.h"
|
35
35
|
#include "src/core/lib/surface/server.h"
|
36
36
|
|
37
|
-
int grpc_server_add_secure_http2_port(grpc_server
|
38
|
-
grpc_server_credentials
|
37
|
+
int grpc_server_add_secure_http2_port(grpc_server* server, const char* addr,
|
38
|
+
grpc_server_credentials* creds) {
|
39
39
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
|
40
|
-
grpc_error
|
41
|
-
grpc_server_security_connector
|
40
|
+
grpc_error* err = GRPC_ERROR_NONE;
|
41
|
+
grpc_server_security_connector* sc = nullptr;
|
42
42
|
int port_num = 0;
|
43
|
+
grpc_security_status status;
|
44
|
+
grpc_channel_args* args = nullptr;
|
43
45
|
GRPC_API_TRACE(
|
44
46
|
"grpc_server_add_secure_http2_port("
|
45
47
|
"server=%p, addr=%s, creds=%p)",
|
46
48
|
3, (server, addr, creds));
|
47
49
|
// Create security context.
|
48
|
-
if (creds ==
|
50
|
+
if (creds == nullptr) {
|
49
51
|
err = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
50
52
|
"No credentials specified for secure server port (creds==NULL)");
|
51
53
|
goto done;
|
52
54
|
}
|
53
|
-
|
55
|
+
status =
|
54
56
|
grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
|
55
57
|
if (status != GRPC_SECURITY_OK) {
|
56
|
-
char
|
58
|
+
char* msg;
|
57
59
|
gpr_asprintf(&msg,
|
58
60
|
"Unable to create secure server with credentials of type %s.",
|
59
61
|
creds->type);
|
@@ -66,18 +68,18 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
|
|
66
68
|
grpc_arg args_to_add[2];
|
67
69
|
args_to_add[0] = grpc_server_credentials_to_arg(creds);
|
68
70
|
args_to_add[1] = grpc_security_connector_to_arg(&sc->base);
|
69
|
-
|
71
|
+
args =
|
70
72
|
grpc_channel_args_copy_and_add(grpc_server_get_channel_args(server),
|
71
73
|
args_to_add, GPR_ARRAY_SIZE(args_to_add));
|
72
74
|
// Add server port.
|
73
75
|
err = grpc_chttp2_server_add_port(&exec_ctx, server, addr, args, &port_num);
|
74
76
|
done:
|
75
|
-
if (sc !=
|
77
|
+
if (sc != nullptr) {
|
76
78
|
GRPC_SECURITY_CONNECTOR_UNREF(&exec_ctx, &sc->base, "server");
|
77
79
|
}
|
78
80
|
grpc_exec_ctx_finish(&exec_ctx);
|
79
81
|
if (err != GRPC_ERROR_NONE) {
|
80
|
-
const char
|
82
|
+
const char* msg = grpc_error_string(err);
|
81
83
|
gpr_log(GPR_ERROR, "%s", msg);
|
82
84
|
|
83
85
|
GRPC_ERROR_UNREF(err);
|
@@ -49,7 +49,7 @@ static uint8_t decode_table[] = {
|
|
49
49
|
|
50
50
|
static const uint8_t tail_xtra[4] = {0, 0, 1, 2};
|
51
51
|
|
52
|
-
static bool input_is_valid(uint8_t
|
52
|
+
static bool input_is_valid(uint8_t* input_ptr, size_t length) {
|
53
53
|
size_t i;
|
54
54
|
|
55
55
|
for (i = 0; i < length; ++i) {
|
@@ -75,7 +75,7 @@ static bool input_is_valid(uint8_t *input_ptr, size_t length) {
|
|
75
75
|
#define COMPOSE_OUTPUT_BYTE_2(input_ptr) \
|
76
76
|
(uint8_t)((decode_table[input_ptr[2]] << 6) | decode_table[input_ptr[3]])
|
77
77
|
|
78
|
-
bool grpc_base64_decode_partial(struct grpc_base64_decode_context
|
78
|
+
bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx) {
|
79
79
|
size_t input_tail;
|
80
80
|
|
81
81
|
if (ctx->input_cur > ctx->input_end || ctx->output_cur > ctx->output_end) {
|
@@ -130,7 +130,7 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) {
|
|
130
130
|
return true;
|
131
131
|
}
|
132
132
|
|
133
|
-
grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx
|
133
|
+
grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx* exec_ctx,
|
134
134
|
grpc_slice input) {
|
135
135
|
size_t input_length = GRPC_SLICE_LENGTH(input);
|
136
136
|
size_t output_length = input_length / 4 * 3;
|
@@ -147,7 +147,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
|
|
147
147
|
}
|
148
148
|
|
149
149
|
if (input_length > 0) {
|
150
|
-
uint8_t
|
150
|
+
uint8_t* input_end = GRPC_SLICE_END_PTR(input);
|
151
151
|
if (*(--input_end) == '=') {
|
152
152
|
output_length--;
|
153
153
|
if (*(--input_end) == '=') {
|
@@ -164,7 +164,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
|
|
164
164
|
ctx.contains_tail = false;
|
165
165
|
|
166
166
|
if (!grpc_base64_decode_partial(&ctx)) {
|
167
|
-
char
|
167
|
+
char* s = grpc_slice_to_c_string(input);
|
168
168
|
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
|
169
169
|
gpr_free(s);
|
170
170
|
grpc_slice_unref_internal(exec_ctx, output);
|
@@ -175,7 +175,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
|
|
175
175
|
return output;
|
176
176
|
}
|
177
177
|
|
178
|
-
grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx
|
178
|
+
grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
|
179
179
|
grpc_slice input,
|
180
180
|
size_t output_length) {
|
181
181
|
size_t input_length = GRPC_SLICE_LENGTH(input);
|
@@ -210,7 +210,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
|
|
210
210
|
ctx.contains_tail = true;
|
211
211
|
|
212
212
|
if (!grpc_base64_decode_partial(&ctx)) {
|
213
|
-
char
|
213
|
+
char* s = grpc_slice_to_c_string(input);
|
214
214
|
gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s);
|
215
215
|
gpr_free(s);
|
216
216
|
grpc_slice_unref_internal(exec_ctx, output);
|
@@ -22,12 +22,16 @@
|
|
22
22
|
#include <grpc/slice.h>
|
23
23
|
#include <stdbool.h>
|
24
24
|
|
25
|
+
#ifdef __cplusplus
|
26
|
+
extern "C" {
|
27
|
+
#endif
|
28
|
+
|
25
29
|
struct grpc_base64_decode_context {
|
26
30
|
/* input/output: */
|
27
|
-
uint8_t
|
28
|
-
uint8_t
|
29
|
-
uint8_t
|
30
|
-
uint8_t
|
31
|
+
uint8_t* input_cur;
|
32
|
+
uint8_t* input_end;
|
33
|
+
uint8_t* output_cur;
|
34
|
+
uint8_t* output_end;
|
31
35
|
/* Indicate if the decoder should handle the tail of input data*/
|
32
36
|
bool contains_tail;
|
33
37
|
};
|
@@ -36,17 +40,21 @@ struct grpc_base64_decode_context {
|
|
36
40
|
or output_end is reached. When input_end is reached, (input_end - input_cur)
|
37
41
|
is less than 4. When output_end is reached, (output_end - output_cur) is less
|
38
42
|
than 3. Returns false if decoding is failed. */
|
39
|
-
bool grpc_base64_decode_partial(struct grpc_base64_decode_context
|
43
|
+
bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx);
|
40
44
|
|
41
45
|
/* base64 decode a slice with pad chars. Returns a new slice, does not take
|
42
46
|
ownership of the input. Returns an empty slice if decoding is failed. */
|
43
|
-
grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx
|
47
|
+
grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx* exec_ctx, grpc_slice input);
|
44
48
|
|
45
49
|
/* base64 decode a slice without pad chars, data length is needed. Returns a new
|
46
50
|
slice, does not take ownership of the input. Returns an empty slice if
|
47
51
|
decoding is failed. */
|
48
|
-
grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx
|
52
|
+
grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx* exec_ctx,
|
49
53
|
grpc_slice input,
|
50
54
|
size_t output_length);
|
51
55
|
|
56
|
+
#ifdef __cplusplus
|
57
|
+
}
|
58
|
+
#endif
|
59
|
+
|
52
60
|
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */
|
@@ -52,8 +52,8 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
|
|
52
52
|
size_t tail_case = input_length % 3;
|
53
53
|
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
|
54
54
|
grpc_slice output = GRPC_SLICE_MALLOC(output_length);
|
55
|
-
uint8_t
|
56
|
-
char
|
55
|
+
uint8_t* in = GRPC_SLICE_START_PTR(input);
|
56
|
+
char* out = (char*)GRPC_SLICE_START_PTR(output);
|
57
57
|
size_t i;
|
58
58
|
|
59
59
|
/* encode full triplets */
|
@@ -85,15 +85,15 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
|
|
85
85
|
break;
|
86
86
|
}
|
87
87
|
|
88
|
-
GPR_ASSERT(out == (char
|
88
|
+
GPR_ASSERT(out == (char*)GRPC_SLICE_END_PTR(output));
|
89
89
|
GPR_ASSERT(in == GRPC_SLICE_END_PTR(input));
|
90
90
|
return output;
|
91
91
|
}
|
92
92
|
|
93
93
|
grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
|
94
94
|
size_t nbits;
|
95
|
-
uint8_t
|
96
|
-
uint8_t
|
95
|
+
uint8_t* in;
|
96
|
+
uint8_t* out;
|
97
97
|
grpc_slice output;
|
98
98
|
uint32_t temp = 0;
|
99
99
|
uint32_t temp_length = 0;
|
@@ -136,17 +136,17 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
|
|
136
136
|
typedef struct {
|
137
137
|
uint32_t temp;
|
138
138
|
uint32_t temp_length;
|
139
|
-
uint8_t
|
139
|
+
uint8_t* out;
|
140
140
|
} huff_out;
|
141
141
|
|
142
|
-
static void enc_flush_some(huff_out
|
142
|
+
static void enc_flush_some(huff_out* out) {
|
143
143
|
while (out->temp_length > 8) {
|
144
144
|
out->temp_length -= 8;
|
145
145
|
*out->out++ = (uint8_t)(out->temp >> out->temp_length);
|
146
146
|
}
|
147
147
|
}
|
148
148
|
|
149
|
-
static void enc_add2(huff_out
|
149
|
+
static void enc_add2(huff_out* out, uint8_t a, uint8_t b) {
|
150
150
|
b64_huff_sym sa = huff_alphabet[a];
|
151
151
|
b64_huff_sym sb = huff_alphabet[b];
|
152
152
|
out->temp = (out->temp << (sa.length + sb.length)) |
|
@@ -155,7 +155,7 @@ static void enc_add2(huff_out *out, uint8_t a, uint8_t b) {
|
|
155
155
|
enc_flush_some(out);
|
156
156
|
}
|
157
157
|
|
158
|
-
static void enc_add1(huff_out
|
158
|
+
static void enc_add1(huff_out* out, uint8_t a) {
|
159
159
|
b64_huff_sym sa = huff_alphabet[a];
|
160
160
|
out->temp = (out->temp << sa.length) | sa.bits;
|
161
161
|
out->temp_length += sa.length;
|
@@ -170,8 +170,8 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input) {
|
|
170
170
|
size_t max_output_bits = 11 * output_syms;
|
171
171
|
size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0);
|
172
172
|
grpc_slice output = GRPC_SLICE_MALLOC(max_output_length);
|
173
|
-
uint8_t
|
174
|
-
uint8_t
|
173
|
+
uint8_t* in = GRPC_SLICE_START_PTR(input);
|
174
|
+
uint8_t* start_out = GRPC_SLICE_START_PTR(output);
|
175
175
|
huff_out out;
|
176
176
|
size_t i;
|
177
177
|
|
@@ -21,6 +21,10 @@
|
|
21
21
|
|
22
22
|
#include <grpc/slice.h>
|
23
23
|
|
24
|
+
#ifdef __cplusplus
|
25
|
+
extern "C" {
|
26
|
+
#endif
|
27
|
+
|
24
28
|
/* base64 encode a slice. Returns a new slice, does not take ownership of the
|
25
29
|
input */
|
26
30
|
grpc_slice grpc_chttp2_base64_encode(grpc_slice input);
|
@@ -36,4 +40,8 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input);
|
|
36
40
|
return y; */
|
37
41
|
grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input);
|
38
42
|
|
43
|
+
#ifdef __cplusplus
|
44
|
+
}
|
45
|
+
#endif
|
46
|
+
|
39
47
|
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */
|
@@ -20,13 +20,6 @@
|
|
20
20
|
#include "src/core/lib/debug/trace.h"
|
21
21
|
#include "src/core/lib/transport/metadata.h"
|
22
22
|
|
23
|
-
void grpc_chttp2_plugin_init(void) {
|
24
|
-
grpc_register_tracer(&grpc_http_trace);
|
25
|
-
grpc_register_tracer(&grpc_flowctl_trace);
|
26
|
-
grpc_register_tracer(&grpc_trace_http2_stream_state);
|
27
|
-
#ifndef NDEBUG
|
28
|
-
grpc_register_tracer(&grpc_trace_chttp2_refcount);
|
29
|
-
#endif
|
30
|
-
}
|
23
|
+
extern "C" void grpc_chttp2_plugin_init(void) {}
|
31
24
|
|
32
|
-
void grpc_chttp2_plugin_shutdown(void) {}
|
25
|
+
extern "C" void grpc_chttp2_plugin_shutdown(void) {}
|
@@ -18,6 +18,9 @@
|
|
18
18
|
|
19
19
|
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
|
20
20
|
|
21
|
+
#include <grpc/support/port_platform.h>
|
22
|
+
|
23
|
+
#include <inttypes.h>
|
21
24
|
#include <limits.h>
|
22
25
|
#include <math.h>
|
23
26
|
#include <stdio.h>
|
@@ -51,7 +54,6 @@
|
|
51
54
|
#include "src/core/lib/transport/transport.h"
|
52
55
|
#include "src/core/lib/transport/transport_impl.h"
|
53
56
|
|
54
|
-
#define DEFAULT_WINDOW 65535
|
55
57
|
#define DEFAULT_CONNECTION_WINDOW_TARGET (1024 * 1024)
|
56
58
|
#define MAX_WINDOW 0x7fffffffu
|
57
59
|
#define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024)
|
@@ -88,101 +90,99 @@ static int g_default_max_pings_without_data = DEFAULT_MAX_PINGS_BETWEEN_DATA;
|
|
88
90
|
static int g_default_max_ping_strikes = DEFAULT_MAX_PING_STRIKES;
|
89
91
|
|
90
92
|
#define MAX_CLIENT_STREAM_ID 0x7fffffffu
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
#ifndef NDEBUG
|
95
|
-
grpc_tracer_flag grpc_trace_chttp2_refcount =
|
96
|
-
GRPC_TRACER_INITIALIZER(false, "chttp2_refcount");
|
97
|
-
#endif
|
93
|
+
grpc_core::TraceFlag grpc_http_trace(false, "http");
|
94
|
+
grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false,
|
95
|
+
"chttp2_refcount");
|
98
96
|
|
99
97
|
/* forward declarations of various callbacks that we'll build closures around */
|
100
|
-
static void write_action_begin_locked(grpc_exec_ctx
|
101
|
-
grpc_error
|
102
|
-
static void write_action(grpc_exec_ctx
|
103
|
-
static void write_action_end_locked(grpc_exec_ctx
|
104
|
-
grpc_error
|
98
|
+
static void write_action_begin_locked(grpc_exec_ctx* exec_ctx, void* t,
|
99
|
+
grpc_error* error);
|
100
|
+
static void write_action(grpc_exec_ctx* exec_ctx, void* t, grpc_error* error);
|
101
|
+
static void write_action_end_locked(grpc_exec_ctx* exec_ctx, void* t,
|
102
|
+
grpc_error* error);
|
105
103
|
|
106
|
-
static void read_action_locked(grpc_exec_ctx
|
107
|
-
grpc_error
|
104
|
+
static void read_action_locked(grpc_exec_ctx* exec_ctx, void* t,
|
105
|
+
grpc_error* error);
|
108
106
|
|
109
|
-
static void complete_fetch_locked(grpc_exec_ctx
|
110
|
-
grpc_error
|
107
|
+
static void complete_fetch_locked(grpc_exec_ctx* exec_ctx, void* gs,
|
108
|
+
grpc_error* error);
|
111
109
|
/** Set a transport level setting, and push it to our peer */
|
112
|
-
static void queue_setting_update(grpc_exec_ctx
|
113
|
-
grpc_chttp2_transport
|
110
|
+
static void queue_setting_update(grpc_exec_ctx* exec_ctx,
|
111
|
+
grpc_chttp2_transport* t,
|
114
112
|
grpc_chttp2_setting_id id, uint32_t value);
|
115
113
|
|
116
|
-
static void close_from_api(grpc_exec_ctx
|
117
|
-
grpc_chttp2_stream
|
114
|
+
static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
115
|
+
grpc_chttp2_stream* s, grpc_error* error);
|
118
116
|
|
119
117
|
/** Start new streams that have been created if we can */
|
120
|
-
static void maybe_start_some_streams(grpc_exec_ctx
|
121
|
-
grpc_chttp2_transport
|
118
|
+
static void maybe_start_some_streams(grpc_exec_ctx* exec_ctx,
|
119
|
+
grpc_chttp2_transport* t);
|
122
120
|
|
123
|
-
static void connectivity_state_set(grpc_exec_ctx
|
124
|
-
grpc_chttp2_transport
|
121
|
+
static void connectivity_state_set(grpc_exec_ctx* exec_ctx,
|
122
|
+
grpc_chttp2_transport* t,
|
125
123
|
grpc_connectivity_state state,
|
126
|
-
grpc_error
|
124
|
+
grpc_error* error, const char* reason);
|
127
125
|
|
128
|
-
static void incoming_byte_stream_destroy_locked(grpc_exec_ctx
|
129
|
-
void
|
130
|
-
grpc_error
|
126
|
+
static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
|
127
|
+
void* byte_stream,
|
128
|
+
grpc_error* error_ignored);
|
131
129
|
static void incoming_byte_stream_publish_error(
|
132
|
-
grpc_exec_ctx
|
133
|
-
grpc_error
|
134
|
-
static void incoming_byte_stream_unref(grpc_exec_ctx
|
135
|
-
grpc_chttp2_incoming_byte_stream
|
136
|
-
|
137
|
-
static void benign_reclaimer_locked(grpc_exec_ctx
|
138
|
-
grpc_error
|
139
|
-
static void destructive_reclaimer_locked(grpc_exec_ctx
|
140
|
-
grpc_error
|
141
|
-
|
142
|
-
static void post_benign_reclaimer(grpc_exec_ctx
|
143
|
-
grpc_chttp2_transport
|
144
|
-
static void post_destructive_reclaimer(grpc_exec_ctx
|
145
|
-
grpc_chttp2_transport
|
146
|
-
|
147
|
-
static void close_transport_locked(grpc_exec_ctx
|
148
|
-
grpc_chttp2_transport
|
149
|
-
static void end_all_the_calls(grpc_exec_ctx
|
150
|
-
grpc_error
|
151
|
-
|
152
|
-
static void
|
153
|
-
|
154
|
-
static void
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
130
|
+
grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
|
131
|
+
grpc_error* error);
|
132
|
+
static void incoming_byte_stream_unref(grpc_exec_ctx* exec_ctx,
|
133
|
+
grpc_chttp2_incoming_byte_stream* bs);
|
134
|
+
|
135
|
+
static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* t,
|
136
|
+
grpc_error* error);
|
137
|
+
static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* t,
|
138
|
+
grpc_error* error);
|
139
|
+
|
140
|
+
static void post_benign_reclaimer(grpc_exec_ctx* exec_ctx,
|
141
|
+
grpc_chttp2_transport* t);
|
142
|
+
static void post_destructive_reclaimer(grpc_exec_ctx* exec_ctx,
|
143
|
+
grpc_chttp2_transport* t);
|
144
|
+
|
145
|
+
static void close_transport_locked(grpc_exec_ctx* exec_ctx,
|
146
|
+
grpc_chttp2_transport* t, grpc_error* error);
|
147
|
+
static void end_all_the_calls(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
148
|
+
grpc_error* error);
|
149
|
+
|
150
|
+
static void schedule_bdp_ping_locked(grpc_exec_ctx* exec_ctx,
|
151
|
+
grpc_chttp2_transport* t);
|
152
|
+
static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
153
|
+
grpc_error* error);
|
154
|
+
static void finish_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
155
|
+
grpc_error* error);
|
156
|
+
static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx* exec_ctx,
|
157
|
+
void* tp, grpc_error* error);
|
158
|
+
|
159
|
+
static void cancel_pings(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
160
|
+
grpc_error* error);
|
161
|
+
static void send_ping_locked(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
162
|
+
grpc_closure* on_initiate,
|
163
|
+
grpc_closure* on_complete);
|
164
|
+
static void retry_initiate_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
165
|
+
grpc_error* error);
|
166
166
|
|
167
167
|
/** keepalive-relevant functions */
|
168
|
-
static void init_keepalive_ping_locked(grpc_exec_ctx
|
169
|
-
grpc_error
|
170
|
-
static void start_keepalive_ping_locked(grpc_exec_ctx
|
171
|
-
grpc_error
|
172
|
-
static void finish_keepalive_ping_locked(grpc_exec_ctx
|
173
|
-
grpc_error
|
174
|
-
static void keepalive_watchdog_fired_locked(grpc_exec_ctx
|
175
|
-
grpc_error
|
176
|
-
|
177
|
-
static void reset_byte_stream(grpc_exec_ctx
|
178
|
-
grpc_error
|
168
|
+
static void init_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
169
|
+
grpc_error* error);
|
170
|
+
static void start_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
171
|
+
grpc_error* error);
|
172
|
+
static void finish_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
173
|
+
grpc_error* error);
|
174
|
+
static void keepalive_watchdog_fired_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
175
|
+
grpc_error* error);
|
176
|
+
|
177
|
+
static void reset_byte_stream(grpc_exec_ctx* exec_ctx, void* arg,
|
178
|
+
grpc_error* error);
|
179
179
|
|
180
180
|
/*******************************************************************************
|
181
181
|
* CONSTRUCTION/DESTRUCTION/REFCOUNTING
|
182
182
|
*/
|
183
183
|
|
184
|
-
static void destruct_transport(grpc_exec_ctx
|
185
|
-
grpc_chttp2_transport
|
184
|
+
static void destruct_transport(grpc_exec_ctx* exec_ctx,
|
185
|
+
grpc_chttp2_transport* t) {
|
186
186
|
size_t i;
|
187
187
|
|
188
188
|
grpc_endpoint_destroy(exec_ctx, t->ep);
|
@@ -197,10 +197,12 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx,
|
|
197
197
|
grpc_chttp2_goaway_parser_destroy(&t->goaway_parser);
|
198
198
|
|
199
199
|
for (i = 0; i < STREAM_LIST_COUNT; i++) {
|
200
|
-
GPR_ASSERT(t->lists[i].head ==
|
201
|
-
GPR_ASSERT(t->lists[i].tail ==
|
200
|
+
GPR_ASSERT(t->lists[i].head == nullptr);
|
201
|
+
GPR_ASSERT(t->lists[i].tail == nullptr);
|
202
202
|
}
|
203
203
|
|
204
|
+
GRPC_ERROR_UNREF(t->goaway_error);
|
205
|
+
|
204
206
|
GPR_ASSERT(grpc_chttp2_stream_map_size(&t->stream_map) == 0);
|
205
207
|
|
206
208
|
grpc_chttp2_stream_map_destroy(&t->stream_map);
|
@@ -212,21 +214,24 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx,
|
|
212
214
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Transport destroyed"));
|
213
215
|
|
214
216
|
while (t->write_cb_pool) {
|
215
|
-
grpc_chttp2_write_cb
|
217
|
+
grpc_chttp2_write_cb* next = t->write_cb_pool->next;
|
216
218
|
gpr_free(t->write_cb_pool);
|
217
219
|
t->write_cb_pool = next;
|
218
220
|
}
|
219
221
|
|
222
|
+
t->flow_control.Destroy();
|
223
|
+
|
224
|
+
GRPC_ERROR_UNREF(t->closed_with_error);
|
220
225
|
gpr_free(t->ping_acks);
|
221
226
|
gpr_free(t->peer_string);
|
222
227
|
gpr_free(t);
|
223
228
|
}
|
224
229
|
|
225
230
|
#ifndef NDEBUG
|
226
|
-
void grpc_chttp2_unref_transport(grpc_exec_ctx
|
227
|
-
grpc_chttp2_transport
|
228
|
-
const char
|
229
|
-
if (
|
231
|
+
void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
|
232
|
+
grpc_chttp2_transport* t, const char* reason,
|
233
|
+
const char* file, int line) {
|
234
|
+
if (grpc_trace_chttp2_refcount.enabled()) {
|
230
235
|
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
|
231
236
|
gpr_log(GPR_DEBUG, "chttp2:unref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]",
|
232
237
|
t, val, val - 1, reason, file, line);
|
@@ -235,9 +240,9 @@ void grpc_chttp2_unref_transport(grpc_exec_ctx *exec_ctx,
|
|
235
240
|
destruct_transport(exec_ctx, t);
|
236
241
|
}
|
237
242
|
|
238
|
-
void grpc_chttp2_ref_transport(grpc_chttp2_transport
|
239
|
-
const char
|
240
|
-
if (
|
243
|
+
void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, const char* reason,
|
244
|
+
const char* file, int line) {
|
245
|
+
if (grpc_trace_chttp2_refcount.enabled()) {
|
241
246
|
gpr_atm val = gpr_atm_no_barrier_load(&t->refs.count);
|
242
247
|
gpr_log(GPR_DEBUG, "chttp2: ref:%p %" PRIdPTR "->%" PRIdPTR " %s [%s:%d]",
|
243
248
|
t, val, val + 1, reason, file, line);
|
@@ -245,20 +250,20 @@ void grpc_chttp2_ref_transport(grpc_chttp2_transport *t, const char *reason,
|
|
245
250
|
gpr_ref(&t->refs);
|
246
251
|
}
|
247
252
|
#else
|
248
|
-
void grpc_chttp2_unref_transport(grpc_exec_ctx
|
249
|
-
grpc_chttp2_transport
|
253
|
+
void grpc_chttp2_unref_transport(grpc_exec_ctx* exec_ctx,
|
254
|
+
grpc_chttp2_transport* t) {
|
250
255
|
if (!gpr_unref(&t->refs)) return;
|
251
256
|
destruct_transport(exec_ctx, t);
|
252
257
|
}
|
253
258
|
|
254
|
-
void grpc_chttp2_ref_transport(grpc_chttp2_transport
|
259
|
+
void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { gpr_ref(&t->refs); }
|
255
260
|
#endif
|
256
261
|
|
257
|
-
static const grpc_transport_vtable
|
262
|
+
static const grpc_transport_vtable* get_vtable(void);
|
258
263
|
|
259
|
-
static void init_transport(grpc_exec_ctx
|
260
|
-
const grpc_channel_args
|
261
|
-
grpc_endpoint
|
264
|
+
static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
265
|
+
const grpc_channel_args* channel_args,
|
266
|
+
grpc_endpoint* ep, bool is_client) {
|
262
267
|
size_t i;
|
263
268
|
int j;
|
264
269
|
|
@@ -274,9 +279,6 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
274
279
|
t->endpoint_reading = 1;
|
275
280
|
t->next_stream_id = is_client ? 1 : 2;
|
276
281
|
t->is_client = is_client;
|
277
|
-
t->flow_control.remote_window = DEFAULT_WINDOW;
|
278
|
-
t->flow_control.announced_window = DEFAULT_WINDOW;
|
279
|
-
t->flow_control.t = t;
|
280
282
|
t->deframe_state = is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0;
|
281
283
|
t->is_first_frame = true;
|
282
284
|
grpc_connectivity_state_init(
|
@@ -301,6 +303,9 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
301
303
|
grpc_combiner_scheduler(t->combiner));
|
302
304
|
GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked, finish_bdp_ping_locked, t,
|
303
305
|
grpc_combiner_scheduler(t->combiner));
|
306
|
+
GRPC_CLOSURE_INIT(&t->next_bdp_ping_timer_expired_locked,
|
307
|
+
next_bdp_ping_timer_expired_locked, t,
|
308
|
+
grpc_combiner_scheduler(t->combiner));
|
304
309
|
GRPC_CLOSURE_INIT(&t->init_keepalive_ping_locked, init_keepalive_ping_locked,
|
305
310
|
t, grpc_combiner_scheduler(t->combiner));
|
306
311
|
GRPC_CLOSURE_INIT(&t->start_keepalive_ping_locked,
|
@@ -313,18 +318,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
313
318
|
keepalive_watchdog_fired_locked, t,
|
314
319
|
grpc_combiner_scheduler(t->combiner));
|
315
320
|
|
316
|
-
|
317
|
-
t->flow_control.last_pid_update = gpr_now(GPR_CLOCK_MONOTONIC);
|
318
|
-
grpc_pid_controller_init(
|
319
|
-
&t->flow_control.pid_controller,
|
320
|
-
(grpc_pid_controller_args){.gain_p = 4,
|
321
|
-
.gain_i = 8,
|
322
|
-
.gain_d = 0,
|
323
|
-
.initial_control_value = log2(DEFAULT_WINDOW),
|
324
|
-
.min_control_value = -1,
|
325
|
-
.max_control_value = 25,
|
326
|
-
.integral_range = 10});
|
327
|
-
|
321
|
+
t->goaway_error = GRPC_ERROR_NONE;
|
328
322
|
grpc_chttp2_goaway_parser_init(&t->goaway_parser);
|
329
323
|
grpc_chttp2_hpack_parser_init(exec_ctx, &t->hpack_parser);
|
330
324
|
|
@@ -348,8 +342,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
348
342
|
window -- this should by rights be 0 */
|
349
343
|
t->force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
|
350
344
|
t->sent_local_settings = 0;
|
351
|
-
t->write_buffer_size =
|
352
|
-
t->flow_control.enable_bdp_probe = true;
|
345
|
+
t->write_buffer_size = grpc_core::chttp2::kDefaultWindow;
|
353
346
|
|
354
347
|
if (is_client) {
|
355
348
|
grpc_slice_buffer_add(&t->outbuf, grpc_slice_from_copied_string(
|
@@ -362,48 +355,40 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
362
355
|
queue_setting_update(exec_ctx, t,
|
363
356
|
GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 0);
|
364
357
|
}
|
365
|
-
queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
|
366
|
-
DEFAULT_WINDOW);
|
367
358
|
queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
|
368
359
|
DEFAULT_MAX_HEADER_LIST_SIZE);
|
369
360
|
queue_setting_update(exec_ctx, t,
|
370
361
|
GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA, 1);
|
371
362
|
|
372
363
|
t->ping_policy.max_pings_without_data = g_default_max_pings_without_data;
|
373
|
-
t->ping_policy.min_sent_ping_interval_without_data =
|
374
|
-
g_default_min_sent_ping_interval_without_data_ms
|
364
|
+
t->ping_policy.min_sent_ping_interval_without_data =
|
365
|
+
g_default_min_sent_ping_interval_without_data_ms;
|
375
366
|
t->ping_policy.max_ping_strikes = g_default_max_ping_strikes;
|
376
|
-
t->ping_policy.min_recv_ping_interval_without_data =
|
377
|
-
g_default_min_recv_ping_interval_without_data_ms
|
367
|
+
t->ping_policy.min_recv_ping_interval_without_data =
|
368
|
+
g_default_min_recv_ping_interval_without_data_ms;
|
378
369
|
|
379
370
|
/* Keepalive setting */
|
380
371
|
if (t->is_client) {
|
381
|
-
t->keepalive_time =
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
g_default_client_keepalive_timeout_ms == INT_MAX
|
388
|
-
? gpr_inf_future(GPR_TIMESPAN)
|
389
|
-
: gpr_time_from_millis(g_default_client_keepalive_timeout_ms,
|
390
|
-
GPR_TIMESPAN);
|
372
|
+
t->keepalive_time = g_default_client_keepalive_time_ms == INT_MAX
|
373
|
+
? GRPC_MILLIS_INF_FUTURE
|
374
|
+
: g_default_client_keepalive_time_ms;
|
375
|
+
t->keepalive_timeout = g_default_client_keepalive_timeout_ms == INT_MAX
|
376
|
+
? GRPC_MILLIS_INF_FUTURE
|
377
|
+
: g_default_client_keepalive_timeout_ms;
|
391
378
|
} else {
|
392
|
-
t->keepalive_time =
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
g_default_server_keepalive_timeout_ms == INT_MAX
|
399
|
-
? gpr_inf_future(GPR_TIMESPAN)
|
400
|
-
: gpr_time_from_millis(g_default_server_keepalive_timeout_ms,
|
401
|
-
GPR_TIMESPAN);
|
379
|
+
t->keepalive_time = g_default_server_keepalive_time_ms == INT_MAX
|
380
|
+
? GRPC_MILLIS_INF_FUTURE
|
381
|
+
: g_default_server_keepalive_time_ms;
|
382
|
+
t->keepalive_timeout = g_default_server_keepalive_timeout_ms == INT_MAX
|
383
|
+
? GRPC_MILLIS_INF_FUTURE
|
384
|
+
: g_default_server_keepalive_timeout_ms;
|
402
385
|
}
|
403
386
|
t->keepalive_permit_without_calls = g_default_keepalive_permit_without_calls;
|
404
387
|
|
405
388
|
t->opt_target = GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY;
|
406
389
|
|
390
|
+
bool enable_bdp = true;
|
391
|
+
|
407
392
|
if (channel_args) {
|
408
393
|
for (i = 0; i < channel_args->num_args; i++) {
|
409
394
|
if (0 == strcmp(channel_args->args[i].key,
|
@@ -433,73 +418,62 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
433
418
|
GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA)) {
|
434
419
|
t->ping_policy.max_pings_without_data = grpc_channel_arg_get_integer(
|
435
420
|
&channel_args->args[i],
|
436
|
-
|
437
|
-
INT_MAX});
|
421
|
+
{g_default_max_pings_without_data, 0, INT_MAX});
|
438
422
|
} else if (0 == strcmp(channel_args->args[i].key,
|
439
423
|
GRPC_ARG_HTTP2_MAX_PING_STRIKES)) {
|
440
424
|
t->ping_policy.max_ping_strikes = grpc_channel_arg_get_integer(
|
441
|
-
&channel_args->args[i],
|
442
|
-
(grpc_integer_options){g_default_max_ping_strikes, 0, INT_MAX});
|
425
|
+
&channel_args->args[i], {g_default_max_ping_strikes, 0, INT_MAX});
|
443
426
|
} else if (0 ==
|
444
427
|
strcmp(
|
445
428
|
channel_args->args[i].key,
|
446
429
|
GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS)) {
|
447
430
|
t->ping_policy.min_sent_ping_interval_without_data =
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
INT_MAX}),
|
454
|
-
GPR_TIMESPAN);
|
431
|
+
grpc_channel_arg_get_integer(
|
432
|
+
&channel_args->args[i],
|
433
|
+
grpc_integer_options{
|
434
|
+
g_default_min_sent_ping_interval_without_data_ms, 0,
|
435
|
+
INT_MAX});
|
455
436
|
} else if (0 ==
|
456
437
|
strcmp(
|
457
438
|
channel_args->args[i].key,
|
458
439
|
GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS)) {
|
459
440
|
t->ping_policy.min_recv_ping_interval_without_data =
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
INT_MAX}),
|
466
|
-
GPR_TIMESPAN);
|
441
|
+
grpc_channel_arg_get_integer(
|
442
|
+
&channel_args->args[i],
|
443
|
+
grpc_integer_options{
|
444
|
+
g_default_min_recv_ping_interval_without_data_ms, 0,
|
445
|
+
INT_MAX});
|
467
446
|
} else if (0 == strcmp(channel_args->args[i].key,
|
468
447
|
GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE)) {
|
469
448
|
t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer(
|
470
|
-
&channel_args->args[i],
|
471
|
-
(grpc_integer_options){0, 0, MAX_WRITE_BUFFER_SIZE});
|
449
|
+
&channel_args->args[i], {0, 0, MAX_WRITE_BUFFER_SIZE});
|
472
450
|
} else if (0 ==
|
473
451
|
strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_BDP_PROBE)) {
|
474
|
-
|
475
|
-
&channel_args->args[i], (grpc_integer_options){1, 0, 1});
|
452
|
+
enable_bdp = grpc_channel_arg_get_bool(&channel_args->args[i], true);
|
476
453
|
} else if (0 == strcmp(channel_args->args[i].key,
|
477
454
|
GRPC_ARG_KEEPALIVE_TIME_MS)) {
|
478
455
|
const int value = grpc_channel_arg_get_integer(
|
479
456
|
&channel_args->args[i],
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
t->keepalive_time = value == INT_MAX
|
485
|
-
? gpr_inf_future(GPR_TIMESPAN)
|
486
|
-
: gpr_time_from_millis(value, GPR_TIMESPAN);
|
457
|
+
grpc_integer_options{t->is_client
|
458
|
+
? g_default_client_keepalive_time_ms
|
459
|
+
: g_default_server_keepalive_time_ms,
|
460
|
+
1, INT_MAX});
|
461
|
+
t->keepalive_time = value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
|
487
462
|
} else if (0 == strcmp(channel_args->args[i].key,
|
488
463
|
GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
|
489
464
|
const int value = grpc_channel_arg_get_integer(
|
490
465
|
&channel_args->args[i],
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
t->keepalive_timeout =
|
496
|
-
|
497
|
-
: gpr_time_from_millis(value, GPR_TIMESPAN);
|
466
|
+
grpc_integer_options{t->is_client
|
467
|
+
? g_default_client_keepalive_timeout_ms
|
468
|
+
: g_default_server_keepalive_timeout_ms,
|
469
|
+
0, INT_MAX});
|
470
|
+
t->keepalive_timeout =
|
471
|
+
value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
|
498
472
|
} else if (0 == strcmp(channel_args->args[i].key,
|
499
473
|
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
|
500
474
|
t->keepalive_permit_without_calls =
|
501
|
-
(uint32_t)grpc_channel_arg_get_integer(
|
502
|
-
|
475
|
+
(uint32_t)grpc_channel_arg_get_integer(&channel_args->args[i],
|
476
|
+
{0, 0, 1});
|
503
477
|
} else if (0 == strcmp(channel_args->args[i].key,
|
504
478
|
GRPC_ARG_OPTIMIZATION_TARGET)) {
|
505
479
|
if (channel_args->args[i].type != GRPC_ARG_STRING) {
|
@@ -519,7 +493,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
519
493
|
}
|
520
494
|
} else {
|
521
495
|
static const struct {
|
522
|
-
const char
|
496
|
+
const char* channel_arg_name;
|
523
497
|
grpc_chttp2_setting_id setting_id;
|
524
498
|
grpc_integer_options integer_options;
|
525
499
|
bool availability[2] /* server, client */;
|
@@ -570,35 +544,44 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
570
544
|
}
|
571
545
|
}
|
572
546
|
|
547
|
+
t->flow_control.Init(exec_ctx, t, enable_bdp);
|
548
|
+
|
573
549
|
/* No pings allowed before receiving a header or data frame. */
|
574
550
|
t->ping_state.pings_before_data_required = 0;
|
575
551
|
t->ping_state.is_delayed_ping_timer_set = false;
|
576
552
|
|
577
|
-
t->ping_recv_state.last_ping_recv_time =
|
553
|
+
t->ping_recv_state.last_ping_recv_time = GRPC_MILLIS_INF_PAST;
|
578
554
|
t->ping_recv_state.ping_strikes = 0;
|
579
555
|
|
580
556
|
/* Start keepalive pings */
|
581
|
-
if (
|
557
|
+
if (t->keepalive_time != GRPC_MILLIS_INF_FUTURE) {
|
582
558
|
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
|
583
559
|
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
|
584
|
-
grpc_timer_init(
|
585
|
-
|
586
|
-
|
587
|
-
&t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
|
560
|
+
grpc_timer_init(exec_ctx, &t->keepalive_ping_timer,
|
561
|
+
grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
|
562
|
+
&t->init_keepalive_ping_locked);
|
588
563
|
} else {
|
589
564
|
/* Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no
|
590
565
|
inflight keeaplive timers */
|
591
566
|
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED;
|
592
567
|
}
|
593
568
|
|
569
|
+
if (enable_bdp) {
|
570
|
+
GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
|
571
|
+
schedule_bdp_ping_locked(exec_ctx, t);
|
572
|
+
|
573
|
+
grpc_chttp2_act_on_flowctl_action(
|
574
|
+
exec_ctx, t->flow_control->PeriodicUpdate(exec_ctx), t, nullptr);
|
575
|
+
}
|
576
|
+
|
594
577
|
grpc_chttp2_initiate_write(exec_ctx, t,
|
595
578
|
GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE);
|
596
579
|
post_benign_reclaimer(exec_ctx, t);
|
597
580
|
}
|
598
581
|
|
599
|
-
static void destroy_transport_locked(grpc_exec_ctx
|
600
|
-
grpc_error
|
601
|
-
grpc_chttp2_transport
|
582
|
+
static void destroy_transport_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
583
|
+
grpc_error* error) {
|
584
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
602
585
|
t->destroying = 1;
|
603
586
|
close_transport_locked(
|
604
587
|
exec_ctx, t,
|
@@ -608,24 +591,26 @@ static void destroy_transport_locked(grpc_exec_ctx *exec_ctx, void *tp,
|
|
608
591
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "destroy");
|
609
592
|
}
|
610
593
|
|
611
|
-
static void destroy_transport(grpc_exec_ctx
|
612
|
-
grpc_chttp2_transport
|
594
|
+
static void destroy_transport(grpc_exec_ctx* exec_ctx, grpc_transport* gt) {
|
595
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
613
596
|
GRPC_CLOSURE_SCHED(exec_ctx,
|
614
597
|
GRPC_CLOSURE_CREATE(destroy_transport_locked, t,
|
615
598
|
grpc_combiner_scheduler(t->combiner)),
|
616
599
|
GRPC_ERROR_NONE);
|
617
600
|
}
|
618
601
|
|
619
|
-
static void close_transport_locked(grpc_exec_ctx
|
620
|
-
grpc_chttp2_transport
|
621
|
-
grpc_error
|
622
|
-
|
602
|
+
static void close_transport_locked(grpc_exec_ctx* exec_ctx,
|
603
|
+
grpc_chttp2_transport* t,
|
604
|
+
grpc_error* error) {
|
605
|
+
end_all_the_calls(exec_ctx, t, GRPC_ERROR_REF(error));
|
606
|
+
cancel_pings(exec_ctx, t, GRPC_ERROR_REF(error));
|
607
|
+
if (t->closed_with_error == GRPC_ERROR_NONE) {
|
623
608
|
if (!grpc_error_has_clear_grpc_status(error)) {
|
624
609
|
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
|
625
610
|
GRPC_STATUS_UNAVAILABLE);
|
626
611
|
}
|
627
612
|
if (t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE) {
|
628
|
-
if (t->close_transport_on_writes_finished ==
|
613
|
+
if (t->close_transport_on_writes_finished == nullptr) {
|
629
614
|
t->close_transport_on_writes_finished =
|
630
615
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
631
616
|
"Delayed close due to in-progress write");
|
@@ -634,13 +619,16 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
|
|
634
619
|
grpc_error_add_child(t->close_transport_on_writes_finished, error);
|
635
620
|
return;
|
636
621
|
}
|
637
|
-
|
622
|
+
GPR_ASSERT(error != GRPC_ERROR_NONE);
|
623
|
+
t->closed_with_error = GRPC_ERROR_REF(error);
|
638
624
|
connectivity_state_set(exec_ctx, t, GRPC_CHANNEL_SHUTDOWN,
|
639
625
|
GRPC_ERROR_REF(error), "close_transport");
|
640
|
-
grpc_endpoint_shutdown(exec_ctx, t->ep, GRPC_ERROR_REF(error));
|
641
626
|
if (t->ping_state.is_delayed_ping_timer_set) {
|
642
627
|
grpc_timer_cancel(exec_ctx, &t->ping_state.delayed_ping_timer);
|
643
628
|
}
|
629
|
+
if (t->have_next_bdp_ping_timer) {
|
630
|
+
grpc_timer_cancel(exec_ctx, &t->next_bdp_ping_timer);
|
631
|
+
}
|
644
632
|
switch (t->keepalive_state) {
|
645
633
|
case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING:
|
646
634
|
grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
|
@@ -656,44 +644,44 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx,
|
|
656
644
|
}
|
657
645
|
|
658
646
|
/* flush writable stream list to avoid dangling references */
|
659
|
-
grpc_chttp2_stream
|
647
|
+
grpc_chttp2_stream* s;
|
660
648
|
while (grpc_chttp2_list_pop_writable_stream(t, &s)) {
|
661
649
|
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:close");
|
662
650
|
}
|
663
|
-
|
664
|
-
|
651
|
+
GPR_ASSERT(t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE);
|
652
|
+
grpc_endpoint_shutdown(exec_ctx, t->ep, GRPC_ERROR_REF(error));
|
665
653
|
}
|
666
|
-
if (t->notify_on_receive_settings !=
|
654
|
+
if (t->notify_on_receive_settings != nullptr) {
|
667
655
|
GRPC_CLOSURE_SCHED(exec_ctx, t->notify_on_receive_settings,
|
668
656
|
GRPC_ERROR_CANCELLED);
|
669
|
-
t->notify_on_receive_settings =
|
657
|
+
t->notify_on_receive_settings = nullptr;
|
670
658
|
}
|
671
659
|
GRPC_ERROR_UNREF(error);
|
672
660
|
}
|
673
661
|
|
674
662
|
#ifndef NDEBUG
|
675
|
-
void grpc_chttp2_stream_ref(grpc_chttp2_stream
|
663
|
+
void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason) {
|
676
664
|
grpc_stream_ref(s->refcount, reason);
|
677
665
|
}
|
678
|
-
void grpc_chttp2_stream_unref(grpc_exec_ctx
|
679
|
-
const char
|
666
|
+
void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s,
|
667
|
+
const char* reason) {
|
680
668
|
grpc_stream_unref(exec_ctx, s->refcount, reason);
|
681
669
|
}
|
682
670
|
#else
|
683
|
-
void grpc_chttp2_stream_ref(grpc_chttp2_stream
|
671
|
+
void grpc_chttp2_stream_ref(grpc_chttp2_stream* s) {
|
684
672
|
grpc_stream_ref(s->refcount);
|
685
673
|
}
|
686
|
-
void grpc_chttp2_stream_unref(grpc_exec_ctx
|
674
|
+
void grpc_chttp2_stream_unref(grpc_exec_ctx* exec_ctx, grpc_chttp2_stream* s) {
|
687
675
|
grpc_stream_unref(exec_ctx, s->refcount);
|
688
676
|
}
|
689
677
|
#endif
|
690
678
|
|
691
|
-
static int init_stream(grpc_exec_ctx
|
692
|
-
grpc_stream
|
693
|
-
const void
|
679
|
+
static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
680
|
+
grpc_stream* gs, grpc_stream_refcount* refcount,
|
681
|
+
const void* server_data, gpr_arena* arena) {
|
694
682
|
GPR_TIMER_BEGIN("init_stream", 0);
|
695
|
-
grpc_chttp2_transport
|
696
|
-
grpc_chttp2_stream
|
683
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
684
|
+
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
|
697
685
|
|
698
686
|
s->t = t;
|
699
687
|
s->refcount = refcount;
|
@@ -706,7 +694,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
|
706
694
|
grpc_chttp2_incoming_metadata_buffer_init(&s->metadata_buffer[1], arena);
|
707
695
|
grpc_chttp2_data_parser_init(&s->data_parser);
|
708
696
|
grpc_slice_buffer_init(&s->flow_controlled_buffer);
|
709
|
-
s->deadline =
|
697
|
+
s->deadline = GRPC_MILLIS_INF_FUTURE;
|
710
698
|
GRPC_CLOSURE_INIT(&s->complete_fetch_locked, complete_fetch_locked, s,
|
711
699
|
grpc_schedule_on_exec_ctx);
|
712
700
|
grpc_slice_buffer_init(&s->unprocessed_incoming_frames_buffer);
|
@@ -727,22 +715,22 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
|
727
715
|
post_destructive_reclaimer(exec_ctx, t);
|
728
716
|
}
|
729
717
|
|
730
|
-
s->flow_control.
|
718
|
+
s->flow_control.Init(t->flow_control.get(), s);
|
731
719
|
GPR_TIMER_END("init_stream", 0);
|
732
720
|
|
733
721
|
return 0;
|
734
722
|
}
|
735
723
|
|
736
|
-
static void destroy_stream_locked(grpc_exec_ctx
|
737
|
-
grpc_error
|
738
|
-
grpc_chttp2_stream
|
739
|
-
grpc_chttp2_transport
|
724
|
+
static void destroy_stream_locked(grpc_exec_ctx* exec_ctx, void* sp,
|
725
|
+
grpc_error* error) {
|
726
|
+
grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
|
727
|
+
grpc_chttp2_transport* t = s->t;
|
740
728
|
|
741
729
|
GPR_TIMER_BEGIN("destroy_stream", 0);
|
742
730
|
|
743
731
|
GPR_ASSERT((s->write_closed && s->read_closed) || s->id == 0);
|
744
732
|
if (s->id != 0) {
|
745
|
-
GPR_ASSERT(grpc_chttp2_stream_map_find(&t->stream_map, s->id) ==
|
733
|
+
GPR_ASSERT(grpc_chttp2_stream_map_find(&t->stream_map, s->id) == nullptr);
|
746
734
|
}
|
747
735
|
|
748
736
|
grpc_slice_buffer_destroy_internal(exec_ctx,
|
@@ -762,12 +750,12 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp,
|
|
762
750
|
}
|
763
751
|
}
|
764
752
|
|
765
|
-
GPR_ASSERT(s->send_initial_metadata_finished ==
|
766
|
-
GPR_ASSERT(s->fetching_send_message ==
|
767
|
-
GPR_ASSERT(s->send_trailing_metadata_finished ==
|
768
|
-
GPR_ASSERT(s->recv_initial_metadata_ready ==
|
769
|
-
GPR_ASSERT(s->recv_message_ready ==
|
770
|
-
GPR_ASSERT(s->recv_trailing_metadata_finished ==
|
753
|
+
GPR_ASSERT(s->send_initial_metadata_finished == nullptr);
|
754
|
+
GPR_ASSERT(s->fetching_send_message == nullptr);
|
755
|
+
GPR_ASSERT(s->send_trailing_metadata_finished == nullptr);
|
756
|
+
GPR_ASSERT(s->recv_initial_metadata_ready == nullptr);
|
757
|
+
GPR_ASSERT(s->recv_message_ready == nullptr);
|
758
|
+
GPR_ASSERT(s->recv_trailing_metadata_finished == nullptr);
|
771
759
|
grpc_chttp2_data_parser_destroy(exec_ctx, &s->data_parser);
|
772
760
|
grpc_chttp2_incoming_metadata_buffer_destroy(exec_ctx,
|
773
761
|
&s->metadata_buffer[0]);
|
@@ -778,7 +766,7 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp,
|
|
778
766
|
GRPC_ERROR_UNREF(s->write_closed_error);
|
779
767
|
GRPC_ERROR_UNREF(s->byte_stream_error);
|
780
768
|
|
781
|
-
|
769
|
+
s->flow_control.Destroy();
|
782
770
|
|
783
771
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "stream");
|
784
772
|
|
@@ -787,48 +775,49 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp,
|
|
787
775
|
GRPC_CLOSURE_SCHED(exec_ctx, s->destroy_stream_arg, GRPC_ERROR_NONE);
|
788
776
|
}
|
789
777
|
|
790
|
-
static void destroy_stream(grpc_exec_ctx
|
791
|
-
grpc_stream
|
792
|
-
grpc_closure
|
778
|
+
static void destroy_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
779
|
+
grpc_stream* gs,
|
780
|
+
grpc_closure* then_schedule_closure) {
|
793
781
|
GPR_TIMER_BEGIN("destroy_stream", 0);
|
794
|
-
grpc_chttp2_transport
|
795
|
-
grpc_chttp2_stream
|
782
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
783
|
+
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
|
796
784
|
|
797
|
-
if (s->stream_compression_ctx !=
|
785
|
+
if (s->stream_compression_ctx != nullptr) {
|
798
786
|
grpc_stream_compression_context_destroy(s->stream_compression_ctx);
|
799
|
-
s->stream_compression_ctx =
|
787
|
+
s->stream_compression_ctx = nullptr;
|
800
788
|
}
|
801
|
-
if (s->stream_decompression_ctx !=
|
789
|
+
if (s->stream_decompression_ctx != nullptr) {
|
802
790
|
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
|
803
|
-
s->stream_decompression_ctx =
|
791
|
+
s->stream_decompression_ctx = nullptr;
|
804
792
|
}
|
805
793
|
|
806
794
|
s->destroy_stream_arg = then_schedule_closure;
|
807
795
|
GRPC_CLOSURE_SCHED(
|
808
|
-
exec_ctx,
|
809
|
-
|
796
|
+
exec_ctx,
|
797
|
+
GRPC_CLOSURE_INIT(&s->destroy_stream, destroy_stream_locked, s,
|
798
|
+
grpc_combiner_scheduler(t->combiner)),
|
810
799
|
GRPC_ERROR_NONE);
|
811
800
|
GPR_TIMER_END("destroy_stream", 0);
|
812
801
|
}
|
813
802
|
|
814
|
-
grpc_chttp2_stream
|
803
|
+
grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
|
815
804
|
uint32_t id) {
|
816
|
-
return (grpc_chttp2_stream
|
805
|
+
return (grpc_chttp2_stream*)grpc_chttp2_stream_map_find(&t->stream_map, id);
|
817
806
|
}
|
818
807
|
|
819
|
-
grpc_chttp2_stream
|
820
|
-
grpc_chttp2_transport
|
808
|
+
grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_exec_ctx* exec_ctx,
|
809
|
+
grpc_chttp2_transport* t,
|
821
810
|
uint32_t id) {
|
822
|
-
if (t->channel_callback.accept_stream ==
|
823
|
-
return
|
811
|
+
if (t->channel_callback.accept_stream == nullptr) {
|
812
|
+
return nullptr;
|
824
813
|
}
|
825
|
-
grpc_chttp2_stream
|
826
|
-
GPR_ASSERT(t->accepting_stream ==
|
814
|
+
grpc_chttp2_stream* accepting;
|
815
|
+
GPR_ASSERT(t->accepting_stream == nullptr);
|
827
816
|
t->accepting_stream = &accepting;
|
828
817
|
t->channel_callback.accept_stream(exec_ctx,
|
829
818
|
t->channel_callback.accept_stream_user_data,
|
830
|
-
&t->base, (void
|
831
|
-
t->accepting_stream =
|
819
|
+
&t->base, (void*)(uintptr_t)id);
|
820
|
+
t->accepting_stream = nullptr;
|
832
821
|
return accepting;
|
833
822
|
}
|
834
823
|
|
@@ -836,7 +825,7 @@ grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx,
|
|
836
825
|
* OUTPUT PROCESSING
|
837
826
|
*/
|
838
827
|
|
839
|
-
static const char
|
828
|
+
static const char* write_state_name(grpc_chttp2_write_state st) {
|
840
829
|
switch (st) {
|
841
830
|
case GRPC_CHTTP2_WRITE_STATE_IDLE:
|
842
831
|
return "IDLE";
|
@@ -848,8 +837,8 @@ static const char *write_state_name(grpc_chttp2_write_state st) {
|
|
848
837
|
GPR_UNREACHABLE_CODE(return "UNKNOWN");
|
849
838
|
}
|
850
839
|
|
851
|
-
static void set_write_state(grpc_exec_ctx
|
852
|
-
grpc_chttp2_write_state st, const char
|
840
|
+
static void set_write_state(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
841
|
+
grpc_chttp2_write_state st, const char* reason) {
|
853
842
|
GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_DEBUG, "W:%p %s state %s -> %s [%s]", t,
|
854
843
|
t->is_client ? "CLIENT" : "SERVER",
|
855
844
|
write_state_name(t->write_state),
|
@@ -857,16 +846,16 @@ static void set_write_state(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
857
846
|
t->write_state = st;
|
858
847
|
if (st == GRPC_CHTTP2_WRITE_STATE_IDLE) {
|
859
848
|
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &t->run_after_write);
|
860
|
-
if (t->close_transport_on_writes_finished !=
|
861
|
-
grpc_error
|
862
|
-
t->close_transport_on_writes_finished =
|
849
|
+
if (t->close_transport_on_writes_finished != nullptr) {
|
850
|
+
grpc_error* err = t->close_transport_on_writes_finished;
|
851
|
+
t->close_transport_on_writes_finished = nullptr;
|
863
852
|
close_transport_locked(exec_ctx, t, err);
|
864
853
|
}
|
865
854
|
}
|
866
855
|
}
|
867
856
|
|
868
857
|
static void inc_initiate_write_reason(
|
869
|
-
grpc_exec_ctx
|
858
|
+
grpc_exec_ctx* exec_ctx, grpc_chttp2_initiate_write_reason reason) {
|
870
859
|
switch (reason) {
|
871
860
|
case GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE:
|
872
861
|
GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_INITIAL_WRITE(exec_ctx);
|
@@ -910,9 +899,6 @@ static void inc_initiate_write_reason(
|
|
910
899
|
case GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS:
|
911
900
|
GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_SEND_SETTINGS(exec_ctx);
|
912
901
|
break;
|
913
|
-
case GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING:
|
914
|
-
GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING(exec_ctx);
|
915
|
-
break;
|
916
902
|
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING:
|
917
903
|
GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_FLOW_CONTROL_UNSTALLED_BY_SETTING(
|
918
904
|
exec_ctx);
|
@@ -940,8 +926,8 @@ static void inc_initiate_write_reason(
|
|
940
926
|
}
|
941
927
|
}
|
942
928
|
|
943
|
-
void grpc_chttp2_initiate_write(grpc_exec_ctx
|
944
|
-
grpc_chttp2_transport
|
929
|
+
void grpc_chttp2_initiate_write(grpc_exec_ctx* exec_ctx,
|
930
|
+
grpc_chttp2_transport* t,
|
945
931
|
grpc_chttp2_initiate_write_reason reason) {
|
946
932
|
GPR_TIMER_BEGIN("grpc_chttp2_initiate_write", 0);
|
947
933
|
|
@@ -969,15 +955,16 @@ void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx,
|
|
969
955
|
GPR_TIMER_END("grpc_chttp2_initiate_write", 0);
|
970
956
|
}
|
971
957
|
|
972
|
-
void grpc_chttp2_mark_stream_writable(grpc_exec_ctx
|
973
|
-
grpc_chttp2_transport
|
974
|
-
grpc_chttp2_stream
|
975
|
-
if (
|
958
|
+
void grpc_chttp2_mark_stream_writable(grpc_exec_ctx* exec_ctx,
|
959
|
+
grpc_chttp2_transport* t,
|
960
|
+
grpc_chttp2_stream* s) {
|
961
|
+
if (t->closed_with_error == GRPC_ERROR_NONE &&
|
962
|
+
grpc_chttp2_list_add_writable_stream(t, s)) {
|
976
963
|
GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:become");
|
977
964
|
}
|
978
965
|
}
|
979
966
|
|
980
|
-
static grpc_closure_scheduler
|
967
|
+
static grpc_closure_scheduler* write_scheduler(grpc_chttp2_transport* t,
|
981
968
|
bool early_results_scheduled,
|
982
969
|
bool partial_write) {
|
983
970
|
/* if it's not the first write in a batch, always offload to the executor:
|
@@ -1001,11 +988,11 @@ static grpc_closure_scheduler *write_scheduler(grpc_chttp2_transport *t,
|
|
1001
988
|
case GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY:
|
1002
989
|
return grpc_schedule_on_exec_ctx;
|
1003
990
|
}
|
1004
|
-
GPR_UNREACHABLE_CODE(return
|
991
|
+
GPR_UNREACHABLE_CODE(return nullptr);
|
1005
992
|
}
|
1006
993
|
|
1007
994
|
#define WRITE_STATE_TUPLE_TO_INT(p, i) (2 * (int)(p) + (int)(i))
|
1008
|
-
static const char
|
995
|
+
static const char* begin_writing_desc(bool partial, bool inlined) {
|
1009
996
|
switch (WRITE_STATE_TUPLE_TO_INT(partial, inlined)) {
|
1010
997
|
case WRITE_STATE_TUPLE_TO_INT(false, false):
|
1011
998
|
return "begin write in background";
|
@@ -1019,13 +1006,13 @@ static const char *begin_writing_desc(bool partial, bool inlined) {
|
|
1019
1006
|
GPR_UNREACHABLE_CODE(return "bad state tuple");
|
1020
1007
|
}
|
1021
1008
|
|
1022
|
-
static void write_action_begin_locked(grpc_exec_ctx
|
1023
|
-
grpc_error
|
1009
|
+
static void write_action_begin_locked(grpc_exec_ctx* exec_ctx, void* gt,
|
1010
|
+
grpc_error* error_ignored) {
|
1024
1011
|
GPR_TIMER_BEGIN("write_action_begin_locked", 0);
|
1025
|
-
grpc_chttp2_transport
|
1012
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
1026
1013
|
GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE);
|
1027
1014
|
grpc_chttp2_begin_write_result r;
|
1028
|
-
if (t->
|
1015
|
+
if (t->closed_with_error != GRPC_ERROR_NONE) {
|
1029
1016
|
r.writing = false;
|
1030
1017
|
} else {
|
1031
1018
|
r = grpc_chttp2_begin_write(exec_ctx, t);
|
@@ -1037,19 +1024,22 @@ static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt,
|
|
1037
1024
|
if (!t->is_first_write_in_batch) {
|
1038
1025
|
GRPC_STATS_INC_HTTP2_WRITES_CONTINUED(exec_ctx);
|
1039
1026
|
}
|
1040
|
-
grpc_closure_scheduler
|
1027
|
+
grpc_closure_scheduler* scheduler =
|
1041
1028
|
write_scheduler(t, r.early_results_scheduled, r.partial);
|
1042
1029
|
if (scheduler != grpc_schedule_on_exec_ctx) {
|
1043
1030
|
GRPC_STATS_INC_HTTP2_WRITES_OFFLOADED(exec_ctx);
|
1044
1031
|
}
|
1045
1032
|
set_write_state(
|
1046
|
-
exec_ctx, t,
|
1047
|
-
|
1033
|
+
exec_ctx, t,
|
1034
|
+
r.partial ? GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE
|
1035
|
+
: GRPC_CHTTP2_WRITE_STATE_WRITING,
|
1048
1036
|
begin_writing_desc(r.partial, scheduler == grpc_schedule_on_exec_ctx));
|
1049
|
-
GRPC_CLOSURE_SCHED(
|
1050
|
-
|
1051
|
-
|
1037
|
+
GRPC_CLOSURE_SCHED(
|
1038
|
+
exec_ctx,
|
1039
|
+
GRPC_CLOSURE_INIT(&t->write_action, write_action, t, scheduler),
|
1040
|
+
GRPC_ERROR_NONE);
|
1052
1041
|
} else {
|
1042
|
+
GRPC_STATS_INC_HTTP2_SPURIOUS_WRITES_BEGUN(exec_ctx);
|
1053
1043
|
set_write_state(exec_ctx, t, GRPC_CHTTP2_WRITE_STATE_IDLE,
|
1054
1044
|
"begin writing nothing");
|
1055
1045
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "writing");
|
@@ -1057,8 +1047,8 @@ static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt,
|
|
1057
1047
|
GPR_TIMER_END("write_action_begin_locked", 0);
|
1058
1048
|
}
|
1059
1049
|
|
1060
|
-
static void write_action(grpc_exec_ctx
|
1061
|
-
grpc_chttp2_transport
|
1050
|
+
static void write_action(grpc_exec_ctx* exec_ctx, void* gt, grpc_error* error) {
|
1051
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
1062
1052
|
GPR_TIMER_BEGIN("write_action", 0);
|
1063
1053
|
grpc_endpoint_write(
|
1064
1054
|
exec_ctx, t->ep, &t->outbuf,
|
@@ -1067,10 +1057,10 @@ static void write_action(grpc_exec_ctx *exec_ctx, void *gt, grpc_error *error) {
|
|
1067
1057
|
GPR_TIMER_END("write_action", 0);
|
1068
1058
|
}
|
1069
1059
|
|
1070
|
-
static void write_action_end_locked(grpc_exec_ctx
|
1071
|
-
grpc_error
|
1060
|
+
static void write_action_end_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
1061
|
+
grpc_error* error) {
|
1072
1062
|
GPR_TIMER_BEGIN("terminate_writing_with_lock", 0);
|
1073
|
-
grpc_chttp2_transport
|
1063
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
1074
1064
|
|
1075
1065
|
if (error != GRPC_ERROR_NONE) {
|
1076
1066
|
close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
|
@@ -1115,10 +1105,10 @@ static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *tp,
|
|
1115
1105
|
|
1116
1106
|
// Dirties an HTTP2 setting to be sent out next time a writing path occurs.
|
1117
1107
|
// If the change needs to occur immediately, manually initiate a write.
|
1118
|
-
static void queue_setting_update(grpc_exec_ctx
|
1119
|
-
grpc_chttp2_transport
|
1108
|
+
static void queue_setting_update(grpc_exec_ctx* exec_ctx,
|
1109
|
+
grpc_chttp2_transport* t,
|
1120
1110
|
grpc_chttp2_setting_id id, uint32_t value) {
|
1121
|
-
const grpc_chttp2_setting_parameters
|
1111
|
+
const grpc_chttp2_setting_parameters* sp =
|
1122
1112
|
&grpc_chttp2_settings_parameters[id];
|
1123
1113
|
uint32_t use_value = GPR_CLAMP(value, sp->min_value, sp->max_value);
|
1124
1114
|
if (use_value != value) {
|
@@ -1131,13 +1121,22 @@ static void queue_setting_update(grpc_exec_ctx *exec_ctx,
|
|
1131
1121
|
}
|
1132
1122
|
}
|
1133
1123
|
|
1134
|
-
void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx
|
1135
|
-
grpc_chttp2_transport
|
1124
|
+
void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx* exec_ctx,
|
1125
|
+
grpc_chttp2_transport* t,
|
1136
1126
|
uint32_t goaway_error,
|
1137
1127
|
grpc_slice goaway_text) {
|
1138
1128
|
// GRPC_CHTTP2_IF_TRACING(
|
1139
1129
|
// gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg));
|
1140
|
-
|
1130
|
+
|
1131
|
+
// Discard the error from a previous goaway frame (if any)
|
1132
|
+
if (t->goaway_error != GRPC_ERROR_NONE) {
|
1133
|
+
GRPC_ERROR_UNREF(t->goaway_error);
|
1134
|
+
}
|
1135
|
+
t->goaway_error = grpc_error_set_str(
|
1136
|
+
grpc_error_set_int(
|
1137
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"),
|
1138
|
+
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)goaway_error),
|
1139
|
+
GRPC_ERROR_STR_RAW_BYTES, goaway_text);
|
1141
1140
|
|
1142
1141
|
/* When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug
|
1143
1142
|
* data equal to "too_many_pings", it should log the occurrence at a log level
|
@@ -1148,31 +1147,23 @@ void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx,
|
|
1148
1147
|
gpr_log(GPR_ERROR,
|
1149
1148
|
"Received a GOAWAY with error code ENHANCE_YOUR_CALM and debug "
|
1150
1149
|
"data equal to \"too_many_pings\"");
|
1151
|
-
double current_keepalive_time_ms =
|
1152
|
-
gpr_timespec_to_micros(t->keepalive_time) / 1000;
|
1150
|
+
double current_keepalive_time_ms = (double)t->keepalive_time;
|
1153
1151
|
t->keepalive_time =
|
1154
1152
|
current_keepalive_time_ms > INT_MAX / KEEPALIVE_TIME_BACKOFF_MULTIPLIER
|
1155
|
-
?
|
1156
|
-
:
|
1157
|
-
|
1158
|
-
GPR_TIMESPAN);
|
1153
|
+
? GRPC_MILLIS_INF_FUTURE
|
1154
|
+
: (grpc_millis)(current_keepalive_time_ms *
|
1155
|
+
KEEPALIVE_TIME_BACKOFF_MULTIPLIER);
|
1159
1156
|
}
|
1160
1157
|
|
1161
1158
|
/* lie: use transient failure from the transport to indicate goaway has been
|
1162
1159
|
* received */
|
1163
|
-
connectivity_state_set(
|
1164
|
-
|
1165
|
-
grpc_error_set_str(
|
1166
|
-
grpc_error_set_int(
|
1167
|
-
GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"),
|
1168
|
-
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)goaway_error),
|
1169
|
-
GRPC_ERROR_STR_RAW_BYTES, goaway_text),
|
1170
|
-
"got_goaway");
|
1160
|
+
connectivity_state_set(exec_ctx, t, GRPC_CHANNEL_TRANSIENT_FAILURE,
|
1161
|
+
GRPC_ERROR_REF(t->goaway_error), "got_goaway");
|
1171
1162
|
}
|
1172
1163
|
|
1173
|
-
static void maybe_start_some_streams(grpc_exec_ctx
|
1174
|
-
grpc_chttp2_transport
|
1175
|
-
grpc_chttp2_stream
|
1164
|
+
static void maybe_start_some_streams(grpc_exec_ctx* exec_ctx,
|
1165
|
+
grpc_chttp2_transport* t) {
|
1166
|
+
grpc_chttp2_stream* s;
|
1176
1167
|
/* start streams where we have free grpc_chttp2_stream ids and free
|
1177
1168
|
* concurrency */
|
1178
1169
|
while (t->next_stream_id <= MAX_CLIENT_STREAM_ID &&
|
@@ -1223,32 +1214,32 @@ static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx,
|
|
1223
1214
|
bits being used for flags defined above) */
|
1224
1215
|
#define CLOSURE_BARRIER_FIRST_REF_BIT (1 << 16)
|
1225
1216
|
|
1226
|
-
static grpc_closure
|
1217
|
+
static grpc_closure* add_closure_barrier(grpc_closure* closure) {
|
1227
1218
|
closure->next_data.scratch += CLOSURE_BARRIER_FIRST_REF_BIT;
|
1228
1219
|
return closure;
|
1229
1220
|
}
|
1230
1221
|
|
1231
|
-
static void null_then_run_closure(grpc_exec_ctx
|
1232
|
-
grpc_closure
|
1233
|
-
grpc_closure
|
1234
|
-
*closure =
|
1222
|
+
static void null_then_run_closure(grpc_exec_ctx* exec_ctx,
|
1223
|
+
grpc_closure** closure, grpc_error* error) {
|
1224
|
+
grpc_closure* c = *closure;
|
1225
|
+
*closure = nullptr;
|
1235
1226
|
GRPC_CLOSURE_RUN(exec_ctx, c, error);
|
1236
1227
|
}
|
1237
1228
|
|
1238
|
-
void grpc_chttp2_complete_closure_step(grpc_exec_ctx
|
1239
|
-
grpc_chttp2_transport
|
1240
|
-
grpc_chttp2_stream
|
1241
|
-
grpc_closure
|
1242
|
-
grpc_error
|
1243
|
-
grpc_closure
|
1244
|
-
*pclosure =
|
1245
|
-
if (closure ==
|
1229
|
+
void grpc_chttp2_complete_closure_step(grpc_exec_ctx* exec_ctx,
|
1230
|
+
grpc_chttp2_transport* t,
|
1231
|
+
grpc_chttp2_stream* s,
|
1232
|
+
grpc_closure** pclosure,
|
1233
|
+
grpc_error* error, const char* desc) {
|
1234
|
+
grpc_closure* closure = *pclosure;
|
1235
|
+
*pclosure = nullptr;
|
1236
|
+
if (closure == nullptr) {
|
1246
1237
|
GRPC_ERROR_UNREF(error);
|
1247
1238
|
return;
|
1248
1239
|
}
|
1249
1240
|
closure->next_data.scratch -= CLOSURE_BARRIER_FIRST_REF_BIT;
|
1250
|
-
if (
|
1251
|
-
const char
|
1241
|
+
if (grpc_http_trace.enabled()) {
|
1242
|
+
const char* errstr = grpc_error_string(error);
|
1252
1243
|
gpr_log(
|
1253
1244
|
GPR_DEBUG,
|
1254
1245
|
"complete_closure_step: t=%p %p refs=%d flags=0x%04x desc=%s err=%s "
|
@@ -1272,7 +1263,7 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
|
|
1272
1263
|
if (closure->next_data.scratch < CLOSURE_BARRIER_FIRST_REF_BIT) {
|
1273
1264
|
if (closure->next_data.scratch & CLOSURE_BARRIER_STATS_BIT) {
|
1274
1265
|
grpc_transport_move_stats(&s->stats, s->collecting_stats);
|
1275
|
-
s->collecting_stats =
|
1266
|
+
s->collecting_stats = nullptr;
|
1276
1267
|
}
|
1277
1268
|
if ((t->write_state == GRPC_CHTTP2_WRITE_STATE_IDLE) ||
|
1278
1269
|
!(closure->next_data.scratch & CLOSURE_BARRIER_MAY_COVER_WRITE)) {
|
@@ -1284,17 +1275,17 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx,
|
|
1284
1275
|
}
|
1285
1276
|
}
|
1286
1277
|
|
1287
|
-
static bool contains_non_ok_status(grpc_metadata_batch
|
1288
|
-
if (batch->idx.named.grpc_status !=
|
1278
|
+
static bool contains_non_ok_status(grpc_metadata_batch* batch) {
|
1279
|
+
if (batch->idx.named.grpc_status != nullptr) {
|
1289
1280
|
return !grpc_mdelem_eq(batch->idx.named.grpc_status->md,
|
1290
1281
|
GRPC_MDELEM_GRPC_STATUS_0);
|
1291
1282
|
}
|
1292
1283
|
return false;
|
1293
1284
|
}
|
1294
1285
|
|
1295
|
-
static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx
|
1296
|
-
grpc_chttp2_transport
|
1297
|
-
grpc_chttp2_stream
|
1286
|
+
static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx* exec_ctx,
|
1287
|
+
grpc_chttp2_transport* t,
|
1288
|
+
grpc_chttp2_stream* s) {
|
1298
1289
|
if (s->id != 0 && (!s->write_buffering ||
|
1299
1290
|
s->flow_controlled_buffer.length > t->write_buffer_size)) {
|
1300
1291
|
grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
|
@@ -1303,20 +1294,20 @@ static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx *exec_ctx,
|
|
1303
1294
|
}
|
1304
1295
|
}
|
1305
1296
|
|
1306
|
-
static void add_fetched_slice_locked(grpc_exec_ctx
|
1307
|
-
grpc_chttp2_transport
|
1308
|
-
grpc_chttp2_stream
|
1297
|
+
static void add_fetched_slice_locked(grpc_exec_ctx* exec_ctx,
|
1298
|
+
grpc_chttp2_transport* t,
|
1299
|
+
grpc_chttp2_stream* s) {
|
1309
1300
|
s->fetched_send_message_length +=
|
1310
1301
|
(uint32_t)GRPC_SLICE_LENGTH(s->fetching_slice);
|
1311
1302
|
grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice);
|
1312
1303
|
maybe_become_writable_due_to_send_msg(exec_ctx, t, s);
|
1313
1304
|
}
|
1314
1305
|
|
1315
|
-
static void continue_fetching_send_locked(grpc_exec_ctx
|
1316
|
-
grpc_chttp2_transport
|
1317
|
-
grpc_chttp2_stream
|
1306
|
+
static void continue_fetching_send_locked(grpc_exec_ctx* exec_ctx,
|
1307
|
+
grpc_chttp2_transport* t,
|
1308
|
+
grpc_chttp2_stream* s) {
|
1318
1309
|
for (;;) {
|
1319
|
-
if (s->fetching_send_message ==
|
1310
|
+
if (s->fetching_send_message == nullptr) {
|
1320
1311
|
/* Stream was cancelled before message fetch completed */
|
1321
1312
|
abort(); /* TODO(ctiller): what cleanup here? */
|
1322
1313
|
return; /* early out */
|
@@ -1329,27 +1320,27 @@ static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
|
|
1329
1320
|
exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_NONE,
|
1330
1321
|
"fetching_send_message_finished");
|
1331
1322
|
} else {
|
1332
|
-
grpc_chttp2_write_cb
|
1333
|
-
if (cb ==
|
1334
|
-
cb = (grpc_chttp2_write_cb
|
1323
|
+
grpc_chttp2_write_cb* cb = t->write_cb_pool;
|
1324
|
+
if (cb == nullptr) {
|
1325
|
+
cb = (grpc_chttp2_write_cb*)gpr_malloc(sizeof(*cb));
|
1335
1326
|
} else {
|
1336
1327
|
t->write_cb_pool = cb->next;
|
1337
1328
|
}
|
1338
1329
|
cb->call_at_byte = notify_offset;
|
1339
1330
|
cb->closure = s->fetching_send_message_finished;
|
1340
|
-
s->fetching_send_message_finished =
|
1341
|
-
grpc_chttp2_write_cb
|
1331
|
+
s->fetching_send_message_finished = nullptr;
|
1332
|
+
grpc_chttp2_write_cb** list =
|
1342
1333
|
s->fetching_send_message->flags & GRPC_WRITE_THROUGH
|
1343
1334
|
? &s->on_write_finished_cbs
|
1344
1335
|
: &s->on_flow_controlled_cbs;
|
1345
1336
|
cb->next = *list;
|
1346
1337
|
*list = cb;
|
1347
1338
|
}
|
1348
|
-
s->fetching_send_message =
|
1339
|
+
s->fetching_send_message = nullptr;
|
1349
1340
|
return; /* early out */
|
1350
1341
|
} else if (grpc_byte_stream_next(exec_ctx, s->fetching_send_message,
|
1351
1342
|
UINT32_MAX, &s->complete_fetch_locked)) {
|
1352
|
-
grpc_error
|
1343
|
+
grpc_error* error = grpc_byte_stream_pull(
|
1353
1344
|
exec_ctx, s->fetching_send_message, &s->fetching_slice);
|
1354
1345
|
if (error != GRPC_ERROR_NONE) {
|
1355
1346
|
grpc_byte_stream_destroy(exec_ctx, s->fetching_send_message);
|
@@ -1361,10 +1352,10 @@ static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
|
|
1361
1352
|
}
|
1362
1353
|
}
|
1363
1354
|
|
1364
|
-
static void complete_fetch_locked(grpc_exec_ctx
|
1365
|
-
grpc_error
|
1366
|
-
grpc_chttp2_stream
|
1367
|
-
grpc_chttp2_transport
|
1355
|
+
static void complete_fetch_locked(grpc_exec_ctx* exec_ctx, void* gs,
|
1356
|
+
grpc_error* error) {
|
1357
|
+
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
|
1358
|
+
grpc_chttp2_transport* t = s->t;
|
1368
1359
|
if (error == GRPC_ERROR_NONE) {
|
1369
1360
|
error = grpc_byte_stream_pull(exec_ctx, s->fetching_send_message,
|
1370
1361
|
&s->fetching_slice);
|
@@ -1379,14 +1370,14 @@ static void complete_fetch_locked(grpc_exec_ctx *exec_ctx, void *gs,
|
|
1379
1370
|
}
|
1380
1371
|
}
|
1381
1372
|
|
1382
|
-
static void do_nothing(grpc_exec_ctx
|
1373
|
+
static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {}
|
1383
1374
|
|
1384
|
-
static void log_metadata(const grpc_metadata_batch
|
1375
|
+
static void log_metadata(const grpc_metadata_batch* md_batch, uint32_t id,
|
1385
1376
|
bool is_client, bool is_initial) {
|
1386
|
-
for (grpc_linked_mdelem
|
1377
|
+
for (grpc_linked_mdelem* md = md_batch->list.head; md != nullptr;
|
1387
1378
|
md = md->next) {
|
1388
|
-
char
|
1389
|
-
char
|
1379
|
+
char* key = grpc_slice_to_c_string(GRPC_MDKEY(md->md));
|
1380
|
+
char* value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md));
|
1390
1381
|
gpr_log(GPR_INFO, "HTTP:%d:%s:%s: %s: %s", id, is_initial ? "HDR" : "TRL",
|
1391
1382
|
is_client ? "CLI" : "SVR", key, value);
|
1392
1383
|
gpr_free(key);
|
@@ -1394,20 +1385,20 @@ static void log_metadata(const grpc_metadata_batch *md_batch, uint32_t id,
|
|
1394
1385
|
}
|
1395
1386
|
}
|
1396
1387
|
|
1397
|
-
static void perform_stream_op_locked(grpc_exec_ctx
|
1398
|
-
grpc_error
|
1388
|
+
static void perform_stream_op_locked(grpc_exec_ctx* exec_ctx, void* stream_op,
|
1389
|
+
grpc_error* error_ignored) {
|
1399
1390
|
GPR_TIMER_BEGIN("perform_stream_op_locked", 0);
|
1400
1391
|
|
1401
|
-
grpc_transport_stream_op_batch
|
1402
|
-
(grpc_transport_stream_op_batch
|
1403
|
-
grpc_chttp2_stream
|
1404
|
-
grpc_transport_stream_op_batch_payload
|
1405
|
-
grpc_chttp2_transport
|
1392
|
+
grpc_transport_stream_op_batch* op =
|
1393
|
+
(grpc_transport_stream_op_batch*)stream_op;
|
1394
|
+
grpc_chttp2_stream* s = (grpc_chttp2_stream*)op->handler_private.extra_arg;
|
1395
|
+
grpc_transport_stream_op_batch_payload* op_payload = op->payload;
|
1396
|
+
grpc_chttp2_transport* t = s->t;
|
1406
1397
|
|
1407
1398
|
GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx);
|
1408
1399
|
|
1409
|
-
if (
|
1410
|
-
char
|
1400
|
+
if (grpc_http_trace.enabled()) {
|
1401
|
+
char* str = grpc_transport_stream_op_batch_string(op);
|
1411
1402
|
gpr_log(GPR_DEBUG, "perform_stream_op_locked: %s; on_complete = %p", str,
|
1412
1403
|
op->on_complete);
|
1413
1404
|
gpr_free(str);
|
@@ -1421,10 +1412,10 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1421
1412
|
}
|
1422
1413
|
}
|
1423
1414
|
|
1424
|
-
grpc_closure
|
1425
|
-
if (on_complete ==
|
1415
|
+
grpc_closure* on_complete = op->on_complete;
|
1416
|
+
if (on_complete == nullptr) {
|
1426
1417
|
on_complete =
|
1427
|
-
GRPC_CLOSURE_CREATE(do_nothing,
|
1418
|
+
GRPC_CLOSURE_CREATE(do_nothing, nullptr, grpc_schedule_on_exec_ctx);
|
1428
1419
|
}
|
1429
1420
|
|
1430
1421
|
/* use final_data as a barrier until enqueue time; the inital counter is
|
@@ -1433,7 +1424,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1433
1424
|
on_complete->error_data.error = GRPC_ERROR_NONE;
|
1434
1425
|
|
1435
1426
|
if (op->collect_stats) {
|
1436
|
-
GPR_ASSERT(s->collecting_stats ==
|
1427
|
+
GPR_ASSERT(s->collecting_stats == nullptr);
|
1437
1428
|
s->collecting_stats = op_payload->collect_stats.collect_stats;
|
1438
1429
|
on_complete->next_data.scratch |= CLOSURE_BARRIER_STATS_BIT;
|
1439
1430
|
}
|
@@ -1446,12 +1437,12 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1446
1437
|
|
1447
1438
|
if (op->send_initial_metadata) {
|
1448
1439
|
GRPC_STATS_INC_HTTP2_OP_SEND_INITIAL_METADATA(exec_ctx);
|
1449
|
-
GPR_ASSERT(s->send_initial_metadata_finished ==
|
1440
|
+
GPR_ASSERT(s->send_initial_metadata_finished == nullptr);
|
1450
1441
|
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
|
1451
1442
|
|
1452
1443
|
/* Identify stream compression */
|
1453
1444
|
if (op_payload->send_initial_metadata.send_initial_metadata->idx.named
|
1454
|
-
.content_encoding ==
|
1445
|
+
.content_encoding == nullptr ||
|
1455
1446
|
grpc_stream_compression_method_parse(
|
1456
1447
|
GRPC_MDVALUE(
|
1457
1448
|
op_payload->send_initial_metadata.send_initial_metadata->idx
|
@@ -1469,8 +1460,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1469
1460
|
t->settings[GRPC_PEER_SETTINGS]
|
1470
1461
|
[GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE];
|
1471
1462
|
if (t->is_client) {
|
1472
|
-
s->deadline =
|
1473
|
-
gpr_time_min(s->deadline, s->send_initial_metadata->deadline);
|
1463
|
+
s->deadline = GPR_MIN(s->deadline, s->send_initial_metadata->deadline);
|
1474
1464
|
}
|
1475
1465
|
if (metadata_size > metadata_peer_limit) {
|
1476
1466
|
grpc_chttp2_cancel_stream(
|
@@ -1490,7 +1480,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1490
1480
|
}
|
1491
1481
|
if (!s->write_closed) {
|
1492
1482
|
if (t->is_client) {
|
1493
|
-
if (
|
1483
|
+
if (t->closed_with_error == GRPC_ERROR_NONE) {
|
1494
1484
|
GPR_ASSERT(s->id == 0);
|
1495
1485
|
grpc_chttp2_list_add_waiting_for_concurrency(t, s);
|
1496
1486
|
maybe_start_some_streams(exec_ctx, t);
|
@@ -1498,7 +1488,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1498
1488
|
grpc_chttp2_cancel_stream(
|
1499
1489
|
exec_ctx, t, s,
|
1500
1490
|
grpc_error_set_int(
|
1501
|
-
|
1491
|
+
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
1492
|
+
"Transport closed", &t->closed_with_error, 1),
|
1502
1493
|
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
|
1503
1494
|
}
|
1504
1495
|
} else {
|
@@ -1512,7 +1503,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1512
1503
|
}
|
1513
1504
|
}
|
1514
1505
|
} else {
|
1515
|
-
s->send_initial_metadata =
|
1506
|
+
s->send_initial_metadata = nullptr;
|
1516
1507
|
grpc_chttp2_complete_closure_step(
|
1517
1508
|
exec_ctx, t, s, &s->send_initial_metadata_finished,
|
1518
1509
|
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
@@ -1521,7 +1512,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1521
1512
|
"send_initial_metadata_finished");
|
1522
1513
|
}
|
1523
1514
|
}
|
1524
|
-
if (op_payload->send_initial_metadata.peer_string !=
|
1515
|
+
if (op_payload->send_initial_metadata.peer_string != nullptr) {
|
1525
1516
|
gpr_atm_rel_store(op_payload->send_initial_metadata.peer_string,
|
1526
1517
|
(gpr_atm)gpr_strdup(t->peer_string));
|
1527
1518
|
}
|
@@ -1548,8 +1539,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1548
1539
|
&s->write_closed_error, 1),
|
1549
1540
|
"fetching_send_message_finished");
|
1550
1541
|
} else {
|
1551
|
-
GPR_ASSERT(s->fetching_send_message ==
|
1552
|
-
uint8_t
|
1542
|
+
GPR_ASSERT(s->fetching_send_message == nullptr);
|
1543
|
+
uint8_t* frame_hdr = grpc_slice_buffer_tiny_add(
|
1553
1544
|
&s->flow_controlled_buffer, GRPC_HEADER_SIZE_IN_BYTES);
|
1554
1545
|
uint32_t flags = op_payload->send_message.send_message->flags;
|
1555
1546
|
frame_hdr[0] = (flags & GRPC_WRITE_INTERNAL_COMPRESS) != 0;
|
@@ -1576,7 +1567,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1576
1567
|
|
1577
1568
|
if (op->send_trailing_metadata) {
|
1578
1569
|
GRPC_STATS_INC_HTTP2_OP_SEND_TRAILING_METADATA(exec_ctx);
|
1579
|
-
GPR_ASSERT(s->send_trailing_metadata_finished ==
|
1570
|
+
GPR_ASSERT(s->send_trailing_metadata_finished == nullptr);
|
1580
1571
|
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
|
1581
1572
|
s->send_trailing_metadata_finished = add_closure_barrier(on_complete);
|
1582
1573
|
s->send_trailing_metadata =
|
@@ -1604,7 +1595,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1604
1595
|
s->seen_error = true;
|
1605
1596
|
}
|
1606
1597
|
if (s->write_closed) {
|
1607
|
-
s->send_trailing_metadata =
|
1598
|
+
s->send_trailing_metadata = nullptr;
|
1608
1599
|
grpc_chttp2_complete_closure_step(
|
1609
1600
|
exec_ctx, t, s, &s->send_trailing_metadata_finished,
|
1610
1601
|
grpc_metadata_batch_is_empty(
|
@@ -1626,14 +1617,14 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1626
1617
|
|
1627
1618
|
if (op->recv_initial_metadata) {
|
1628
1619
|
GRPC_STATS_INC_HTTP2_OP_RECV_INITIAL_METADATA(exec_ctx);
|
1629
|
-
GPR_ASSERT(s->recv_initial_metadata_ready ==
|
1620
|
+
GPR_ASSERT(s->recv_initial_metadata_ready == nullptr);
|
1630
1621
|
s->recv_initial_metadata_ready =
|
1631
1622
|
op_payload->recv_initial_metadata.recv_initial_metadata_ready;
|
1632
1623
|
s->recv_initial_metadata =
|
1633
1624
|
op_payload->recv_initial_metadata.recv_initial_metadata;
|
1634
1625
|
s->trailing_metadata_available =
|
1635
1626
|
op_payload->recv_initial_metadata.trailing_metadata_available;
|
1636
|
-
if (op_payload->recv_initial_metadata.peer_string !=
|
1627
|
+
if (op_payload->recv_initial_metadata.peer_string != nullptr) {
|
1637
1628
|
gpr_atm_rel_store(op_payload->recv_initial_metadata.peer_string,
|
1638
1629
|
(gpr_atm)gpr_strdup(t->peer_string));
|
1639
1630
|
}
|
@@ -1643,20 +1634,17 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1643
1634
|
if (op->recv_message) {
|
1644
1635
|
GRPC_STATS_INC_HTTP2_OP_RECV_MESSAGE(exec_ctx);
|
1645
1636
|
size_t already_received;
|
1646
|
-
GPR_ASSERT(s->recv_message_ready ==
|
1637
|
+
GPR_ASSERT(s->recv_message_ready == nullptr);
|
1647
1638
|
GPR_ASSERT(!s->pending_byte_stream);
|
1648
1639
|
s->recv_message_ready = op_payload->recv_message.recv_message_ready;
|
1649
1640
|
s->recv_message = op_payload->recv_message.recv_message;
|
1650
1641
|
if (s->id != 0) {
|
1651
1642
|
if (!s->read_closed) {
|
1652
1643
|
already_received = s->frame_storage.length;
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
exec_ctx,
|
1658
|
-
grpc_chttp2_flowctl_get_action(&t->flow_control, &s->flow_control),
|
1659
|
-
t, s);
|
1644
|
+
s->flow_control->IncomingByteStreamUpdate(GRPC_HEADER_SIZE_IN_BYTES,
|
1645
|
+
already_received);
|
1646
|
+
grpc_chttp2_act_on_flowctl_action(exec_ctx,
|
1647
|
+
s->flow_control->MakeAction(), t, s);
|
1660
1648
|
}
|
1661
1649
|
}
|
1662
1650
|
grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
|
@@ -1664,7 +1652,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1664
1652
|
|
1665
1653
|
if (op->recv_trailing_metadata) {
|
1666
1654
|
GRPC_STATS_INC_HTTP2_OP_RECV_TRAILING_METADATA(exec_ctx);
|
1667
|
-
GPR_ASSERT(s->recv_trailing_metadata_finished ==
|
1655
|
+
GPR_ASSERT(s->recv_trailing_metadata_finished == nullptr);
|
1668
1656
|
s->recv_trailing_metadata_finished = add_closure_barrier(on_complete);
|
1669
1657
|
s->recv_trailing_metadata =
|
1670
1658
|
op_payload->recv_trailing_metadata.recv_trailing_metadata;
|
@@ -1679,30 +1667,28 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
|
|
1679
1667
|
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "perform_stream_op");
|
1680
1668
|
}
|
1681
1669
|
|
1682
|
-
static void perform_stream_op(grpc_exec_ctx
|
1683
|
-
grpc_stream
|
1684
|
-
grpc_transport_stream_op_batch
|
1670
|
+
static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
1671
|
+
grpc_stream* gs,
|
1672
|
+
grpc_transport_stream_op_batch* op) {
|
1685
1673
|
GPR_TIMER_BEGIN("perform_stream_op", 0);
|
1686
|
-
grpc_chttp2_transport
|
1687
|
-
grpc_chttp2_stream
|
1674
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
1675
|
+
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
|
1688
1676
|
|
1689
1677
|
if (!t->is_client) {
|
1690
1678
|
if (op->send_initial_metadata) {
|
1691
|
-
|
1679
|
+
grpc_millis deadline =
|
1692
1680
|
op->payload->send_initial_metadata.send_initial_metadata->deadline;
|
1693
|
-
GPR_ASSERT(
|
1694
|
-
gpr_time_cmp(gpr_inf_future(deadline.clock_type), deadline));
|
1681
|
+
GPR_ASSERT(deadline == GRPC_MILLIS_INF_FUTURE);
|
1695
1682
|
}
|
1696
1683
|
if (op->send_trailing_metadata) {
|
1697
|
-
|
1684
|
+
grpc_millis deadline =
|
1698
1685
|
op->payload->send_trailing_metadata.send_trailing_metadata->deadline;
|
1699
|
-
GPR_ASSERT(
|
1700
|
-
gpr_time_cmp(gpr_inf_future(deadline.clock_type), deadline));
|
1686
|
+
GPR_ASSERT(deadline == GRPC_MILLIS_INF_FUTURE);
|
1701
1687
|
}
|
1702
1688
|
}
|
1703
1689
|
|
1704
|
-
if (
|
1705
|
-
char
|
1690
|
+
if (grpc_http_trace.enabled()) {
|
1691
|
+
char* str = grpc_transport_stream_op_batch_string(op);
|
1706
1692
|
gpr_log(GPR_DEBUG, "perform_stream_op[s=%p]: %s", s, str);
|
1707
1693
|
gpr_free(str);
|
1708
1694
|
}
|
@@ -1717,37 +1703,37 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
|
1717
1703
|
GPR_TIMER_END("perform_stream_op", 0);
|
1718
1704
|
}
|
1719
1705
|
|
1720
|
-
static void cancel_pings(grpc_exec_ctx
|
1721
|
-
grpc_error
|
1706
|
+
static void cancel_pings(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
1707
|
+
grpc_error* error) {
|
1722
1708
|
/* callback remaining pings: they're not allowed to call into the transpot,
|
1723
1709
|
and maybe they hold resources that need to be freed */
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
}
|
1710
|
+
grpc_chttp2_ping_queue* pq = &t->ping_queue;
|
1711
|
+
GPR_ASSERT(error != GRPC_ERROR_NONE);
|
1712
|
+
for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) {
|
1713
|
+
grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error));
|
1714
|
+
GRPC_CLOSURE_LIST_SCHED(exec_ctx, &pq->lists[j]);
|
1730
1715
|
}
|
1731
1716
|
GRPC_ERROR_UNREF(error);
|
1732
1717
|
}
|
1733
1718
|
|
1734
|
-
static void send_ping_locked(
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1719
|
+
static void send_ping_locked(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
1720
|
+
grpc_closure* on_initiate, grpc_closure* on_ack) {
|
1721
|
+
if (t->closed_with_error != GRPC_ERROR_NONE) {
|
1722
|
+
GRPC_CLOSURE_SCHED(exec_ctx, on_initiate,
|
1723
|
+
GRPC_ERROR_REF(t->closed_with_error));
|
1724
|
+
GRPC_CLOSURE_SCHED(exec_ctx, on_ack, GRPC_ERROR_REF(t->closed_with_error));
|
1725
|
+
return;
|
1726
|
+
}
|
1727
|
+
grpc_chttp2_ping_queue* pq = &t->ping_queue;
|
1740
1728
|
grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_INITIATE], on_initiate,
|
1741
1729
|
GRPC_ERROR_NONE);
|
1742
|
-
|
1743
|
-
|
1744
|
-
grpc_chttp2_initiate_write(exec_ctx, t, initiate_write_reason);
|
1745
|
-
}
|
1730
|
+
grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_NEXT], on_ack,
|
1731
|
+
GRPC_ERROR_NONE);
|
1746
1732
|
}
|
1747
1733
|
|
1748
|
-
static void retry_initiate_ping_locked(grpc_exec_ctx
|
1749
|
-
grpc_error
|
1750
|
-
grpc_chttp2_transport
|
1734
|
+
static void retry_initiate_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
1735
|
+
grpc_error* error) {
|
1736
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
1751
1737
|
t->ping_state.is_delayed_ping_timer_set = false;
|
1752
1738
|
if (error == GRPC_ERROR_NONE) {
|
1753
1739
|
grpc_chttp2_initiate_write(exec_ctx, t,
|
@@ -1755,12 +1741,11 @@ static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
|
|
1755
1741
|
}
|
1756
1742
|
}
|
1757
1743
|
|
1758
|
-
void grpc_chttp2_ack_ping(grpc_exec_ctx
|
1744
|
+
void grpc_chttp2_ack_ping(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
1759
1745
|
uint64_t id) {
|
1760
|
-
grpc_chttp2_ping_queue
|
1761
|
-
&t->ping_queues[id % GRPC_CHTTP2_PING_TYPE_COUNT];
|
1746
|
+
grpc_chttp2_ping_queue* pq = &t->ping_queue;
|
1762
1747
|
if (pq->inflight_id != id) {
|
1763
|
-
char
|
1748
|
+
char* from = grpc_endpoint_get_peer(t->ep);
|
1764
1749
|
gpr_log(GPR_DEBUG, "Unknown ping response from %s: %" PRIx64, from, id);
|
1765
1750
|
gpr_free(from);
|
1766
1751
|
return;
|
@@ -1772,13 +1757,13 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
1772
1757
|
}
|
1773
1758
|
}
|
1774
1759
|
|
1775
|
-
static void send_goaway(grpc_exec_ctx
|
1776
|
-
grpc_error
|
1760
|
+
static void send_goaway(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
1761
|
+
grpc_error* error) {
|
1777
1762
|
t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED;
|
1778
1763
|
grpc_http2_error_code http_error;
|
1779
1764
|
grpc_slice slice;
|
1780
|
-
grpc_error_get_status(error,
|
1781
|
-
&slice, &http_error);
|
1765
|
+
grpc_error_get_status(exec_ctx, error, GRPC_MILLIS_INF_FUTURE, nullptr,
|
1766
|
+
&slice, &http_error, nullptr);
|
1782
1767
|
grpc_chttp2_goaway_append(t->last_new_stream_id, (uint32_t)http_error,
|
1783
1768
|
grpc_slice_ref_internal(slice), &t->qbuf);
|
1784
1769
|
grpc_chttp2_initiate_write(exec_ctx, t,
|
@@ -1786,9 +1771,9 @@ static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
1786
1771
|
GRPC_ERROR_UNREF(error);
|
1787
1772
|
}
|
1788
1773
|
|
1789
|
-
void grpc_chttp2_add_ping_strike(grpc_exec_ctx
|
1790
|
-
grpc_chttp2_transport
|
1791
|
-
|
1774
|
+
void grpc_chttp2_add_ping_strike(grpc_exec_ctx* exec_ctx,
|
1775
|
+
grpc_chttp2_transport* t) {
|
1776
|
+
t->ping_recv_state.ping_strikes++;
|
1792
1777
|
if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes &&
|
1793
1778
|
t->ping_policy.max_ping_strikes != 0) {
|
1794
1779
|
send_goaway(exec_ctx, t,
|
@@ -1797,16 +1782,19 @@ void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
|
|
1797
1782
|
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
|
1798
1783
|
/*The transport will be closed after the write is done */
|
1799
1784
|
close_transport_locked(
|
1800
|
-
exec_ctx, t,
|
1785
|
+
exec_ctx, t,
|
1786
|
+
grpc_error_set_int(
|
1787
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many pings"),
|
1788
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE));
|
1801
1789
|
}
|
1802
1790
|
}
|
1803
1791
|
|
1804
|
-
static void perform_transport_op_locked(grpc_exec_ctx
|
1805
|
-
void
|
1806
|
-
grpc_error
|
1807
|
-
grpc_transport_op
|
1808
|
-
grpc_chttp2_transport
|
1809
|
-
(grpc_chttp2_transport
|
1792
|
+
static void perform_transport_op_locked(grpc_exec_ctx* exec_ctx,
|
1793
|
+
void* stream_op,
|
1794
|
+
grpc_error* error_ignored) {
|
1795
|
+
grpc_transport_op* op = (grpc_transport_op*)stream_op;
|
1796
|
+
grpc_chttp2_transport* t =
|
1797
|
+
(grpc_chttp2_transport*)op->handler_private.extra_arg;
|
1810
1798
|
|
1811
1799
|
if (op->goaway_error) {
|
1812
1800
|
send_goaway(exec_ctx, t, op->goaway_error);
|
@@ -1827,12 +1815,12 @@ static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
|
|
1827
1815
|
}
|
1828
1816
|
|
1829
1817
|
if (op->send_ping) {
|
1830
|
-
send_ping_locked(exec_ctx, t,
|
1831
|
-
|
1832
|
-
|
1818
|
+
send_ping_locked(exec_ctx, t, nullptr, op->send_ping);
|
1819
|
+
grpc_chttp2_initiate_write(exec_ctx, t,
|
1820
|
+
GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING);
|
1833
1821
|
}
|
1834
1822
|
|
1835
|
-
if (op->on_connectivity_state_change !=
|
1823
|
+
if (op->on_connectivity_state_change != nullptr) {
|
1836
1824
|
grpc_connectivity_state_notify_on_state_change(
|
1837
1825
|
exec_ctx, &t->channel_callback.state_tracker, op->connectivity_state,
|
1838
1826
|
op->on_connectivity_state_change);
|
@@ -1847,10 +1835,10 @@ static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
|
|
1847
1835
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "transport_op");
|
1848
1836
|
}
|
1849
1837
|
|
1850
|
-
static void perform_transport_op(grpc_exec_ctx
|
1851
|
-
grpc_transport_op
|
1852
|
-
grpc_chttp2_transport
|
1853
|
-
char
|
1838
|
+
static void perform_transport_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
1839
|
+
grpc_transport_op* op) {
|
1840
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
1841
|
+
char* msg = grpc_transport_op_string(op);
|
1854
1842
|
gpr_free(msg);
|
1855
1843
|
op->handler_private.extra_arg = gt;
|
1856
1844
|
GRPC_CHTTP2_REF_TRANSPORT(t, "transport_op");
|
@@ -1865,10 +1853,10 @@ static void perform_transport_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
|
1865
1853
|
* INPUT PROCESSING - GENERAL
|
1866
1854
|
*/
|
1867
1855
|
|
1868
|
-
void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx
|
1869
|
-
grpc_chttp2_transport
|
1870
|
-
grpc_chttp2_stream
|
1871
|
-
if (s->recv_initial_metadata_ready !=
|
1856
|
+
void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx* exec_ctx,
|
1857
|
+
grpc_chttp2_transport* t,
|
1858
|
+
grpc_chttp2_stream* s) {
|
1859
|
+
if (s->recv_initial_metadata_ready != nullptr &&
|
1872
1860
|
s->published_metadata[0] != GRPC_METADATA_NOT_PUBLISHED) {
|
1873
1861
|
if (s->seen_error) {
|
1874
1862
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
|
@@ -1884,12 +1872,12 @@ void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_exec_ctx *exec_ctx,
|
|
1884
1872
|
}
|
1885
1873
|
}
|
1886
1874
|
|
1887
|
-
void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx
|
1888
|
-
grpc_chttp2_transport
|
1889
|
-
grpc_chttp2_stream
|
1890
|
-
grpc_error
|
1891
|
-
if (s->recv_message_ready !=
|
1892
|
-
*s->recv_message =
|
1875
|
+
void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx* exec_ctx,
|
1876
|
+
grpc_chttp2_transport* t,
|
1877
|
+
grpc_chttp2_stream* s) {
|
1878
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
1879
|
+
if (s->recv_message_ready != nullptr) {
|
1880
|
+
*s->recv_message = nullptr;
|
1893
1881
|
if (s->final_metadata_requested && s->seen_error) {
|
1894
1882
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
|
1895
1883
|
if (!s->pending_byte_stream) {
|
@@ -1905,7 +1893,9 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
|
|
1905
1893
|
&s->frame_storage);
|
1906
1894
|
s->unprocessed_incoming_frames_decompressed = false;
|
1907
1895
|
}
|
1908
|
-
if (!s->unprocessed_incoming_frames_decompressed
|
1896
|
+
if (!s->unprocessed_incoming_frames_decompressed &&
|
1897
|
+
s->stream_decompression_method !=
|
1898
|
+
GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS) {
|
1909
1899
|
GPR_ASSERT(s->decompressed_data_buffer.length == 0);
|
1910
1900
|
bool end_of_context;
|
1911
1901
|
if (!s->stream_decompression_ctx) {
|
@@ -1916,7 +1906,7 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
|
|
1916
1906
|
if (!grpc_stream_decompress(
|
1917
1907
|
s->stream_decompression_ctx,
|
1918
1908
|
&s->unprocessed_incoming_frames_buffer,
|
1919
|
-
&s->decompressed_data_buffer,
|
1909
|
+
&s->decompressed_data_buffer, nullptr,
|
1920
1910
|
GRPC_HEADER_SIZE_IN_BYTES - s->decompressed_header_bytes,
|
1921
1911
|
&end_of_context)) {
|
1922
1912
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx,
|
@@ -1932,17 +1922,17 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
|
|
1932
1922
|
}
|
1933
1923
|
error = grpc_deframe_unprocessed_incoming_frames(
|
1934
1924
|
exec_ctx, &s->data_parser, s, &s->decompressed_data_buffer,
|
1935
|
-
|
1925
|
+
nullptr, s->recv_message);
|
1936
1926
|
if (end_of_context) {
|
1937
1927
|
grpc_stream_compression_context_destroy(
|
1938
1928
|
s->stream_decompression_ctx);
|
1939
|
-
s->stream_decompression_ctx =
|
1929
|
+
s->stream_decompression_ctx = nullptr;
|
1940
1930
|
}
|
1941
1931
|
}
|
1942
1932
|
} else {
|
1943
1933
|
error = grpc_deframe_unprocessed_incoming_frames(
|
1944
1934
|
exec_ctx, &s->data_parser, s,
|
1945
|
-
&s->unprocessed_incoming_frames_buffer,
|
1935
|
+
&s->unprocessed_incoming_frames_buffer, nullptr, s->recv_message);
|
1946
1936
|
}
|
1947
1937
|
if (error != GRPC_ERROR_NONE) {
|
1948
1938
|
s->seen_error = true;
|
@@ -1951,26 +1941,26 @@ void grpc_chttp2_maybe_complete_recv_message(grpc_exec_ctx *exec_ctx,
|
|
1951
1941
|
grpc_slice_buffer_reset_and_unref_internal(
|
1952
1942
|
exec_ctx, &s->unprocessed_incoming_frames_buffer);
|
1953
1943
|
break;
|
1954
|
-
} else if (*s->recv_message !=
|
1944
|
+
} else if (*s->recv_message != nullptr) {
|
1955
1945
|
break;
|
1956
1946
|
}
|
1957
1947
|
}
|
1958
1948
|
}
|
1959
|
-
if (error == GRPC_ERROR_NONE && *s->recv_message !=
|
1949
|
+
if (error == GRPC_ERROR_NONE && *s->recv_message != nullptr) {
|
1960
1950
|
null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
|
1961
1951
|
} else if (s->published_metadata[1] != GRPC_METADATA_NOT_PUBLISHED) {
|
1962
|
-
*s->recv_message =
|
1952
|
+
*s->recv_message = nullptr;
|
1963
1953
|
null_then_run_closure(exec_ctx, &s->recv_message_ready, GRPC_ERROR_NONE);
|
1964
1954
|
}
|
1965
1955
|
GRPC_ERROR_UNREF(error);
|
1966
1956
|
}
|
1967
1957
|
}
|
1968
1958
|
|
1969
|
-
void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx
|
1970
|
-
grpc_chttp2_transport
|
1971
|
-
grpc_chttp2_stream
|
1959
|
+
void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx* exec_ctx,
|
1960
|
+
grpc_chttp2_transport* t,
|
1961
|
+
grpc_chttp2_stream* s) {
|
1972
1962
|
grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s);
|
1973
|
-
if (s->recv_trailing_metadata_finished !=
|
1963
|
+
if (s->recv_trailing_metadata_finished != nullptr && s->read_closed &&
|
1974
1964
|
s->write_closed) {
|
1975
1965
|
if (s->seen_error) {
|
1976
1966
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
|
@@ -1982,7 +1972,7 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
|
|
1982
1972
|
bool pending_data = s->pending_byte_stream ||
|
1983
1973
|
s->unprocessed_incoming_frames_buffer.length > 0;
|
1984
1974
|
if (s->read_closed && s->frame_storage.length > 0 && !pending_data &&
|
1985
|
-
!s->seen_error && s->recv_trailing_metadata_finished !=
|
1975
|
+
!s->seen_error && s->recv_trailing_metadata_finished != nullptr) {
|
1986
1976
|
/* Maybe some SYNC_FLUSH data is left in frame_storage. Consume them and
|
1987
1977
|
* maybe decompress the next 5 bytes in the stream. */
|
1988
1978
|
bool end_of_context;
|
@@ -1990,10 +1980,10 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
|
|
1990
1980
|
s->stream_decompression_ctx = grpc_stream_compression_context_create(
|
1991
1981
|
s->stream_decompression_method);
|
1992
1982
|
}
|
1993
|
-
if (!grpc_stream_decompress(
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1983
|
+
if (!grpc_stream_decompress(
|
1984
|
+
s->stream_decompression_ctx, &s->frame_storage,
|
1985
|
+
&s->unprocessed_incoming_frames_buffer, nullptr,
|
1986
|
+
GRPC_HEADER_SIZE_IN_BYTES, &end_of_context)) {
|
1997
1987
|
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &s->frame_storage);
|
1998
1988
|
grpc_slice_buffer_reset_and_unref_internal(
|
1999
1989
|
exec_ctx, &s->unprocessed_incoming_frames_buffer);
|
@@ -2005,12 +1995,12 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
|
|
2005
1995
|
}
|
2006
1996
|
if (end_of_context) {
|
2007
1997
|
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
|
2008
|
-
s->stream_decompression_ctx =
|
1998
|
+
s->stream_decompression_ctx = nullptr;
|
2009
1999
|
}
|
2010
2000
|
}
|
2011
2001
|
}
|
2012
2002
|
if (s->read_closed && s->frame_storage.length == 0 && !pending_data &&
|
2013
|
-
s->recv_trailing_metadata_finished !=
|
2003
|
+
s->recv_trailing_metadata_finished != nullptr) {
|
2014
2004
|
grpc_chttp2_incoming_metadata_buffer_publish(
|
2015
2005
|
exec_ctx, &s->metadata_buffer[1], s->recv_trailing_metadata);
|
2016
2006
|
grpc_chttp2_complete_closure_step(
|
@@ -2020,24 +2010,24 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
|
|
2020
2010
|
}
|
2021
2011
|
}
|
2022
2012
|
|
2023
|
-
static void remove_stream(grpc_exec_ctx
|
2024
|
-
uint32_t id, grpc_error
|
2025
|
-
grpc_chttp2_stream
|
2026
|
-
(grpc_chttp2_stream
|
2013
|
+
static void remove_stream(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
2014
|
+
uint32_t id, grpc_error* error) {
|
2015
|
+
grpc_chttp2_stream* s =
|
2016
|
+
(grpc_chttp2_stream*)grpc_chttp2_stream_map_delete(&t->stream_map, id);
|
2027
2017
|
GPR_ASSERT(s);
|
2028
2018
|
if (t->incoming_stream == s) {
|
2029
|
-
t->incoming_stream =
|
2019
|
+
t->incoming_stream = nullptr;
|
2030
2020
|
grpc_chttp2_parsing_become_skip_parser(exec_ctx, t);
|
2031
2021
|
}
|
2032
2022
|
if (s->pending_byte_stream) {
|
2033
|
-
if (s->on_next !=
|
2034
|
-
grpc_chttp2_incoming_byte_stream
|
2023
|
+
if (s->on_next != nullptr) {
|
2024
|
+
grpc_chttp2_incoming_byte_stream* bs = s->data_parser.parsing_frame;
|
2035
2025
|
if (error == GRPC_ERROR_NONE) {
|
2036
2026
|
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
|
2037
2027
|
}
|
2038
2028
|
incoming_byte_stream_publish_error(exec_ctx, bs, error);
|
2039
2029
|
incoming_byte_stream_unref(exec_ctx, bs);
|
2040
|
-
s->data_parser.parsing_frame =
|
2030
|
+
s->data_parser.parsing_frame = nullptr;
|
2041
2031
|
} else {
|
2042
2032
|
GRPC_ERROR_UNREF(s->byte_stream_error);
|
2043
2033
|
s->byte_stream_error = GRPC_ERROR_REF(error);
|
@@ -2062,9 +2052,9 @@ static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
2062
2052
|
maybe_start_some_streams(exec_ctx, t);
|
2063
2053
|
}
|
2064
2054
|
|
2065
|
-
void grpc_chttp2_cancel_stream(grpc_exec_ctx
|
2066
|
-
grpc_chttp2_transport
|
2067
|
-
grpc_error
|
2055
|
+
void grpc_chttp2_cancel_stream(grpc_exec_ctx* exec_ctx,
|
2056
|
+
grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
2057
|
+
grpc_error* due_to_error) {
|
2068
2058
|
if (!t->is_client && !s->sent_trailing_metadata &&
|
2069
2059
|
grpc_error_has_clear_grpc_status(due_to_error)) {
|
2070
2060
|
close_from_api(exec_ctx, t, s, due_to_error);
|
@@ -2074,7 +2064,8 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx,
|
|
2074
2064
|
if (!s->read_closed || !s->write_closed) {
|
2075
2065
|
if (s->id != 0) {
|
2076
2066
|
grpc_http2_error_code http_error;
|
2077
|
-
grpc_error_get_status(due_to_error, s->deadline,
|
2067
|
+
grpc_error_get_status(exec_ctx, due_to_error, s->deadline, nullptr,
|
2068
|
+
nullptr, &http_error, nullptr);
|
2078
2069
|
grpc_slice_buffer_add(
|
2079
2070
|
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, (uint32_t)http_error,
|
2080
2071
|
&s->stats.outgoing));
|
@@ -2088,12 +2079,12 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx,
|
|
2088
2079
|
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, 1, 1, due_to_error);
|
2089
2080
|
}
|
2090
2081
|
|
2091
|
-
void grpc_chttp2_fake_status(grpc_exec_ctx
|
2092
|
-
grpc_chttp2_stream
|
2082
|
+
void grpc_chttp2_fake_status(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
2083
|
+
grpc_chttp2_stream* s, grpc_error* error) {
|
2093
2084
|
grpc_status_code status;
|
2094
2085
|
grpc_slice slice;
|
2095
|
-
grpc_error_get_status(error, s->deadline, &status, &slice,
|
2096
|
-
|
2086
|
+
grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, nullptr,
|
2087
|
+
nullptr);
|
2097
2088
|
if (status != GRPC_STATUS_OK) {
|
2098
2089
|
s->seen_error = true;
|
2099
2090
|
}
|
@@ -2104,7 +2095,7 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
2104
2095
|
what we want - which is safe because we haven't told anyone
|
2105
2096
|
about the metadata yet */
|
2106
2097
|
if (s->published_metadata[1] == GRPC_METADATA_NOT_PUBLISHED ||
|
2107
|
-
s->recv_trailing_metadata_finished !=
|
2098
|
+
s->recv_trailing_metadata_finished != nullptr) {
|
2108
2099
|
char status_string[GPR_LTOA_MIN_BUFSIZE];
|
2109
2100
|
gpr_ltoa(status, status_string);
|
2110
2101
|
GRPC_LOG_IF_ERROR("add_status",
|
@@ -2128,7 +2119,7 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
2128
2119
|
GRPC_ERROR_UNREF(error);
|
2129
2120
|
}
|
2130
2121
|
|
2131
|
-
static void add_error(grpc_error
|
2122
|
+
static void add_error(grpc_error* error, grpc_error** refs, size_t* nrefs) {
|
2132
2123
|
if (error == GRPC_ERROR_NONE) return;
|
2133
2124
|
for (size_t i = 0; i < *nrefs; i++) {
|
2134
2125
|
if (error == refs[i]) {
|
@@ -2139,14 +2130,14 @@ static void add_error(grpc_error *error, grpc_error **refs, size_t *nrefs) {
|
|
2139
2130
|
++*nrefs;
|
2140
2131
|
}
|
2141
2132
|
|
2142
|
-
static grpc_error
|
2143
|
-
const char
|
2144
|
-
grpc_error
|
2133
|
+
static grpc_error* removal_error(grpc_error* extra_error, grpc_chttp2_stream* s,
|
2134
|
+
const char* master_error_msg) {
|
2135
|
+
grpc_error* refs[3];
|
2145
2136
|
size_t nrefs = 0;
|
2146
2137
|
add_error(s->read_closed_error, refs, &nrefs);
|
2147
2138
|
add_error(s->write_closed_error, refs, &nrefs);
|
2148
2139
|
add_error(extra_error, refs, &nrefs);
|
2149
|
-
grpc_error
|
2140
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
2150
2141
|
if (nrefs > 0) {
|
2151
2142
|
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(master_error_msg,
|
2152
2143
|
refs, nrefs);
|
@@ -2155,11 +2146,11 @@ static grpc_error *removal_error(grpc_error *extra_error, grpc_chttp2_stream *s,
|
|
2155
2146
|
return error;
|
2156
2147
|
}
|
2157
2148
|
|
2158
|
-
static void flush_write_list(grpc_exec_ctx
|
2159
|
-
grpc_chttp2_stream
|
2160
|
-
grpc_error
|
2149
|
+
static void flush_write_list(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
2150
|
+
grpc_chttp2_stream* s, grpc_chttp2_write_cb** list,
|
2151
|
+
grpc_error* error) {
|
2161
2152
|
while (*list) {
|
2162
|
-
grpc_chttp2_write_cb
|
2153
|
+
grpc_chttp2_write_cb* cb = *list;
|
2163
2154
|
*list = cb->next;
|
2164
2155
|
grpc_chttp2_complete_closure_step(exec_ctx, t, s, &cb->closure,
|
2165
2156
|
GRPC_ERROR_REF(error),
|
@@ -2170,22 +2161,22 @@ static void flush_write_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
2170
2161
|
GRPC_ERROR_UNREF(error);
|
2171
2162
|
}
|
2172
2163
|
|
2173
|
-
void grpc_chttp2_fail_pending_writes(grpc_exec_ctx
|
2174
|
-
grpc_chttp2_transport
|
2175
|
-
grpc_chttp2_stream
|
2164
|
+
void grpc_chttp2_fail_pending_writes(grpc_exec_ctx* exec_ctx,
|
2165
|
+
grpc_chttp2_transport* t,
|
2166
|
+
grpc_chttp2_stream* s, grpc_error* error) {
|
2176
2167
|
error =
|
2177
2168
|
removal_error(error, s, "Pending writes failed due to stream closure");
|
2178
|
-
s->send_initial_metadata =
|
2169
|
+
s->send_initial_metadata = nullptr;
|
2179
2170
|
grpc_chttp2_complete_closure_step(
|
2180
2171
|
exec_ctx, t, s, &s->send_initial_metadata_finished, GRPC_ERROR_REF(error),
|
2181
2172
|
"send_initial_metadata_finished");
|
2182
2173
|
|
2183
|
-
s->send_trailing_metadata =
|
2174
|
+
s->send_trailing_metadata = nullptr;
|
2184
2175
|
grpc_chttp2_complete_closure_step(
|
2185
2176
|
exec_ctx, t, s, &s->send_trailing_metadata_finished,
|
2186
2177
|
GRPC_ERROR_REF(error), "send_trailing_metadata_finished");
|
2187
2178
|
|
2188
|
-
s->fetching_send_message =
|
2179
|
+
s->fetching_send_message = nullptr;
|
2189
2180
|
grpc_chttp2_complete_closure_step(
|
2190
2181
|
exec_ctx, t, s, &s->fetching_send_message_finished, GRPC_ERROR_REF(error),
|
2191
2182
|
"fetching_send_message_finished");
|
@@ -2194,10 +2185,10 @@ void grpc_chttp2_fail_pending_writes(grpc_exec_ctx *exec_ctx,
|
|
2194
2185
|
flush_write_list(exec_ctx, t, s, &s->on_flow_controlled_cbs, error);
|
2195
2186
|
}
|
2196
2187
|
|
2197
|
-
void grpc_chttp2_mark_stream_closed(grpc_exec_ctx
|
2198
|
-
grpc_chttp2_transport
|
2199
|
-
grpc_chttp2_stream
|
2200
|
-
int close_writes, grpc_error
|
2188
|
+
void grpc_chttp2_mark_stream_closed(grpc_exec_ctx* exec_ctx,
|
2189
|
+
grpc_chttp2_transport* t,
|
2190
|
+
grpc_chttp2_stream* s, int close_reads,
|
2191
|
+
int close_writes, grpc_error* error) {
|
2201
2192
|
if (s->read_closed && s->write_closed) {
|
2202
2193
|
/* already closed */
|
2203
2194
|
grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
|
@@ -2218,7 +2209,7 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
|
|
2218
2209
|
}
|
2219
2210
|
if (s->read_closed && s->write_closed) {
|
2220
2211
|
became_closed = true;
|
2221
|
-
grpc_error
|
2212
|
+
grpc_error* overall_error =
|
2222
2213
|
removal_error(GRPC_ERROR_REF(error), s, "Stream removed");
|
2223
2214
|
if (s->id != 0) {
|
2224
2215
|
remove_stream(exec_ctx, t, s->id, GRPC_ERROR_REF(overall_error));
|
@@ -2246,18 +2237,19 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx,
|
|
2246
2237
|
GRPC_ERROR_UNREF(error);
|
2247
2238
|
}
|
2248
2239
|
|
2249
|
-
static void close_from_api(grpc_exec_ctx
|
2250
|
-
grpc_chttp2_stream
|
2240
|
+
static void close_from_api(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
2241
|
+
grpc_chttp2_stream* s, grpc_error* error) {
|
2251
2242
|
grpc_slice hdr;
|
2252
2243
|
grpc_slice status_hdr;
|
2253
2244
|
grpc_slice http_status_hdr;
|
2254
2245
|
grpc_slice content_type_hdr;
|
2255
2246
|
grpc_slice message_pfx;
|
2256
|
-
uint8_t
|
2247
|
+
uint8_t* p;
|
2257
2248
|
uint32_t len = 0;
|
2258
2249
|
grpc_status_code grpc_status;
|
2259
2250
|
grpc_slice slice;
|
2260
|
-
grpc_error_get_status(error, s->deadline, &grpc_status, &slice,
|
2251
|
+
grpc_error_get_status(exec_ctx, error, s->deadline, &grpc_status, &slice,
|
2252
|
+
nullptr, nullptr);
|
2261
2253
|
|
2262
2254
|
GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100);
|
2263
2255
|
|
@@ -2405,20 +2397,20 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
2405
2397
|
}
|
2406
2398
|
|
2407
2399
|
typedef struct {
|
2408
|
-
grpc_exec_ctx
|
2409
|
-
grpc_error
|
2410
|
-
grpc_chttp2_transport
|
2400
|
+
grpc_exec_ctx* exec_ctx;
|
2401
|
+
grpc_error* error;
|
2402
|
+
grpc_chttp2_transport* t;
|
2411
2403
|
} cancel_stream_cb_args;
|
2412
2404
|
|
2413
|
-
static void cancel_stream_cb(void
|
2414
|
-
cancel_stream_cb_args
|
2415
|
-
grpc_chttp2_stream
|
2405
|
+
static void cancel_stream_cb(void* user_data, uint32_t key, void* stream) {
|
2406
|
+
cancel_stream_cb_args* args = (cancel_stream_cb_args*)user_data;
|
2407
|
+
grpc_chttp2_stream* s = (grpc_chttp2_stream*)stream;
|
2416
2408
|
grpc_chttp2_cancel_stream(args->exec_ctx, args->t, s,
|
2417
2409
|
GRPC_ERROR_REF(args->error));
|
2418
2410
|
}
|
2419
2411
|
|
2420
|
-
static void end_all_the_calls(grpc_exec_ctx
|
2421
|
-
grpc_error
|
2412
|
+
static void end_all_the_calls(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
2413
|
+
grpc_error* error) {
|
2422
2414
|
cancel_stream_cb_args args = {exec_ctx, error, t};
|
2423
2415
|
grpc_chttp2_stream_map_for_each(&t->stream_map, cancel_stream_cb, &args);
|
2424
2416
|
GRPC_ERROR_UNREF(error);
|
@@ -2428,73 +2420,60 @@ static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
|
|
2428
2420
|
* INPUT PROCESSING - PARSING
|
2429
2421
|
*/
|
2430
2422
|
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
switch (
|
2436
|
-
case
|
2437
|
-
break;
|
2438
|
-
case GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY:
|
2439
|
-
grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
|
2440
|
-
grpc_chttp2_initiate_write(
|
2441
|
-
exec_ctx, t, GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL);
|
2442
|
-
break;
|
2443
|
-
case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE:
|
2444
|
-
grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
|
2445
|
-
break;
|
2446
|
-
}
|
2447
|
-
switch (action.send_transport_update) {
|
2448
|
-
case GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED:
|
2423
|
+
template <class F>
|
2424
|
+
static void WithUrgency(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
|
2425
|
+
grpc_core::chttp2::FlowControlAction::Urgency urgency,
|
2426
|
+
grpc_chttp2_initiate_write_reason reason, F action) {
|
2427
|
+
switch (urgency) {
|
2428
|
+
case grpc_core::chttp2::FlowControlAction::Urgency::NO_ACTION_NEEDED:
|
2449
2429
|
break;
|
2450
|
-
case
|
2451
|
-
grpc_chttp2_initiate_write(
|
2452
|
-
|
2430
|
+
case grpc_core::chttp2::FlowControlAction::Urgency::UPDATE_IMMEDIATELY:
|
2431
|
+
grpc_chttp2_initiate_write(exec_ctx, t, reason);
|
2432
|
+
// fallthrough
|
2433
|
+
case grpc_core::chttp2::FlowControlAction::Urgency::QUEUE_UPDATE:
|
2434
|
+
action();
|
2453
2435
|
break;
|
2454
|
-
// this is the same as no action b/c every time the transport enters the
|
2455
|
-
// writing path it will maybe do an update
|
2456
|
-
case GRPC_CHTTP2_FLOWCTL_QUEUE_UPDATE:
|
2457
|
-
break;
|
2458
|
-
}
|
2459
|
-
if (action.send_setting_update != GRPC_CHTTP2_FLOWCTL_NO_ACTION_NEEDED) {
|
2460
|
-
if (action.initial_window_size > 0) {
|
2461
|
-
queue_setting_update(exec_ctx, t,
|
2462
|
-
GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
|
2463
|
-
(uint32_t)action.initial_window_size);
|
2464
|
-
}
|
2465
|
-
if (action.max_frame_size > 0) {
|
2466
|
-
queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
|
2467
|
-
(uint32_t)action.max_frame_size);
|
2468
|
-
}
|
2469
|
-
if (action.send_setting_update == GRPC_CHTTP2_FLOWCTL_UPDATE_IMMEDIATELY) {
|
2470
|
-
grpc_chttp2_initiate_write(exec_ctx, t,
|
2471
|
-
GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS);
|
2472
|
-
}
|
2473
|
-
}
|
2474
|
-
if (action.need_ping) {
|
2475
|
-
GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
|
2476
|
-
grpc_bdp_estimator_schedule_ping(&t->flow_control.bdp_estimator);
|
2477
|
-
send_ping_locked(exec_ctx, t,
|
2478
|
-
GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE,
|
2479
|
-
&t->start_bdp_ping_locked, &t->finish_bdp_ping_locked,
|
2480
|
-
GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING);
|
2481
2436
|
}
|
2482
2437
|
}
|
2483
2438
|
|
2484
|
-
|
2485
|
-
|
2439
|
+
void grpc_chttp2_act_on_flowctl_action(
|
2440
|
+
grpc_exec_ctx* exec_ctx, const grpc_core::chttp2::FlowControlAction& action,
|
2441
|
+
grpc_chttp2_transport* t, grpc_chttp2_stream* s) {
|
2442
|
+
WithUrgency(
|
2443
|
+
exec_ctx, t, action.send_stream_update(),
|
2444
|
+
GRPC_CHTTP2_INITIATE_WRITE_STREAM_FLOW_CONTROL,
|
2445
|
+
[exec_ctx, t, s]() { grpc_chttp2_mark_stream_writable(exec_ctx, t, s); });
|
2446
|
+
WithUrgency(exec_ctx, t, action.send_transport_update(),
|
2447
|
+
GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL, []() {});
|
2448
|
+
WithUrgency(exec_ctx, t, action.send_initial_window_update(),
|
2449
|
+
GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS,
|
2450
|
+
[exec_ctx, t, &action]() {
|
2451
|
+
queue_setting_update(exec_ctx, t,
|
2452
|
+
GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
|
2453
|
+
action.initial_window_size());
|
2454
|
+
});
|
2455
|
+
WithUrgency(
|
2456
|
+
exec_ctx, t, action.send_max_frame_size_update(),
|
2457
|
+
GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS, [exec_ctx, t, &action]() {
|
2458
|
+
queue_setting_update(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
|
2459
|
+
action.max_frame_size());
|
2460
|
+
});
|
2461
|
+
}
|
2462
|
+
|
2463
|
+
static grpc_error* try_http_parsing(grpc_exec_ctx* exec_ctx,
|
2464
|
+
grpc_chttp2_transport* t) {
|
2486
2465
|
grpc_http_parser parser;
|
2487
2466
|
size_t i = 0;
|
2488
|
-
grpc_error
|
2467
|
+
grpc_error* error = GRPC_ERROR_NONE;
|
2489
2468
|
grpc_http_response response;
|
2490
2469
|
memset(&response, 0, sizeof(response));
|
2491
2470
|
|
2492
2471
|
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
|
2493
2472
|
|
2494
|
-
grpc_error
|
2473
|
+
grpc_error* parse_error = GRPC_ERROR_NONE;
|
2495
2474
|
for (; i < t->read_buffer.count && parse_error == GRPC_ERROR_NONE; i++) {
|
2496
2475
|
parse_error =
|
2497
|
-
grpc_http_parser_parse(&parser, t->read_buffer.slices[i],
|
2476
|
+
grpc_http_parser_parse(&parser, t->read_buffer.slices[i], nullptr);
|
2498
2477
|
}
|
2499
2478
|
if (parse_error == GRPC_ERROR_NONE &&
|
2500
2479
|
(parse_error = grpc_http_parser_eof(&parser)) == GRPC_ERROR_NONE) {
|
@@ -2511,31 +2490,30 @@ static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx,
|
|
2511
2490
|
return error;
|
2512
2491
|
}
|
2513
2492
|
|
2514
|
-
static void read_action_locked(grpc_exec_ctx
|
2515
|
-
grpc_error
|
2493
|
+
static void read_action_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
2494
|
+
grpc_error* error) {
|
2516
2495
|
GPR_TIMER_BEGIN("reading_action_locked", 0);
|
2517
2496
|
|
2518
|
-
grpc_chttp2_transport
|
2497
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
2519
2498
|
|
2520
2499
|
GRPC_ERROR_REF(error);
|
2521
2500
|
|
2522
|
-
grpc_error
|
2501
|
+
grpc_error* err = error;
|
2523
2502
|
if (err != GRPC_ERROR_NONE) {
|
2524
2503
|
err = grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
2525
2504
|
"Endpoint read failed", &err, 1),
|
2526
2505
|
GRPC_ERROR_INT_OCCURRED_DURING_WRITE,
|
2527
2506
|
t->write_state);
|
2528
2507
|
}
|
2529
|
-
GPR_SWAP(grpc_error
|
2508
|
+
GPR_SWAP(grpc_error*, err, error);
|
2530
2509
|
GRPC_ERROR_UNREF(err);
|
2531
|
-
if (
|
2510
|
+
if (t->closed_with_error == GRPC_ERROR_NONE) {
|
2532
2511
|
GPR_TIMER_BEGIN("reading_action.parse", 0);
|
2533
2512
|
size_t i = 0;
|
2534
|
-
grpc_error
|
2513
|
+
grpc_error* errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE,
|
2535
2514
|
GRPC_ERROR_NONE};
|
2536
2515
|
for (; i < t->read_buffer.count && errors[1] == GRPC_ERROR_NONE; i++) {
|
2537
|
-
|
2538
|
-
&t->flow_control.bdp_estimator,
|
2516
|
+
t->flow_control->bdp_estimator()->AddIncomingBytes(
|
2539
2517
|
(int64_t)GRPC_SLICE_LENGTH(t->read_buffer.slices[i]));
|
2540
2518
|
errors[1] =
|
2541
2519
|
grpc_chttp2_perform_read(exec_ctx, t, t->read_buffer.slices[i]);
|
@@ -2552,9 +2530,9 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
|
|
2552
2530
|
GPR_TIMER_END("reading_action.parse", 0);
|
2553
2531
|
|
2554
2532
|
GPR_TIMER_BEGIN("post_parse_locked", 0);
|
2555
|
-
if (t->
|
2556
|
-
if (t->
|
2557
|
-
grpc_chttp2_stream
|
2533
|
+
if (t->initial_window_update != 0) {
|
2534
|
+
if (t->initial_window_update > 0) {
|
2535
|
+
grpc_chttp2_stream* s;
|
2558
2536
|
while (grpc_chttp2_list_pop_stalled_by_stream(t, &s)) {
|
2559
2537
|
grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
|
2560
2538
|
grpc_chttp2_initiate_write(
|
@@ -2562,20 +2540,27 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
|
|
2562
2540
|
GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING);
|
2563
2541
|
}
|
2564
2542
|
}
|
2565
|
-
t->
|
2543
|
+
t->initial_window_update = 0;
|
2566
2544
|
}
|
2567
2545
|
GPR_TIMER_END("post_parse_locked", 0);
|
2568
2546
|
}
|
2569
2547
|
|
2570
2548
|
GPR_TIMER_BEGIN("post_reading_action_locked", 0);
|
2571
2549
|
bool keep_reading = false;
|
2572
|
-
if (error == GRPC_ERROR_NONE && t->
|
2573
|
-
error =
|
2550
|
+
if (error == GRPC_ERROR_NONE && t->closed_with_error != GRPC_ERROR_NONE) {
|
2551
|
+
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
|
2552
|
+
"Transport closed", &t->closed_with_error, 1);
|
2574
2553
|
}
|
2575
2554
|
if (error != GRPC_ERROR_NONE) {
|
2555
|
+
/* If a goaway frame was received, this might be the reason why the read
|
2556
|
+
* failed. Add this info to the error */
|
2557
|
+
if (t->goaway_error != GRPC_ERROR_NONE) {
|
2558
|
+
error = grpc_error_add_child(error, GRPC_ERROR_REF(t->goaway_error));
|
2559
|
+
}
|
2560
|
+
|
2576
2561
|
close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
|
2577
2562
|
t->endpoint_reading = 0;
|
2578
|
-
} else if (
|
2563
|
+
} else if (t->closed_with_error == GRPC_ERROR_NONE) {
|
2579
2564
|
keep_reading = true;
|
2580
2565
|
GRPC_CHTTP2_REF_TRANSPORT(t, "keep_reading");
|
2581
2566
|
}
|
@@ -2584,9 +2569,8 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
|
|
2584
2569
|
if (keep_reading) {
|
2585
2570
|
grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer,
|
2586
2571
|
&t->read_action_locked);
|
2587
|
-
grpc_chttp2_act_on_flowctl_action(
|
2588
|
-
|
2589
|
-
NULL);
|
2572
|
+
grpc_chttp2_act_on_flowctl_action(exec_ctx, t->flow_control->MakeAction(),
|
2573
|
+
t, nullptr);
|
2590
2574
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading");
|
2591
2575
|
} else {
|
2592
2576
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "reading_action");
|
@@ -2599,40 +2583,70 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
|
|
2599
2583
|
GPR_TIMER_END("reading_action_locked", 0);
|
2600
2584
|
}
|
2601
2585
|
|
2602
|
-
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2586
|
+
// t is reffed prior to calling the first time, and once the callback chain
|
2587
|
+
// that kicks off finishes, it's unreffed
|
2588
|
+
static void schedule_bdp_ping_locked(grpc_exec_ctx* exec_ctx,
|
2589
|
+
grpc_chttp2_transport* t) {
|
2590
|
+
t->flow_control->bdp_estimator()->SchedulePing();
|
2591
|
+
send_ping_locked(exec_ctx, t, &t->start_bdp_ping_locked,
|
2592
|
+
&t->finish_bdp_ping_locked);
|
2593
|
+
}
|
2594
|
+
|
2595
|
+
static void start_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
2596
|
+
grpc_error* error) {
|
2597
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
2598
|
+
if (grpc_http_trace.enabled()) {
|
2599
|
+
gpr_log(GPR_DEBUG, "%s: Start BDP ping err=%s", t->peer_string,
|
2600
|
+
grpc_error_string(error));
|
2607
2601
|
}
|
2608
2602
|
/* Reset the keepalive ping timer */
|
2609
2603
|
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) {
|
2610
2604
|
grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer);
|
2611
2605
|
}
|
2612
|
-
|
2606
|
+
t->flow_control->bdp_estimator()->StartPing();
|
2613
2607
|
}
|
2614
2608
|
|
2615
|
-
static void finish_bdp_ping_locked(grpc_exec_ctx
|
2616
|
-
grpc_error
|
2617
|
-
grpc_chttp2_transport
|
2618
|
-
if (
|
2619
|
-
gpr_log(GPR_DEBUG, "%s: Complete BDP ping", t->peer_string
|
2609
|
+
static void finish_bdp_ping_locked(grpc_exec_ctx* exec_ctx, void* tp,
|
2610
|
+
grpc_error* error) {
|
2611
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
2612
|
+
if (grpc_http_trace.enabled()) {
|
2613
|
+
gpr_log(GPR_DEBUG, "%s: Complete BDP ping err=%s", t->peer_string,
|
2614
|
+
grpc_error_string(error));
|
2620
2615
|
}
|
2621
|
-
|
2622
|
-
|
2623
|
-
|
2616
|
+
if (error != GRPC_ERROR_NONE) {
|
2617
|
+
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping");
|
2618
|
+
return;
|
2619
|
+
}
|
2620
|
+
grpc_millis next_ping =
|
2621
|
+
t->flow_control->bdp_estimator()->CompletePing(exec_ctx);
|
2622
|
+
grpc_chttp2_act_on_flowctl_action(
|
2623
|
+
exec_ctx, t->flow_control->PeriodicUpdate(exec_ctx), t, nullptr);
|
2624
|
+
GPR_ASSERT(!t->have_next_bdp_ping_timer);
|
2625
|
+
t->have_next_bdp_ping_timer = true;
|
2626
|
+
grpc_timer_init(exec_ctx, &t->next_bdp_ping_timer, next_ping,
|
2627
|
+
&t->next_bdp_ping_timer_expired_locked);
|
2628
|
+
}
|
2629
|
+
|
2630
|
+
static void next_bdp_ping_timer_expired_locked(grpc_exec_ctx* exec_ctx,
|
2631
|
+
void* tp, grpc_error* error) {
|
2632
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
2633
|
+
GPR_ASSERT(t->have_next_bdp_ping_timer);
|
2634
|
+
t->have_next_bdp_ping_timer = false;
|
2635
|
+
if (error != GRPC_ERROR_NONE) {
|
2636
|
+
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping");
|
2637
|
+
return;
|
2638
|
+
}
|
2639
|
+
schedule_bdp_ping_locked(exec_ctx, t);
|
2624
2640
|
}
|
2625
2641
|
|
2626
|
-
void grpc_chttp2_config_default_keepalive_args(grpc_channel_args
|
2642
|
+
void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
|
2627
2643
|
bool is_client) {
|
2628
2644
|
size_t i;
|
2629
2645
|
if (args) {
|
2630
2646
|
for (i = 0; i < args->num_args; i++) {
|
2631
2647
|
if (0 == strcmp(args->args[i].key, GRPC_ARG_KEEPALIVE_TIME_MS)) {
|
2632
2648
|
const int value = grpc_channel_arg_get_integer(
|
2633
|
-
&args->args[i],
|
2634
|
-
(grpc_integer_options){g_default_client_keepalive_time_ms, 1,
|
2635
|
-
INT_MAX});
|
2649
|
+
&args->args[i], {g_default_client_keepalive_time_ms, 1, INT_MAX});
|
2636
2650
|
if (is_client) {
|
2637
2651
|
g_default_client_keepalive_time_ms = value;
|
2638
2652
|
} else {
|
@@ -2642,8 +2656,7 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
|
|
2642
2656
|
strcmp(args->args[i].key, GRPC_ARG_KEEPALIVE_TIMEOUT_MS)) {
|
2643
2657
|
const int value = grpc_channel_arg_get_integer(
|
2644
2658
|
&args->args[i],
|
2645
|
-
|
2646
|
-
INT_MAX});
|
2659
|
+
{g_default_client_keepalive_timeout_ms, 0, INT_MAX});
|
2647
2660
|
if (is_client) {
|
2648
2661
|
g_default_client_keepalive_timeout_ms = value;
|
2649
2662
|
} else {
|
@@ -2654,18 +2667,15 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
|
|
2654
2667
|
g_default_keepalive_permit_without_calls =
|
2655
2668
|
(uint32_t)grpc_channel_arg_get_integer(
|
2656
2669
|
&args->args[i],
|
2657
|
-
|
2658
|
-
0, 1});
|
2670
|
+
{g_default_keepalive_permit_without_calls, 0, 1});
|
2659
2671
|
} else if (0 ==
|
2660
2672
|
strcmp(args->args[i].key, GRPC_ARG_HTTP2_MAX_PING_STRIKES)) {
|
2661
2673
|
g_default_max_ping_strikes = grpc_channel_arg_get_integer(
|
2662
|
-
&args->args[i],
|
2663
|
-
(grpc_integer_options){g_default_max_ping_strikes, 0, INT_MAX});
|
2674
|
+
&args->args[i], {g_default_max_ping_strikes, 0, INT_MAX});
|
2664
2675
|
} else if (0 == strcmp(args->args[i].key,
|
2665
2676
|
GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA)) {
|
2666
2677
|
g_default_max_pings_without_data = grpc_channel_arg_get_integer(
|
2667
|
-
&args->args[i],
|
2668
|
-
g_default_max_pings_without_data, 0, INT_MAX});
|
2678
|
+
&args->args[i], {g_default_max_pings_without_data, 0, INT_MAX});
|
2669
2679
|
} else if (0 ==
|
2670
2680
|
strcmp(
|
2671
2681
|
args->args[i].key,
|
@@ -2673,9 +2683,7 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
|
|
2673
2683
|
g_default_min_sent_ping_interval_without_data_ms =
|
2674
2684
|
grpc_channel_arg_get_integer(
|
2675
2685
|
&args->args[i],
|
2676
|
-
|
2677
|
-
g_default_min_sent_ping_interval_without_data_ms, 0,
|
2678
|
-
INT_MAX});
|
2686
|
+
{g_default_min_sent_ping_interval_without_data_ms, 0, INT_MAX});
|
2679
2687
|
} else if (0 ==
|
2680
2688
|
strcmp(
|
2681
2689
|
args->args[i].key,
|
@@ -2683,82 +2691,79 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
|
|
2683
2691
|
g_default_min_recv_ping_interval_without_data_ms =
|
2684
2692
|
grpc_channel_arg_get_integer(
|
2685
2693
|
&args->args[i],
|
2686
|
-
|
2687
|
-
g_default_min_recv_ping_interval_without_data_ms, 0,
|
2688
|
-
INT_MAX});
|
2694
|
+
{g_default_min_recv_ping_interval_without_data_ms, 0, INT_MAX});
|
2689
2695
|
}
|
2690
2696
|
}
|
2691
2697
|
}
|
2692
2698
|
}
|
2693
2699
|
|
2694
|
-
static void init_keepalive_ping_locked(grpc_exec_ctx
|
2695
|
-
grpc_error
|
2696
|
-
grpc_chttp2_transport
|
2700
|
+
static void init_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
2701
|
+
grpc_error* error) {
|
2702
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
2697
2703
|
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
|
2698
|
-
if (t->destroying || t->
|
2704
|
+
if (t->destroying || t->closed_with_error != GRPC_ERROR_NONE) {
|
2699
2705
|
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
|
2700
2706
|
} else if (error == GRPC_ERROR_NONE) {
|
2701
2707
|
if (t->keepalive_permit_without_calls ||
|
2702
2708
|
grpc_chttp2_stream_map_size(&t->stream_map) > 0) {
|
2703
2709
|
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING;
|
2704
2710
|
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive ping end");
|
2705
|
-
send_ping_locked(exec_ctx, t,
|
2706
|
-
&t->
|
2707
|
-
|
2708
|
-
|
2711
|
+
send_ping_locked(exec_ctx, t, &t->start_keepalive_ping_locked,
|
2712
|
+
&t->finish_keepalive_ping_locked);
|
2713
|
+
grpc_chttp2_initiate_write(exec_ctx, t,
|
2714
|
+
GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING);
|
2709
2715
|
} else {
|
2710
2716
|
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
|
2711
|
-
grpc_timer_init(
|
2712
|
-
|
2713
|
-
|
2714
|
-
&t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
|
2717
|
+
grpc_timer_init(exec_ctx, &t->keepalive_ping_timer,
|
2718
|
+
grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
|
2719
|
+
&t->init_keepalive_ping_locked);
|
2715
2720
|
}
|
2716
2721
|
} else if (error == GRPC_ERROR_CANCELLED) {
|
2717
2722
|
/* The keepalive ping timer may be cancelled by bdp */
|
2718
2723
|
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
|
2719
|
-
grpc_timer_init(
|
2720
|
-
|
2721
|
-
|
2722
|
-
&t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
|
2724
|
+
grpc_timer_init(exec_ctx, &t->keepalive_ping_timer,
|
2725
|
+
grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
|
2726
|
+
&t->init_keepalive_ping_locked);
|
2723
2727
|
}
|
2724
2728
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "init keepalive ping");
|
2725
2729
|
}
|
2726
2730
|
|
2727
|
-
static void start_keepalive_ping_locked(grpc_exec_ctx
|
2728
|
-
grpc_error
|
2729
|
-
grpc_chttp2_transport
|
2731
|
+
static void start_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
2732
|
+
grpc_error* error) {
|
2733
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
2730
2734
|
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog");
|
2731
|
-
grpc_timer_init(
|
2732
|
-
|
2733
|
-
|
2734
|
-
&t->keepalive_watchdog_fired_locked, gpr_now(GPR_CLOCK_MONOTONIC));
|
2735
|
+
grpc_timer_init(exec_ctx, &t->keepalive_watchdog_timer,
|
2736
|
+
grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
|
2737
|
+
&t->keepalive_watchdog_fired_locked);
|
2735
2738
|
}
|
2736
2739
|
|
2737
|
-
static void finish_keepalive_ping_locked(grpc_exec_ctx
|
2738
|
-
grpc_error
|
2739
|
-
grpc_chttp2_transport
|
2740
|
+
static void finish_keepalive_ping_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
2741
|
+
grpc_error* error) {
|
2742
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
2740
2743
|
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
|
2741
2744
|
if (error == GRPC_ERROR_NONE) {
|
2742
2745
|
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
|
2743
2746
|
grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer);
|
2744
2747
|
GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping");
|
2745
|
-
grpc_timer_init(
|
2746
|
-
|
2747
|
-
|
2748
|
-
&t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC));
|
2748
|
+
grpc_timer_init(exec_ctx, &t->keepalive_ping_timer,
|
2749
|
+
grpc_exec_ctx_now(exec_ctx) + t->keepalive_time,
|
2750
|
+
&t->init_keepalive_ping_locked);
|
2749
2751
|
}
|
2750
2752
|
}
|
2751
2753
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keepalive ping end");
|
2752
2754
|
}
|
2753
2755
|
|
2754
|
-
static void keepalive_watchdog_fired_locked(grpc_exec_ctx
|
2755
|
-
grpc_error
|
2756
|
-
grpc_chttp2_transport
|
2756
|
+
static void keepalive_watchdog_fired_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
2757
|
+
grpc_error* error) {
|
2758
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
2757
2759
|
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
|
2758
2760
|
if (error == GRPC_ERROR_NONE) {
|
2759
2761
|
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
|
2760
|
-
close_transport_locked(
|
2761
|
-
|
2762
|
+
close_transport_locked(
|
2763
|
+
exec_ctx, t,
|
2764
|
+
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
2765
|
+
"keepalive watchdog timeout"),
|
2766
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL));
|
2762
2767
|
}
|
2763
2768
|
} else {
|
2764
2769
|
/* The watchdog timer should have been cancelled by
|
@@ -2775,10 +2780,10 @@ static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
|
2775
2780
|
* CALLBACK LOOP
|
2776
2781
|
*/
|
2777
2782
|
|
2778
|
-
static void connectivity_state_set(grpc_exec_ctx
|
2779
|
-
grpc_chttp2_transport
|
2783
|
+
static void connectivity_state_set(grpc_exec_ctx* exec_ctx,
|
2784
|
+
grpc_chttp2_transport* t,
|
2780
2785
|
grpc_connectivity_state state,
|
2781
|
-
grpc_error
|
2786
|
+
grpc_error* error, const char* reason) {
|
2782
2787
|
GRPC_CHTTP2_IF_TRACING(
|
2783
2788
|
gpr_log(GPR_DEBUG, "set connectivity_state=%d", state));
|
2784
2789
|
grpc_connectivity_state_set(exec_ctx, &t->channel_callback.state_tracker,
|
@@ -2789,15 +2794,15 @@ static void connectivity_state_set(grpc_exec_ctx *exec_ctx,
|
|
2789
2794
|
* POLLSET STUFF
|
2790
2795
|
*/
|
2791
2796
|
|
2792
|
-
static void set_pollset(grpc_exec_ctx
|
2793
|
-
grpc_stream
|
2794
|
-
grpc_chttp2_transport
|
2797
|
+
static void set_pollset(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
2798
|
+
grpc_stream* gs, grpc_pollset* pollset) {
|
2799
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
2795
2800
|
grpc_endpoint_add_to_pollset(exec_ctx, t->ep, pollset);
|
2796
2801
|
}
|
2797
2802
|
|
2798
|
-
static void set_pollset_set(grpc_exec_ctx
|
2799
|
-
grpc_stream
|
2800
|
-
grpc_chttp2_transport
|
2803
|
+
static void set_pollset_set(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
|
2804
|
+
grpc_stream* gs, grpc_pollset_set* pollset_set) {
|
2805
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
2801
2806
|
grpc_endpoint_add_to_pollset_set(exec_ctx, t->ep, pollset_set);
|
2802
2807
|
}
|
2803
2808
|
|
@@ -2805,9 +2810,9 @@ static void set_pollset_set(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
|
|
2805
2810
|
* BYTE STREAM
|
2806
2811
|
*/
|
2807
2812
|
|
2808
|
-
static void reset_byte_stream(grpc_exec_ctx
|
2809
|
-
grpc_error
|
2810
|
-
grpc_chttp2_stream
|
2813
|
+
static void reset_byte_stream(grpc_exec_ctx* exec_ctx, void* arg,
|
2814
|
+
grpc_error* error) {
|
2815
|
+
grpc_chttp2_stream* s = (grpc_chttp2_stream*)arg;
|
2811
2816
|
|
2812
2817
|
s->pending_byte_stream = false;
|
2813
2818
|
if (error == GRPC_ERROR_NONE) {
|
@@ -2816,7 +2821,7 @@ static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg,
|
|
2816
2821
|
} else {
|
2817
2822
|
GPR_ASSERT(error != GRPC_ERROR_NONE);
|
2818
2823
|
GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
|
2819
|
-
s->on_next =
|
2824
|
+
s->on_next = nullptr;
|
2820
2825
|
GRPC_ERROR_UNREF(s->byte_stream_error);
|
2821
2826
|
s->byte_stream_error = GRPC_ERROR_NONE;
|
2822
2827
|
grpc_chttp2_cancel_stream(exec_ctx, s->t, s, GRPC_ERROR_REF(error));
|
@@ -2824,30 +2829,27 @@ static void reset_byte_stream(grpc_exec_ctx *exec_ctx, void *arg,
|
|
2824
2829
|
}
|
2825
2830
|
}
|
2826
2831
|
|
2827
|
-
static void incoming_byte_stream_unref(grpc_exec_ctx
|
2828
|
-
grpc_chttp2_incoming_byte_stream
|
2832
|
+
static void incoming_byte_stream_unref(grpc_exec_ctx* exec_ctx,
|
2833
|
+
grpc_chttp2_incoming_byte_stream* bs) {
|
2829
2834
|
if (gpr_unref(&bs->refs)) {
|
2830
2835
|
gpr_free(bs);
|
2831
2836
|
}
|
2832
2837
|
}
|
2833
2838
|
|
2834
|
-
static void incoming_byte_stream_next_locked(grpc_exec_ctx
|
2835
|
-
void
|
2836
|
-
grpc_error
|
2837
|
-
grpc_chttp2_incoming_byte_stream
|
2838
|
-
(grpc_chttp2_incoming_byte_stream
|
2839
|
-
grpc_chttp2_transport
|
2840
|
-
grpc_chttp2_stream
|
2839
|
+
static void incoming_byte_stream_next_locked(grpc_exec_ctx* exec_ctx,
|
2840
|
+
void* argp,
|
2841
|
+
grpc_error* error_ignored) {
|
2842
|
+
grpc_chttp2_incoming_byte_stream* bs =
|
2843
|
+
(grpc_chttp2_incoming_byte_stream*)argp;
|
2844
|
+
grpc_chttp2_transport* t = bs->transport;
|
2845
|
+
grpc_chttp2_stream* s = bs->stream;
|
2841
2846
|
|
2842
2847
|
size_t cur_length = s->frame_storage.length;
|
2843
2848
|
if (!s->read_closed) {
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
exec_ctx,
|
2849
|
-
grpc_chttp2_flowctl_get_action(&t->flow_control, &s->flow_control), t,
|
2850
|
-
s);
|
2849
|
+
s->flow_control->IncomingByteStreamUpdate(bs->next_action.max_size_hint,
|
2850
|
+
cur_length);
|
2851
|
+
grpc_chttp2_act_on_flowctl_action(exec_ctx, s->flow_control->MakeAction(),
|
2852
|
+
t, s);
|
2851
2853
|
}
|
2852
2854
|
GPR_ASSERT(s->unprocessed_incoming_frames_buffer.length == 0);
|
2853
2855
|
if (s->frame_storage.length > 0) {
|
@@ -2858,9 +2860,9 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
|
|
2858
2860
|
} else if (s->byte_stream_error != GRPC_ERROR_NONE) {
|
2859
2861
|
GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
|
2860
2862
|
GRPC_ERROR_REF(s->byte_stream_error));
|
2861
|
-
if (s->data_parser.parsing_frame !=
|
2863
|
+
if (s->data_parser.parsing_frame != nullptr) {
|
2862
2864
|
incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
|
2863
|
-
s->data_parser.parsing_frame =
|
2865
|
+
s->data_parser.parsing_frame = nullptr;
|
2864
2866
|
}
|
2865
2867
|
} else if (s->read_closed) {
|
2866
2868
|
if (bs->remaining_bytes != 0) {
|
@@ -2868,9 +2870,9 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
|
|
2868
2870
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
|
2869
2871
|
GRPC_CLOSURE_SCHED(exec_ctx, bs->next_action.on_complete,
|
2870
2872
|
GRPC_ERROR_REF(s->byte_stream_error));
|
2871
|
-
if (s->data_parser.parsing_frame !=
|
2873
|
+
if (s->data_parser.parsing_frame != nullptr) {
|
2872
2874
|
incoming_byte_stream_unref(exec_ctx, s->data_parser.parsing_frame);
|
2873
|
-
s->data_parser.parsing_frame =
|
2875
|
+
s->data_parser.parsing_frame = nullptr;
|
2874
2876
|
}
|
2875
2877
|
} else {
|
2876
2878
|
/* Should never reach here. */
|
@@ -2882,14 +2884,14 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
|
|
2882
2884
|
incoming_byte_stream_unref(exec_ctx, bs);
|
2883
2885
|
}
|
2884
2886
|
|
2885
|
-
static bool incoming_byte_stream_next(grpc_exec_ctx
|
2886
|
-
grpc_byte_stream
|
2887
|
+
static bool incoming_byte_stream_next(grpc_exec_ctx* exec_ctx,
|
2888
|
+
grpc_byte_stream* byte_stream,
|
2887
2889
|
size_t max_size_hint,
|
2888
|
-
grpc_closure
|
2890
|
+
grpc_closure* on_complete) {
|
2889
2891
|
GPR_TIMER_BEGIN("incoming_byte_stream_next", 0);
|
2890
|
-
grpc_chttp2_incoming_byte_stream
|
2891
|
-
(grpc_chttp2_incoming_byte_stream
|
2892
|
-
grpc_chttp2_stream
|
2892
|
+
grpc_chttp2_incoming_byte_stream* bs =
|
2893
|
+
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
2894
|
+
grpc_chttp2_stream* s = bs->stream;
|
2893
2895
|
if (s->unprocessed_incoming_frames_buffer.length > 0) {
|
2894
2896
|
GPR_TIMER_END("incoming_byte_stream_next", 0);
|
2895
2897
|
return true;
|
@@ -2908,14 +2910,14 @@ static bool incoming_byte_stream_next(grpc_exec_ctx *exec_ctx,
|
|
2908
2910
|
}
|
2909
2911
|
}
|
2910
2912
|
|
2911
|
-
static grpc_error
|
2912
|
-
grpc_byte_stream
|
2913
|
-
grpc_slice
|
2913
|
+
static grpc_error* incoming_byte_stream_pull(grpc_exec_ctx* exec_ctx,
|
2914
|
+
grpc_byte_stream* byte_stream,
|
2915
|
+
grpc_slice* slice) {
|
2914
2916
|
GPR_TIMER_BEGIN("incoming_byte_stream_pull", 0);
|
2915
|
-
grpc_chttp2_incoming_byte_stream
|
2916
|
-
(grpc_chttp2_incoming_byte_stream
|
2917
|
-
grpc_chttp2_stream
|
2918
|
-
grpc_error
|
2917
|
+
grpc_chttp2_incoming_byte_stream* bs =
|
2918
|
+
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
2919
|
+
grpc_chttp2_stream* s = bs->stream;
|
2920
|
+
grpc_error* error;
|
2919
2921
|
|
2920
2922
|
if (s->unprocessed_incoming_frames_buffer.length > 0) {
|
2921
2923
|
if (!s->unprocessed_incoming_frames_decompressed) {
|
@@ -2926,7 +2928,7 @@ static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
|
|
2926
2928
|
}
|
2927
2929
|
if (!grpc_stream_decompress(s->stream_decompression_ctx,
|
2928
2930
|
&s->unprocessed_incoming_frames_buffer,
|
2929
|
-
&s->decompressed_data_buffer,
|
2931
|
+
&s->decompressed_data_buffer, nullptr,
|
2930
2932
|
MAX_SIZE_T, &end_of_context)) {
|
2931
2933
|
error =
|
2932
2934
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Stream decompression error.");
|
@@ -2938,7 +2940,7 @@ static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
|
|
2938
2940
|
s->unprocessed_incoming_frames_decompressed = true;
|
2939
2941
|
if (end_of_context) {
|
2940
2942
|
grpc_stream_compression_context_destroy(s->stream_decompression_ctx);
|
2941
|
-
s->stream_decompression_ctx =
|
2943
|
+
s->stream_decompression_ctx = nullptr;
|
2942
2944
|
}
|
2943
2945
|
if (s->unprocessed_incoming_frames_buffer.length == 0) {
|
2944
2946
|
*slice = grpc_empty_slice();
|
@@ -2946,7 +2948,7 @@ static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
|
|
2946
2948
|
}
|
2947
2949
|
error = grpc_deframe_unprocessed_incoming_frames(
|
2948
2950
|
exec_ctx, &s->data_parser, s, &s->unprocessed_incoming_frames_buffer,
|
2949
|
-
slice,
|
2951
|
+
slice, nullptr);
|
2950
2952
|
if (error != GRPC_ERROR_NONE) {
|
2951
2953
|
return error;
|
2952
2954
|
}
|
@@ -2959,44 +2961,45 @@ static grpc_error *incoming_byte_stream_pull(grpc_exec_ctx *exec_ctx,
|
|
2959
2961
|
return GRPC_ERROR_NONE;
|
2960
2962
|
}
|
2961
2963
|
|
2962
|
-
static void incoming_byte_stream_destroy_locked(grpc_exec_ctx
|
2963
|
-
void
|
2964
|
-
grpc_error
|
2964
|
+
static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
|
2965
|
+
void* byte_stream,
|
2966
|
+
grpc_error* error_ignored);
|
2965
2967
|
|
2966
|
-
static void incoming_byte_stream_destroy(grpc_exec_ctx
|
2967
|
-
grpc_byte_stream
|
2968
|
+
static void incoming_byte_stream_destroy(grpc_exec_ctx* exec_ctx,
|
2969
|
+
grpc_byte_stream* byte_stream) {
|
2968
2970
|
GPR_TIMER_BEGIN("incoming_byte_stream_destroy", 0);
|
2969
|
-
grpc_chttp2_incoming_byte_stream
|
2970
|
-
(grpc_chttp2_incoming_byte_stream
|
2971
|
+
grpc_chttp2_incoming_byte_stream* bs =
|
2972
|
+
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
2971
2973
|
GRPC_CLOSURE_SCHED(
|
2972
|
-
exec_ctx,
|
2973
|
-
|
2974
|
-
|
2974
|
+
exec_ctx,
|
2975
|
+
GRPC_CLOSURE_INIT(&bs->destroy_action,
|
2976
|
+
incoming_byte_stream_destroy_locked, bs,
|
2977
|
+
grpc_combiner_scheduler(bs->transport->combiner)),
|
2975
2978
|
GRPC_ERROR_NONE);
|
2976
2979
|
GPR_TIMER_END("incoming_byte_stream_destroy", 0);
|
2977
2980
|
}
|
2978
2981
|
|
2979
2982
|
static void incoming_byte_stream_publish_error(
|
2980
|
-
grpc_exec_ctx
|
2981
|
-
grpc_error
|
2982
|
-
grpc_chttp2_stream
|
2983
|
+
grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
|
2984
|
+
grpc_error* error) {
|
2985
|
+
grpc_chttp2_stream* s = bs->stream;
|
2983
2986
|
|
2984
2987
|
GPR_ASSERT(error != GRPC_ERROR_NONE);
|
2985
2988
|
GRPC_CLOSURE_SCHED(exec_ctx, s->on_next, GRPC_ERROR_REF(error));
|
2986
|
-
s->on_next =
|
2989
|
+
s->on_next = nullptr;
|
2987
2990
|
GRPC_ERROR_UNREF(s->byte_stream_error);
|
2988
2991
|
s->byte_stream_error = GRPC_ERROR_REF(error);
|
2989
2992
|
grpc_chttp2_cancel_stream(exec_ctx, bs->transport, bs->stream,
|
2990
2993
|
GRPC_ERROR_REF(error));
|
2991
2994
|
}
|
2992
2995
|
|
2993
|
-
grpc_error
|
2994
|
-
grpc_exec_ctx
|
2995
|
-
grpc_slice slice, grpc_slice
|
2996
|
-
grpc_chttp2_stream
|
2996
|
+
grpc_error* grpc_chttp2_incoming_byte_stream_push(
|
2997
|
+
grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
|
2998
|
+
grpc_slice slice, grpc_slice* slice_out) {
|
2999
|
+
grpc_chttp2_stream* s = bs->stream;
|
2997
3000
|
|
2998
3001
|
if (bs->remaining_bytes < GRPC_SLICE_LENGTH(slice)) {
|
2999
|
-
grpc_error
|
3002
|
+
grpc_error* error =
|
3000
3003
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Too many bytes in stream");
|
3001
3004
|
|
3002
3005
|
GRPC_CLOSURE_SCHED(exec_ctx, &s->reset_byte_stream, GRPC_ERROR_REF(error));
|
@@ -3004,17 +3007,17 @@ grpc_error *grpc_chttp2_incoming_byte_stream_push(
|
|
3004
3007
|
return error;
|
3005
3008
|
} else {
|
3006
3009
|
bs->remaining_bytes -= (uint32_t)GRPC_SLICE_LENGTH(slice);
|
3007
|
-
if (slice_out !=
|
3010
|
+
if (slice_out != nullptr) {
|
3008
3011
|
*slice_out = slice;
|
3009
3012
|
}
|
3010
3013
|
return GRPC_ERROR_NONE;
|
3011
3014
|
}
|
3012
3015
|
}
|
3013
3016
|
|
3014
|
-
grpc_error
|
3015
|
-
grpc_exec_ctx
|
3016
|
-
grpc_error
|
3017
|
-
grpc_chttp2_stream
|
3017
|
+
grpc_error* grpc_chttp2_incoming_byte_stream_finished(
|
3018
|
+
grpc_exec_ctx* exec_ctx, grpc_chttp2_incoming_byte_stream* bs,
|
3019
|
+
grpc_error* error, bool reset_on_error) {
|
3020
|
+
grpc_chttp2_stream* s = bs->stream;
|
3018
3021
|
|
3019
3022
|
if (error == GRPC_ERROR_NONE) {
|
3020
3023
|
if (bs->remaining_bytes != 0) {
|
@@ -3028,11 +3031,11 @@ grpc_error *grpc_chttp2_incoming_byte_stream_finished(
|
|
3028
3031
|
return error;
|
3029
3032
|
}
|
3030
3033
|
|
3031
|
-
static void incoming_byte_stream_shutdown(grpc_exec_ctx
|
3032
|
-
grpc_byte_stream
|
3033
|
-
grpc_error
|
3034
|
-
grpc_chttp2_incoming_byte_stream
|
3035
|
-
(grpc_chttp2_incoming_byte_stream
|
3034
|
+
static void incoming_byte_stream_shutdown(grpc_exec_ctx* exec_ctx,
|
3035
|
+
grpc_byte_stream* byte_stream,
|
3036
|
+
grpc_error* error) {
|
3037
|
+
grpc_chttp2_incoming_byte_stream* bs =
|
3038
|
+
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
3036
3039
|
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
|
3037
3040
|
exec_ctx, bs, error, true /* reset_on_error */));
|
3038
3041
|
}
|
@@ -3041,13 +3044,13 @@ static const grpc_byte_stream_vtable grpc_chttp2_incoming_byte_stream_vtable = {
|
|
3041
3044
|
incoming_byte_stream_next, incoming_byte_stream_pull,
|
3042
3045
|
incoming_byte_stream_shutdown, incoming_byte_stream_destroy};
|
3043
3046
|
|
3044
|
-
static void incoming_byte_stream_destroy_locked(grpc_exec_ctx
|
3045
|
-
void
|
3046
|
-
grpc_error
|
3047
|
-
grpc_chttp2_incoming_byte_stream
|
3048
|
-
(grpc_chttp2_incoming_byte_stream
|
3049
|
-
grpc_chttp2_stream
|
3050
|
-
grpc_chttp2_transport
|
3047
|
+
static void incoming_byte_stream_destroy_locked(grpc_exec_ctx* exec_ctx,
|
3048
|
+
void* byte_stream,
|
3049
|
+
grpc_error* error_ignored) {
|
3050
|
+
grpc_chttp2_incoming_byte_stream* bs =
|
3051
|
+
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
3052
|
+
grpc_chttp2_stream* s = bs->stream;
|
3053
|
+
grpc_chttp2_transport* t = s->t;
|
3051
3054
|
|
3052
3055
|
GPR_ASSERT(bs->base.vtable == &grpc_chttp2_incoming_byte_stream_vtable);
|
3053
3056
|
incoming_byte_stream_unref(exec_ctx, bs);
|
@@ -3056,11 +3059,11 @@ static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
|
|
3056
3059
|
grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s);
|
3057
3060
|
}
|
3058
3061
|
|
3059
|
-
grpc_chttp2_incoming_byte_stream
|
3060
|
-
grpc_exec_ctx
|
3062
|
+
grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
|
3063
|
+
grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
3061
3064
|
uint32_t frame_size, uint32_t flags) {
|
3062
|
-
grpc_chttp2_incoming_byte_stream
|
3063
|
-
(grpc_chttp2_incoming_byte_stream
|
3065
|
+
grpc_chttp2_incoming_byte_stream* incoming_byte_stream =
|
3066
|
+
(grpc_chttp2_incoming_byte_stream*)gpr_malloc(
|
3064
3067
|
sizeof(*incoming_byte_stream));
|
3065
3068
|
incoming_byte_stream->base.length = frame_size;
|
3066
3069
|
incoming_byte_stream->remaining_bytes = frame_size;
|
@@ -3078,8 +3081,8 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create(
|
|
3078
3081
|
* RESOURCE QUOTAS
|
3079
3082
|
*/
|
3080
3083
|
|
3081
|
-
static void post_benign_reclaimer(grpc_exec_ctx
|
3082
|
-
grpc_chttp2_transport
|
3084
|
+
static void post_benign_reclaimer(grpc_exec_ctx* exec_ctx,
|
3085
|
+
grpc_chttp2_transport* t) {
|
3083
3086
|
if (!t->benign_reclaimer_registered) {
|
3084
3087
|
t->benign_reclaimer_registered = true;
|
3085
3088
|
GRPC_CHTTP2_REF_TRANSPORT(t, "benign_reclaimer");
|
@@ -3089,8 +3092,8 @@ static void post_benign_reclaimer(grpc_exec_ctx *exec_ctx,
|
|
3089
3092
|
}
|
3090
3093
|
}
|
3091
3094
|
|
3092
|
-
static void post_destructive_reclaimer(grpc_exec_ctx
|
3093
|
-
grpc_chttp2_transport
|
3095
|
+
static void post_destructive_reclaimer(grpc_exec_ctx* exec_ctx,
|
3096
|
+
grpc_chttp2_transport* t) {
|
3094
3097
|
if (!t->destructive_reclaimer_registered) {
|
3095
3098
|
t->destructive_reclaimer_registered = true;
|
3096
3099
|
GRPC_CHTTP2_REF_TRANSPORT(t, "destructive_reclaimer");
|
@@ -3100,14 +3103,14 @@ static void post_destructive_reclaimer(grpc_exec_ctx *exec_ctx,
|
|
3100
3103
|
}
|
3101
3104
|
}
|
3102
3105
|
|
3103
|
-
static void benign_reclaimer_locked(grpc_exec_ctx
|
3104
|
-
grpc_error
|
3105
|
-
grpc_chttp2_transport
|
3106
|
+
static void benign_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
3107
|
+
grpc_error* error) {
|
3108
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
3106
3109
|
if (error == GRPC_ERROR_NONE &&
|
3107
3110
|
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
|
3108
3111
|
/* Channel with no active streams: send a goaway to try and make it
|
3109
3112
|
* disconnect cleanly */
|
3110
|
-
if (
|
3113
|
+
if (grpc_resource_quota_trace.enabled()) {
|
3111
3114
|
gpr_log(GPR_DEBUG, "HTTP2: %s - send goaway to free memory",
|
3112
3115
|
t->peer_string);
|
3113
3116
|
}
|
@@ -3115,8 +3118,7 @@ static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
|
3115
3118
|
grpc_error_set_int(
|
3116
3119
|
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"),
|
3117
3120
|
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM));
|
3118
|
-
} else if (error == GRPC_ERROR_NONE &&
|
3119
|
-
GRPC_TRACER_ON(grpc_resource_quota_trace)) {
|
3121
|
+
} else if (error == GRPC_ERROR_NONE && grpc_resource_quota_trace.enabled()) {
|
3120
3122
|
gpr_log(GPR_DEBUG,
|
3121
3123
|
"HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR
|
3122
3124
|
" streams",
|
@@ -3130,15 +3132,15 @@ static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
|
3130
3132
|
GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "benign_reclaimer");
|
3131
3133
|
}
|
3132
3134
|
|
3133
|
-
static void destructive_reclaimer_locked(grpc_exec_ctx
|
3134
|
-
grpc_error
|
3135
|
-
grpc_chttp2_transport
|
3135
|
+
static void destructive_reclaimer_locked(grpc_exec_ctx* exec_ctx, void* arg,
|
3136
|
+
grpc_error* error) {
|
3137
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
3136
3138
|
size_t n = grpc_chttp2_stream_map_size(&t->stream_map);
|
3137
3139
|
t->destructive_reclaimer_registered = false;
|
3138
3140
|
if (error == GRPC_ERROR_NONE && n > 0) {
|
3139
|
-
grpc_chttp2_stream
|
3140
|
-
(grpc_chttp2_stream
|
3141
|
-
if (
|
3141
|
+
grpc_chttp2_stream* s =
|
3142
|
+
(grpc_chttp2_stream*)grpc_chttp2_stream_map_rand(&t->stream_map);
|
3143
|
+
if (grpc_resource_quota_trace.enabled()) {
|
3142
3144
|
gpr_log(GPR_DEBUG, "HTTP2: %s - abandon stream id %d", t->peer_string,
|
3143
3145
|
s->id);
|
3144
3146
|
}
|
@@ -3166,7 +3168,7 @@ static void destructive_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
|
|
3166
3168
|
* MONITORING
|
3167
3169
|
*/
|
3168
3170
|
|
3169
|
-
const char
|
3171
|
+
const char* grpc_chttp2_initiate_write_reason_string(
|
3170
3172
|
grpc_chttp2_initiate_write_reason reason) {
|
3171
3173
|
switch (reason) {
|
3172
3174
|
case GRPC_CHTTP2_INITIATE_WRITE_INITIAL_WRITE:
|
@@ -3195,8 +3197,6 @@ const char *grpc_chttp2_initiate_write_reason_string(
|
|
3195
3197
|
return "TRANSPORT_FLOW_CONTROL";
|
3196
3198
|
case GRPC_CHTTP2_INITIATE_WRITE_SEND_SETTINGS:
|
3197
3199
|
return "SEND_SETTINGS";
|
3198
|
-
case GRPC_CHTTP2_INITIATE_WRITE_BDP_ESTIMATOR_PING:
|
3199
|
-
return "BDP_ESTIMATOR_PING";
|
3200
3200
|
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING:
|
3201
3201
|
return "FLOW_CONTROL_UNSTALLED_BY_SETTING";
|
3202
3202
|
case GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE:
|
@@ -3215,9 +3215,9 @@ const char *grpc_chttp2_initiate_write_reason_string(
|
|
3215
3215
|
GPR_UNREACHABLE_CODE(return "unknown");
|
3216
3216
|
}
|
3217
3217
|
|
3218
|
-
static grpc_endpoint
|
3219
|
-
grpc_transport
|
3220
|
-
return ((grpc_chttp2_transport
|
3218
|
+
static grpc_endpoint* chttp2_get_endpoint(grpc_exec_ctx* exec_ctx,
|
3219
|
+
grpc_transport* t) {
|
3220
|
+
return ((grpc_chttp2_transport*)t)->ep;
|
3221
3221
|
}
|
3222
3222
|
|
3223
3223
|
static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
|
@@ -3231,24 +3231,24 @@ static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
|
|
3231
3231
|
destroy_transport,
|
3232
3232
|
chttp2_get_endpoint};
|
3233
3233
|
|
3234
|
-
static const grpc_transport_vtable
|
3234
|
+
static const grpc_transport_vtable* get_vtable(void) { return &vtable; }
|
3235
3235
|
|
3236
|
-
grpc_transport
|
3237
|
-
grpc_exec_ctx
|
3238
|
-
grpc_endpoint
|
3239
|
-
grpc_chttp2_transport
|
3240
|
-
(grpc_chttp2_transport
|
3236
|
+
grpc_transport* grpc_create_chttp2_transport(
|
3237
|
+
grpc_exec_ctx* exec_ctx, const grpc_channel_args* channel_args,
|
3238
|
+
grpc_endpoint* ep, bool is_client) {
|
3239
|
+
grpc_chttp2_transport* t =
|
3240
|
+
(grpc_chttp2_transport*)gpr_zalloc(sizeof(grpc_chttp2_transport));
|
3241
3241
|
init_transport(exec_ctx, t, channel_args, ep, is_client);
|
3242
3242
|
return &t->base;
|
3243
3243
|
}
|
3244
3244
|
|
3245
3245
|
void grpc_chttp2_transport_start_reading(
|
3246
|
-
grpc_exec_ctx
|
3247
|
-
grpc_slice_buffer
|
3248
|
-
grpc_chttp2_transport
|
3246
|
+
grpc_exec_ctx* exec_ctx, grpc_transport* transport,
|
3247
|
+
grpc_slice_buffer* read_buffer, grpc_closure* notify_on_receive_settings) {
|
3248
|
+
grpc_chttp2_transport* t = (grpc_chttp2_transport*)transport;
|
3249
3249
|
GRPC_CHTTP2_REF_TRANSPORT(
|
3250
3250
|
t, "reading_action"); /* matches unref inside reading_action */
|
3251
|
-
if (read_buffer !=
|
3251
|
+
if (read_buffer != nullptr) {
|
3252
3252
|
grpc_slice_buffer_move_into(read_buffer, &t->read_buffer);
|
3253
3253
|
gpr_free(read_buffer);
|
3254
3254
|
}
|