Index: net/quic/quic_connection.cc |
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc |
index 46636fae13f9e6ec0be2b186b3a860d950578baa..75640a3fd9dd6a3658b6d6b4d3928a9883c32fb3 100644 |
--- a/net/quic/quic_connection.cc |
+++ b/net/quic/quic_connection.cc |
@@ -129,7 +129,7 @@ class SendAlarm : public QuicAlarm::Delegate { |
explicit SendAlarm(QuicConnection* connection) : connection_(connection) {} |
QuicTime OnAlarm() override { |
- connection_->WriteIfNotBlocked(); |
+ connection_->WriteAndBundleAcksIfNotBlocked(); |
// Never reschedule the alarm, since CanWrite does that. |
return QuicTime::Zero(); |
} |
@@ -284,6 +284,7 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id, |
ack_mode_(TCP_ACKING), |
delay_setting_retransmission_alarm_(false), |
pending_retransmission_alarm_(false), |
+ defer_send_in_response_to_packets_(false), |
arena_(), |
ack_alarm_(helper->CreateAlarm(arena_.New<AckAlarm>(this), &arena_)), |
retransmission_alarm_( |
@@ -1135,11 +1136,14 @@ void QuicConnection::MaybeSendInResponseToPacket() { |
if (!connected_) { |
return; |
} |
- ScopedPacketBundler bundler(this, ack_queued_ ? SEND_ACK : NO_ACK); |
- |
// Now that we have received an ack, we might be able to send packets which |
// are queued locally, or drain streams which are blocked. |
- WriteIfNotBlocked(); |
+ if (defer_send_in_response_to_packets_) { |
+ send_alarm_->Cancel(); |
+ send_alarm_->Set(clock_->ApproximateNow()); |
+ } else { |
+ WriteAndBundleAcksIfNotBlocked(); |
+ } |
} |
void QuicConnection::SendVersionNegotiationPacket() { |
@@ -1400,6 +1404,13 @@ void QuicConnection::WriteIfNotBlocked() { |
} |
} |
+void QuicConnection::WriteAndBundleAcksIfNotBlocked() { |
+ if (!writer_->IsWriteBlocked()) { |
+ ScopedPacketBundler bundler(this, ack_queued_ ? SEND_ACK : NO_ACK); |
+ OnCanWrite(); |
+ } |
+} |
+ |
bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { |
if (FLAGS_check_peer_address_change_after_decryption) { |
if (perspective_ == Perspective::IS_SERVER && |