grpc 0.14.1 → 0.15.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 +1398 -817
- data/include/grpc/compression.h +2 -1
- data/include/grpc/grpc.h +10 -1
- data/include/grpc/grpc_cronet.h +51 -0
- data/include/grpc/grpc_posix.h +70 -0
- data/include/grpc/impl/codegen/atm.h +2 -2
- data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
- data/include/grpc/impl/codegen/compression_types.h +39 -5
- data/include/grpc/impl/codegen/connectivity_state.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +10 -0
- data/include/grpc/impl/codegen/log.h +2 -1
- data/include/grpc/impl/codegen/port_platform.h +30 -12
- data/include/grpc/impl/codegen/slice_buffer.h +2 -3
- data/include/grpc/impl/codegen/sync.h +2 -2
- data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
- data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
- data/include/grpc/support/avl.h +5 -0
- data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
- data/include/grpc/support/string_util.h +2 -1
- data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
- data/src/core/ext/census/gen/census.pb.c +179 -0
- data/src/core/ext/census/gen/census.pb.h +294 -0
- data/src/core/ext/census/grpc_filter.c +11 -7
- data/src/core/ext/client_config/channel_connectivity.c +28 -14
- data/src/core/ext/client_config/client_channel.c +77 -53
- data/src/core/ext/client_config/connector.h +1 -1
- data/src/core/ext/client_config/lb_policy.c +9 -6
- data/src/core/ext/client_config/lb_policy.h +9 -5
- data/src/core/ext/client_config/subchannel.c +58 -39
- data/src/core/ext/client_config/subchannel.h +3 -2
- data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
- data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
- data/src/core/ext/client_config/subchannel_index.c +20 -9
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
- data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
- data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
- data/src/core/ext/load_reporting/load_reporting.c +133 -0
- data/src/core/ext/load_reporting/load_reporting.h +75 -0
- data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
- data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
- data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
- data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
- data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
- data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
- data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
- data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
- data/src/core/lib/channel/channel_args.c +26 -12
- data/src/core/lib/channel/channel_args.h +1 -1
- data/src/core/lib/channel/channel_stack.c +12 -8
- data/src/core/lib/channel/channel_stack.h +27 -11
- data/src/core/lib/channel/channel_stack_builder.c +2 -2
- data/src/core/lib/channel/compress_filter.c +26 -31
- data/src/core/lib/channel/compress_filter.h +4 -4
- data/src/core/lib/channel/connected_channel.c +7 -5
- data/src/core/lib/channel/http_client_filter.c +34 -8
- data/src/core/lib/channel/http_client_filter.h +1 -1
- data/src/core/lib/channel/http_server_filter.c +21 -12
- data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
- data/src/core/lib/http/httpcli.c +81 -59
- data/src/core/lib/http/httpcli.h +11 -15
- data/src/core/lib/http/httpcli_security_connector.c +5 -3
- data/src/core/lib/http/parser.c +127 -118
- data/src/core/lib/http/parser.h +11 -6
- data/src/core/lib/iomgr/closure.c +20 -16
- data/src/core/lib/iomgr/closure.h +19 -15
- data/src/core/lib/iomgr/endpoint.h +1 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
- data/src/core/lib/iomgr/error.c +535 -0
- data/src/core/lib/iomgr/error.h +192 -0
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
- data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
- data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
- data/src/core/lib/iomgr/ev_posix.c +104 -14
- data/src/core/lib/iomgr/ev_posix.h +17 -7
- data/src/core/lib/iomgr/exec_ctx.c +25 -7
- data/src/core/lib/iomgr/exec_ctx.h +27 -8
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/executor.h +1 -1
- data/src/core/lib/iomgr/iocp_windows.c +2 -41
- data/src/core/lib/iomgr/iocp_windows.h +0 -8
- data/src/core/lib/iomgr/iomgr.c +5 -4
- data/src/core/lib/iomgr/iomgr_posix.c +5 -1
- data/src/core/lib/iomgr/iomgr_windows.c +1 -1
- data/src/core/lib/{support → iomgr}/load_file.c +15 -17
- data/src/core/lib/{support → iomgr}/load_file.h +8 -7
- data/src/core/lib/iomgr/polling_entity.c +104 -0
- data/src/core/lib/iomgr/polling_entity.h +81 -0
- data/src/core/lib/iomgr/pollset.h +6 -5
- data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
- data/src/core/lib/iomgr/pollset_windows.c +10 -6
- data/src/core/lib/iomgr/resolve_address.h +5 -9
- data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
- data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
- data/src/core/lib/iomgr/sockaddr.h +2 -2
- data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
- data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
- data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
- data/src/core/lib/iomgr/socket_windows.c +61 -2
- data/src/core/lib/iomgr/socket_windows.h +13 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
- data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
- data/src/core/lib/iomgr/tcp_posix.c +43 -39
- data/src/core/lib/iomgr/tcp_server.h +5 -3
- data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
- data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
- data/src/core/lib/iomgr/tcp_windows.c +45 -50
- data/src/core/lib/iomgr/tcp_windows.h +1 -1
- data/src/core/lib/iomgr/timer.c +26 -13
- data/src/core/lib/iomgr/udp_server.c +28 -4
- data/src/core/lib/iomgr/udp_server.h +5 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
- data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
- data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
- data/src/core/lib/iomgr/workqueue.h +5 -4
- data/src/core/lib/iomgr/workqueue_posix.c +40 -26
- data/src/core/lib/iomgr/workqueue_windows.c +2 -2
- data/src/core/lib/profiling/basic_timers.c +2 -2
- data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
- data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
- data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
- data/src/core/lib/security/credentials/credentials.c +233 -0
- data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
- data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
- data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
- data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
- data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
- data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
- data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
- data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
- data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
- data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
- data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
- data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
- data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
- data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
- data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
- data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
- data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
- data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
- data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
- data/src/core/lib/security/transport/tsi_error.c +40 -0
- data/src/core/lib/security/transport/tsi_error.h +42 -0
- data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
- data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
- data/src/core/lib/security/util/json_util.c +61 -0
- data/src/core/lib/security/util/json_util.h +55 -0
- data/src/core/lib/support/avl.c +11 -0
- data/src/core/lib/support/cpu_windows.c +2 -2
- data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
- data/src/core/lib/support/log.c +3 -1
- data/src/core/lib/support/log_linux.c +2 -2
- data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
- data/src/core/lib/support/murmur_hash.c +3 -5
- data/src/core/lib/support/string.c +10 -0
- data/src/core/lib/support/string.h +4 -0
- data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
- data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
- data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
- data/src/core/lib/support/subprocess_windows.c +1 -1
- data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
- data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
- data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
- data/src/core/lib/support/tmpfile_msys.c +1 -1
- data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
- data/src/core/lib/surface/alarm.c +2 -2
- data/src/core/lib/surface/byte_buffer_reader.c +13 -6
- data/src/core/lib/surface/call.c +323 -123
- data/src/core/lib/surface/call.h +2 -0
- data/src/core/lib/surface/call_log_batch.c +1 -1
- data/src/core/lib/surface/channel.c +64 -15
- data/src/core/lib/surface/channel.h +9 -0
- data/src/core/lib/surface/channel_ping.c +3 -3
- data/src/core/lib/surface/completion_queue.c +75 -19
- data/src/core/lib/surface/completion_queue.h +7 -2
- data/src/core/lib/surface/init.c +2 -1
- data/src/core/lib/surface/init_secure.c +4 -4
- data/src/core/lib/surface/lame_client.c +12 -8
- data/src/core/lib/surface/server.c +213 -120
- data/src/core/lib/surface/server.h +1 -0
- data/src/core/lib/surface/version.c +1 -1
- data/src/core/lib/transport/connectivity_state.c +40 -18
- data/src/core/lib/transport/connectivity_state.h +4 -1
- data/src/core/lib/transport/metadata.c +23 -23
- data/src/core/lib/transport/metadata.h +4 -0
- data/src/core/lib/transport/metadata_batch.c +9 -0
- data/src/core/lib/transport/metadata_batch.h +3 -0
- data/src/core/lib/transport/static_metadata.c +6 -5
- data/src/core/lib/transport/static_metadata.h +64 -60
- data/src/core/lib/transport/transport.c +24 -12
- data/src/core/lib/transport/transport.h +6 -5
- data/src/core/lib/transport/transport_impl.h +4 -0
- data/src/core/lib/transport/transport_op_string.c +2 -2
- data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
- data/src/ruby/bin/math_services.rb +41 -2
- data/src/ruby/ext/grpc/rb_call.c +42 -40
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
- data/src/ruby/ext/grpc/rb_loader.c +1 -1
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc.rb +0 -3
- data/src/ruby/lib/grpc/errors.rb +3 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
- data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
- data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
- data/src/ruby/lib/grpc/generic/service.rb +8 -8
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
- data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
- data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
- data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
- data/src/ruby/pb/test/client.rb +5 -2
- data/src/ruby/spec/generic/active_call_spec.rb +3 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
- data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
- data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
- data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
- metadata +86 -48
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
- data/src/core/lib/security/credentials.c +0 -1296
- data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -44,9 +44,8 @@
|
|
44
44
|
|
45
45
|
typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser;
|
46
46
|
|
47
|
-
typedef
|
48
|
-
|
49
|
-
const uint8_t *end);
|
47
|
+
typedef grpc_error *(*grpc_chttp2_hpack_parser_state)(
|
48
|
+
grpc_chttp2_hpack_parser *p, const uint8_t *beg, const uint8_t *end);
|
50
49
|
|
51
50
|
typedef struct {
|
52
51
|
char *str;
|
@@ -59,6 +58,8 @@ struct grpc_chttp2_hpack_parser {
|
|
59
58
|
void (*on_header)(void *user_data, grpc_mdelem *md);
|
60
59
|
void *on_header_user_data;
|
61
60
|
|
61
|
+
grpc_error *last_error;
|
62
|
+
|
62
63
|
/* current parse state - or a function that implements it */
|
63
64
|
grpc_chttp2_hpack_parser_state state;
|
64
65
|
/* future states dependent on the opening op code */
|
@@ -103,12 +104,13 @@ void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser *p);
|
|
103
104
|
void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p);
|
104
105
|
|
105
106
|
/* returns 1 on success, 0 on error */
|
106
|
-
|
107
|
-
|
107
|
+
grpc_error *grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p,
|
108
|
+
const uint8_t *beg,
|
109
|
+
const uint8_t *end);
|
108
110
|
|
109
111
|
/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
|
110
112
|
the transport */
|
111
|
-
|
113
|
+
grpc_error *grpc_chttp2_header_parser_parse(
|
112
114
|
grpc_exec_ctx *exec_ctx, void *hpack_parser,
|
113
115
|
grpc_chttp2_transport_parsing *transport_parsing,
|
114
116
|
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
|
@@ -38,6 +38,7 @@
|
|
38
38
|
|
39
39
|
#include <grpc/support/alloc.h>
|
40
40
|
#include <grpc/support/log.h>
|
41
|
+
#include <grpc/support/string_util.h>
|
41
42
|
|
42
43
|
#include "src/core/lib/support/murmur_hash.h"
|
43
44
|
|
@@ -262,18 +263,19 @@ void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl,
|
|
262
263
|
tbl->max_bytes = max_bytes;
|
263
264
|
}
|
264
265
|
|
265
|
-
|
266
|
-
|
266
|
+
grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
|
267
|
+
uint32_t bytes) {
|
267
268
|
if (tbl->current_table_bytes == bytes) {
|
268
|
-
return
|
269
|
+
return GRPC_ERROR_NONE;
|
269
270
|
}
|
270
271
|
if (bytes > tbl->max_bytes) {
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
272
|
+
char *msg;
|
273
|
+
gpr_asprintf(&msg,
|
274
|
+
"Attempt to make hpack table %d bytes when max is %d bytes",
|
275
|
+
bytes, tbl->max_bytes);
|
276
|
+
grpc_error *err = GRPC_ERROR_CREATE(msg);
|
277
|
+
gpr_free(msg);
|
278
|
+
return err;
|
277
279
|
}
|
278
280
|
if (grpc_http_trace) {
|
279
281
|
gpr_log(GPR_DEBUG, "Update hpack parser table size to %d", bytes);
|
@@ -291,23 +293,25 @@ int grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
|
|
291
293
|
rebuild_ents(tbl, new_cap);
|
292
294
|
}
|
293
295
|
}
|
294
|
-
return
|
296
|
+
return GRPC_ERROR_NONE;
|
295
297
|
}
|
296
298
|
|
297
|
-
|
299
|
+
grpc_error *grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
|
298
300
|
/* determine how many bytes of buffer this entry represents */
|
299
301
|
size_t elem_bytes = GPR_SLICE_LENGTH(md->key->slice) +
|
300
302
|
GPR_SLICE_LENGTH(md->value->slice) +
|
301
303
|
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
|
302
304
|
|
303
305
|
if (tbl->current_table_bytes > tbl->max_bytes) {
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
306
|
+
char *msg;
|
307
|
+
gpr_asprintf(
|
308
|
+
&msg,
|
309
|
+
"HPACK max table size reduced to %d but not reflected by hpack "
|
310
|
+
"stream (still at %d)",
|
311
|
+
tbl->max_bytes, tbl->current_table_bytes);
|
312
|
+
grpc_error *err = GRPC_ERROR_CREATE(msg);
|
313
|
+
gpr_free(msg);
|
314
|
+
return err;
|
311
315
|
}
|
312
316
|
|
313
317
|
/* we can't add elements bigger than the max table size */
|
@@ -324,7 +328,7 @@ int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
|
|
324
328
|
while (tbl->num_ents) {
|
325
329
|
evict1(tbl);
|
326
330
|
}
|
327
|
-
return
|
331
|
+
return GRPC_ERROR_NONE;
|
328
332
|
}
|
329
333
|
|
330
334
|
/* evict entries to ensure no overflow */
|
@@ -339,7 +343,7 @@ int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
|
|
339
343
|
/* update accounting values */
|
340
344
|
tbl->num_ents++;
|
341
345
|
tbl->mem_used += (uint32_t)elem_bytes;
|
342
|
-
return
|
346
|
+
return GRPC_ERROR_NONE;
|
343
347
|
}
|
344
348
|
|
345
349
|
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
|
@@ -36,6 +36,7 @@
|
|
36
36
|
|
37
37
|
#include <grpc/support/port_platform.h>
|
38
38
|
#include <grpc/support/slice.h>
|
39
|
+
#include "src/core/lib/iomgr/error.h"
|
39
40
|
#include "src/core/lib/transport/metadata.h"
|
40
41
|
|
41
42
|
/* HPACK header table */
|
@@ -87,15 +88,15 @@ void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl);
|
|
87
88
|
void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl *tbl);
|
88
89
|
void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl *tbl,
|
89
90
|
uint32_t max_bytes);
|
90
|
-
|
91
|
-
|
91
|
+
grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
|
92
|
+
uint32_t bytes);
|
92
93
|
|
93
94
|
/* lookup a table entry based on its hpack index */
|
94
95
|
grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
|
95
96
|
uint32_t index);
|
96
97
|
/* add a table entry to the index */
|
97
|
-
|
98
|
-
|
98
|
+
grpc_error *grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl,
|
99
|
+
grpc_mdelem *md) GRPC_MUST_USE_RESULT;
|
99
100
|
/* Find a key/value pair in the table... returns the index in the table of the
|
100
101
|
most similar entry, or 0 if the value was not found */
|
101
102
|
typedef struct {
|
@@ -65,6 +65,7 @@ void grpc_chttp2_incoming_metadata_buffer_add(
|
|
65
65
|
gpr_realloc(buffer->elems, sizeof(*buffer->elems) * buffer->capacity);
|
66
66
|
}
|
67
67
|
buffer->elems[buffer->count++].md = elem;
|
68
|
+
buffer->size += GRPC_MDELEM_LENGTH(elem);
|
68
69
|
}
|
69
70
|
|
70
71
|
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
|
@@ -156,7 +156,7 @@ struct grpc_chttp2_incoming_byte_stream {
|
|
156
156
|
grpc_byte_stream base;
|
157
157
|
gpr_refcount refs;
|
158
158
|
struct grpc_chttp2_incoming_byte_stream *next_message;
|
159
|
-
|
159
|
+
grpc_error *error;
|
160
160
|
|
161
161
|
grpc_chttp2_transport *transport;
|
162
162
|
grpc_chttp2_stream *stream;
|
@@ -265,6 +265,7 @@ struct grpc_chttp2_transport_parsing {
|
|
265
265
|
uint8_t incoming_frame_type;
|
266
266
|
uint8_t incoming_frame_flags;
|
267
267
|
uint8_t header_eof;
|
268
|
+
bool is_first_frame;
|
268
269
|
uint32_t expect_continuation_stream_id;
|
269
270
|
uint32_t incoming_frame_size;
|
270
271
|
uint32_t incoming_stream_id;
|
@@ -275,10 +276,10 @@ struct grpc_chttp2_transport_parsing {
|
|
275
276
|
/* active parser */
|
276
277
|
void *parser_data;
|
277
278
|
grpc_chttp2_stream_parsing *incoming_stream;
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
279
|
+
grpc_error *(*parser)(grpc_exec_ctx *exec_ctx, void *parser_user_data,
|
280
|
+
grpc_chttp2_transport_parsing *transport_parsing,
|
281
|
+
grpc_chttp2_stream_parsing *stream_parsing,
|
282
|
+
gpr_slice slice, int is_last);
|
282
283
|
|
283
284
|
/* received settings */
|
284
285
|
uint32_t settings[GRPC_CHTTP2_NUM_SETTINGS];
|
@@ -383,6 +384,9 @@ struct grpc_chttp2_transport {
|
|
383
384
|
|
384
385
|
/** Transport op to be applied post-parsing */
|
385
386
|
grpc_transport_op *post_parsing_op;
|
387
|
+
|
388
|
+
/** Message explaining the reason of dropping connection */
|
389
|
+
gpr_slice optional_drop_message;
|
386
390
|
};
|
387
391
|
|
388
392
|
typedef struct {
|
@@ -422,23 +426,22 @@ typedef struct {
|
|
422
426
|
/** number of streams that are currently being read */
|
423
427
|
gpr_refcount active_streams;
|
424
428
|
|
425
|
-
/**
|
426
|
-
'queued'; when the close is flow controlled into the send path, we are
|
427
|
-
'sending' it; when the write has been performed it is 'sent' */
|
429
|
+
/** Is this stream closed for writing. */
|
428
430
|
bool write_closed;
|
429
|
-
/**
|
431
|
+
/** Is this stream reading half-closed. */
|
430
432
|
bool read_closed;
|
431
|
-
/**
|
433
|
+
/** Are all published incoming byte streams closed. */
|
432
434
|
bool all_incoming_byte_streams_finished;
|
433
|
-
/**
|
435
|
+
/** Is this stream in the stream map. */
|
434
436
|
bool in_stream_map;
|
435
|
-
/**
|
436
|
-
can be thrown away */
|
437
|
+
/** Has this stream seen an error.
|
438
|
+
If true, then pending incoming frames can be thrown away. */
|
437
439
|
bool seen_error;
|
440
|
+
bool exceeded_metadata_size;
|
438
441
|
|
439
442
|
bool published_initial_metadata;
|
440
443
|
bool published_trailing_metadata;
|
441
|
-
bool
|
444
|
+
bool final_metadata_requested;
|
442
445
|
|
443
446
|
grpc_chttp2_incoming_metadata_buffer received_initial_metadata;
|
444
447
|
grpc_chttp2_incoming_metadata_buffer received_trailing_metadata;
|
@@ -470,24 +473,23 @@ typedef struct {
|
|
470
473
|
} grpc_chttp2_stream_writing;
|
471
474
|
|
472
475
|
struct grpc_chttp2_stream_parsing {
|
476
|
+
/** saw some stream level error */
|
477
|
+
grpc_error *forced_close_error;
|
473
478
|
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
|
474
479
|
uint32_t id;
|
475
480
|
/** has this stream received a close */
|
476
481
|
uint8_t received_close;
|
477
|
-
/** saw a rst_stream */
|
478
|
-
uint8_t saw_rst_stream;
|
479
482
|
/** how many header frames have we received? */
|
480
483
|
uint8_t header_frames_received;
|
481
484
|
/** which metadata did we get (on this parse) */
|
482
485
|
uint8_t got_metadata_on_parse[2];
|
483
486
|
/** should we raise the seen_error flag in transport_global */
|
484
|
-
|
487
|
+
bool seen_error;
|
488
|
+
bool exceeded_metadata_size;
|
485
489
|
/** window available for peer to send to us */
|
486
490
|
int64_t incoming_window;
|
487
491
|
/** parsing state for data frames */
|
488
492
|
grpc_chttp2_data_parser data_parser;
|
489
|
-
/** reason give to rst_stream */
|
490
|
-
uint32_t rst_stream_reason;
|
491
493
|
/** amount of window given */
|
492
494
|
int64_t outgoing_window;
|
493
495
|
/** number of bytes received - reset at end of parse thread execution */
|
@@ -524,13 +526,12 @@ struct grpc_chttp2_stream {
|
|
524
526
|
are required, and schedule them if so */
|
525
527
|
int grpc_chttp2_unlocking_check_writes(grpc_exec_ctx *exec_ctx,
|
526
528
|
grpc_chttp2_transport_global *global,
|
527
|
-
grpc_chttp2_transport_writing *writing
|
528
|
-
int is_parsing);
|
529
|
+
grpc_chttp2_transport_writing *writing);
|
529
530
|
void grpc_chttp2_perform_writes(
|
530
531
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_writing *transport_writing,
|
531
532
|
grpc_endpoint *endpoint);
|
532
533
|
void grpc_chttp2_terminate_writing(grpc_exec_ctx *exec_ctx,
|
533
|
-
void *transport_writing,
|
534
|
+
void *transport_writing, grpc_error *error);
|
534
535
|
void grpc_chttp2_cleanup_writing(grpc_exec_ctx *exec_ctx,
|
535
536
|
grpc_chttp2_transport_global *global,
|
536
537
|
grpc_chttp2_transport_writing *writing);
|
@@ -539,9 +540,9 @@ void grpc_chttp2_prepare_to_read(grpc_chttp2_transport_global *global,
|
|
539
540
|
grpc_chttp2_transport_parsing *parsing);
|
540
541
|
/** Process one slice of incoming data; return 1 if the connection is still
|
541
542
|
viable after reading, or 0 if the connection should be torn down */
|
542
|
-
|
543
|
-
|
544
|
-
|
543
|
+
grpc_error *grpc_chttp2_perform_read(
|
544
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
545
|
+
gpr_slice slice);
|
545
546
|
void grpc_chttp2_publish_reads(grpc_exec_ctx *exec_ctx,
|
546
547
|
grpc_chttp2_transport_global *global,
|
547
548
|
grpc_chttp2_transport_parsing *parsing);
|
@@ -671,9 +672,10 @@ void grpc_chttp2_for_all_streams(
|
|
671
672
|
void grpc_chttp2_parsing_become_skip_parser(
|
672
673
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
|
673
674
|
|
674
|
-
void grpc_chttp2_complete_closure_step(
|
675
|
-
|
676
|
-
|
675
|
+
void grpc_chttp2_complete_closure_step(
|
676
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global,
|
677
|
+
grpc_chttp2_stream_global *stream_global, grpc_closure **pclosure,
|
678
|
+
grpc_error *error);
|
677
679
|
|
678
680
|
void grpc_chttp2_run_with_global_lock(grpc_exec_ctx *exec_ctx,
|
679
681
|
grpc_chttp2_transport *transport,
|
@@ -776,8 +778,8 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx,
|
|
776
778
|
grpc_status_code status, gpr_slice *details);
|
777
779
|
void grpc_chttp2_mark_stream_closed(
|
778
780
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global,
|
779
|
-
grpc_chttp2_stream_global *stream_global, int close_reads,
|
780
|
-
|
781
|
+
grpc_chttp2_stream_global *stream_global, int close_reads, int close_writes,
|
782
|
+
grpc_error *error);
|
781
783
|
void grpc_chttp2_start_writing(grpc_exec_ctx *exec_ctx,
|
782
784
|
grpc_chttp2_transport_global *transport_global);
|
783
785
|
|
@@ -809,8 +811,8 @@ void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx,
|
|
809
811
|
grpc_chttp2_incoming_byte_stream *bs,
|
810
812
|
gpr_slice slice);
|
811
813
|
void grpc_chttp2_incoming_byte_stream_finished(
|
812
|
-
grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
|
813
|
-
int from_parsing_thread);
|
814
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs,
|
815
|
+
grpc_error *error, int from_parsing_thread);
|
814
816
|
|
815
817
|
void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx,
|
816
818
|
grpc_chttp2_transport_parsing *parsing,
|
@@ -45,30 +45,34 @@
|
|
45
45
|
#include "src/core/lib/profiling/timers.h"
|
46
46
|
#include "src/core/lib/transport/static_metadata.h"
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
#define TRANSPORT_FROM_PARSING(tp) \
|
49
|
+
((grpc_chttp2_transport *)((char *)(tp)-offsetof(grpc_chttp2_transport, \
|
50
|
+
parsing)))
|
51
|
+
|
52
|
+
static grpc_error *init_frame_parser(
|
53
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
|
54
|
+
static grpc_error *init_header_frame_parser(
|
51
55
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
52
56
|
int is_continuation);
|
53
|
-
static
|
57
|
+
static grpc_error *init_data_frame_parser(
|
58
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
|
59
|
+
static grpc_error *init_rst_stream_parser(
|
54
60
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
|
55
|
-
static
|
61
|
+
static grpc_error *init_settings_frame_parser(
|
56
62
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
|
57
|
-
static
|
63
|
+
static grpc_error *init_window_update_frame_parser(
|
58
64
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
|
59
|
-
static
|
65
|
+
static grpc_error *init_ping_parser(
|
60
66
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
|
61
|
-
static
|
62
|
-
|
63
|
-
static
|
64
|
-
grpc_chttp2_transport_parsing *transport_parsing);
|
65
|
-
static int init_skip_frame_parser(
|
67
|
+
static grpc_error *init_goaway_parser(
|
68
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing);
|
69
|
+
static grpc_error *init_skip_frame_parser(
|
66
70
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
67
71
|
int is_header);
|
68
72
|
|
69
|
-
static
|
70
|
-
|
71
|
-
|
73
|
+
static grpc_error *parse_frame_slice(
|
74
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
75
|
+
gpr_slice slice, int is_last);
|
72
76
|
|
73
77
|
void grpc_chttp2_prepare_to_read(
|
74
78
|
grpc_chttp2_transport_global *transport_global,
|
@@ -170,7 +174,9 @@ void grpc_chttp2_publish_reads(
|
|
170
174
|
while (grpc_chttp2_list_pop_parsing_seen_stream(
|
171
175
|
transport_global, transport_parsing, &stream_global, &stream_parsing)) {
|
172
176
|
if (stream_parsing->seen_error) {
|
173
|
-
stream_global->seen_error =
|
177
|
+
stream_global->seen_error = true;
|
178
|
+
stream_global->exceeded_metadata_size =
|
179
|
+
stream_parsing->exceeded_metadata_size;
|
174
180
|
grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
|
175
181
|
}
|
176
182
|
|
@@ -224,38 +230,42 @@ void grpc_chttp2_publish_reads(
|
|
224
230
|
grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
|
225
231
|
}
|
226
232
|
|
227
|
-
if (stream_parsing->
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
233
|
+
if (stream_parsing->forced_close_error != GRPC_ERROR_NONE) {
|
234
|
+
intptr_t reason;
|
235
|
+
bool has_reason = grpc_error_get_int(stream_parsing->forced_close_error,
|
236
|
+
GRPC_ERROR_INT_HTTP2_ERROR, &reason);
|
237
|
+
if (has_reason && reason != GRPC_CHTTP2_NO_ERROR) {
|
238
|
+
grpc_status_code status_code =
|
239
|
+
has_reason ? grpc_chttp2_http2_error_to_grpc_status(
|
240
|
+
(grpc_chttp2_error_code)reason)
|
241
|
+
: GRPC_STATUS_INTERNAL;
|
242
|
+
const char *status_details =
|
243
|
+
grpc_error_string(stream_parsing->forced_close_error);
|
244
|
+
gpr_slice slice_details = gpr_slice_from_copied_string(status_details);
|
245
|
+
grpc_error_free_string(status_details);
|
237
246
|
grpc_chttp2_fake_status(exec_ctx, transport_global, stream_global,
|
238
247
|
status_code, &slice_details);
|
239
248
|
}
|
240
249
|
grpc_chttp2_mark_stream_closed(exec_ctx, transport_global, stream_global,
|
241
|
-
1, 1);
|
250
|
+
1, 1, stream_parsing->forced_close_error);
|
242
251
|
}
|
243
252
|
|
244
253
|
if (stream_parsing->received_close) {
|
245
254
|
grpc_chttp2_mark_stream_closed(exec_ctx, transport_global, stream_global,
|
246
|
-
1, 0);
|
255
|
+
1, 0, GRPC_ERROR_NONE);
|
247
256
|
}
|
248
257
|
}
|
249
258
|
}
|
250
259
|
|
251
|
-
|
252
|
-
|
253
|
-
|
260
|
+
grpc_error *grpc_chttp2_perform_read(
|
261
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
262
|
+
gpr_slice slice) {
|
254
263
|
uint8_t *beg = GPR_SLICE_START_PTR(slice);
|
255
264
|
uint8_t *end = GPR_SLICE_END_PTR(slice);
|
256
265
|
uint8_t *cur = beg;
|
266
|
+
grpc_error *err;
|
257
267
|
|
258
|
-
if (cur == end) return
|
268
|
+
if (cur == end) return GRPC_ERROR_NONE;
|
259
269
|
|
260
270
|
switch (transport_parsing->deframe_state) {
|
261
271
|
case GRPC_DTS_CLIENT_PREFIX_0:
|
@@ -285,21 +295,25 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
285
295
|
while (cur != end && transport_parsing->deframe_state != GRPC_DTS_FH_0) {
|
286
296
|
if (*cur != GRPC_CHTTP2_CLIENT_CONNECT_STRING[transport_parsing
|
287
297
|
->deframe_state]) {
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
298
|
+
char *msg;
|
299
|
+
gpr_asprintf(
|
300
|
+
&msg,
|
301
|
+
"Connect string mismatch: expected '%c' (%d) got '%c' (%d) "
|
302
|
+
"at byte %d",
|
303
|
+
GRPC_CHTTP2_CLIENT_CONNECT_STRING[transport_parsing
|
304
|
+
->deframe_state],
|
305
|
+
(int)(uint8_t)GRPC_CHTTP2_CLIENT_CONNECT_STRING
|
306
|
+
[transport_parsing->deframe_state],
|
307
|
+
*cur, (int)*cur, transport_parsing->deframe_state);
|
308
|
+
err = GRPC_ERROR_CREATE(msg);
|
309
|
+
gpr_free(msg);
|
310
|
+
return err;
|
297
311
|
}
|
298
312
|
++cur;
|
299
313
|
++transport_parsing->deframe_state;
|
300
314
|
}
|
301
315
|
if (cur == end) {
|
302
|
-
return
|
316
|
+
return GRPC_ERROR_NONE;
|
303
317
|
}
|
304
318
|
/* fallthrough */
|
305
319
|
dts_fh_0:
|
@@ -308,7 +322,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
308
322
|
transport_parsing->incoming_frame_size = ((uint32_t)*cur) << 16;
|
309
323
|
if (++cur == end) {
|
310
324
|
transport_parsing->deframe_state = GRPC_DTS_FH_1;
|
311
|
-
return
|
325
|
+
return GRPC_ERROR_NONE;
|
312
326
|
}
|
313
327
|
/* fallthrough */
|
314
328
|
case GRPC_DTS_FH_1:
|
@@ -316,7 +330,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
316
330
|
transport_parsing->incoming_frame_size |= ((uint32_t)*cur) << 8;
|
317
331
|
if (++cur == end) {
|
318
332
|
transport_parsing->deframe_state = GRPC_DTS_FH_2;
|
319
|
-
return
|
333
|
+
return GRPC_ERROR_NONE;
|
320
334
|
}
|
321
335
|
/* fallthrough */
|
322
336
|
case GRPC_DTS_FH_2:
|
@@ -324,7 +338,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
324
338
|
transport_parsing->incoming_frame_size |= *cur;
|
325
339
|
if (++cur == end) {
|
326
340
|
transport_parsing->deframe_state = GRPC_DTS_FH_3;
|
327
|
-
return
|
341
|
+
return GRPC_ERROR_NONE;
|
328
342
|
}
|
329
343
|
/* fallthrough */
|
330
344
|
case GRPC_DTS_FH_3:
|
@@ -332,7 +346,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
332
346
|
transport_parsing->incoming_frame_type = *cur;
|
333
347
|
if (++cur == end) {
|
334
348
|
transport_parsing->deframe_state = GRPC_DTS_FH_4;
|
335
|
-
return
|
349
|
+
return GRPC_ERROR_NONE;
|
336
350
|
}
|
337
351
|
/* fallthrough */
|
338
352
|
case GRPC_DTS_FH_4:
|
@@ -340,7 +354,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
340
354
|
transport_parsing->incoming_frame_flags = *cur;
|
341
355
|
if (++cur == end) {
|
342
356
|
transport_parsing->deframe_state = GRPC_DTS_FH_5;
|
343
|
-
return
|
357
|
+
return GRPC_ERROR_NONE;
|
344
358
|
}
|
345
359
|
/* fallthrough */
|
346
360
|
case GRPC_DTS_FH_5:
|
@@ -348,7 +362,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
348
362
|
transport_parsing->incoming_stream_id = (((uint32_t)*cur) & 0x7f) << 24;
|
349
363
|
if (++cur == end) {
|
350
364
|
transport_parsing->deframe_state = GRPC_DTS_FH_6;
|
351
|
-
return
|
365
|
+
return GRPC_ERROR_NONE;
|
352
366
|
}
|
353
367
|
/* fallthrough */
|
354
368
|
case GRPC_DTS_FH_6:
|
@@ -356,7 +370,7 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
356
370
|
transport_parsing->incoming_stream_id |= ((uint32_t)*cur) << 16;
|
357
371
|
if (++cur == end) {
|
358
372
|
transport_parsing->deframe_state = GRPC_DTS_FH_7;
|
359
|
-
return
|
373
|
+
return GRPC_ERROR_NONE;
|
360
374
|
}
|
361
375
|
/* fallthrough */
|
362
376
|
case GRPC_DTS_FH_7:
|
@@ -364,15 +378,16 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
364
378
|
transport_parsing->incoming_stream_id |= ((uint32_t)*cur) << 8;
|
365
379
|
if (++cur == end) {
|
366
380
|
transport_parsing->deframe_state = GRPC_DTS_FH_8;
|
367
|
-
return
|
381
|
+
return GRPC_ERROR_NONE;
|
368
382
|
}
|
369
383
|
/* fallthrough */
|
370
384
|
case GRPC_DTS_FH_8:
|
371
385
|
GPR_ASSERT(cur < end);
|
372
386
|
transport_parsing->incoming_stream_id |= ((uint32_t)*cur);
|
373
387
|
transport_parsing->deframe_state = GRPC_DTS_FRAME;
|
374
|
-
|
375
|
-
|
388
|
+
err = init_frame_parser(exec_ctx, transport_parsing);
|
389
|
+
if (err != GRPC_ERROR_NONE) {
|
390
|
+
return err;
|
376
391
|
}
|
377
392
|
if (transport_parsing->incoming_stream_id != 0 &&
|
378
393
|
transport_parsing->incoming_stream_id >
|
@@ -381,62 +396,69 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
381
396
|
transport_parsing->incoming_stream_id;
|
382
397
|
}
|
383
398
|
if (transport_parsing->incoming_frame_size == 0) {
|
384
|
-
|
385
|
-
|
386
|
-
|
399
|
+
err = parse_frame_slice(exec_ctx, transport_parsing, gpr_empty_slice(),
|
400
|
+
1);
|
401
|
+
if (err != GRPC_ERROR_NONE) {
|
402
|
+
return err;
|
387
403
|
}
|
388
404
|
transport_parsing->incoming_stream = NULL;
|
389
405
|
if (++cur == end) {
|
390
406
|
transport_parsing->deframe_state = GRPC_DTS_FH_0;
|
391
|
-
return
|
407
|
+
return GRPC_ERROR_NONE;
|
392
408
|
}
|
393
409
|
goto dts_fh_0; /* loop */
|
394
410
|
} else if (transport_parsing->incoming_frame_size >
|
395
411
|
transport_parsing->max_frame_size) {
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
412
|
+
char *msg;
|
413
|
+
gpr_asprintf(&msg, "Frame size %d is larger than max frame size %d",
|
414
|
+
transport_parsing->incoming_frame_size,
|
415
|
+
transport_parsing->max_frame_size);
|
416
|
+
err = GRPC_ERROR_CREATE(msg);
|
417
|
+
gpr_free(msg);
|
418
|
+
return err;
|
400
419
|
}
|
401
420
|
if (++cur == end) {
|
402
|
-
return
|
421
|
+
return GRPC_ERROR_NONE;
|
403
422
|
}
|
404
423
|
/* fallthrough */
|
405
424
|
case GRPC_DTS_FRAME:
|
406
425
|
GPR_ASSERT(cur < end);
|
407
426
|
if ((uint32_t)(end - cur) == transport_parsing->incoming_frame_size) {
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
427
|
+
err = parse_frame_slice(exec_ctx, transport_parsing,
|
428
|
+
gpr_slice_sub_no_ref(slice, (size_t)(cur - beg),
|
429
|
+
(size_t)(end - beg)),
|
430
|
+
1);
|
431
|
+
if (err != GRPC_ERROR_NONE) {
|
432
|
+
return err;
|
413
433
|
}
|
414
434
|
transport_parsing->deframe_state = GRPC_DTS_FH_0;
|
415
435
|
transport_parsing->incoming_stream = NULL;
|
416
|
-
return
|
436
|
+
return GRPC_ERROR_NONE;
|
417
437
|
} else if ((uint32_t)(end - cur) >
|
418
438
|
transport_parsing->incoming_frame_size) {
|
419
439
|
size_t cur_offset = (size_t)(cur - beg);
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
440
|
+
err = parse_frame_slice(
|
441
|
+
exec_ctx, transport_parsing,
|
442
|
+
gpr_slice_sub_no_ref(
|
443
|
+
slice, cur_offset,
|
444
|
+
cur_offset + transport_parsing->incoming_frame_size),
|
445
|
+
1);
|
446
|
+
if (err != GRPC_ERROR_NONE) {
|
447
|
+
return err;
|
427
448
|
}
|
428
449
|
cur += transport_parsing->incoming_frame_size;
|
429
450
|
transport_parsing->incoming_stream = NULL;
|
430
451
|
goto dts_fh_0; /* loop */
|
431
452
|
} else {
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
453
|
+
err = parse_frame_slice(exec_ctx, transport_parsing,
|
454
|
+
gpr_slice_sub_no_ref(slice, (size_t)(cur - beg),
|
455
|
+
(size_t)(end - beg)),
|
456
|
+
0);
|
457
|
+
if (err != GRPC_ERROR_NONE) {
|
458
|
+
return err;
|
437
459
|
}
|
438
460
|
transport_parsing->incoming_frame_size -= (uint32_t)(end - cur);
|
439
|
-
return
|
461
|
+
return GRPC_ERROR_NONE;
|
440
462
|
}
|
441
463
|
GPR_UNREACHABLE_CODE(return 0);
|
442
464
|
}
|
@@ -444,23 +466,41 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
|
|
444
466
|
GPR_UNREACHABLE_CODE(return 0);
|
445
467
|
}
|
446
468
|
|
447
|
-
static
|
448
|
-
|
469
|
+
static grpc_error *init_frame_parser(
|
470
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) {
|
471
|
+
if (transport_parsing->is_first_frame &&
|
472
|
+
transport_parsing->incoming_frame_type != GRPC_CHTTP2_FRAME_SETTINGS) {
|
473
|
+
char *msg;
|
474
|
+
gpr_asprintf(
|
475
|
+
&msg, "Expected SETTINGS frame as the first frame, got frame type %d",
|
476
|
+
transport_parsing->incoming_frame_type);
|
477
|
+
grpc_error *err = GRPC_ERROR_CREATE(msg);
|
478
|
+
gpr_free(msg);
|
479
|
+
return err;
|
480
|
+
}
|
481
|
+
transport_parsing->is_first_frame = false;
|
449
482
|
if (transport_parsing->expect_continuation_stream_id != 0) {
|
450
483
|
if (transport_parsing->incoming_frame_type !=
|
451
484
|
GRPC_CHTTP2_FRAME_CONTINUATION) {
|
452
|
-
|
453
|
-
|
454
|
-
|
485
|
+
char *msg;
|
486
|
+
gpr_asprintf(&msg, "Expected CONTINUATION frame, got frame type %02x",
|
487
|
+
transport_parsing->incoming_frame_type);
|
488
|
+
grpc_error *err = GRPC_ERROR_CREATE(msg);
|
489
|
+
gpr_free(msg);
|
490
|
+
return err;
|
455
491
|
}
|
456
492
|
if (transport_parsing->expect_continuation_stream_id !=
|
457
493
|
transport_parsing->incoming_stream_id) {
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
494
|
+
char *msg;
|
495
|
+
gpr_asprintf(
|
496
|
+
&msg,
|
497
|
+
"Expected CONTINUATION frame for grpc_chttp2_stream %08x, got "
|
498
|
+
"grpc_chttp2_stream %08x",
|
499
|
+
transport_parsing->expect_continuation_stream_id,
|
500
|
+
transport_parsing->incoming_stream_id);
|
501
|
+
grpc_error *err = GRPC_ERROR_CREATE(msg);
|
502
|
+
gpr_free(msg);
|
503
|
+
return err;
|
464
504
|
}
|
465
505
|
return init_header_frame_parser(exec_ctx, transport_parsing, 1);
|
466
506
|
}
|
@@ -470,8 +510,7 @@ static int init_frame_parser(grpc_exec_ctx *exec_ctx,
|
|
470
510
|
case GRPC_CHTTP2_FRAME_HEADER:
|
471
511
|
return init_header_frame_parser(exec_ctx, transport_parsing, 0);
|
472
512
|
case GRPC_CHTTP2_FRAME_CONTINUATION:
|
473
|
-
|
474
|
-
return 0;
|
513
|
+
return GRPC_ERROR_CREATE("Unexpected CONTINUATION frame");
|
475
514
|
case GRPC_CHTTP2_FRAME_RST_STREAM:
|
476
515
|
return init_rst_stream_parser(exec_ctx, transport_parsing);
|
477
516
|
case GRPC_CHTTP2_FRAME_SETTINGS:
|
@@ -483,22 +522,24 @@ static int init_frame_parser(grpc_exec_ctx *exec_ctx,
|
|
483
522
|
case GRPC_CHTTP2_FRAME_GOAWAY:
|
484
523
|
return init_goaway_parser(exec_ctx, transport_parsing);
|
485
524
|
default:
|
486
|
-
|
487
|
-
|
525
|
+
if (grpc_http_trace) {
|
526
|
+
gpr_log(GPR_ERROR, "Unknown frame type %02x",
|
527
|
+
transport_parsing->incoming_frame_type);
|
528
|
+
}
|
488
529
|
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
|
489
530
|
}
|
490
531
|
}
|
491
532
|
|
492
|
-
static
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
return
|
533
|
+
static grpc_error *skip_parser(grpc_exec_ctx *exec_ctx, void *parser,
|
534
|
+
grpc_chttp2_transport_parsing *transport_parsing,
|
535
|
+
grpc_chttp2_stream_parsing *stream_parsing,
|
536
|
+
gpr_slice slice, int is_last) {
|
537
|
+
return GRPC_ERROR_NONE;
|
497
538
|
}
|
498
539
|
|
499
540
|
static void skip_header(void *tp, grpc_mdelem *md) { GRPC_MDELEM_UNREF(md); }
|
500
541
|
|
501
|
-
static
|
542
|
+
static grpc_error *init_skip_frame_parser(
|
502
543
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
503
544
|
int is_header) {
|
504
545
|
if (is_header) {
|
@@ -513,7 +554,7 @@ static int init_skip_frame_parser(
|
|
513
554
|
} else {
|
514
555
|
transport_parsing->parser = skip_parser;
|
515
556
|
}
|
516
|
-
return
|
557
|
+
return GRPC_ERROR_NONE;
|
517
558
|
}
|
518
559
|
|
519
560
|
void grpc_chttp2_parsing_become_skip_parser(
|
@@ -523,22 +564,28 @@ void grpc_chttp2_parsing_become_skip_parser(
|
|
523
564
|
transport_parsing->parser == grpc_chttp2_header_parser_parse);
|
524
565
|
}
|
525
566
|
|
526
|
-
static
|
567
|
+
static grpc_error *update_incoming_window(
|
527
568
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
528
569
|
grpc_chttp2_stream_parsing *stream_parsing) {
|
529
570
|
uint32_t incoming_frame_size = transport_parsing->incoming_frame_size;
|
530
571
|
if (incoming_frame_size > transport_parsing->incoming_window) {
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
572
|
+
char *msg;
|
573
|
+
gpr_asprintf(&msg, "frame of size %d overflows incoming window of %" PRId64,
|
574
|
+
transport_parsing->incoming_frame_size,
|
575
|
+
transport_parsing->incoming_window);
|
576
|
+
grpc_error *err = GRPC_ERROR_CREATE(msg);
|
577
|
+
gpr_free(msg);
|
578
|
+
return err;
|
535
579
|
}
|
536
580
|
|
537
581
|
if (incoming_frame_size > stream_parsing->incoming_window) {
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
582
|
+
char *msg;
|
583
|
+
gpr_asprintf(&msg, "frame of size %d overflows incoming window of %" PRId64,
|
584
|
+
transport_parsing->incoming_frame_size,
|
585
|
+
stream_parsing->incoming_window);
|
586
|
+
grpc_error *err = GRPC_ERROR_CREATE(msg);
|
587
|
+
gpr_free(msg);
|
588
|
+
return err;
|
542
589
|
}
|
543
590
|
|
544
591
|
GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("parse", transport_parsing, incoming_window,
|
@@ -549,15 +596,15 @@ static grpc_chttp2_parse_error update_incoming_window(
|
|
549
596
|
|
550
597
|
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing, stream_parsing);
|
551
598
|
|
552
|
-
return
|
599
|
+
return GRPC_ERROR_NONE;
|
553
600
|
}
|
554
601
|
|
555
|
-
static
|
602
|
+
static grpc_error *init_data_frame_parser(
|
556
603
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) {
|
557
604
|
grpc_chttp2_stream_parsing *stream_parsing =
|
558
605
|
grpc_chttp2_parsing_lookup_stream(transport_parsing,
|
559
606
|
transport_parsing->incoming_stream_id);
|
560
|
-
|
607
|
+
grpc_error *err = GRPC_ERROR_NONE;
|
561
608
|
if (stream_parsing == NULL) {
|
562
609
|
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
|
563
610
|
}
|
@@ -565,33 +612,32 @@ static int init_data_frame_parser(
|
|
565
612
|
if (stream_parsing->received_close) {
|
566
613
|
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
|
567
614
|
}
|
568
|
-
if (err ==
|
615
|
+
if (err == GRPC_ERROR_NONE) {
|
569
616
|
err = update_incoming_window(exec_ctx, transport_parsing, stream_parsing);
|
570
617
|
}
|
571
|
-
if (err ==
|
618
|
+
if (err == GRPC_ERROR_NONE) {
|
572
619
|
err = grpc_chttp2_data_parser_begin_frame(
|
573
|
-
&stream_parsing->data_parser, transport_parsing->incoming_frame_flags
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
620
|
+
&stream_parsing->data_parser, transport_parsing->incoming_frame_flags,
|
621
|
+
stream_parsing->id);
|
622
|
+
}
|
623
|
+
if (err == GRPC_ERROR_NONE) {
|
624
|
+
transport_parsing->incoming_stream = stream_parsing;
|
625
|
+
transport_parsing->parser = grpc_chttp2_data_parser_parse;
|
626
|
+
transport_parsing->parser_data = &stream_parsing->data_parser;
|
627
|
+
return GRPC_ERROR_NONE;
|
628
|
+
} else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
|
629
|
+
/* handle stream errors by closing the stream */
|
630
|
+
stream_parsing->received_close = 1;
|
631
|
+
stream_parsing->forced_close_error = err;
|
632
|
+
gpr_slice_buffer_add(
|
633
|
+
&transport_parsing->qbuf,
|
634
|
+
grpc_chttp2_rst_stream_create(transport_parsing->incoming_stream_id,
|
635
|
+
GRPC_CHTTP2_PROTOCOL_ERROR,
|
636
|
+
&stream_parsing->stats.outgoing));
|
637
|
+
return init_skip_frame_parser(exec_ctx, transport_parsing, 0);
|
638
|
+
} else {
|
639
|
+
return err;
|
593
640
|
}
|
594
|
-
GPR_UNREACHABLE_CODE(return 0);
|
595
641
|
}
|
596
642
|
|
597
643
|
static void free_timeout(void *p) { gpr_free(p); }
|
@@ -612,7 +658,7 @@ static void on_initial_header(void *tp, grpc_mdelem *md) {
|
|
612
658
|
|
613
659
|
if (md->key == GRPC_MDSTR_GRPC_STATUS && md != GRPC_MDELEM_GRPC_STATUS_0) {
|
614
660
|
/* TODO(ctiller): check for a status like " 0" */
|
615
|
-
stream_parsing->seen_error =
|
661
|
+
stream_parsing->seen_error = true;
|
616
662
|
}
|
617
663
|
|
618
664
|
if (md->key == GRPC_MDSTR_GRPC_TIMEOUT) {
|
@@ -633,8 +679,27 @@ static void on_initial_header(void *tp, grpc_mdelem *md) {
|
|
633
679
|
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), *cached_timeout));
|
634
680
|
GRPC_MDELEM_UNREF(md);
|
635
681
|
} else {
|
636
|
-
|
637
|
-
|
682
|
+
const size_t new_size =
|
683
|
+
stream_parsing->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md);
|
684
|
+
grpc_chttp2_transport_global *transport_global =
|
685
|
+
&TRANSPORT_FROM_PARSING(transport_parsing)->global;
|
686
|
+
const size_t metadata_size_limit =
|
687
|
+
transport_global->settings[GRPC_LOCAL_SETTINGS]
|
688
|
+
[GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE];
|
689
|
+
if (new_size > metadata_size_limit) {
|
690
|
+
if (!stream_parsing->exceeded_metadata_size) {
|
691
|
+
gpr_log(GPR_DEBUG,
|
692
|
+
"received initial metadata size exceeds limit (%" PRIuPTR
|
693
|
+
" vs. %" PRIuPTR ")",
|
694
|
+
new_size, metadata_size_limit);
|
695
|
+
stream_parsing->seen_error = true;
|
696
|
+
stream_parsing->exceeded_metadata_size = true;
|
697
|
+
}
|
698
|
+
GRPC_MDELEM_UNREF(md);
|
699
|
+
} else {
|
700
|
+
grpc_chttp2_incoming_metadata_buffer_add(
|
701
|
+
&stream_parsing->metadata_buffer[0], md);
|
702
|
+
}
|
638
703
|
}
|
639
704
|
|
640
705
|
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing, stream_parsing);
|
@@ -658,18 +723,37 @@ static void on_trailing_header(void *tp, grpc_mdelem *md) {
|
|
658
723
|
|
659
724
|
if (md->key == GRPC_MDSTR_GRPC_STATUS && md != GRPC_MDELEM_GRPC_STATUS_0) {
|
660
725
|
/* TODO(ctiller): check for a status like " 0" */
|
661
|
-
stream_parsing->seen_error =
|
726
|
+
stream_parsing->seen_error = true;
|
727
|
+
}
|
728
|
+
|
729
|
+
const size_t new_size =
|
730
|
+
stream_parsing->metadata_buffer[1].size + GRPC_MDELEM_LENGTH(md);
|
731
|
+
grpc_chttp2_transport_global *transport_global =
|
732
|
+
&TRANSPORT_FROM_PARSING(transport_parsing)->global;
|
733
|
+
const size_t metadata_size_limit =
|
734
|
+
transport_global->settings[GRPC_LOCAL_SETTINGS]
|
735
|
+
[GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE];
|
736
|
+
if (new_size > metadata_size_limit) {
|
737
|
+
if (!stream_parsing->exceeded_metadata_size) {
|
738
|
+
gpr_log(GPR_DEBUG,
|
739
|
+
"received trailing metadata size exceeds limit (%" PRIuPTR
|
740
|
+
" vs. %" PRIuPTR ")",
|
741
|
+
new_size, metadata_size_limit);
|
742
|
+
stream_parsing->seen_error = true;
|
743
|
+
stream_parsing->exceeded_metadata_size = true;
|
744
|
+
}
|
745
|
+
GRPC_MDELEM_UNREF(md);
|
746
|
+
} else {
|
747
|
+
grpc_chttp2_incoming_metadata_buffer_add(
|
748
|
+
&stream_parsing->metadata_buffer[1], md);
|
662
749
|
}
|
663
750
|
|
664
|
-
grpc_chttp2_incoming_metadata_buffer_add(&stream_parsing->metadata_buffer[1],
|
665
|
-
md);
|
666
|
-
|
667
751
|
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing, stream_parsing);
|
668
752
|
|
669
753
|
GPR_TIMER_END("on_trailing_header", 0);
|
670
754
|
}
|
671
755
|
|
672
|
-
static
|
756
|
+
static grpc_error *init_header_frame_parser(
|
673
757
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
674
758
|
int is_continuation) {
|
675
759
|
uint8_t is_eoh = (transport_parsing->incoming_frame_flags &
|
@@ -764,15 +848,16 @@ static int init_header_frame_parser(
|
|
764
848
|
GRPC_CHTTP2_FLAG_HAS_PRIORITY)) {
|
765
849
|
grpc_chttp2_hpack_parser_set_has_priority(&transport_parsing->hpack_parser);
|
766
850
|
}
|
767
|
-
return
|
851
|
+
return GRPC_ERROR_NONE;
|
768
852
|
}
|
769
853
|
|
770
|
-
static
|
854
|
+
static grpc_error *init_window_update_frame_parser(
|
771
855
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) {
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
856
|
+
grpc_error *err = grpc_chttp2_window_update_parser_begin_frame(
|
857
|
+
&transport_parsing->simple.window_update,
|
858
|
+
transport_parsing->incoming_frame_size,
|
859
|
+
transport_parsing->incoming_frame_flags);
|
860
|
+
if (err != GRPC_ERROR_NONE) return err;
|
776
861
|
if (transport_parsing->incoming_stream_id != 0) {
|
777
862
|
grpc_chttp2_stream_parsing *stream_parsing =
|
778
863
|
transport_parsing->incoming_stream = grpc_chttp2_parsing_lookup_stream(
|
@@ -784,26 +869,27 @@ static int init_window_update_frame_parser(
|
|
784
869
|
}
|
785
870
|
transport_parsing->parser = grpc_chttp2_window_update_parser_parse;
|
786
871
|
transport_parsing->parser_data = &transport_parsing->simple.window_update;
|
787
|
-
return
|
872
|
+
return GRPC_ERROR_NONE;
|
788
873
|
}
|
789
874
|
|
790
|
-
static
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
875
|
+
static grpc_error *init_ping_parser(
|
876
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) {
|
877
|
+
grpc_error *err = grpc_chttp2_ping_parser_begin_frame(
|
878
|
+
&transport_parsing->simple.ping, transport_parsing->incoming_frame_size,
|
879
|
+
transport_parsing->incoming_frame_flags);
|
880
|
+
if (err != GRPC_ERROR_NONE) return err;
|
796
881
|
transport_parsing->parser = grpc_chttp2_ping_parser_parse;
|
797
882
|
transport_parsing->parser_data = &transport_parsing->simple.ping;
|
798
|
-
return
|
883
|
+
return GRPC_ERROR_NONE;
|
799
884
|
}
|
800
885
|
|
801
|
-
static
|
886
|
+
static grpc_error *init_rst_stream_parser(
|
802
887
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) {
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
888
|
+
grpc_error *err = grpc_chttp2_rst_stream_parser_begin_frame(
|
889
|
+
&transport_parsing->simple.rst_stream,
|
890
|
+
transport_parsing->incoming_frame_size,
|
891
|
+
transport_parsing->incoming_frame_flags);
|
892
|
+
if (err != GRPC_ERROR_NONE) return err;
|
807
893
|
grpc_chttp2_stream_parsing *stream_parsing =
|
808
894
|
transport_parsing->incoming_stream = grpc_chttp2_parsing_lookup_stream(
|
809
895
|
transport_parsing, transport_parsing->incoming_stream_id);
|
@@ -813,37 +899,32 @@ static int init_rst_stream_parser(
|
|
813
899
|
stream_parsing->stats.incoming.framing_bytes += 9;
|
814
900
|
transport_parsing->parser = grpc_chttp2_rst_stream_parser_parse;
|
815
901
|
transport_parsing->parser_data = &transport_parsing->simple.rst_stream;
|
816
|
-
return
|
902
|
+
return GRPC_ERROR_NONE;
|
817
903
|
}
|
818
904
|
|
819
|
-
static
|
905
|
+
static grpc_error *init_goaway_parser(
|
820
906
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) {
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
907
|
+
grpc_error *err = grpc_chttp2_goaway_parser_begin_frame(
|
908
|
+
&transport_parsing->goaway_parser, transport_parsing->incoming_frame_size,
|
909
|
+
transport_parsing->incoming_frame_flags);
|
910
|
+
if (err != GRPC_ERROR_NONE) return err;
|
825
911
|
transport_parsing->parser = grpc_chttp2_goaway_parser_parse;
|
826
912
|
transport_parsing->parser_data = &transport_parsing->goaway_parser;
|
827
|
-
return
|
913
|
+
return GRPC_ERROR_NONE;
|
828
914
|
}
|
829
915
|
|
830
|
-
static
|
916
|
+
static grpc_error *init_settings_frame_parser(
|
831
917
|
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) {
|
832
|
-
int ok;
|
833
|
-
|
834
918
|
if (transport_parsing->incoming_stream_id != 0) {
|
835
|
-
|
836
|
-
transport_parsing->incoming_stream_id);
|
837
|
-
return 0;
|
919
|
+
return GRPC_ERROR_CREATE("Settings frame received for grpc_chttp2_stream");
|
838
920
|
}
|
839
921
|
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
return 0;
|
922
|
+
grpc_error *err = grpc_chttp2_settings_parser_begin_frame(
|
923
|
+
&transport_parsing->simple.settings,
|
924
|
+
transport_parsing->incoming_frame_size,
|
925
|
+
transport_parsing->incoming_frame_flags, transport_parsing->settings);
|
926
|
+
if (err != GRPC_ERROR_NONE) {
|
927
|
+
return err;
|
847
928
|
}
|
848
929
|
if (transport_parsing->incoming_frame_flags & GRPC_CHTTP2_FLAG_ACK) {
|
849
930
|
transport_parsing->settings_ack_received = 1;
|
@@ -857,7 +938,7 @@ static int init_settings_frame_parser(
|
|
857
938
|
}
|
858
939
|
transport_parsing->parser = grpc_chttp2_settings_parser_parse;
|
859
940
|
transport_parsing->parser_data = &transport_parsing->simple.settings;
|
860
|
-
return
|
941
|
+
return GRPC_ERROR_NONE;
|
861
942
|
}
|
862
943
|
|
863
944
|
/*
|
@@ -866,34 +947,37 @@ static int is_window_update_legal(int64_t window_update, int64_t window) {
|
|
866
947
|
}
|
867
948
|
*/
|
868
949
|
|
869
|
-
static
|
870
|
-
|
871
|
-
|
950
|
+
static grpc_error *parse_frame_slice(
|
951
|
+
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing,
|
952
|
+
gpr_slice slice, int is_last) {
|
872
953
|
grpc_chttp2_stream_parsing *stream_parsing =
|
873
954
|
transport_parsing->incoming_stream;
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
955
|
+
grpc_error *err = transport_parsing->parser(
|
956
|
+
exec_ctx, transport_parsing->parser_data, transport_parsing,
|
957
|
+
stream_parsing, slice, is_last);
|
958
|
+
if (err == GRPC_ERROR_NONE) {
|
959
|
+
if (stream_parsing) {
|
960
|
+
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
|
961
|
+
stream_parsing);
|
962
|
+
}
|
963
|
+
return GRPC_ERROR_NONE;
|
964
|
+
} else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) {
|
965
|
+
if (grpc_http_trace) {
|
966
|
+
const char *msg = grpc_error_string(err);
|
967
|
+
gpr_log(GPR_ERROR, "%s", msg);
|
968
|
+
grpc_error_free_string(msg);
|
969
|
+
}
|
970
|
+
grpc_chttp2_parsing_become_skip_parser(exec_ctx, transport_parsing);
|
971
|
+
if (stream_parsing) {
|
972
|
+
stream_parsing->forced_close_error = err;
|
973
|
+
gpr_slice_buffer_add(
|
974
|
+
&transport_parsing->qbuf,
|
975
|
+
grpc_chttp2_rst_stream_create(transport_parsing->incoming_stream_id,
|
976
|
+
GRPC_CHTTP2_PROTOCOL_ERROR,
|
977
|
+
&stream_parsing->stats.outgoing));
|
978
|
+
} else {
|
979
|
+
GRPC_ERROR_UNREF(err);
|
980
|
+
}
|
897
981
|
}
|
898
|
-
|
982
|
+
return err;
|
899
983
|
}
|