Stop decoder processing on connection error in OgHttp2Session.
Based on a comment in cl/401338105, this CL changes
OgHttp2Session::LatchErrorAndNotify() to also call decoder_.StopProcessing().
Because decoder_.StopProcessing() itself eventually leads back to
OgHttp2Session::LatchErrorAndNotify(), this CL also prevents
LatchErrorAndNotify() from taking action when it has already been called,
avoiding multiple visitor_.OnConnectionError() calls.
PiperOrigin-RevId: 403101766
diff --git a/http2/adapter/oghttp2_adapter_test.cc b/http2/adapter/oghttp2_adapter_test.cc
index 8070994..48baba1 100644
--- a/http2/adapter/oghttp2_adapter_test.cc
+++ b/http2/adapter/oghttp2_adapter_test.cc
@@ -444,11 +444,6 @@
.WillOnce(
testing::Return(Http2VisitorInterface::HEADER_CONNECTION_ERROR));
EXPECT_CALL(visitor, OnConnectionError(ConnectionError::kHeaderError));
- // Note: OgHttp2Adapter continues processing bytes until the input is
- // complete.
- EXPECT_CALL(visitor, OnFrameHeader(1, _, DATA, 0));
- EXPECT_CALL(visitor, OnBeginDataForStream(1, _));
- EXPECT_CALL(visitor, OnDataForStream(1, "This is the response body."));
const int64_t stream_result = adapter->ProcessBytes(stream_frames);
EXPECT_LT(stream_result, 0);
@@ -516,11 +511,6 @@
.WillOnce(testing::Return(false));
// Rejecting headers leads to a connection error.
EXPECT_CALL(visitor, OnConnectionError(ConnectionError::kHeaderError));
- // Note: OgHttp2Adapter continues processing bytes until the input is
- // complete.
- EXPECT_CALL(visitor, OnFrameHeader(1, _, DATA, 0));
- EXPECT_CALL(visitor, OnBeginDataForStream(1, _));
- EXPECT_CALL(visitor, OnDataForStream(1, "This is the response body."));
const int64_t stream_result = adapter->ProcessBytes(stream_frames);
EXPECT_LT(stream_result, 0);
diff --git a/http2/adapter/oghttp2_session.cc b/http2/adapter/oghttp2_session.cc
index 607cda4..2784bef 100644
--- a/http2/adapter/oghttp2_session.cc
+++ b/http2/adapter/oghttp2_session.cc
@@ -1039,8 +1039,14 @@
}
void OgHttp2Session::LatchErrorAndNotify(ConnectionError error) {
+ if (latched_error_) {
+ // Do not kick a connection when it is down.
+ return;
+ }
+
latched_error_ = true;
visitor_.OnConnectionError(error);
+ decoder_.StopProcessing();
}
} // namespace adapter