Index: net/quic/quic_connection.cc |
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc |
index 182bd301f71d097d79a41b9c5d5d7fe7091534fc..e8a71e85cece8a429c20317a95e65655ace30c5b 100644 |
--- a/net/quic/quic_connection.cc |
+++ b/net/quic/quic_connection.cc |
@@ -1367,11 +1367,10 @@ bool QuicConnection::WritePacket(QueuedPacket packet) { |
encrypted_deleter.reset(encrypted); |
} |
- LOG_IF(DFATAL, encrypted->length() > |
- packet_generator_.max_packet_length()) |
- << "Writing an encrypted packet larger than max_packet_length:" |
- << packet_generator_.max_packet_length() << " encrypted length: " |
- << encrypted->length(); |
+ if (!FLAGS_quic_allow_oversized_packets_for_test) { |
+ DCHECK_LE(encrypted->length(), kMaxPacketSize); |
+ } |
+ DCHECK_LE(encrypted->length(), packet_generator_.max_packet_length()); |
DVLOG(1) << ENDPOINT << "Sending packet " << sequence_number |
<< " : " << (packet.packet->is_fec_packet() ? "FEC " : |
(packet.retransmittable == HAS_RETRANSMITTABLE_DATA |
@@ -1383,12 +1382,6 @@ bool QuicConnection::WritePacket(QueuedPacket packet) { |
DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl |
<< QuicUtils::StringToHexASCIIDump(packet.packet->AsStringPiece()); |
- DCHECK(encrypted->length() <= kMaxPacketSize || |
- FLAGS_quic_allow_oversized_packets_for_test) |
- << "Packet " << sequence_number << " will not be read; too large: " |
- << packet.packet->length() << " " << encrypted->length() << " " |
- << " close: " << (packet.type == CONNECTION_CLOSE ? "yes" : "no"); |
- |
WriteResult result = writer_->WritePacket(encrypted->data(), |
encrypted->length(), |
self_address().address(), |
@@ -1409,8 +1402,8 @@ bool QuicConnection::WritePacket(QueuedPacket packet) { |
visitor_->OnWriteBlocked(); |
// If the socket buffers the the data, then the packet should not |
// be queued and sent again, which would result in an unnecessary |
- // duplicate packet being sent. The helper must call OnPacketSent |
- // when the packet is actually sent. |
+ // duplicate packet being sent. The helper must call OnCanWrite |
+ // when the write completes, and OnWriteError if an error occurs. |
if (!writer_->IsWriteBlockedDataBuffered()) { |
return false; |
} |
@@ -1449,7 +1442,12 @@ bool QuicConnection::WritePacket(QueuedPacket packet) { |
++stats_.packets_retransmitted; |
} |
- return OnPacketSent(result); |
+ if (result.status == WRITE_STATUS_ERROR) { |
+ OnWriteError(result.error_code); |
+ return false; |
+ } |
+ |
+ return true; |
} |
bool QuicConnection::ShouldDiscardPacket( |
@@ -1493,16 +1491,11 @@ bool QuicConnection::ShouldDiscardPacket( |
return false; |
} |
-bool QuicConnection::OnPacketSent(WriteResult result) { |
- if (result.status == WRITE_STATUS_ERROR) { |
- DVLOG(1) << ENDPOINT << "Write failed with error: " << result.error_code |
- << " (" << ErrorToString(result.error_code) << ")"; |
- // We can't send an error as the socket is presumably borked. |
- CloseConnection(QUIC_PACKET_WRITE_ERROR, false); |
- return false; |
- } |
- |
- return true; |
+void QuicConnection::OnWriteError(int error_code) { |
+ DVLOG(1) << ENDPOINT << "Write failed with error: " << error_code |
+ << " (" << ErrorToString(error_code) << ")"; |
+ // We can't send an error as the socket is presumably borked. |
+ CloseConnection(QUIC_PACKET_WRITE_ERROR, false); |
} |
bool QuicConnection::OnSerializedPacket( |