Chromium Code Reviews| 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); |
| } |
| } |