From 3ae09756357d772ff1ccd6ac640f38ff28edac00 Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Sat, 3 Aug 2024 15:01:27 -0700 Subject: [PATCH] Sync c-core 1.65.4 --- gRPC-C++.podspec | 2 +- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- include/grpcpp/version_info.h | 4 +- .../chttp2/transport/hpack_parser.cc | 63 +++++++++++-------- .../transport/chttp2/transport/hpack_parser.h | 2 + .../!ProtoCompiler-gRPCCppPlugin.podspec | 2 +- .../!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/version.h | 2 +- 11 files changed, 48 insertions(+), 37 deletions(-) diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 7c23281e7..e7917ae6a 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-C++' # TODO (mxyan): use version that match gRPC version when pod is stabilized - version = '1.65.2' + version = '1.65.4' s.version = version s.summary = 'gRPC C++ library' s.homepage = 'https://grpc.io' diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index a19f85138..f2b8814ea 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.65.2' + version = '1.65.4' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'https://grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 2a3f770c3..4150746fb 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.65.2' + version = '1.65.4' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'https://grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 3aa0caa16..11335c489 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.65.2' + version = '1.65.4' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'https://grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 84232a9f2..c3e89f768 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.65.2' + version = '1.65.4' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'https://grpc.io' diff --git a/include/grpcpp/version_info.h b/include/grpcpp/version_info.h index 2e1c38673..6f4d451b7 100644 --- a/include/grpcpp/version_info.h +++ b/include/grpcpp/version_info.h @@ -20,8 +20,8 @@ #define GRPC_CPP_VERSION_MAJOR 1 #define GRPC_CPP_VERSION_MINOR 65 -#define GRPC_CPP_VERSION_PATCH 2 +#define GRPC_CPP_VERSION_PATCH 4 #define GRPC_CPP_VERSION_TAG "" -#define GRPC_CPP_VERSION_STRING "1.65.2" +#define GRPC_CPP_VERSION_STRING "1.65.4" #endif // GRPCPP_VERSION_INFO_H diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.cc b/src/core/ext/transport/chttp2/transport/hpack_parser.cc index 84b4e8627..6bd34f82c 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.cc @@ -90,12 +90,14 @@ constexpr Base64InverseTable kBase64InverseTable; class HPackParser::Input { public: Input(grpc_slice_refcount* current_slice_refcount, const uint8_t* begin, - const uint8_t* end, absl::BitGenRef bitsrc, HpackParseResult& error) + const uint8_t* end, absl::BitGenRef bitsrc, + HpackParseResult& frame_error, HpackParseResult& field_error) : current_slice_refcount_(current_slice_refcount), begin_(begin), end_(end), frontier_(begin), - error_(error), + frame_error_(frame_error), + field_error_(field_error), bitsrc_(bitsrc) {} // If input is backed by a slice, retrieve its refcount. If not, return @@ -214,14 +216,18 @@ class HPackParser::Input { // Check if we saw an EOF bool eof_error() const { - return min_progress_size_ != 0 || error_.connection_error(); + return min_progress_size_ != 0 || frame_error_.connection_error(); + } + + // Reset the field error to be ok + void ClearFieldError() { + if (field_error_.ok()) return; + field_error_ = HpackParseResult(); } // Minimum number of bytes to unstuck the current parse size_t min_progress_size() const { return min_progress_size_; } - bool has_error() const { return !error_.ok(); } - // Set the current error - tweaks the error to include a stream id so that // chttp2 does not close the connection. // Intended for errors that are specific to a stream and recoverable. @@ -245,10 +251,7 @@ class HPackParser::Input { // read prior to being able to get further in this parse. void UnexpectedEOF(size_t min_progress_size) { CHECK_GT(min_progress_size, 0u); - if (min_progress_size_ != 0 || error_.connection_error()) { - DCHECK(eof_error()); - return; - } + if (eof_error()) return; // Set min progress size, taking into account bytes parsed already but not // consumed. min_progress_size_ = min_progress_size + (begin_ - frontier_); @@ -301,13 +304,18 @@ class HPackParser::Input { // Do not use this directly, instead use SetErrorAndContinueParsing or // SetErrorAndStopParsing. void SetError(HpackParseResult error) { - if (!error_.ok() || min_progress_size_ > 0) { - if (error.connection_error() && !error_.connection_error()) { - error_ = std::move(error); // connection errors dominate + SetErrorFor(frame_error_, error); + SetErrorFor(field_error_, std::move(error)); + } + + void SetErrorFor(HpackParseResult& error, HpackParseResult new_error) { + if (!error.ok() || min_progress_size_ > 0) { + if (new_error.connection_error() && !error.connection_error()) { + error = std::move(new_error); // connection errors dominate } return; } - error_ = std::move(error); + error = std::move(new_error); } // Refcount if we are backed by a slice @@ -319,7 +327,8 @@ class HPackParser::Input { // Frontier denotes the first byte past successfully processed input const uint8_t* frontier_; // Current error - HpackParseResult& error_; + HpackParseResult& frame_error_; + HpackParseResult& field_error_; // If the error was EOF, we flag it here by noting how many more bytes would // be needed to make progress size_t min_progress_size_ = 0; @@ -596,6 +605,7 @@ class HPackParser::Parser { bool ParseTop() { DCHECK(state_.parse_state == ParseState::kTop); auto cur = *input_->Next(); + input_->ClearFieldError(); switch (cur >> 4) { // Literal header not indexed - First byte format: 0000xxxx // Literal header never indexed - First byte format: 0001xxxx @@ -701,7 +711,7 @@ class HPackParser::Parser { break; } gpr_log( - GPR_DEBUG, "HTTP:%d:%s:%s: %s%s", log_info_.stream_id, type, + GPR_INFO, "HTTP:%d:%s:%s: %s%s", log_info_.stream_id, type, log_info_.is_client ? "CLI" : "SVR", memento.md.DebugString().c_str(), memento.parse_status == nullptr ? "" @@ -950,11 +960,10 @@ class HPackParser::Parser { state_.string_length) : String::Parse(input_, state_.is_string_huff_compressed, state_.string_length); - HpackParseResult& status = state_.frame_error; absl::string_view key_string; if (auto* s = absl::get_if(&state_.key)) { key_string = s->as_string_view(); - if (status.ok()) { + if (state_.field_error.ok()) { auto r = ValidateKey(key_string); if (r != ValidateMetadataResult::kOk) { input_->SetErrorAndContinueParsing( @@ -964,7 +973,7 @@ class HPackParser::Parser { } else { const auto* memento = absl::get(state_.key); key_string = memento->md.key(); - if (status.ok() && memento->parse_status != nullptr) { + if (state_.field_error.ok() && memento->parse_status != nullptr) { input_->SetErrorAndContinueParsing(*memento->parse_status); } } @@ -991,16 +1000,16 @@ class HPackParser::Parser { key_string.size() + value.wire_size + hpack_constants::kEntryOverhead; auto md = grpc_metadata_batch::Parse( key_string, std::move(value_slice), state_.add_to_table, transport_size, - [key_string, &status, this](absl::string_view message, const Slice&) { - if (!status.ok()) return; + [key_string, this](absl::string_view message, const Slice&) { + if (!state_.field_error.ok()) return; input_->SetErrorAndContinueParsing( HpackParseResult::MetadataParseError(key_string)); gpr_log(GPR_ERROR, "Error parsing '%s' metadata: %s", std::string(key_string).c_str(), std::string(message).c_str()); }); - HPackTable::Memento memento{std::move(md), - status.PersistentStreamErrorOrNullptr()}; + HPackTable::Memento memento{ + std::move(md), state_.field_error.PersistentStreamErrorOrNullptr()}; input_->UpdateFrontier(); state_.parse_state = ParseState::kTop; if (state_.add_to_table) { @@ -1113,13 +1122,13 @@ grpc_error_handle HPackParser::Parse( std::vector buffer = std::move(unparsed_bytes_); return ParseInput( Input(nullptr, buffer.data(), buffer.data() + buffer.size(), bitsrc, - state_.frame_error), + state_.frame_error, state_.field_error), is_last, call_tracer); } - return ParseInput( - Input(slice.refcount, GRPC_SLICE_START_PTR(slice), - GRPC_SLICE_END_PTR(slice), bitsrc, state_.frame_error), - is_last, call_tracer); + return ParseInput(Input(slice.refcount, GRPC_SLICE_START_PTR(slice), + GRPC_SLICE_END_PTR(slice), bitsrc, state_.frame_error, + state_.field_error), + is_last, call_tracer); } grpc_error_handle HPackParser::ParseInput( diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index 463e051dc..9df4487f3 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -235,6 +235,8 @@ class HPackParser { HPackTable hpack_table; // Error so far for this frame (set by class Input) HpackParseResult frame_error; + // Error so far for this field (set by class Input) + HpackParseResult field_error; // Length of frame so far. uint32_t frame_length = 0; // Length of the string being parsed diff --git a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec index 76df51cf9..366fadd25 100644 --- a/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCCppPlugin' - v = '1.65.2' + v = '1.65.4' s.version = v s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 6dfa88a85..334cd0ab5 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.65.2' + v = '1.65.4' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/version.h b/src/objective-c/GRPCClient/version.h index 30d42230b..fdc43b51a 100644 --- a/src/objective-c/GRPCClient/version.h +++ b/src/objective-c/GRPCClient/version.h @@ -22,4 +22,4 @@ // instead. This file can be regenerated from the template by running // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.65.2" +#define GRPC_OBJC_VERSION_STRING @"1.65.4"