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

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

Issue 359653003: Simplify the QuicDispatcher::OnCanWrite logic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed wtc's comments in Patch Set 1 Created 6 years, 6 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_dispatcher.h ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_dispatcher.cc
diff --git a/net/tools/quic/quic_dispatcher.cc b/net/tools/quic/quic_dispatcher.cc
index 52778febec2f809abfc693937e1486aadaf5e3eb..d53e58e602fdf2b6f62494bb781059759b9bd17a 100644
--- a/net/tools/quic/quic_dispatcher.cc
+++ b/net/tools/quic/quic_dispatcher.cc
@@ -296,21 +296,13 @@ void QuicDispatcher::OnCanWrite() {
// We got an EPOLLOUT: the socket should not be blocked.
writer_->SetWritable();
- // Give each writer one attempt to write.
- int num_writers = write_blocked_list_.size();
- for (int i = 0; i < num_writers; ++i) {
- if (write_blocked_list_.empty()) {
- return;
- }
+ // Give all the blocked writers one chance to write, until we're blocked again
+ // or there's no work left.
+ while (!write_blocked_list_.empty() && !writer_->IsWriteBlocked()) {
QuicBlockedWriterInterface* blocked_writer =
write_blocked_list_.begin()->first;
write_blocked_list_.erase(write_blocked_list_.begin());
blocked_writer->OnCanWrite();
- if (writer_->IsWriteBlocked()) {
- // We were unable to write. Wait for the next EPOLLOUT. The writer is
- // responsible for adding itself to the blocked list via OnWriteBlocked().
- return;
- }
}
}
@@ -352,9 +344,16 @@ void QuicDispatcher::OnConnectionClosed(QuicConnectionId connection_id,
CleanUpSession(it);
}
-void QuicDispatcher::OnWriteBlocked(QuicBlockedWriterInterface* writer) {
- DCHECK(writer_->IsWriteBlocked());
- write_blocked_list_.insert(make_pair(writer, true));
+void QuicDispatcher::OnWriteBlocked(
+ QuicBlockedWriterInterface* blocked_writer) {
+ if (!writer_->IsWriteBlocked()) {
+ LOG(DFATAL) <<
+ "QuicDispatcher::OnWriteBlocked called when the writer is not blocked.";
+ // Return without adding the connection to the blocked list, to avoid
+ // infinite loops in OnCanWrite.
+ return;
+ }
+ write_blocked_list_.insert(make_pair(blocked_writer, true));
}
QuicPacketWriter* QuicDispatcher::CreateWriter(int fd) {
« no previous file with comments | « net/tools/quic/quic_dispatcher.h ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698