grpc 1.1.2 → 1.2.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 +1257 -404
- data/etc/roots.pem +189 -102
- data/include/grpc/census.h +7 -7
- data/include/grpc/compression.h +4 -4
- data/include/grpc/grpc.h +13 -7
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +26 -9
- data/include/grpc/impl/codegen/grpc_types.h +39 -30
- data/include/grpc/impl/codegen/slice.h +24 -6
- data/include/grpc/impl/codegen/sync.h +8 -0
- data/include/grpc/load_reporting.h +63 -0
- data/include/grpc/slice.h +37 -1
- data/include/grpc/slice_buffer.h +7 -0
- data/include/grpc/support/alloc.h +3 -0
- data/include/grpc/support/useful.h +3 -0
- data/src/core/ext/census/gen/census.pb.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.c +9 -36
- data/src/core/ext/census/gen/trace_context.pb.h +20 -26
- data/src/core/ext/census/grpc_filter.c +3 -5
- data/src/core/ext/census/trace_context.c +1 -1
- data/src/core/ext/census/trace_context.h +3 -0
- data/src/core/ext/census/trace_label.h +61 -0
- data/src/core/ext/census/trace_propagation.h +63 -0
- data/src/core/ext/census/trace_status.h +45 -0
- data/src/core/ext/census/trace_string.h +50 -0
- data/src/core/ext/census/tracing.c +31 -11
- data/src/core/ext/census/tracing.h +124 -0
- data/src/core/ext/client_channel/client_channel.c +456 -368
- data/src/core/ext/client_channel/client_channel.h +4 -0
- data/src/core/ext/client_channel/client_channel_plugin.c +6 -1
- data/src/core/ext/client_channel/connector.c +3 -3
- data/src/core/ext/client_channel/connector.h +4 -3
- data/src/core/ext/client_channel/http_connect_handshaker.c +62 -72
- data/src/core/ext/client_channel/http_connect_handshaker.h +7 -10
- data/src/core/ext/client_channel/http_proxy.c +125 -0
- data/src/core/ext/client_channel/http_proxy.h +39 -0
- data/src/core/ext/client_channel/lb_policy.c +56 -35
- data/src/core/ext/client_channel/lb_policy.h +46 -39
- data/src/core/ext/client_channel/lb_policy_factory.h +1 -0
- data/src/core/ext/client_channel/parse_address.c +32 -6
- data/src/core/ext/client_channel/proxy_mapper.c +63 -0
- data/src/core/ext/client_channel/proxy_mapper.h +89 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.c +133 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.h +59 -0
- data/src/core/ext/client_channel/resolver.c +16 -9
- data/src/core/ext/client_channel/resolver.h +23 -12
- data/src/core/ext/client_channel/resolver_factory.h +1 -0
- data/src/core/ext/client_channel/resolver_registry.c +15 -11
- data/src/core/ext/client_channel/resolver_registry.h +5 -3
- data/src/core/ext/client_channel/subchannel.c +44 -27
- data/src/core/ext/client_channel/subchannel.h +6 -2
- data/src/core/ext/client_channel/uri_parser.c +26 -14
- data/src/core/ext/client_channel/uri_parser.h +3 -1
- data/src/core/ext/lb_policy/grpclb/grpclb.c +220 -209
- data/src/core/ext/lb_policy/grpclb/grpclb_channel.h +56 -0
- data/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c +107 -0
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +3 -6
- data/src/core/ext/lb_policy/pick_first/pick_first.c +71 -116
- data/src/core/ext/lb_policy/round_robin/round_robin.c +52 -67
- data/src/core/ext/load_reporting/load_reporting.c +20 -0
- data/src/core/ext/load_reporting/load_reporting.h +1 -16
- data/src/core/ext/load_reporting/load_reporting_filter.c +28 -54
- data/src/core/ext/resolver/dns/native/dns_resolver.c +31 -45
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +20 -29
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +11 -8
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +11 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +143 -46
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +12 -50
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +1 -2
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +0 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +606 -374
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +17 -5
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +9 -13
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +12 -11
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +5 -6
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +100 -53
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +126 -70
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +13 -7
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +22 -19
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +6 -6
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +23 -11
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +169 -42
- data/src/core/ext/transport/chttp2/transport/parsing.c +98 -41
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +29 -14
- data/src/core/ext/transport/chttp2/transport/writing.c +137 -15
- data/src/core/lib/channel/channel_stack.c +14 -44
- data/src/core/lib/channel/channel_stack.h +10 -17
- data/src/core/lib/channel/channel_stack_builder.c +2 -3
- data/src/core/lib/channel/compress_filter.c +54 -46
- data/src/core/lib/channel/connected_channel.c +4 -4
- data/src/core/lib/channel/connected_channel.h +5 -0
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/deadline_filter.c +61 -61
- data/src/core/lib/channel/deadline_filter.h +8 -5
- data/src/core/lib/channel/handshaker.c +47 -7
- data/src/core/lib/channel/handshaker.h +21 -3
- data/src/core/lib/channel/http_client_filter.c +149 -99
- data/src/core/lib/channel/http_server_filter.c +163 -147
- data/src/core/lib/channel/message_size_filter.c +15 -10
- data/src/core/lib/compression/algorithm_metadata.h +4 -4
- data/src/core/lib/compression/compression.c +17 -23
- data/src/core/lib/http/httpcli.c +3 -2
- data/src/core/lib/http/httpcli.h +2 -1
- data/src/core/lib/http/httpcli_security_connector.c +2 -3
- data/src/core/lib/http/parser.c +2 -2
- data/src/core/lib/iomgr/closure.c +6 -3
- data/src/core/lib/iomgr/closure.h +4 -2
- data/src/core/lib/iomgr/combiner.c +35 -5
- data/src/core/lib/iomgr/combiner.h +21 -2
- data/src/core/lib/iomgr/endpoint.c +3 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/error.c +60 -94
- data/src/core/lib/iomgr/error.h +7 -10
- data/src/core/lib/iomgr/error_internal.h +54 -0
- data/src/core/lib/iomgr/ev_epoll_linux.c +253 -109
- data/src/core/lib/iomgr/ev_poll_posix.c +61 -29
- data/src/core/lib/iomgr/ev_posix.c +7 -8
- data/src/core/lib/iomgr/ev_posix.h +4 -4
- data/src/core/lib/iomgr/exec_ctx.c +11 -6
- data/src/core/lib/iomgr/exec_ctx.h +11 -14
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/load_file.c +1 -1
- data/src/core/lib/iomgr/network_status_tracker.c +5 -81
- data/src/core/lib/iomgr/pollset.h +1 -3
- data/src/core/lib/iomgr/pollset_set.h +2 -1
- data/src/core/lib/iomgr/pollset_set_uv.c +2 -1
- data/src/core/lib/iomgr/pollset_set_windows.c +2 -1
- data/src/core/lib/iomgr/pollset_uv.c +25 -11
- data/src/core/lib/iomgr/pollset_windows.c +0 -11
- data/src/core/lib/iomgr/resolve_address_uv.c +50 -2
- data/src/core/lib/iomgr/resource_quota.c +41 -11
- data/src/core/lib/iomgr/resource_quota.h +6 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +33 -17
- data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +2 -3
- data/src/core/lib/iomgr/tcp_client_uv.c +1 -3
- data/src/core/lib/iomgr/tcp_client_windows.c +21 -6
- data/src/core/lib/iomgr/tcp_posix.c +4 -5
- data/src/core/lib/iomgr/tcp_server_posix.c +269 -94
- data/src/core/lib/iomgr/tcp_server_windows.c +1 -1
- data/src/core/lib/iomgr/tcp_uv.c +11 -5
- data/src/core/lib/iomgr/tcp_windows.c +20 -7
- data/src/core/lib/iomgr/timer_generic.c +15 -22
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_uv.c +10 -6
- data/src/core/lib/iomgr/timer_uv.h +1 -1
- data/src/core/lib/iomgr/udp_server.c +45 -6
- data/src/core/lib/iomgr/udp_server.h +7 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +11 -1
- data/src/core/lib/json/json.c +1 -2
- data/src/core/lib/profiling/basic_timers.c +17 -3
- data/src/core/lib/security/context/security_context.c +3 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -8
- data/src/core/lib/security/credentials/credentials.c +48 -2
- data/src/core/lib/security/credentials/credentials.h +13 -0
- data/src/core/lib/security/credentials/credentials_metadata.c +1 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.c +6 -8
- data/src/core/lib/security/credentials/fake/fake_credentials.h +15 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +3 -3
- data/src/core/lib/security/credentials/iam/iam_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +5 -8
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +3 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +15 -13
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +2 -4
- data/src/core/lib/security/transport/client_auth_filter.c +72 -47
- data/src/core/lib/security/transport/lb_targets_info.c +70 -0
- data/src/core/lib/security/transport/lb_targets_info.h +47 -0
- data/src/core/lib/security/transport/secure_endpoint.c +3 -3
- data/src/core/lib/security/transport/security_connector.c +125 -28
- data/src/core/lib/security/transport/security_connector.h +4 -3
- data/src/core/lib/security/transport/security_handshaker.c +13 -9
- data/src/core/lib/security/transport/server_auth_filter.c +31 -40
- data/src/core/lib/security/util/b64.c +1 -1
- data/src/core/lib/slice/slice.c +110 -20
- data/src/core/lib/slice/slice_buffer.c +92 -39
- data/src/core/lib/{transport/mdstr_hash_table.c → slice/slice_hash_table.c} +40 -33
- data/src/core/lib/{transport/mdstr_hash_table.h → slice/slice_hash_table.h} +21 -21
- data/src/core/lib/slice/slice_intern.c +346 -0
- data/src/core/lib/slice/slice_internal.h +15 -0
- data/src/core/lib/slice/slice_string_helpers.c +5 -0
- data/src/core/lib/slice/slice_string_helpers.h +5 -0
- data/src/core/lib/support/alloc.c +26 -1
- data/src/core/lib/support/cmdline.c +2 -4
- data/src/core/lib/support/cpu_posix.c +2 -7
- data/src/core/lib/support/histogram.c +1 -2
- data/src/core/lib/support/log_posix.c +8 -4
- data/src/core/lib/support/spinlock.h +52 -0
- data/src/core/lib/support/subprocess_posix.c +1 -2
- data/src/core/lib/support/sync.c +7 -1
- data/src/core/lib/support/sync_posix.c +9 -0
- data/src/core/lib/support/time_windows.c +7 -1
- data/src/core/lib/surface/call.c +647 -629
- data/src/core/lib/surface/call.h +4 -1
- data/src/core/lib/surface/call_details.c +8 -2
- data/src/core/lib/surface/call_log_batch.c +17 -6
- data/src/core/lib/surface/channel.c +49 -59
- data/src/core/lib/surface/channel.h +5 -6
- data/src/core/lib/surface/completion_queue.c +16 -45
- data/src/core/lib/surface/completion_queue.h +0 -3
- data/src/core/lib/surface/init.c +6 -2
- data/src/core/lib/surface/init_secure.c +1 -1
- data/src/core/lib/surface/lame_client.c +14 -4
- data/src/core/lib/surface/server.c +79 -82
- data/src/core/lib/surface/validate_metadata.c +46 -15
- data/src/core/lib/surface/validate_metadata.h +43 -0
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.c +104 -0
- data/src/core/lib/transport/bdp_estimator.h +76 -0
- data/src/core/lib/transport/connectivity_state.c +33 -13
- data/src/core/lib/transport/connectivity_state.h +15 -5
- data/src/core/lib/transport/error_utils.c +124 -0
- data/src/core/lib/transport/error_utils.h +56 -0
- data/src/core/{ext/transport/chttp2 → lib}/transport/http2_errors.h +18 -18
- data/src/core/lib/transport/metadata.c +259 -503
- data/src/core/lib/transport/metadata.h +69 -68
- data/src/core/lib/transport/metadata_batch.c +183 -63
- data/src/core/lib/transport/metadata_batch.h +50 -26
- data/src/core/lib/transport/pid_controller.c +28 -8
- data/src/core/lib/transport/pid_controller.h +15 -2
- data/src/core/lib/transport/service_config.c +21 -18
- data/src/core/lib/transport/service_config.h +5 -5
- data/src/core/lib/transport/static_metadata.c +753 -112
- data/src/core/lib/transport/static_metadata.h +403 -264
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.c +18 -20
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.h +9 -10
- data/src/core/lib/transport/timeout_encoding.c +11 -9
- data/src/core/lib/transport/timeout_encoding.h +3 -1
- data/src/core/lib/transport/transport.c +47 -87
- data/src/core/lib/transport/transport.h +20 -25
- data/src/core/lib/transport/transport_op_string.c +7 -19
- data/src/core/lib/tsi/fake_transport_security.c +2 -4
- data/src/core/lib/tsi/ssl_transport_security.c +7 -16
- data/src/core/lib/tsi/transport_security.c +2 -4
- data/src/ruby/ext/grpc/extconf.rb +4 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +7 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +3 -0
- data/src/ruby/ext/grpc/rb_call.c +47 -46
- data/src/ruby/ext/grpc/rb_channel.c +21 -6
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +59 -8
- data/src/ruby/ext/grpc/rb_server.c +6 -4
- data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +33 -9
@@ -40,7 +40,7 @@
|
|
40
40
|
#include <grpc/support/log.h>
|
41
41
|
#include <grpc/support/string_util.h>
|
42
42
|
|
43
|
-
grpc_slice grpc_chttp2_ping_create(uint8_t ack,
|
43
|
+
grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) {
|
44
44
|
grpc_slice slice = grpc_slice_malloc(9 + 8);
|
45
45
|
uint8_t *p = GRPC_SLICE_START_PTR(slice);
|
46
46
|
|
@@ -53,7 +53,14 @@ grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) {
|
|
53
53
|
*p++ = 0;
|
54
54
|
*p++ = 0;
|
55
55
|
*p++ = 0;
|
56
|
-
|
56
|
+
*p++ = (uint8_t)(opaque_8bytes >> 56);
|
57
|
+
*p++ = (uint8_t)(opaque_8bytes >> 48);
|
58
|
+
*p++ = (uint8_t)(opaque_8bytes >> 40);
|
59
|
+
*p++ = (uint8_t)(opaque_8bytes >> 32);
|
60
|
+
*p++ = (uint8_t)(opaque_8bytes >> 24);
|
61
|
+
*p++ = (uint8_t)(opaque_8bytes >> 16);
|
62
|
+
*p++ = (uint8_t)(opaque_8bytes >> 8);
|
63
|
+
*p++ = (uint8_t)(opaque_8bytes);
|
57
64
|
|
58
65
|
return slice;
|
59
66
|
}
|
@@ -70,6 +77,7 @@ grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
|
|
70
77
|
}
|
71
78
|
parser->byte = 0;
|
72
79
|
parser->is_ack = flags;
|
80
|
+
parser->opaque_8bytes = 0;
|
73
81
|
return GRPC_ERROR_NONE;
|
74
82
|
}
|
75
83
|
|
@@ -83,7 +91,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
|
|
83
91
|
grpc_chttp2_ping_parser *p = parser;
|
84
92
|
|
85
93
|
while (p->byte != 8 && cur != end) {
|
86
|
-
p->opaque_8bytes
|
94
|
+
p->opaque_8bytes |= (((uint64_t)*cur) << (56 - 8 * p->byte));
|
87
95
|
cur++;
|
88
96
|
p->byte++;
|
89
97
|
}
|
@@ -93,8 +101,12 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
|
|
93
101
|
if (p->is_ack) {
|
94
102
|
grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes);
|
95
103
|
} else {
|
96
|
-
|
97
|
-
|
104
|
+
if (t->ping_ack_count == t->ping_ack_capacity) {
|
105
|
+
t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3);
|
106
|
+
t->ping_acks = gpr_realloc(
|
107
|
+
t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks));
|
108
|
+
}
|
109
|
+
t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes;
|
98
110
|
grpc_chttp2_initiate_write(exec_ctx, t, false, "ping response");
|
99
111
|
}
|
100
112
|
}
|
@@ -41,10 +41,10 @@
|
|
41
41
|
typedef struct {
|
42
42
|
uint8_t byte;
|
43
43
|
uint8_t is_ack;
|
44
|
-
|
44
|
+
uint64_t opaque_8bytes;
|
45
45
|
} grpc_chttp2_ping_parser;
|
46
46
|
|
47
|
-
grpc_slice grpc_chttp2_ping_create(uint8_t ack,
|
47
|
+
grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes);
|
48
48
|
|
49
49
|
grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser,
|
50
50
|
uint32_t length, uint8_t flags);
|
@@ -39,8 +39,7 @@
|
|
39
39
|
#include <grpc/support/string_util.h>
|
40
40
|
|
41
41
|
#include "src/core/ext/transport/chttp2/transport/frame.h"
|
42
|
-
#include "src/core/
|
43
|
-
#include "src/core/ext/transport/chttp2/transport/status_conversion.h"
|
42
|
+
#include "src/core/lib/transport/http2_errors.h"
|
44
43
|
|
45
44
|
grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
|
46
45
|
grpc_transport_one_way_stats *stats) {
|
@@ -109,17 +108,14 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
|
|
109
108
|
(((uint32_t)p->reason_bytes[2]) << 8) |
|
110
109
|
(((uint32_t)p->reason_bytes[3]));
|
111
110
|
grpc_error *error = GRPC_ERROR_NONE;
|
112
|
-
if (reason !=
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
(
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
grpc_slice slice_details = grpc_slice_from_copied_string(status_details);
|
121
|
-
gpr_free(status_details);
|
122
|
-
grpc_chttp2_fake_status(exec_ctx, t, s, status_code, &slice_details);
|
111
|
+
if (reason != GRPC_HTTP2_NO_ERROR || s->header_frames_received < 2) {
|
112
|
+
char *message;
|
113
|
+
gpr_asprintf(&message, "Received RST_STREAM with error code %d", reason);
|
114
|
+
error = grpc_error_set_int(
|
115
|
+
grpc_error_set_str(GRPC_ERROR_CREATE("RST_STREAM"),
|
116
|
+
GRPC_ERROR_STR_GRPC_MESSAGE, message),
|
117
|
+
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
|
118
|
+
gpr_free(message);
|
123
119
|
}
|
124
120
|
grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, true, error);
|
125
121
|
}
|
@@ -43,8 +43,8 @@
|
|
43
43
|
|
44
44
|
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
|
45
45
|
#include "src/core/ext/transport/chttp2/transport/frame.h"
|
46
|
-
#include "src/core/ext/transport/chttp2/transport/http2_errors.h"
|
47
46
|
#include "src/core/lib/debug/trace.h"
|
47
|
+
#include "src/core/lib/transport/http2_errors.h"
|
48
48
|
|
49
49
|
#define MAX_MAX_HEADER_LIST_SIZE (1024 * 1024 * 1024)
|
50
50
|
|
@@ -52,21 +52,21 @@
|
|
52
52
|
const grpc_chttp2_setting_parameters
|
53
53
|
grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS] = {
|
54
54
|
{NULL, 0, 0, 0, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
|
55
|
-
|
55
|
+
GRPC_HTTP2_PROTOCOL_ERROR},
|
56
56
|
{"HEADER_TABLE_SIZE", 4096, 0, 0xffffffff,
|
57
|
-
GRPC_CHTTP2_CLAMP_INVALID_VALUE,
|
57
|
+
GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
|
58
58
|
{"ENABLE_PUSH", 1, 0, 1, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
|
59
|
-
|
59
|
+
GRPC_HTTP2_PROTOCOL_ERROR},
|
60
60
|
{"MAX_CONCURRENT_STREAMS", 0xffffffffu, 0, 0xffffffffu,
|
61
|
-
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
|
61
|
+
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
|
62
62
|
{"INITIAL_WINDOW_SIZE", 65535, 0, 0x7fffffffu,
|
63
63
|
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
|
64
|
-
|
64
|
+
GRPC_HTTP2_FLOW_CONTROL_ERROR},
|
65
65
|
{"MAX_FRAME_SIZE", 16384, 16384, 16777215,
|
66
|
-
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE,
|
66
|
+
GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_HTTP2_PROTOCOL_ERROR},
|
67
67
|
{"MAX_HEADER_LIST_SIZE", MAX_MAX_HEADER_LIST_SIZE, 0,
|
68
68
|
MAX_MAX_HEADER_LIST_SIZE, GRPC_CHTTP2_CLAMP_INVALID_VALUE,
|
69
|
-
|
69
|
+
GRPC_HTTP2_PROTOCOL_ERROR},
|
70
70
|
};
|
71
71
|
|
72
72
|
static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) {
|
@@ -236,7 +236,7 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
|
|
236
236
|
}
|
237
237
|
if (parser->id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE &&
|
238
238
|
parser->incoming_settings[parser->id] != parser->value) {
|
239
|
-
t->initial_window_update
|
239
|
+
t->initial_window_update +=
|
240
240
|
(int64_t)parser->value - parser->incoming_settings[parser->id];
|
241
241
|
if (grpc_http_trace) {
|
242
242
|
gpr_log(GPR_DEBUG, "adding %d for initial_window change",
|
@@ -245,8 +245,9 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
|
|
245
245
|
}
|
246
246
|
parser->incoming_settings[parser->id] = parser->value;
|
247
247
|
if (grpc_http_trace) {
|
248
|
-
gpr_log(GPR_DEBUG, "CHTTP2:%s: got setting %d = %d",
|
249
|
-
t->is_client ? "CLI" : "SVR",
|
248
|
+
gpr_log(GPR_DEBUG, "CHTTP2:%s:%s: got setting %d = %d",
|
249
|
+
t->is_client ? "CLI" : "SVR", t->peer_string, parser->id,
|
250
|
+
parser->value);
|
250
251
|
}
|
251
252
|
} else if (grpc_http_trace) {
|
252
253
|
gpr_log(GPR_ERROR, "CHTTP2: Ignoring unknown setting %d (value %d)",
|
@@ -87,7 +87,7 @@ extern const grpc_chttp2_setting_parameters
|
|
87
87
|
grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS];
|
88
88
|
|
89
89
|
/* Create a settings frame by diffing old & new, and updating old to be new */
|
90
|
-
grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *
|
90
|
+
grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *newval,
|
91
91
|
uint32_t force_mask, size_t count);
|
92
92
|
/* Create an ack settings frame */
|
93
93
|
grpc_slice grpc_chttp2_settings_ack_create(void);
|
@@ -110,13 +110,12 @@ grpc_error *grpc_chttp2_window_update_parser_parse(
|
|
110
110
|
|
111
111
|
if (t->incoming_stream_id != 0) {
|
112
112
|
if (s != NULL) {
|
113
|
-
|
114
|
-
GRPC_CHTTP2_FLOW_CREDIT_STREAM("parse", t, s, outgoing_window,
|
113
|
+
GRPC_CHTTP2_FLOW_CREDIT_STREAM("parse", t, s, outgoing_window_delta,
|
115
114
|
received_update);
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
if (grpc_chttp2_list_remove_stalled_by_stream(t, s)) {
|
116
|
+
grpc_chttp2_become_writable(
|
117
|
+
exec_ctx, t, s, GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED,
|
118
|
+
"stream.read_flow_control");
|
120
119
|
}
|
121
120
|
}
|
122
121
|
} else {
|
@@ -49,6 +49,7 @@
|
|
49
49
|
#include "src/core/ext/transport/chttp2/transport/hpack_table.h"
|
50
50
|
#include "src/core/ext/transport/chttp2/transport/varint.h"
|
51
51
|
#include "src/core/lib/slice/slice_internal.h"
|
52
|
+
#include "src/core/lib/slice/slice_string_helpers.h"
|
52
53
|
#include "src/core/lib/transport/metadata.h"
|
53
54
|
#include "src/core/lib/transport/static_metadata.h"
|
54
55
|
#include "src/core/lib/transport/timeout_encoding.h"
|
@@ -64,6 +65,10 @@
|
|
64
65
|
/* don't consider adding anything bigger than this to the hpack table */
|
65
66
|
#define MAX_DECODER_SPACE_USAGE 512
|
66
67
|
|
68
|
+
static grpc_slice_refcount terminal_slice_refcount = {NULL, NULL};
|
69
|
+
static const grpc_slice terminal_slice = {&terminal_slice_refcount,
|
70
|
+
.data.refcounted = {0, 0}};
|
71
|
+
|
67
72
|
extern int grpc_http_trace;
|
68
73
|
|
69
74
|
typedef struct {
|
@@ -168,6 +173,7 @@ static void add_header_data(framer_state *st, grpc_slice slice) {
|
|
168
173
|
|
169
174
|
static uint8_t *add_tiny_header_data(framer_state *st, size_t len) {
|
170
175
|
ensure_space(st, len);
|
176
|
+
st->stats->header_bytes += len;
|
171
177
|
return grpc_slice_buffer_tiny_add(st->output, len);
|
172
178
|
}
|
173
179
|
|
@@ -185,9 +191,12 @@ static void evict_entry(grpc_chttp2_hpack_compressor *c) {
|
|
185
191
|
|
186
192
|
/* add an element to the decoder table */
|
187
193
|
static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
188
|
-
grpc_mdelem
|
189
|
-
|
190
|
-
|
194
|
+
grpc_mdelem elem) {
|
195
|
+
GPR_ASSERT(GRPC_MDELEM_IS_INTERNED(elem));
|
196
|
+
|
197
|
+
uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
|
198
|
+
uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
|
199
|
+
uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
|
191
200
|
uint32_t new_index = c->tail_remote_index + c->table_elems + 1;
|
192
201
|
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
|
193
202
|
|
@@ -212,17 +221,18 @@ static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
212
221
|
c->table_elems++;
|
213
222
|
|
214
223
|
/* Store this element into {entries,indices}_elem */
|
215
|
-
if (c->entries_elems[HASH_FRAGMENT_2(elem_hash)]
|
224
|
+
if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem)) {
|
216
225
|
/* already there: update with new index */
|
217
226
|
c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
|
218
|
-
} else if (c->entries_elems[HASH_FRAGMENT_3(elem_hash)]
|
227
|
+
} else if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)],
|
228
|
+
elem)) {
|
219
229
|
/* already there (cuckoo): update with new index */
|
220
230
|
c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
|
221
|
-
} else if (c->entries_elems[HASH_FRAGMENT_2(elem_hash)]
|
231
|
+
} else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_2(elem_hash)])) {
|
222
232
|
/* not there, but a free element: add */
|
223
233
|
c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
|
224
234
|
c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
|
225
|
-
} else if (c->entries_elems[HASH_FRAGMENT_3(elem_hash)]
|
235
|
+
} else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_3(elem_hash)])) {
|
226
236
|
/* not there (cuckoo), but a free element: add */
|
227
237
|
c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
|
228
238
|
c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
|
@@ -241,24 +251,34 @@ static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
241
251
|
|
242
252
|
/* do exactly the same for the key (so we can find by that again too) */
|
243
253
|
|
244
|
-
if (c->entries_keys[HASH_FRAGMENT_2(key_hash)]
|
254
|
+
if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)],
|
255
|
+
GRPC_MDKEY(elem))) {
|
245
256
|
c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
|
246
|
-
} else if (c->entries_keys[HASH_FRAGMENT_3(key_hash)]
|
257
|
+
} else if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_3(key_hash)],
|
258
|
+
GRPC_MDKEY(elem))) {
|
247
259
|
c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
|
248
|
-
} else if (c->entries_keys[HASH_FRAGMENT_2(key_hash)] ==
|
249
|
-
|
260
|
+
} else if (c->entries_keys[HASH_FRAGMENT_2(key_hash)].refcount ==
|
261
|
+
&terminal_slice_refcount) {
|
262
|
+
c->entries_keys[HASH_FRAGMENT_2(key_hash)] =
|
263
|
+
grpc_slice_ref_internal(GRPC_MDKEY(elem));
|
250
264
|
c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
|
251
|
-
} else if (c->entries_keys[HASH_FRAGMENT_3(key_hash)] ==
|
252
|
-
|
265
|
+
} else if (c->entries_keys[HASH_FRAGMENT_3(key_hash)].refcount ==
|
266
|
+
&terminal_slice_refcount) {
|
267
|
+
c->entries_keys[HASH_FRAGMENT_3(key_hash)] =
|
268
|
+
grpc_slice_ref_internal(GRPC_MDKEY(elem));
|
253
269
|
c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
|
254
270
|
} else if (c->indices_keys[HASH_FRAGMENT_2(key_hash)] <
|
255
271
|
c->indices_keys[HASH_FRAGMENT_3(key_hash)]) {
|
256
|
-
|
257
|
-
|
272
|
+
grpc_slice_unref_internal(exec_ctx,
|
273
|
+
c->entries_keys[HASH_FRAGMENT_2(key_hash)]);
|
274
|
+
c->entries_keys[HASH_FRAGMENT_2(key_hash)] =
|
275
|
+
grpc_slice_ref_internal(GRPC_MDKEY(elem));
|
258
276
|
c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
|
259
277
|
} else {
|
260
|
-
|
261
|
-
|
278
|
+
grpc_slice_unref_internal(exec_ctx,
|
279
|
+
c->entries_keys[HASH_FRAGMENT_3(key_hash)]);
|
280
|
+
c->entries_keys[HASH_FRAGMENT_3(key_hash)] =
|
281
|
+
grpc_slice_ref_internal(GRPC_MDKEY(elem));
|
262
282
|
c->indices_keys[HASH_FRAGMENT_3(key_hash)] = new_index;
|
263
283
|
}
|
264
284
|
}
|
@@ -270,20 +290,18 @@ static void emit_indexed(grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
|
|
270
290
|
len);
|
271
291
|
}
|
272
292
|
|
273
|
-
static grpc_slice get_wire_value(grpc_mdelem
|
274
|
-
if (grpc_is_binary_header(
|
275
|
-
(const char *)GRPC_SLICE_START_PTR(elem->key->slice),
|
276
|
-
GRPC_SLICE_LENGTH(elem->key->slice))) {
|
293
|
+
static grpc_slice get_wire_value(grpc_mdelem elem, uint8_t *huffman_prefix) {
|
294
|
+
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
|
277
295
|
*huffman_prefix = 0x80;
|
278
|
-
return
|
296
|
+
return grpc_chttp2_base64_encode_and_huffman_compress(GRPC_MDVALUE(elem));
|
279
297
|
}
|
280
298
|
/* TODO(ctiller): opportunistically compress non-binary headers */
|
281
299
|
*huffman_prefix = 0x00;
|
282
|
-
return elem
|
300
|
+
return grpc_slice_ref_internal(GRPC_MDVALUE(elem));
|
283
301
|
}
|
284
302
|
|
285
303
|
static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
|
286
|
-
uint32_t key_index, grpc_mdelem
|
304
|
+
uint32_t key_index, grpc_mdelem elem,
|
287
305
|
framer_state *st) {
|
288
306
|
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
|
289
307
|
uint8_t huffman_prefix;
|
@@ -296,11 +314,11 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
|
|
296
314
|
add_tiny_header_data(st, len_pfx), len_pfx);
|
297
315
|
GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, huffman_prefix,
|
298
316
|
add_tiny_header_data(st, len_val_len), len_val_len);
|
299
|
-
add_header_data(st,
|
317
|
+
add_header_data(st, value_slice);
|
300
318
|
}
|
301
319
|
|
302
320
|
static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
|
303
|
-
uint32_t key_index, grpc_mdelem
|
321
|
+
uint32_t key_index, grpc_mdelem elem,
|
304
322
|
framer_state *st) {
|
305
323
|
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
|
306
324
|
uint8_t huffman_prefix;
|
@@ -313,12 +331,12 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
|
|
313
331
|
add_tiny_header_data(st, len_pfx), len_pfx);
|
314
332
|
GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, huffman_prefix,
|
315
333
|
add_tiny_header_data(st, len_val_len), len_val_len);
|
316
|
-
add_header_data(st,
|
334
|
+
add_header_data(st, value_slice);
|
317
335
|
}
|
318
336
|
|
319
337
|
static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
|
320
|
-
grpc_mdelem
|
321
|
-
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem
|
338
|
+
grpc_mdelem elem, framer_state *st) {
|
339
|
+
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
|
322
340
|
uint8_t huffman_prefix;
|
323
341
|
grpc_slice value_slice = get_wire_value(elem, &huffman_prefix);
|
324
342
|
uint32_t len_val = (uint32_t)GRPC_SLICE_LENGTH(value_slice);
|
@@ -329,15 +347,15 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
|
|
329
347
|
*add_tiny_header_data(st, 1) = 0x40;
|
330
348
|
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
|
331
349
|
add_tiny_header_data(st, len_key_len), len_key_len);
|
332
|
-
add_header_data(st, grpc_slice_ref_internal(elem
|
350
|
+
add_header_data(st, grpc_slice_ref_internal(GRPC_MDKEY(elem)));
|
333
351
|
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, huffman_prefix,
|
334
352
|
add_tiny_header_data(st, len_val_len), len_val_len);
|
335
|
-
add_header_data(st,
|
353
|
+
add_header_data(st, value_slice);
|
336
354
|
}
|
337
355
|
|
338
356
|
static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
|
339
|
-
grpc_mdelem
|
340
|
-
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem
|
357
|
+
grpc_mdelem elem, framer_state *st) {
|
358
|
+
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
|
341
359
|
uint8_t huffman_prefix;
|
342
360
|
grpc_slice value_slice = get_wire_value(elem, &huffman_prefix);
|
343
361
|
uint32_t len_val = (uint32_t)GRPC_SLICE_LENGTH(value_slice);
|
@@ -348,10 +366,10 @@ static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
|
|
348
366
|
*add_tiny_header_data(st, 1) = 0x00;
|
349
367
|
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
|
350
368
|
add_tiny_header_data(st, len_key_len), len_key_len);
|
351
|
-
add_header_data(st, grpc_slice_ref_internal(elem
|
369
|
+
add_header_data(st, grpc_slice_ref_internal(GRPC_MDKEY(elem)));
|
352
370
|
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, huffman_prefix,
|
353
371
|
add_tiny_header_data(st, len_val_len), len_val_len);
|
354
|
-
add_header_data(st,
|
372
|
+
add_header_data(st, value_slice);
|
355
373
|
}
|
356
374
|
|
357
375
|
static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor *c,
|
@@ -369,15 +387,9 @@ static uint32_t dynidx(grpc_chttp2_hpack_compressor *c, uint32_t elem_index) {
|
|
369
387
|
|
370
388
|
/* encode an mdelem */
|
371
389
|
static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
372
|
-
grpc_mdelem
|
373
|
-
|
374
|
-
|
375
|
-
size_t decoder_space_usage;
|
376
|
-
uint32_t indices_key;
|
377
|
-
int should_add_elem;
|
378
|
-
|
379
|
-
GPR_ASSERT(GRPC_SLICE_LENGTH(elem->key->slice) > 0);
|
380
|
-
if (GRPC_SLICE_START_PTR(elem->key->slice)[0] != ':') { /* regular header */
|
390
|
+
grpc_mdelem elem, framer_state *st) {
|
391
|
+
GPR_ASSERT(GRPC_SLICE_LENGTH(GRPC_MDKEY(elem)) > 0);
|
392
|
+
if (GRPC_SLICE_START_PTR(GRPC_MDKEY(elem))[0] != ':') { /* regular header */
|
381
393
|
st->seen_regular_header = 1;
|
382
394
|
} else {
|
383
395
|
GPR_ASSERT(
|
@@ -385,11 +397,39 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
385
397
|
"Reserved header (colon-prefixed) happening after regular ones.");
|
386
398
|
}
|
387
399
|
|
400
|
+
if (grpc_http_trace && !GRPC_MDELEM_IS_INTERNED(elem)) {
|
401
|
+
char *k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
|
402
|
+
char *v = grpc_slice_to_c_string(GRPC_MDVALUE(elem));
|
403
|
+
gpr_log(
|
404
|
+
GPR_DEBUG,
|
405
|
+
"Encode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
|
406
|
+
k, v, GRPC_MDELEM_IS_INTERNED(elem), GRPC_MDELEM_STORAGE(elem),
|
407
|
+
grpc_slice_is_interned(GRPC_MDKEY(elem)),
|
408
|
+
grpc_slice_is_interned(GRPC_MDVALUE(elem)));
|
409
|
+
gpr_free(k);
|
410
|
+
gpr_free(v);
|
411
|
+
}
|
412
|
+
if (!GRPC_MDELEM_IS_INTERNED(elem)) {
|
413
|
+
emit_lithdr_noidx_v(c, elem, st);
|
414
|
+
return;
|
415
|
+
}
|
416
|
+
|
417
|
+
uint32_t key_hash;
|
418
|
+
uint32_t value_hash;
|
419
|
+
uint32_t elem_hash;
|
420
|
+
size_t decoder_space_usage;
|
421
|
+
uint32_t indices_key;
|
422
|
+
int should_add_elem;
|
423
|
+
|
424
|
+
key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
|
425
|
+
value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
|
426
|
+
elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
|
427
|
+
|
388
428
|
inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems);
|
389
429
|
|
390
430
|
/* is this elem currently in the decoders table? */
|
391
431
|
|
392
|
-
if (c->entries_elems[HASH_FRAGMENT_2(elem_hash)]
|
432
|
+
if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) &&
|
393
433
|
c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) {
|
394
434
|
/* HIT: complete element (first cuckoo hash) */
|
395
435
|
emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]),
|
@@ -397,7 +437,7 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
397
437
|
return;
|
398
438
|
}
|
399
439
|
|
400
|
-
if (c->entries_elems[HASH_FRAGMENT_3(elem_hash)]
|
440
|
+
if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) &&
|
401
441
|
c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) {
|
402
442
|
/* HIT: complete element (second cuckoo hash) */
|
403
443
|
emit_indexed(c, dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]),
|
@@ -414,7 +454,8 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
414
454
|
/* no hits for the elem... maybe there's a key? */
|
415
455
|
|
416
456
|
indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)];
|
417
|
-
if (c->entries_keys[HASH_FRAGMENT_2(key_hash)]
|
457
|
+
if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)],
|
458
|
+
GRPC_MDKEY(elem)) &&
|
418
459
|
indices_key > c->tail_remote_index) {
|
419
460
|
/* HIT: key (first cuckoo hash) */
|
420
461
|
if (should_add_elem) {
|
@@ -429,7 +470,8 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
|
|
429
470
|
}
|
430
471
|
|
431
472
|
indices_key = c->indices_keys[HASH_FRAGMENT_3(key_hash)];
|
432
|
-
if (c->entries_keys[HASH_FRAGMENT_3(key_hash)]
|
473
|
+
if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_3(key_hash)],
|
474
|
+
GRPC_MDKEY(elem)) &&
|
433
475
|
indices_key > c->tail_remote_index) {
|
434
476
|
/* HIT: key (first cuckoo hash) */
|
435
477
|
if (should_add_elem) {
|
@@ -463,11 +505,11 @@ static void deadline_enc(grpc_exec_ctx *exec_ctx,
|
|
463
505
|
grpc_chttp2_hpack_compressor *c, gpr_timespec deadline,
|
464
506
|
framer_state *st) {
|
465
507
|
char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
|
466
|
-
grpc_mdelem
|
508
|
+
grpc_mdelem mdelem;
|
467
509
|
grpc_http2_encode_timeout(
|
468
510
|
gpr_time_sub(deadline, gpr_now(deadline.clock_type)), timeout_str);
|
469
|
-
mdelem =
|
470
|
-
|
511
|
+
mdelem = grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_TIMEOUT,
|
512
|
+
grpc_slice_from_copied_string(timeout_str));
|
471
513
|
hpack_enc(exec_ctx, c, mdelem, st);
|
472
514
|
GRPC_MDELEM_UNREF(exec_ctx, mdelem);
|
473
515
|
}
|
@@ -484,14 +526,19 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c) {
|
|
484
526
|
gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
|
485
527
|
memset(c->table_elem_size, 0,
|
486
528
|
sizeof(*c->table_elem_size) * c->cap_table_elems);
|
529
|
+
for (size_t i = 0; i < GPR_ARRAY_SIZE(c->entries_keys); i++) {
|
530
|
+
c->entries_keys[i] = terminal_slice;
|
531
|
+
}
|
487
532
|
}
|
488
533
|
|
489
534
|
void grpc_chttp2_hpack_compressor_destroy(grpc_exec_ctx *exec_ctx,
|
490
535
|
grpc_chttp2_hpack_compressor *c) {
|
491
536
|
int i;
|
492
537
|
for (i = 0; i < GRPC_CHTTP2_HPACKC_NUM_VALUES; i++) {
|
493
|
-
if (c->entries_keys[i]
|
494
|
-
|
538
|
+
if (c->entries_keys[i].refcount != &terminal_slice_refcount) {
|
539
|
+
grpc_slice_unref_internal(exec_ctx, c->entries_keys[i]);
|
540
|
+
}
|
541
|
+
GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[i]);
|
495
542
|
}
|
496
543
|
gpr_free(c->table_elem_size);
|
497
544
|
}
|