Skip to content
Snippets Groups Projects
Commit 56565fca authored by Craig Tiller's avatar Craig Tiller
Browse files

Force receiving a SETTINGS frame as the first frame

parent 4e29480e
No related branches found
No related tags found
No related merge requests found
...@@ -264,6 +264,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, ...@@ -264,6 +264,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
t->parsing.is_client = is_client; t->parsing.is_client = is_client;
t->parsing.deframe_state = t->parsing.deframe_state =
is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0; is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0;
t->parsing.is_first_frame = true;
t->writing.is_client = is_client; t->writing.is_client = is_client;
t->optional_drop_message = gpr_empty_slice(); t->optional_drop_message = gpr_empty_slice();
grpc_connectivity_state_init( grpc_connectivity_state_init(
...@@ -1805,7 +1806,7 @@ static void post_reading_action_locked(grpc_exec_ctx *exec_ctx, ...@@ -1805,7 +1806,7 @@ static void post_reading_action_locked(grpc_exec_ctx *exec_ctx,
UNREF_TRANSPORT(exec_ctx, t, "reading_action"); UNREF_TRANSPORT(exec_ctx, t, "reading_action");
} }
GRPC_ERROR_UNREF(error); GRPC_LOG_IF_ERROR("close_transport", error);
} }
/******************************************************************************* /*******************************************************************************
......
...@@ -265,6 +265,7 @@ struct grpc_chttp2_transport_parsing { ...@@ -265,6 +265,7 @@ struct grpc_chttp2_transport_parsing {
uint8_t incoming_frame_type; uint8_t incoming_frame_type;
uint8_t incoming_frame_flags; uint8_t incoming_frame_flags;
uint8_t header_eof; uint8_t header_eof;
bool is_first_frame;
uint32_t expect_continuation_stream_id; uint32_t expect_continuation_stream_id;
uint32_t incoming_frame_size; uint32_t incoming_frame_size;
uint32_t incoming_stream_id; uint32_t incoming_stream_id;
......
...@@ -468,6 +468,17 @@ grpc_error *grpc_chttp2_perform_read( ...@@ -468,6 +468,17 @@ grpc_error *grpc_chttp2_perform_read(
static grpc_error *init_frame_parser( static grpc_error *init_frame_parser(
grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) { grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_parsing *transport_parsing) {
if (transport_parsing->is_first_frame &&
transport_parsing->incoming_frame_type != GRPC_CHTTP2_FRAME_SETTINGS) {
char *msg;
gpr_asprintf(
&msg, "Expected SETTINGS frame as the first frame, got frame type %d",
transport_parsing->incoming_frame_type);
grpc_error *err = GRPC_ERROR_CREATE(msg);
gpr_free(msg);
return err;
}
transport_parsing->is_first_frame = false;
if (transport_parsing->expect_continuation_stream_id != 0) { if (transport_parsing->expect_continuation_stream_id != 0) {
if (transport_parsing->incoming_frame_type != if (transport_parsing->incoming_frame_type !=
GRPC_CHTTP2_FRAME_CONTINUATION) { GRPC_CHTTP2_FRAME_CONTINUATION) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment