| Index: net/quic/quic_connection.cc
|
| diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
|
| index 32c44f44a5e81a6c4e19e23e284d0c07570b0a31..4ce94c467763a634e01202552d349012d623559c 100644
|
| --- a/net/quic/quic_connection.cc
|
| +++ b/net/quic/quic_connection.cc
|
| @@ -767,24 +767,33 @@ void QuicConnection::MaybeSendInResponseToPacket() {
|
| }
|
|
|
| void QuicConnection::SendVersionNegotiationPacket() {
|
| + // TODO(alyssar): implement zero server state negotiation.
|
| + pending_version_negotiation_packet_ = true;
|
| + if (writer_->IsWriteBlocked()) {
|
| + visitor_->OnWriteBlocked();
|
| + return;
|
| + }
|
| scoped_ptr<QuicEncryptedPacket> version_packet(
|
| packet_creator_.SerializeVersionNegotiationPacket(
|
| framer_.supported_versions()));
|
| - // TODO(satyamshekhar): implement zero server state negotiation.
|
| - WriteResult result =
|
| - writer_->WritePacket(version_packet->data(), version_packet->length(),
|
| - self_address().address(), peer_address(), this);
|
| - if (result.status == WRITE_STATUS_OK ||
|
| - (result.status == WRITE_STATUS_BLOCKED &&
|
| - writer_->IsWriteBlockedDataBuffered())) {
|
| - pending_version_negotiation_packet_ = false;
|
| - return;
|
| - }
|
| + WriteResult result = writer_->WritePacket(
|
| + version_packet->data(), version_packet->length(),
|
| + self_address().address(), peer_address(), this);
|
| +
|
| if (result.status == WRITE_STATUS_ERROR) {
|
| // We can't send an error as the socket is presumably borked.
|
| CloseConnection(QUIC_PACKET_WRITE_ERROR, false);
|
| + return;
|
| }
|
| - pending_version_negotiation_packet_ = true;
|
| + if (result.status == WRITE_STATUS_BLOCKED) {
|
| + visitor_->OnWriteBlocked();
|
| + if (writer_->IsWriteBlockedDataBuffered()) {
|
| + pending_version_negotiation_packet_ = false;
|
| + }
|
| + return;
|
| + }
|
| +
|
| + pending_version_negotiation_packet_ = false;
|
| }
|
|
|
| QuicConsumedData QuicConnection::SendStreamData(
|
| @@ -1031,6 +1040,7 @@ bool QuicConnection::CanWrite(TransmissionType transmission_type,
|
| HasRetransmittableData retransmittable,
|
| IsHandshake handshake) {
|
| if (writer_->IsWriteBlocked()) {
|
| + visitor_->OnWriteBlocked();
|
| return false;
|
| }
|
|
|
| @@ -1111,6 +1121,7 @@ bool QuicConnection::WritePacket(EncryptionLevel level,
|
| // This assures we won't try to write *forced* packets when blocked.
|
| // Return true to stop processing.
|
| if (writer_->IsWriteBlocked()) {
|
| + visitor_->OnWriteBlocked();
|
| return true;
|
| }
|
| }
|
| @@ -1154,6 +1165,7 @@ bool QuicConnection::WritePacket(EncryptionLevel level,
|
| debug_visitor_->OnPacketSent(sequence_number, level, *encrypted, result);
|
| }
|
| if (result.status == WRITE_STATUS_BLOCKED) {
|
| + 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
|
|
|