From 2e698ad26b9bc8ce663a16f2cf8a496846ef2031 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 16 Jul 2021 13:02:20 -0700 Subject: [PATCH] maybe fixes --- .../transport/chttp2/transport/hpack_parser.cc | 18 +++++++++++------- .../transport/chttp2/transport/hpack_parser.h | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index a0b35c7a8e6..5585a15df32 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -1559,7 +1559,7 @@ void HPackParser::QueueBufferToParse(const grpc_slice& slice) { queued_slices_.push_back(grpc_slice_ref_internal(slice)); } -grpc_error_handle HPackParser::FinishFrame() { +grpc_error_handle HPackParser::Parse() { grpc_error_handle error = GRPC_ERROR_NONE; for (const auto& slice : queued_slices_) { error = Parse(slice); @@ -1569,11 +1569,12 @@ grpc_error_handle HPackParser::FinishFrame() { grpc_slice_unref_internal(slice); } queued_slices_.clear(); + return error; +} +void HPackParser::FinishFrame() { sink_ = Sink(); dynamic_table_updates_allowed_ = 2; - - return error; } grpc_error_handle HPackParser::Parse(const grpc_slice& slice) { @@ -1645,12 +1646,14 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser, s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice); } parser->QueueBufferToParse(slice); - if (!is_last || !parser->is_boundary()) { + if (!is_last) { return GRPC_ERROR_NONE; } - grpc_error_handle error = parser->FinishFrame(); - if (error != GRPC_ERROR_NONE) { - return error; + if (parser->is_boundary()) { + grpc_error_handle error = parser->Parse(); + if (error != GRPC_ERROR_NONE) { + return error; + } } /* need to check for null stream: this can occur if we receive an invalid stream id on a header */ @@ -1682,5 +1685,6 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser, grpc_chttp2_mark_stream_closed(t, s, true, false, GRPC_ERROR_NONE); } } + parser->FinishFrame(); return GRPC_ERROR_NONE; } diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index ff88c560b96..758e67a000d 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -46,7 +46,8 @@ class HPackParser { void BeginFrame(Sink sink, Boundary boundary, Priority priority); void ResetSink(Sink sink) { sink_ = std::move(sink); } void QueueBufferToParse(const grpc_slice& slice); - grpc_error_handle FinishFrame(); + grpc_error_handle Parse(); + void FinishFrame(); grpc_chttp2_hptbl* hpack_table() { return &table_; } bool is_boundary() const { return boundary_ != Boundary::None; }