Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Unified Diff: net/tools/quic/quic_simple_server.cc

Issue 2313053002: Limits only 16 new QUIC connections can be opened per socket event for QuicSimpleServer. Fix test f… (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_simple_server.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_simple_server.cc
diff --git a/net/tools/quic/quic_simple_server.cc b/net/tools/quic/quic_simple_server.cc
index 91a000b98e7722b8181b0a12be9da2751bc6af35..9ce920b4894181b0d374018cc8ca0f1fabac93dc 100644
--- a/net/tools/quic/quic_simple_server.cc
+++ b/net/tools/quic/quic_simple_server.cc
@@ -27,6 +27,7 @@ namespace net {
namespace {
const char kSourceAddressTokenSecret[] = "secret";
+const size_t kNumSessionsToCreatePerSocketEvent = 16;
// Allocate some extra space so we can send an error if the client goes over
// the limit.
@@ -53,6 +54,7 @@ QuicSimpleServer::QuicSimpleServer(
read_pending_(false),
synchronous_read_count_(0),
read_buffer_(new IOBufferWithSize(kReadBufferSize)),
+ check_packet_buffer_(true),
weak_factory_(this) {
Initialize();
}
@@ -152,12 +154,26 @@ void QuicSimpleServer::StartReading() {
}
read_pending_ = true;
+ if (check_packet_buffer_) {
+ dispatcher_->ProcessBufferedChlos(kNumSessionsToCreatePerSocketEvent);
+ }
+
+ check_packet_buffer_ = false;
int result = socket_->RecvFrom(
read_buffer_.get(), read_buffer_->size(), &client_address_,
base::Bind(&QuicSimpleServer::OnReadComplete, base::Unretained(this)));
if (result == ERR_IO_PENDING) {
synchronous_read_count_ = 0;
+ if (dispatcher_->HasChlosBuffered()) {
+ // No more packets to read, but still keep processing buffered packets if
+ // there is any.
+ read_pending_ = false;
Ryan Hamilton 2016/09/06 21:18:33 This looks like a bug. read_pending_ should be tru
+ check_packet_buffer_ = true;
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&QuicSimpleServer::StartReading,
+ weak_factory_.GetWeakPtr()));
Ryan Hamilton 2016/09/06 21:18:33 I don't think this is the right method to call. Th
+ }
return;
}
@@ -165,10 +181,12 @@ void QuicSimpleServer::StartReading() {
synchronous_read_count_ = 0;
// Schedule the processing through the message loop to 1) prevent infinite
// recursion and 2) avoid blocking the thread for too long.
+ check_packet_buffer_ = true;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&QuicSimpleServer::OnReadComplete,
weak_factory_.GetWeakPtr(), result));
} else {
+ // No need to check buffer befor following read.
Ryan Hamilton 2016/09/06 21:18:33 nit: "before" not "befor" That being said, I'm su
OnReadComplete(result);
}
}
« no previous file with comments | « net/tools/quic/quic_simple_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698