Commit 0cc05978 authored by David Schinazi's avatar David Schinazi Committed by Commit Bot

Do not shutdown QuicSimpleServer on some errors

We found an issue during interop with other

R=renjietang@chromium.org

our server by sending a packet that is larger
than our receive buffer. That was because we were
incorrectly shutting down the server on any read
failure. The fix is to whitelist errors that we
know do not cause the socket to become unusable.

implementations: anyone can cause us to shutdown
Change-Id: I32a20109aa345654ae225f64170f97274c9c36a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2233823
Auto-Submit: David Schinazi <dschinazi@chromium.org>
Commit-Queue: Renjie Tang <renjietang@chromium.org>
Reviewed-by: default avatarRenjie Tang <renjietang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775834}
parent 51291f88
...@@ -125,6 +125,7 @@ bool QuicSimpleServer::Listen(const IPEndPoint& address) { ...@@ -125,6 +125,7 @@ bool QuicSimpleServer::Listen(const IPEndPoint& address) {
} }
void QuicSimpleServer::Shutdown() { void QuicSimpleServer::Shutdown() {
LOG(WARNING) << "QuicSimpleServer is shutting down";
// Before we shut down the epoll server, give all active sessions a chance to // Before we shut down the epoll server, give all active sessions a chance to
// notify clients that they're closing. // notify clients that they're closing.
dispatcher_->Shutdown(); dispatcher_->Shutdown();
...@@ -177,20 +178,24 @@ void QuicSimpleServer::StartReading() { ...@@ -177,20 +178,24 @@ void QuicSimpleServer::StartReading() {
void QuicSimpleServer::OnReadComplete(int result) { void QuicSimpleServer::OnReadComplete(int result) {
read_pending_ = false; read_pending_ = false;
if (result == 0)
result = ERR_CONNECTION_CLOSED;
if (result < 0) { if (result > 0) {
quic::QuicReceivedPacket packet(read_buffer_->data(), result,
helper_->GetClock()->Now(), false);
dispatcher_->ProcessPacket(ToQuicSocketAddress(server_address_),
ToQuicSocketAddress(client_address_), packet);
} else {
LOG(ERROR) << "QuicSimpleServer read failed: " << ErrorToString(result); LOG(ERROR) << "QuicSimpleServer read failed: " << ErrorToString(result);
Shutdown(); // Do not act on ERR_MSG_TOO_BIG as that indicates that we received a UDP
return; // packet whose payload is larger than our receive buffer. Do not act on 0
// as that indicates that we received a UDP packet with an empty payload.
// In both cases, the socket should still be usable.
if (result != ERR_MSG_TOO_BIG && result != 0) {
Shutdown();
return;
}
} }
quic::QuicReceivedPacket packet(read_buffer_->data(), result,
helper_->GetClock()->Now(), false);
dispatcher_->ProcessPacket(ToQuicSocketAddress(server_address_),
ToQuicSocketAddress(client_address_), packet);
StartReading(); StartReading();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment