Index: net/quic/quic_dispatcher.cc |
diff --git a/net/quic/quic_dispatcher.cc b/net/quic/quic_dispatcher.cc |
index 280622da381c178db3b7da98592df0c9664d3787..5eb8b0a0bf39b16014590c470d9784d7369d5def 100644 |
--- a/net/quic/quic_dispatcher.cc |
+++ b/net/quic/quic_dispatcher.cc |
@@ -177,7 +177,7 @@ QuicDispatcher::~QuicDispatcher() { |
STLDeleteElements(&closed_session_list_); |
} |
-void QuicDispatcher::Initialize(QuicPacketWriter* writer) { |
+void QuicDispatcher::Initialize(QuicServerPacketWriter* writer) { |
DCHECK(writer_ == NULL); |
writer_.reset(writer); |
time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); |
@@ -301,24 +301,16 @@ void QuicDispatcher::DeleteSessions() { |
} |
void QuicDispatcher::OnCanWrite() { |
- // We got an EPOLLOUT: the socket should not be blocked. |
+ // We finished a write: 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; |
- } |
+ // Let all the blocked writers try 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; |
- } |
} |
} |
@@ -366,9 +358,18 @@ QuicSession* QuicDispatcher::CreateQuicSession( |
QuicConnectionId connection_id, |
const IPEndPoint& server_address, |
const IPEndPoint& client_address) { |
+ QuicPerConnectionPacketWriter* connection_packet_writer = |
+ new QuicPerConnectionPacketWriter(writer_.get()); |
+ QuicConnection* connection = |
+ CreateQuicConnection(connection_id, |
+ server_address, |
+ client_address, |
+ connection_packet_writer); |
+ connection_packet_writer->set_connection(connection); |
QuicServerSession* session = new QuicServerSession( |
config_, |
- CreateQuicConnection(connection_id, server_address, client_address), |
+ connection, |
+ connection_packet_writer, |
this); |
session->InitializeSession(crypto_config_); |
return session; |
@@ -377,12 +378,13 @@ QuicSession* QuicDispatcher::CreateQuicSession( |
QuicConnection* QuicDispatcher::CreateQuicConnection( |
QuicConnectionId connection_id, |
const IPEndPoint& server_address, |
- const IPEndPoint& client_address) { |
+ const IPEndPoint& client_address, |
+ QuicPerConnectionPacketWriter* writer) { |
if (FLAGS_enable_quic_stream_flow_control_2 && |
FLAGS_enable_quic_connection_flow_control_2) { |
DVLOG(1) << "Creating QuicDispatcher with all versions."; |
return new QuicConnection(connection_id, client_address, helper_, |
- writer_.get(), true, supported_versions_); |
+ writer, true, supported_versions_); |
} |
if (FLAGS_enable_quic_stream_flow_control_2 && |
@@ -390,14 +392,14 @@ QuicConnection* QuicDispatcher::CreateQuicConnection( |
DVLOG(1) << "Connection flow control disabled, creating QuicDispatcher " |
<< "WITHOUT version 19 or higher."; |
return new QuicConnection(connection_id, client_address, helper_, |
- writer_.get(), true, |
+ writer, true, |
supported_versions_no_connection_flow_control_); |
} |
DVLOG(1) << "Flow control disabled, creating QuicDispatcher WITHOUT " |
<< "version 17 or higher."; |
return new QuicConnection(connection_id, client_address, helper_, |
- writer_.get(), true, |
+ writer, true, |
supported_versions_no_flow_control_); |
} |