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

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: use synchronous_read_count_ as indicator of new read loop 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..ff172c7dbb086aa9b562f9cb927be62a750ce118 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,10 @@ void QuicSimpleServer::Shutdown() {
}
void QuicSimpleServer::StartReading() {
+ if (synchronous_read_count_ == 0) {
Ryan Hamilton 2016/09/07 19:46:18 If you wanted, you could add a comment here like:
+ dispatcher_->ProcessBufferedChlos(kNumSessionsToCreatePerSocketEvent);
+ }
+
if (read_pending_) {
return;
}
@@ -158,17 +163,28 @@ void QuicSimpleServer::StartReading() {
if (result == ERR_IO_PENDING) {
synchronous_read_count_ = 0;
+ if (dispatcher_->HasChlosBuffered()) {
+ // No more packets to read, but still keep processing buffered packets in
+ // next socket event if there is any.
Ryan Hamilton 2016/09/07 19:46:18 nit: Can you shrink this comment to: // No more p
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&QuicSimpleServer::StartReading,
+ weak_factory_.GetWeakPtr()));
+ }
return;
}
+ // For synchronous read, if server has read enough for current socket event,
+ // yeild and continue processing in next event.
Ryan Hamilton 2016/09/07 19:46:18 I'd just drop this comment (and the next two) sinc
if (++synchronous_read_count_ > 32) {
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 buffer in next event.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&QuicSimpleServer::OnReadComplete,
weak_factory_.GetWeakPtr(), result));
} else {
+ // No need to check buffer for following reads.
OnReadComplete(result);
}
}
« 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