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

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: 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
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..aa930915223dcbea03803282cb0cbbb2030c271e 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,15 @@ 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) {
+ if (!writer_->IsWriteBlocked()) {
+ LOG(DFATAL) <<
+ "QuicDispatcher::OnWriteBlocked called when the writer is not blocked.";
+ // Return without adding the session to the blocked list, to avoid infinite
wtc 2014/06/27 17:08:01 I believe |blocked| is a QuicConnection, not a Qui
ramant (doing other things) 2014/06/27 19:18:39 Done.
+ // loops in OnCanWrite
+ return;
+ }
+ write_blocked_list_.insert(make_pair(blocked, true));
}
QuicPacketWriter* QuicDispatcher::CreateWriter(int fd) {

Powered by Google App Engine
This is Rietveld 408576698