grpc 1.6.7 → 1.7.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +579 -77
- data/include/grpc/byte_buffer.h +1 -63
- data/include/grpc/compression.h +27 -5
- data/include/grpc/fork.h +24 -0
- data/include/grpc/grpc.h +12 -6
- data/include/grpc/grpc_security.h +28 -7
- data/include/grpc/impl/codegen/atm.h +1 -0
- data/include/grpc/impl/codegen/byte_buffer.h +86 -0
- data/include/grpc/impl/codegen/compression_types.h +63 -5
- data/include/grpc/impl/codegen/fork.h +48 -0
- data/include/grpc/impl/codegen/grpc_types.h +26 -9
- data/include/grpc/impl/codegen/port_platform.h +11 -4
- data/include/grpc/impl/codegen/slice.h +6 -1
- data/include/grpc/impl/codegen/sync.h +3 -1
- data/include/grpc/impl/codegen/sync_custom.h +36 -0
- data/include/grpc/module.modulemap +75 -3
- data/include/grpc/slice.h +1 -5
- data/include/grpc/support/sync_custom.h +24 -0
- data/src/core/ext/census/base_resources.c +14 -14
- data/src/core/ext/census/context.c +7 -5
- data/src/core/ext/census/grpc_filter.c +12 -14
- data/src/core/ext/census/mlog.c +2 -1
- data/src/core/ext/census/resource.c +13 -9
- data/src/core/ext/filters/client_channel/channel_connectivity.c +15 -8
- data/src/core/ext/filters/client_channel/client_channel.c +418 -439
- data/src/core/ext/filters/client_channel/client_channel_factory.c +4 -5
- data/src/core/ext/filters/client_channel/client_channel_plugin.c +2 -2
- data/src/core/ext/filters/client_channel/http_connect_handshaker.c +7 -5
- data/src/core/ext/filters/client_channel/http_proxy.c +17 -21
- data/src/core/ext/filters/client_channel/lb_policy.c +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c +7 -7
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +371 -257
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c +7 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +25 -14
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +33 -28
- data/src/core/ext/filters/client_channel/lb_policy_factory.c +10 -8
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -1
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.c +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +7 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +62 -28
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +29 -23
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +25 -14
- data/src/core/ext/filters/client_channel/retry_throttle.c +9 -6
- data/src/core/ext/filters/client_channel/subchannel.c +30 -30
- data/src/core/ext/filters/client_channel/subchannel.h +1 -4
- data/src/core/ext/filters/client_channel/subchannel_index.c +31 -15
- data/src/core/ext/filters/client_channel/subchannel_index.h +7 -0
- data/src/core/ext/filters/client_channel/uri_parser.c +4 -3
- data/src/core/ext/filters/deadline/deadline_filter.c +78 -39
- data/src/core/ext/filters/deadline/deadline_filter.h +7 -1
- data/src/core/ext/filters/http/client/http_client_filter.c +14 -14
- data/src/core/ext/filters/http/http_filters_plugin.c +1 -1
- data/src/core/ext/filters/http/message_compress/message_compress_filter.c +240 -175
- data/src/core/ext/filters/http/server/http_server_filter.c +48 -36
- data/src/core/ext/filters/load_reporting/{load_reporting_filter.c → server_load_reporting_filter.c} +11 -12
- data/src/core/ext/filters/load_reporting/{load_reporting_filter.h → server_load_reporting_filter.h} +6 -5
- data/src/core/ext/filters/load_reporting/{load_reporting.c → server_load_reporting_plugin.c} +19 -13
- data/src/core/ext/filters/load_reporting/{load_reporting.h → server_load_reporting_plugin.h} +4 -3
- data/src/core/ext/filters/max_age/max_age_filter.c +2 -3
- data/src/core/ext/filters/message_size/message_size_filter.c +4 -2
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +0 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +5 -5
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +20 -18
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +1 -0
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +493 -210
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.c +9 -8
- data/src/core/ext/transport/chttp2/transport/frame_data.c +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +10 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +9 -5
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +62 -41
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +52 -8
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +3 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +60 -30
- data/src/core/ext/transport/chttp2/transport/parsing.c +16 -5
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +36 -16
- data/src/core/ext/transport/chttp2/transport/stream_map.c +6 -4
- data/src/core/ext/transport/chttp2/transport/writing.c +133 -105
- data/src/core/ext/transport/inproc/inproc_transport.c +61 -65
- data/src/core/lib/channel/channel_args.c +112 -12
- data/src/core/lib/channel/channel_args.h +31 -0
- data/src/core/lib/channel/channel_stack.c +1 -15
- data/src/core/lib/channel/channel_stack.h +3 -10
- data/src/core/lib/channel/channel_stack_builder.c +41 -10
- data/src/core/lib/channel/channel_stack_builder.h +10 -0
- data/src/core/lib/channel/connected_channel.c +94 -23
- data/src/core/lib/channel/handshaker.c +8 -6
- data/src/core/lib/channel/handshaker_registry.c +1 -1
- data/src/core/lib/compression/algorithm_metadata.h +14 -0
- data/src/core/lib/compression/compression.c +101 -1
- data/src/core/lib/compression/stream_compression.c +32 -146
- data/src/core/lib/compression/stream_compression.h +28 -4
- data/src/core/lib/compression/stream_compression_gzip.c +228 -0
- data/src/core/lib/{iomgr/ev_epoll_thread_pool_linux.h → compression/stream_compression_gzip.h} +5 -7
- data/src/core/lib/compression/stream_compression_identity.c +94 -0
- data/src/core/lib/{iomgr/ev_epoll_limited_pollers_linux.h → compression/stream_compression_identity.h} +7 -8
- data/src/core/lib/debug/stats.c +174 -0
- data/src/core/lib/debug/stats.h +61 -0
- data/src/core/lib/debug/stats_data.c +687 -0
- data/src/core/lib/debug/stats_data.h +470 -0
- data/src/core/lib/debug/trace.c +3 -3
- data/src/core/lib/debug/trace.h +1 -1
- data/src/core/lib/http/format_request.c +1 -1
- data/src/core/lib/http/httpcli.c +8 -7
- data/src/core/lib/http/httpcli_security_connector.c +2 -1
- data/src/core/lib/http/parser.c +4 -3
- data/src/core/lib/iomgr/call_combiner.c +202 -0
- data/src/core/lib/iomgr/call_combiner.h +121 -0
- data/src/core/lib/iomgr/closure.c +18 -4
- data/src/core/lib/iomgr/combiner.c +11 -4
- data/src/core/lib/iomgr/error.c +26 -24
- data/src/core/lib/iomgr/ev_epoll1_linux.c +395 -212
- data/src/core/lib/iomgr/ev_epollex_linux.c +141 -128
- data/src/core/lib/iomgr/ev_epollsig_linux.c +44 -41
- data/src/core/lib/iomgr/ev_poll_posix.c +99 -75
- data/src/core/lib/iomgr/ev_posix.c +5 -9
- data/src/core/lib/iomgr/ev_posix.h +1 -1
- data/src/core/lib/iomgr/exec_ctx.h +6 -1
- data/src/core/lib/iomgr/executor.c +142 -36
- data/src/core/lib/iomgr/executor.h +6 -1
- data/src/core/lib/iomgr/fork_posix.c +88 -0
- data/src/core/lib/iomgr/fork_windows.c +39 -0
- data/src/core/lib/iomgr/iocp_windows.c +2 -0
- data/src/core/lib/iomgr/iomgr.c +2 -8
- data/src/core/lib/iomgr/is_epollexclusive_available.c +6 -6
- data/src/core/lib/iomgr/load_file.c +2 -1
- data/src/core/lib/iomgr/polling_entity.c +9 -9
- data/src/core/lib/iomgr/polling_entity.h +7 -1
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_uv.c +1 -1
- data/src/core/lib/iomgr/pollset_windows.c +3 -3
- data/src/core/lib/iomgr/port.h +4 -0
- data/src/core/lib/iomgr/resolve_address_posix.c +8 -7
- data/src/core/lib/iomgr/resolve_address_windows.c +1 -1
- data/src/core/lib/iomgr/resource_quota.c +24 -19
- data/src/core/lib/iomgr/socket_factory_posix.c +4 -4
- data/src/core/lib/iomgr/socket_mutator.c +4 -4
- data/src/core/lib/iomgr/socket_utils_windows.c +0 -4
- data/src/core/lib/iomgr/tcp_client_posix.c +5 -4
- data/src/core/lib/iomgr/tcp_posix.c +181 -20
- data/src/core/lib/iomgr/tcp_server_posix.c +8 -7
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +1 -1
- data/src/core/lib/iomgr/timer.h +4 -0
- data/src/core/lib/iomgr/timer_generic.c +138 -3
- data/src/core/lib/iomgr/timer_generic.h +3 -0
- data/src/core/lib/iomgr/timer_heap.c +4 -4
- data/src/core/lib/iomgr/timer_manager.c +2 -2
- data/src/core/lib/iomgr/timer_uv.c +2 -0
- data/src/core/lib/iomgr/udp_server.c +10 -8
- data/src/core/lib/iomgr/unix_sockets_posix.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_cv.c +9 -8
- data/src/core/lib/iomgr/wakeup_fd_cv.h +2 -2
- data/src/core/lib/json/json.c +1 -1
- data/src/core/lib/json/json_string.c +13 -13
- data/src/core/lib/profiling/timers.h +18 -8
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -10
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +11 -6
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +4 -4
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +132 -50
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
- data/src/core/lib/security/transport/client_auth_filter.c +68 -135
- data/src/core/lib/security/transport/secure_endpoint.c +110 -90
- data/src/core/lib/security/transport/secure_endpoint.h +8 -3
- data/src/core/lib/security/transport/security_connector.c +10 -12
- data/src/core/lib/security/transport/security_handshaker.c +45 -24
- data/src/core/lib/security/transport/server_auth_filter.c +71 -20
- data/src/core/lib/slice/b64.c +2 -2
- data/src/core/lib/slice/slice.c +16 -14
- data/src/core/lib/slice/slice_buffer.c +5 -4
- data/src/core/lib/slice/slice_hash_table.c +3 -2
- data/src/core/lib/slice/slice_intern.c +8 -5
- data/src/core/lib/support/block_annotate.h +22 -0
- data/src/core/lib/support/fork.c +62 -0
- data/src/core/lib/support/fork.h +35 -0
- data/src/core/lib/support/log_linux.c +1 -1
- data/src/core/lib/support/string.c +15 -1
- data/src/core/lib/support/string.h +3 -0
- data/src/core/lib/support/thd_internal.h +6 -0
- data/src/core/lib/support/thd_posix.c +56 -0
- data/src/core/lib/support/thd_windows.c +2 -0
- data/src/core/lib/surface/alarm.c +22 -15
- data/src/core/lib/surface/byte_buffer.c +4 -2
- data/src/core/lib/surface/call.c +442 -141
- data/src/core/lib/surface/call.h +6 -6
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/call_test_only.h +12 -0
- data/src/core/lib/surface/channel.c +39 -4
- data/src/core/lib/surface/channel_init.c +6 -6
- data/src/core/lib/surface/channel_ping.c +2 -2
- data/src/core/lib/surface/completion_queue.c +56 -57
- data/src/core/lib/surface/init.c +17 -3
- data/src/core/lib/surface/init_secure.c +5 -1
- data/src/core/lib/surface/lame_client.cc +9 -10
- data/src/core/lib/surface/server.c +81 -72
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/byte_stream.c +1 -0
- data/src/core/lib/transport/byte_stream.h +3 -1
- data/src/core/lib/transport/connectivity_state.c +2 -1
- data/src/core/lib/transport/metadata.c +7 -4
- data/src/core/lib/transport/metadata_batch.c +18 -16
- data/src/core/lib/transport/metadata_batch.h +1 -0
- data/src/core/lib/transport/service_config.c +5 -3
- data/src/core/lib/transport/static_metadata.c +395 -614
- data/src/core/lib/transport/static_metadata.h +165 -133
- data/src/core/lib/transport/status_conversion.c +1 -1
- data/src/core/lib/transport/transport.c +20 -20
- data/src/core/lib/transport/transport.h +8 -5
- data/src/core/lib/transport/transport_impl.h +0 -3
- data/src/core/lib/transport/transport_op_string.c +8 -1
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -4
- data/src/core/tsi/fake_transport_security.c +133 -2
- data/src/core/tsi/fake_transport_security.h +5 -0
- data/src/core/tsi/ssl_transport_security.c +105 -8
- data/src/core/tsi/ssl_transport_security.h +30 -7
- data/src/core/tsi/transport_security.h +8 -2
- data/src/core/tsi/transport_security_grpc.c +20 -13
- data/src/core/tsi/transport_security_grpc.h +13 -9
- data/src/ruby/ext/grpc/rb_call_credentials.c +6 -2
- data/src/ruby/ext/grpc/rb_grpc.c +1 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +30 -20
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +50 -35
- data/src/ruby/lib/grpc.rb +1 -0
- data/src/ruby/lib/grpc/generic/active_call.rb +34 -9
- data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -10
- data/src/ruby/lib/grpc/generic/client_stub.rb +95 -38
- data/src/ruby/lib/grpc/generic/interceptor_registry.rb +53 -0
- data/src/ruby/lib/grpc/generic/interceptors.rb +186 -0
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +66 -20
- data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -3
- data/src/ruby/lib/grpc/google_rpc_status_utils.rb +1 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +1 -0
- data/src/ruby/spec/channel_connection_spec.rb +1 -34
- data/src/ruby/spec/client_server_spec.rb +188 -82
- data/src/ruby/spec/generic/active_call_spec.rb +65 -11
- data/src/ruby/spec/generic/client_interceptors_spec.rb +153 -0
- data/src/ruby/spec/generic/interceptor_registry_spec.rb +65 -0
- data/src/ruby/spec/generic/rpc_desc_spec.rb +38 -0
- data/src/ruby/spec/generic/rpc_server_spec.rb +1 -34
- data/src/ruby/spec/generic/server_interceptors_spec.rb +218 -0
- data/src/ruby/spec/spec_helper.rb +4 -0
- data/src/ruby/spec/support/helpers.rb +73 -0
- data/src/ruby/spec/support/services.rb +147 -0
- data/third_party/cares/ares_build.h +21 -62
- data/third_party/cares/cares/ares.h +23 -1
- data/third_party/cares/cares/ares__close_sockets.c +2 -2
- data/third_party/cares/cares/ares_create_query.c +3 -3
- data/third_party/cares/cares/ares_expand_name.c +6 -2
- data/third_party/cares/cares/ares_expand_string.c +1 -1
- data/third_party/cares/cares/ares_getnameinfo.c +27 -7
- data/third_party/cares/cares/ares_init.c +407 -39
- data/third_party/cares/cares/ares_library_init.c +10 -0
- data/third_party/cares/cares/ares_library_init.h +2 -1
- data/third_party/cares/cares/ares_nowarn.c +6 -6
- data/third_party/cares/cares/ares_nowarn.h +2 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +6 -1
- data/third_party/cares/cares/ares_private.h +11 -0
- data/third_party/cares/cares/ares_process.c +126 -37
- data/third_party/cares/cares/ares_version.h +2 -2
- data/third_party/cares/cares/ares_writev.c +2 -2
- data/third_party/cares/cares/config-win32.h +8 -34
- data/third_party/cares/cares/inet_net_pton.c +2 -2
- data/third_party/cares/cares/setup_once.h +5 -5
- data/third_party/cares/config_darwin/ares_config.h +98 -196
- data/third_party/cares/config_linux/ares_config.h +103 -203
- metadata +47 -20
- data/src/core/lib/iomgr/ev_epoll_limited_pollers_linux.c +0 -1957
- data/src/core/lib/iomgr/ev_epoll_thread_pool_linux.c +0 -1182
@@ -18,6 +18,7 @@
|
|
18
18
|
|
19
19
|
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
20
20
|
|
21
|
+
#include <limits.h>
|
21
22
|
#include <math.h>
|
22
23
|
#include <string.h>
|
23
24
|
|
@@ -59,24 +60,24 @@ static void pretrace(shadow_flow_control* shadow_fc,
|
|
59
60
|
|
60
61
|
#define TRACE_PADDING 30
|
61
62
|
|
62
|
-
static char* fmt_int64_diff_str(int64_t
|
63
|
+
static char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) {
|
63
64
|
char* str;
|
64
|
-
if (
|
65
|
-
gpr_asprintf(&str, "%" PRId64 " -> %" PRId64 "",
|
65
|
+
if (old_val != new_val) {
|
66
|
+
gpr_asprintf(&str, "%" PRId64 " -> %" PRId64 "", old_val, new_val);
|
66
67
|
} else {
|
67
|
-
gpr_asprintf(&str, "%" PRId64 "",
|
68
|
+
gpr_asprintf(&str, "%" PRId64 "", old_val);
|
68
69
|
}
|
69
70
|
char* str_lp = gpr_leftpad(str, ' ', TRACE_PADDING);
|
70
71
|
gpr_free(str);
|
71
72
|
return str_lp;
|
72
73
|
}
|
73
74
|
|
74
|
-
static char* fmt_uint32_diff_str(uint32_t
|
75
|
+
static char* fmt_uint32_diff_str(uint32_t old_val, uint32_t new_val) {
|
75
76
|
char* str;
|
76
|
-
if (
|
77
|
-
gpr_asprintf(&str, "%" PRIu32 " -> %" PRIu32 "",
|
77
|
+
if (new_val > 0 && old_val != new_val) {
|
78
|
+
gpr_asprintf(&str, "%" PRIu32 " -> %" PRIu32 "", old_val, new_val);
|
78
79
|
} else {
|
79
|
-
gpr_asprintf(&str, "%" PRIu32 "",
|
80
|
+
gpr_asprintf(&str, "%" PRIu32 "", old_val);
|
80
81
|
}
|
81
82
|
char* str_lp = gpr_leftpad(str, ' ', TRACE_PADDING);
|
82
83
|
gpr_free(str);
|
@@ -210,7 +210,7 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
|
|
210
210
|
|
211
211
|
if (cur != end) {
|
212
212
|
grpc_slice_buffer_undo_take_first(
|
213
|
-
|
213
|
+
slices,
|
214
214
|
grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
|
215
215
|
}
|
216
216
|
grpc_slice_unref_internal(exec_ctx, slice);
|
@@ -277,7 +277,7 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames(
|
|
277
277
|
p->state = GRPC_CHTTP2_DATA_FH_0;
|
278
278
|
cur += p->frame_size;
|
279
279
|
grpc_slice_buffer_undo_take_first(
|
280
|
-
|
280
|
+
slices,
|
281
281
|
grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
|
282
282
|
grpc_slice_unref_internal(exec_ctx, slice);
|
283
283
|
return GRPC_ERROR_NONE;
|
@@ -46,7 +46,7 @@ grpc_error *grpc_chttp2_goaway_parser_begin_frame(grpc_chttp2_goaway_parser *p,
|
|
46
46
|
|
47
47
|
gpr_free(p->debug_data);
|
48
48
|
p->debug_length = length - 8;
|
49
|
-
p->debug_data = gpr_malloc(p->debug_length);
|
49
|
+
p->debug_data = (char *)gpr_malloc(p->debug_length);
|
50
50
|
p->debug_pos = 0;
|
51
51
|
p->state = GRPC_CHTTP2_GOAWAY_LSI0;
|
52
52
|
return GRPC_ERROR_NONE;
|
@@ -60,7 +60,7 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
|
|
60
60
|
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
|
61
61
|
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
|
62
62
|
uint8_t *cur = beg;
|
63
|
-
grpc_chttp2_goaway_parser *p = parser;
|
63
|
+
grpc_chttp2_goaway_parser *p = (grpc_chttp2_goaway_parser *)parser;
|
64
64
|
|
65
65
|
switch (p->state) {
|
66
66
|
case GRPC_CHTTP2_GOAWAY_LSI0:
|
@@ -75,7 +75,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
|
|
75
75
|
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
|
76
76
|
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
|
77
77
|
uint8_t *cur = beg;
|
78
|
-
grpc_chttp2_ping_parser *p = parser;
|
78
|
+
grpc_chttp2_ping_parser *p = (grpc_chttp2_ping_parser *)parser;
|
79
79
|
|
80
80
|
while (p->byte != 8 && cur != end) {
|
81
81
|
p->opaque_8bytes |= (((uint64_t)*cur) << (56 - 8 * p->byte));
|
@@ -92,7 +92,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
|
|
92
92
|
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
|
93
93
|
gpr_timespec next_allowed_ping =
|
94
94
|
gpr_time_add(t->ping_recv_state.last_ping_recv_time,
|
95
|
-
t->ping_policy.
|
95
|
+
t->ping_policy.min_recv_ping_interval_without_data);
|
96
96
|
|
97
97
|
if (t->keepalive_permit_without_calls == 0 &&
|
98
98
|
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
|
@@ -113,11 +113,12 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
|
|
113
113
|
if (!g_disable_ping_ack) {
|
114
114
|
if (t->ping_ack_count == t->ping_ack_capacity) {
|
115
115
|
t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3);
|
116
|
-
t->ping_acks = gpr_realloc(
|
116
|
+
t->ping_acks = (uint64_t *)gpr_realloc(
|
117
117
|
t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks));
|
118
118
|
}
|
119
119
|
t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes;
|
120
|
-
grpc_chttp2_initiate_write(exec_ctx, t,
|
120
|
+
grpc_chttp2_initiate_write(exec_ctx, t,
|
121
|
+
GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE);
|
121
122
|
}
|
122
123
|
}
|
123
124
|
}
|
@@ -77,7 +77,7 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
|
|
77
77
|
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
|
78
78
|
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
|
79
79
|
uint8_t *cur = beg;
|
80
|
-
grpc_chttp2_rst_stream_parser *p = parser;
|
80
|
+
grpc_chttp2_rst_stream_parser *p = (grpc_chttp2_rst_stream_parser *)parser;
|
81
81
|
|
82
82
|
while (p->byte != 4 && cur != end) {
|
83
83
|
p->reason_bytes[p->byte] = *cur;
|
@@ -44,7 +44,8 @@ static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) {
|
|
44
44
|
return out;
|
45
45
|
}
|
46
46
|
|
47
|
-
grpc_slice grpc_chttp2_settings_create(uint32_t *
|
47
|
+
grpc_slice grpc_chttp2_settings_create(uint32_t *old_settings,
|
48
|
+
const uint32_t *new_settings,
|
48
49
|
uint32_t force_mask, size_t count) {
|
49
50
|
size_t i;
|
50
51
|
uint32_t n = 0;
|
@@ -52,21 +53,21 @@ grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
|
|
52
53
|
uint8_t *p;
|
53
54
|
|
54
55
|
for (i = 0; i < count; i++) {
|
55
|
-
n += (
|
56
|
+
n += (new_settings[i] != old_settings[i] || (force_mask & (1u << i)) != 0);
|
56
57
|
}
|
57
58
|
|
58
59
|
output = GRPC_SLICE_MALLOC(9 + 6 * n);
|
59
60
|
p = fill_header(GRPC_SLICE_START_PTR(output), 6 * n, 0);
|
60
61
|
|
61
62
|
for (i = 0; i < count; i++) {
|
62
|
-
if (
|
63
|
+
if (new_settings[i] != old_settings[i] || (force_mask & (1u << i)) != 0) {
|
63
64
|
*p++ = (uint8_t)(grpc_setting_id_to_wire_id[i] >> 8);
|
64
65
|
*p++ = (uint8_t)(grpc_setting_id_to_wire_id[i]);
|
65
|
-
*p++ = (uint8_t)(
|
66
|
-
*p++ = (uint8_t)(
|
67
|
-
*p++ = (uint8_t)(
|
68
|
-
*p++ = (uint8_t)(
|
69
|
-
|
66
|
+
*p++ = (uint8_t)(new_settings[i] >> 24);
|
67
|
+
*p++ = (uint8_t)(new_settings[i] >> 16);
|
68
|
+
*p++ = (uint8_t)(new_settings[i] >> 8);
|
69
|
+
*p++ = (uint8_t)(new_settings[i]);
|
70
|
+
old_settings[i] = new_settings[i];
|
70
71
|
}
|
71
72
|
}
|
72
73
|
|
@@ -111,7 +112,7 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
|
|
111
112
|
grpc_chttp2_transport *t,
|
112
113
|
grpc_chttp2_stream *s,
|
113
114
|
grpc_slice slice, int is_last) {
|
114
|
-
grpc_chttp2_settings_parser *parser = p;
|
115
|
+
grpc_chttp2_settings_parser *parser = (grpc_chttp2_settings_parser *)p;
|
115
116
|
const uint8_t *cur = GRPC_SLICE_START_PTR(slice);
|
116
117
|
const uint8_t *end = GRPC_SLICE_END_PTR(slice);
|
117
118
|
char *msg;
|
@@ -70,7 +70,8 @@ grpc_error *grpc_chttp2_window_update_parser_parse(
|
|
70
70
|
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
|
71
71
|
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
|
72
72
|
uint8_t *cur = beg;
|
73
|
-
grpc_chttp2_window_update_parser *p =
|
73
|
+
grpc_chttp2_window_update_parser *p =
|
74
|
+
(grpc_chttp2_window_update_parser *)parser;
|
74
75
|
|
75
76
|
while (p->byte != 4 && cur != end) {
|
76
77
|
p->amount |= ((uint32_t)*cur) << (8 * (3 - p->byte));
|
@@ -98,9 +99,10 @@ grpc_error *grpc_chttp2_window_update_parser_parse(
|
|
98
99
|
grpc_chttp2_flowctl_recv_stream_update(
|
99
100
|
&t->flow_control, &s->flow_control, received_update);
|
100
101
|
if (grpc_chttp2_list_remove_stalled_by_stream(t, s)) {
|
101
|
-
|
102
|
-
|
103
|
-
|
102
|
+
grpc_chttp2_mark_stream_writable(exec_ctx, t, s);
|
103
|
+
grpc_chttp2_initiate_write(
|
104
|
+
exec_ctx, t,
|
105
|
+
GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE);
|
104
106
|
}
|
105
107
|
}
|
106
108
|
} else {
|
@@ -109,7 +111,9 @@ grpc_error *grpc_chttp2_window_update_parser_parse(
|
|
109
111
|
received_update);
|
110
112
|
bool is_zero = t->flow_control.remote_window <= 0;
|
111
113
|
if (was_zero && !is_zero) {
|
112
|
-
grpc_chttp2_initiate_write(
|
114
|
+
grpc_chttp2_initiate_write(
|
115
|
+
exec_ctx, t,
|
116
|
+
GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED);
|
113
117
|
}
|
114
118
|
}
|
115
119
|
}
|
@@ -33,6 +33,7 @@
|
|
33
33
|
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
|
34
34
|
#include "src/core/ext/transport/chttp2/transport/hpack_table.h"
|
35
35
|
#include "src/core/ext/transport/chttp2/transport/varint.h"
|
36
|
+
#include "src/core/lib/debug/stats.h"
|
36
37
|
#include "src/core/lib/slice/slice_internal.h"
|
37
38
|
#include "src/core/lib/slice/slice_string_helpers.h"
|
38
39
|
#include "src/core/lib/transport/metadata.h"
|
@@ -51,8 +52,10 @@
|
|
51
52
|
#define MAX_DECODER_SPACE_USAGE 512
|
52
53
|
|
53
54
|
static grpc_slice_refcount terminal_slice_refcount = {NULL, NULL};
|
54
|
-
static const grpc_slice terminal_slice = {
|
55
|
-
|
55
|
+
static const grpc_slice terminal_slice = {
|
56
|
+
&terminal_slice_refcount, /* refcount */
|
57
|
+
{{0, 0}} /* data.refcounted */
|
58
|
+
};
|
56
59
|
|
57
60
|
extern grpc_tracer_flag grpc_http_trace;
|
58
61
|
|
@@ -269,8 +272,10 @@ static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
269
272
|
}
|
270
273
|
}
|
271
274
|
|
272
|
-
static void emit_indexed(
|
275
|
+
static void emit_indexed(grpc_exec_ctx *exec_ctx,
|
276
|
+
grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
|
273
277
|
framer_state *st) {
|
278
|
+
GRPC_STATS_INC_HPACK_SEND_INDEXED(exec_ctx);
|
274
279
|
uint32_t len = GRPC_CHTTP2_VARINT_LENGTH(elem_index, 1);
|
275
280
|
GRPC_CHTTP2_WRITE_VARINT(elem_index, 1, 0x80, add_tiny_header_data(st, len),
|
276
281
|
len);
|
@@ -282,30 +287,31 @@ typedef struct {
|
|
282
287
|
bool insert_null_before_wire_value;
|
283
288
|
} wire_value;
|
284
289
|
|
285
|
-
static wire_value get_wire_value(grpc_mdelem elem,
|
290
|
+
static wire_value get_wire_value(grpc_exec_ctx *exec_ctx, grpc_mdelem elem,
|
291
|
+
bool true_binary_enabled) {
|
292
|
+
wire_value wire_val;
|
286
293
|
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
|
287
294
|
if (true_binary_enabled) {
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
295
|
+
GRPC_STATS_INC_HPACK_SEND_BINARY(exec_ctx);
|
296
|
+
wire_val.huffman_prefix = 0x00;
|
297
|
+
wire_val.insert_null_before_wire_value = true;
|
298
|
+
wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem));
|
299
|
+
|
293
300
|
} else {
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
};
|
301
|
+
GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64(exec_ctx);
|
302
|
+
wire_val.huffman_prefix = 0x80;
|
303
|
+
wire_val.insert_null_before_wire_value = false;
|
304
|
+
wire_val.data =
|
305
|
+
grpc_chttp2_base64_encode_and_huffman_compress(GRPC_MDVALUE(elem));
|
300
306
|
}
|
301
307
|
} else {
|
302
308
|
/* TODO(ctiller): opportunistically compress non-binary headers */
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
};
|
309
|
+
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
|
310
|
+
wire_val.huffman_prefix = 0x00;
|
311
|
+
wire_val.insert_null_before_wire_value = false;
|
312
|
+
wire_val.data = grpc_slice_ref_internal(GRPC_MDVALUE(elem));
|
308
313
|
}
|
314
|
+
return wire_val;
|
309
315
|
}
|
310
316
|
|
311
317
|
static size_t wire_value_length(wire_value v) {
|
@@ -317,11 +323,14 @@ static void add_wire_value(framer_state *st, wire_value v) {
|
|
317
323
|
add_header_data(st, v.data);
|
318
324
|
}
|
319
325
|
|
320
|
-
static void emit_lithdr_incidx(
|
326
|
+
static void emit_lithdr_incidx(grpc_exec_ctx *exec_ctx,
|
327
|
+
grpc_chttp2_hpack_compressor *c,
|
321
328
|
uint32_t key_index, grpc_mdelem elem,
|
322
329
|
framer_state *st) {
|
330
|
+
GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX(exec_ctx);
|
323
331
|
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
|
324
|
-
wire_value value =
|
332
|
+
wire_value value =
|
333
|
+
get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
|
325
334
|
size_t len_val = wire_value_length(value);
|
326
335
|
uint32_t len_val_len;
|
327
336
|
GPR_ASSERT(len_val <= UINT32_MAX);
|
@@ -333,11 +342,14 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
|
|
333
342
|
add_wire_value(st, value);
|
334
343
|
}
|
335
344
|
|
336
|
-
static void emit_lithdr_noidx(
|
345
|
+
static void emit_lithdr_noidx(grpc_exec_ctx *exec_ctx,
|
346
|
+
grpc_chttp2_hpack_compressor *c,
|
337
347
|
uint32_t key_index, grpc_mdelem elem,
|
338
348
|
framer_state *st) {
|
349
|
+
GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX(exec_ctx);
|
339
350
|
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
|
340
|
-
wire_value value =
|
351
|
+
wire_value value =
|
352
|
+
get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
|
341
353
|
size_t len_val = wire_value_length(value);
|
342
354
|
uint32_t len_val_len;
|
343
355
|
GPR_ASSERT(len_val <= UINT32_MAX);
|
@@ -349,10 +361,14 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
|
|
349
361
|
add_wire_value(st, value);
|
350
362
|
}
|
351
363
|
|
352
|
-
static void emit_lithdr_incidx_v(
|
364
|
+
static void emit_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
|
365
|
+
grpc_chttp2_hpack_compressor *c,
|
353
366
|
grpc_mdelem elem, framer_state *st) {
|
367
|
+
GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(exec_ctx);
|
368
|
+
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
|
354
369
|
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
|
355
|
-
wire_value value =
|
370
|
+
wire_value value =
|
371
|
+
get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
|
356
372
|
uint32_t len_val = (uint32_t)wire_value_length(value);
|
357
373
|
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
|
358
374
|
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
|
@@ -367,10 +383,14 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
|
|
367
383
|
add_wire_value(st, value);
|
368
384
|
}
|
369
385
|
|
370
|
-
static void emit_lithdr_noidx_v(
|
386
|
+
static void emit_lithdr_noidx_v(grpc_exec_ctx *exec_ctx,
|
387
|
+
grpc_chttp2_hpack_compressor *c,
|
371
388
|
grpc_mdelem elem, framer_state *st) {
|
389
|
+
GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(exec_ctx);
|
390
|
+
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
|
372
391
|
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
|
373
|
-
wire_value value =
|
392
|
+
wire_value value =
|
393
|
+
get_wire_value(exec_ctx, elem, st->use_true_binary_metadata);
|
374
394
|
uint32_t len_val = (uint32_t)wire_value_length(value);
|
375
395
|
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
|
376
396
|
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
|
@@ -423,7 +443,7 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
423
443
|
gpr_free(v);
|
424
444
|
}
|
425
445
|
if (!GRPC_MDELEM_IS_INTERNED(elem)) {
|
426
|
-
emit_lithdr_noidx_v(c, elem, st);
|
446
|
+
emit_lithdr_noidx_v(exec_ctx, c, elem, st);
|
427
447
|
return;
|
428
448
|
}
|
429
449
|
|
@@ -445,16 +465,16 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
445
465
|
if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) &&
|
446
466
|
c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) {
|
447
467
|
/* HIT: complete element (first cuckoo hash) */
|
448
|
-
emit_indexed(
|
449
|
-
st);
|
468
|
+
emit_indexed(exec_ctx, c,
|
469
|
+
dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), st);
|
450
470
|
return;
|
451
471
|
}
|
452
472
|
|
453
473
|
if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) &&
|
454
474
|
c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) {
|
455
475
|
/* HIT: complete element (second cuckoo hash) */
|
456
|
-
emit_indexed(
|
457
|
-
st);
|
476
|
+
emit_indexed(exec_ctx, c,
|
477
|
+
dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), st);
|
458
478
|
return;
|
459
479
|
}
|
460
480
|
|
@@ -472,11 +492,11 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
472
492
|
indices_key > c->tail_remote_index) {
|
473
493
|
/* HIT: key (first cuckoo hash) */
|
474
494
|
if (should_add_elem) {
|
475
|
-
emit_lithdr_incidx(c, dynidx(c, indices_key), elem, st);
|
495
|
+
emit_lithdr_incidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
|
476
496
|
add_elem(exec_ctx, c, elem);
|
477
497
|
return;
|
478
498
|
} else {
|
479
|
-
emit_lithdr_noidx(c, dynidx(c, indices_key), elem, st);
|
499
|
+
emit_lithdr_noidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
|
480
500
|
return;
|
481
501
|
}
|
482
502
|
GPR_UNREACHABLE_CODE(return );
|
@@ -488,11 +508,11 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
488
508
|
indices_key > c->tail_remote_index) {
|
489
509
|
/* HIT: key (first cuckoo hash) */
|
490
510
|
if (should_add_elem) {
|
491
|
-
emit_lithdr_incidx(c, dynidx(c, indices_key), elem, st);
|
511
|
+
emit_lithdr_incidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
|
492
512
|
add_elem(exec_ctx, c, elem);
|
493
513
|
return;
|
494
514
|
} else {
|
495
|
-
emit_lithdr_noidx(c, dynidx(c, indices_key), elem, st);
|
515
|
+
emit_lithdr_noidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
|
496
516
|
return;
|
497
517
|
}
|
498
518
|
GPR_UNREACHABLE_CODE(return );
|
@@ -501,11 +521,11 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
501
521
|
/* no elem, key in the table... fall back to literal emission */
|
502
522
|
|
503
523
|
if (should_add_elem) {
|
504
|
-
emit_lithdr_incidx_v(c, elem, st);
|
524
|
+
emit_lithdr_incidx_v(exec_ctx, c, elem, st);
|
505
525
|
add_elem(exec_ctx, c, elem);
|
506
526
|
return;
|
507
527
|
} else {
|
508
|
-
emit_lithdr_noidx_v(c, elem, st);
|
528
|
+
emit_lithdr_noidx_v(exec_ctx, c, elem, st);
|
509
529
|
return;
|
510
530
|
}
|
511
531
|
GPR_UNREACHABLE_CODE(return );
|
@@ -536,7 +556,7 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c) {
|
|
536
556
|
c->max_table_elems = c->cap_table_elems;
|
537
557
|
c->max_usable_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
|
538
558
|
c->table_elem_size =
|
539
|
-
gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
|
559
|
+
(uint16_t *)gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
|
540
560
|
memset(c->table_elem_size, 0,
|
541
561
|
sizeof(*c->table_elem_size) * c->cap_table_elems);
|
542
562
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(c->entries_keys); i++) {
|
@@ -564,7 +584,8 @@ void grpc_chttp2_hpack_compressor_set_max_usable_size(
|
|
564
584
|
}
|
565
585
|
|
566
586
|
static void rebuild_elems(grpc_chttp2_hpack_compressor *c, uint32_t new_cap) {
|
567
|
-
uint16_t *table_elem_size =
|
587
|
+
uint16_t *table_elem_size =
|
588
|
+
(uint16_t *)gpr_malloc(sizeof(*table_elem_size) * new_cap);
|
568
589
|
uint32_t i;
|
569
590
|
|
570
591
|
memset(table_elem_size, 0, sizeof(*table_elem_size) * new_cap);
|
@@ -30,6 +30,7 @@
|
|
30
30
|
#include <grpc/support/useful.h>
|
31
31
|
|
32
32
|
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
|
33
|
+
#include "src/core/lib/debug/stats.h"
|
33
34
|
#include "src/core/lib/profiling/timers.h"
|
34
35
|
#include "src/core/lib/slice/slice_internal.h"
|
35
36
|
#include "src/core/lib/support/string.h"
|
@@ -777,8 +778,7 @@ static grpc_error *parse_stream_dep0(grpc_exec_ctx *exec_ctx,
|
|
777
778
|
return parse_stream_dep1(exec_ctx, p, cur + 1, end);
|
778
779
|
}
|
779
780
|
|
780
|
-
/* emit an indexed field;
|
781
|
-
begin the next field on completion */
|
781
|
+
/* emit an indexed field; jumps to begin the next field on completion */
|
782
782
|
static grpc_error *finish_indexed_field(grpc_exec_ctx *exec_ctx,
|
783
783
|
grpc_chttp2_hpack_parser *p,
|
784
784
|
const uint8_t *cur,
|
@@ -792,6 +792,7 @@ static grpc_error *finish_indexed_field(grpc_exec_ctx *exec_ctx,
|
|
792
792
|
GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents);
|
793
793
|
}
|
794
794
|
GRPC_MDELEM_REF(md);
|
795
|
+
GRPC_STATS_INC_HPACK_RECV_INDEXED(exec_ctx);
|
795
796
|
grpc_error *err = on_hdr(exec_ctx, p, md, 0);
|
796
797
|
if (err != GRPC_ERROR_NONE) return err;
|
797
798
|
return parse_begin(exec_ctx, p, cur, end);
|
@@ -820,14 +821,14 @@ static grpc_error *parse_indexed_field_x(grpc_exec_ctx *exec_ctx,
|
|
820
821
|
return parse_value0(exec_ctx, p, cur + 1, end);
|
821
822
|
}
|
822
823
|
|
823
|
-
/* finish a literal header with incremental indexing
|
824
|
-
begin */
|
824
|
+
/* finish a literal header with incremental indexing */
|
825
825
|
static grpc_error *finish_lithdr_incidx(grpc_exec_ctx *exec_ctx,
|
826
826
|
grpc_chttp2_hpack_parser *p,
|
827
827
|
const uint8_t *cur,
|
828
828
|
const uint8_t *end) {
|
829
829
|
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
|
830
830
|
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
|
831
|
+
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX(exec_ctx);
|
831
832
|
grpc_error *err = on_hdr(
|
832
833
|
exec_ctx, p,
|
833
834
|
grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
|
@@ -842,6 +843,7 @@ static grpc_error *finish_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
|
|
842
843
|
grpc_chttp2_hpack_parser *p,
|
843
844
|
const uint8_t *cur,
|
844
845
|
const uint8_t *end) {
|
846
|
+
GRPC_STATS_INC_HPACK_RECV_LITHDR_INCIDX_V(exec_ctx);
|
845
847
|
grpc_error *err = on_hdr(
|
846
848
|
exec_ctx, p,
|
847
849
|
grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
|
@@ -898,6 +900,7 @@ static grpc_error *finish_lithdr_notidx(grpc_exec_ctx *exec_ctx,
|
|
898
900
|
const uint8_t *end) {
|
899
901
|
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
|
900
902
|
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
|
903
|
+
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX(exec_ctx);
|
901
904
|
grpc_error *err = on_hdr(
|
902
905
|
exec_ctx, p,
|
903
906
|
grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
|
@@ -912,6 +915,7 @@ static grpc_error *finish_lithdr_notidx_v(grpc_exec_ctx *exec_ctx,
|
|
912
915
|
grpc_chttp2_hpack_parser *p,
|
913
916
|
const uint8_t *cur,
|
914
917
|
const uint8_t *end) {
|
918
|
+
GRPC_STATS_INC_HPACK_RECV_LITHDR_NOTIDX_V(exec_ctx);
|
915
919
|
grpc_error *err = on_hdr(
|
916
920
|
exec_ctx, p,
|
917
921
|
grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
|
@@ -968,6 +972,7 @@ static grpc_error *finish_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
|
|
968
972
|
const uint8_t *end) {
|
969
973
|
grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
|
970
974
|
GPR_ASSERT(!GRPC_MDISNULL(md)); /* handled in string parsing */
|
975
|
+
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX(exec_ctx);
|
971
976
|
grpc_error *err = on_hdr(
|
972
977
|
exec_ctx, p,
|
973
978
|
grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(md)),
|
@@ -982,6 +987,7 @@ static grpc_error *finish_lithdr_nvridx_v(grpc_exec_ctx *exec_ctx,
|
|
982
987
|
grpc_chttp2_hpack_parser *p,
|
983
988
|
const uint8_t *cur,
|
984
989
|
const uint8_t *end) {
|
990
|
+
GRPC_STATS_INC_HPACK_RECV_LITHDR_NVRIDX_V(exec_ctx);
|
985
991
|
grpc_error *err = on_hdr(
|
986
992
|
exec_ctx, p,
|
987
993
|
grpc_mdelem_from_slices(exec_ctx, take_string(exec_ctx, p, &p->key, true),
|
@@ -1284,7 +1290,7 @@ static void append_bytes(grpc_chttp2_hpack_parser_string *str,
|
|
1284
1290
|
GPR_ASSERT(str->data.copied.length + length <= UINT32_MAX);
|
1285
1291
|
str->data.copied.capacity = (uint32_t)(str->data.copied.length + length);
|
1286
1292
|
str->data.copied.str =
|
1287
|
-
gpr_realloc(str->data.copied.str, str->data.copied.capacity);
|
1293
|
+
(char *)gpr_realloc(str->data.copied.str, str->data.copied.capacity);
|
1288
1294
|
}
|
1289
1295
|
memcpy(str->data.copied.str + str->data.copied.length, data, length);
|
1290
1296
|
GPR_ASSERT(length <= UINT32_MAX - str->data.copied.length);
|
@@ -1310,9 +1316,11 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
|
|
1310
1316
|
/* 'true-binary' case */
|
1311
1317
|
++cur;
|
1312
1318
|
p->binary = NOT_BINARY;
|
1319
|
+
GRPC_STATS_INC_HPACK_RECV_BINARY(exec_ctx);
|
1313
1320
|
append_bytes(str, cur, (size_t)(end - cur));
|
1314
1321
|
return GRPC_ERROR_NONE;
|
1315
1322
|
}
|
1323
|
+
GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64(exec_ctx);
|
1316
1324
|
/* fallthrough */
|
1317
1325
|
b64_byte0:
|
1318
1326
|
case B64_BYTE0:
|
@@ -1510,6 +1518,7 @@ static grpc_error *begin_parse_string(grpc_exec_ctx *exec_ctx,
|
|
1510
1518
|
grpc_chttp2_hpack_parser_string *str) {
|
1511
1519
|
if (!p->huff && binary == NOT_BINARY && (end - cur) >= (intptr_t)p->strlen &&
|
1512
1520
|
p->current_slice_refcount != NULL) {
|
1521
|
+
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
|
1513
1522
|
str->copied = false;
|
1514
1523
|
str->data.referenced.refcount = p->current_slice_refcount;
|
1515
1524
|
str->data.referenced.data.refcounted.bytes = (uint8_t *)cur;
|
@@ -1523,6 +1532,20 @@ static grpc_error *begin_parse_string(grpc_exec_ctx *exec_ctx,
|
|
1523
1532
|
p->parsing.str = str;
|
1524
1533
|
p->huff_state = 0;
|
1525
1534
|
p->binary = binary;
|
1535
|
+
switch (p->binary) {
|
1536
|
+
case NOT_BINARY:
|
1537
|
+
if (p->huff) {
|
1538
|
+
GRPC_STATS_INC_HPACK_RECV_HUFFMAN(exec_ctx);
|
1539
|
+
} else {
|
1540
|
+
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED(exec_ctx);
|
1541
|
+
}
|
1542
|
+
break;
|
1543
|
+
case BINARY_BEGIN:
|
1544
|
+
/* stats incremented later: don't know true binary or not */
|
1545
|
+
break;
|
1546
|
+
default:
|
1547
|
+
abort();
|
1548
|
+
}
|
1526
1549
|
return parse_string(exec_ctx, p, cur, end);
|
1527
1550
|
}
|
1528
1551
|
|
@@ -1643,24 +1666,38 @@ static const maybe_complete_func_type maybe_complete_funcs[] = {
|
|
1643
1666
|
|
1644
1667
|
static void force_client_rst_stream(grpc_exec_ctx *exec_ctx, void *sp,
|
1645
1668
|
grpc_error *error) {
|
1646
|
-
grpc_chttp2_stream *s = sp;
|
1669
|
+
grpc_chttp2_stream *s = (grpc_chttp2_stream *)sp;
|
1647
1670
|
grpc_chttp2_transport *t = s->t;
|
1648
1671
|
if (!s->write_closed) {
|
1649
1672
|
grpc_slice_buffer_add(
|
1650
1673
|
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_HTTP2_NO_ERROR,
|
1651
1674
|
&s->stats.outgoing));
|
1652
|
-
grpc_chttp2_initiate_write(exec_ctx, t,
|
1675
|
+
grpc_chttp2_initiate_write(exec_ctx, t,
|
1676
|
+
GRPC_CHTTP2_INITIATE_WRITE_FORCE_RST_STREAM);
|
1653
1677
|
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, GRPC_ERROR_NONE);
|
1654
1678
|
}
|
1655
1679
|
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "final_rst");
|
1656
1680
|
}
|
1657
1681
|
|
1682
|
+
static void parse_stream_compression_md(grpc_exec_ctx *exec_ctx,
|
1683
|
+
grpc_chttp2_transport *t,
|
1684
|
+
grpc_chttp2_stream *s,
|
1685
|
+
grpc_metadata_batch *initial_metadata) {
|
1686
|
+
if (initial_metadata->idx.named.content_encoding == NULL ||
|
1687
|
+
grpc_stream_compression_method_parse(
|
1688
|
+
GRPC_MDVALUE(initial_metadata->idx.named.content_encoding->md), false,
|
1689
|
+
&s->stream_decompression_method) == 0) {
|
1690
|
+
s->stream_decompression_method =
|
1691
|
+
GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS;
|
1692
|
+
}
|
1693
|
+
}
|
1694
|
+
|
1658
1695
|
grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
|
1659
1696
|
void *hpack_parser,
|
1660
1697
|
grpc_chttp2_transport *t,
|
1661
1698
|
grpc_chttp2_stream *s,
|
1662
1699
|
grpc_slice slice, int is_last) {
|
1663
|
-
grpc_chttp2_hpack_parser *parser = hpack_parser;
|
1700
|
+
grpc_chttp2_hpack_parser *parser = (grpc_chttp2_hpack_parser *)hpack_parser;
|
1664
1701
|
GPR_TIMER_BEGIN("grpc_chttp2_hpack_parser_parse", 0);
|
1665
1702
|
if (s != NULL) {
|
1666
1703
|
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
|
@@ -1681,9 +1718,16 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
|
|
1681
1718
|
if (s != NULL) {
|
1682
1719
|
if (parser->is_boundary) {
|
1683
1720
|
if (s->header_frames_received == GPR_ARRAY_SIZE(s->metadata_buffer)) {
|
1721
|
+
GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);
|
1684
1722
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1685
1723
|
"Too many trailer frames");
|
1686
1724
|
}
|
1725
|
+
/* Process stream compression md element if it exists */
|
1726
|
+
if (s->header_frames_received ==
|
1727
|
+
0) { /* Only acts on initial metadata */
|
1728
|
+
parse_stream_compression_md(exec_ctx, t, s,
|
1729
|
+
&s->metadata_buffer[0].batch);
|
1730
|
+
}
|
1687
1731
|
s->published_metadata[s->header_frames_received] =
|
1688
1732
|
GRPC_METADATA_PUBLISHED_FROM_WIRE;
|
1689
1733
|
maybe_complete_funcs[s->header_frames_received](exec_ctx, t, s);
|