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

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: refine comment 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/quic/core/quic_flags_list.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..36a174c7a2a13a10572b5519d2a1ec243a447ef4 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.
@@ -147,6 +148,11 @@ void QuicSimpleServer::Shutdown() {
}
void QuicSimpleServer::StartReading() {
+ if (synchronous_read_count_ == 0) {
+ // Only process buffered packets once per message loop.
+ dispatcher_->ProcessBufferedChlos(kNumSessionsToCreatePerSocketEvent);
+ }
+
if (read_pending_) {
return;
}
@@ -158,6 +164,12 @@ void QuicSimpleServer::StartReading() {
if (result == ERR_IO_PENDING) {
synchronous_read_count_ = 0;
+ if (dispatcher_->HasChlosBuffered()) {
+ // No more packets to read, so yield before processing buffered packets.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&QuicSimpleServer::StartReading,
+ weak_factory_.GetWeakPtr()));
+ }
return;
}
« no previous file with comments | « net/quic/core/quic_flags_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698