mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-15 07:06:11 -04:00
Internal change
PiperOrigin-RevId: 360794882
This commit is contained in:
@@ -81,6 +81,18 @@ void EndpointManager::EndpointChannelLoopRunnable(
|
||||
|
||||
if (!keep_using_channel.ok()) {
|
||||
Exception exception = keep_using_channel.GetException();
|
||||
// An "invalid proto" may be a final payload on a channel we're about to
|
||||
// close, so we'll loop back around once. We set |last_failed_medium| to
|
||||
// ensure we don't loop indefinitely. See crbug.com/1182031 for more
|
||||
// detail.
|
||||
if (exception.Raised(Exception::kInvalidProtocolBuffer)) {
|
||||
last_failed_medium = channel->GetMedium();
|
||||
NEARBY_LOG(INFO,
|
||||
"Received invalid protobuf message, re-fetching endpoint "
|
||||
"channel; last_failed_medium=%d",
|
||||
last_failed_medium);
|
||||
continue;
|
||||
}
|
||||
if (exception.Raised(Exception::kIo)) {
|
||||
last_failed_medium = channel->GetMedium();
|
||||
NEARBY_LOG(INFO, "Endpoint channel IO exception; last_failed_medium=%d",
|
||||
|
||||
@@ -253,6 +253,15 @@ TEST_F(EndpointManagerTest, SendControlMessageWorks) {
|
||||
NEARBY_LOG(INFO, "Will call destructors now");
|
||||
}
|
||||
|
||||
TEST_F(EndpointManagerTest, SingleReadOnInvalidPayload) {
|
||||
auto endpoint_channel = std::make_unique<MockEndpointChannel>();
|
||||
EXPECT_CALL(*endpoint_channel, Read())
|
||||
.WillOnce(
|
||||
Return(ExceptionOr<ByteArray>(Exception::kInvalidProtocolBuffer)));
|
||||
EXPECT_CALL(*endpoint_channel, Close(_)).Times(1);
|
||||
RegisterEndpoint(std::move(endpoint_channel));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
Reference in New Issue
Block a user