OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 DVLOG(1) << ENDPOINT << "Received an old ack frame: ignoring"; | 674 DVLOG(1) << ENDPOINT << "Received an old ack frame: ignoring"; |
675 return true; | 675 return true; |
676 } | 676 } |
677 | 677 |
678 const char* error = ValidateAckFrame(incoming_ack); | 678 const char* error = ValidateAckFrame(incoming_ack); |
679 if (error != nullptr) { | 679 if (error != nullptr) { |
680 SendConnectionCloseWithDetails(QUIC_INVALID_ACK_DATA, error); | 680 SendConnectionCloseWithDetails(QUIC_INVALID_ACK_DATA, error); |
681 return false; | 681 return false; |
682 } | 682 } |
683 | 683 |
684 if (FLAGS_quic_respect_send_alarm2 && send_alarm_->IsSet()) { | 684 if (send_alarm_->IsSet()) { |
685 send_alarm_->Cancel(); | 685 send_alarm_->Cancel(); |
686 } | 686 } |
687 ProcessAckFrame(incoming_ack); | 687 ProcessAckFrame(incoming_ack); |
688 if (incoming_ack.is_truncated) { | 688 if (incoming_ack.is_truncated) { |
689 should_last_packet_instigate_acks_ = true; | 689 should_last_packet_instigate_acks_ = true; |
690 } | 690 } |
691 // If the peer is still waiting for a packet that we are no longer planning to | 691 // If the peer is still waiting for a packet that we are no longer planning to |
692 // send, send an ack to raise the high water mark. | 692 // send, send an ack to raise the high water mark. |
693 if (!incoming_ack.missing_packets.Empty() && | 693 if (!incoming_ack.missing_packets.Empty() && |
694 GetLeastUnacked() > incoming_ack.missing_packets.Min()) { | 694 GetLeastUnacked() > incoming_ack.missing_packets.Min()) { |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) { | 1483 bool QuicConnection::CanWrite(HasRetransmittableData retransmittable) { |
1484 if (!connected_) { | 1484 if (!connected_) { |
1485 return false; | 1485 return false; |
1486 } | 1486 } |
1487 | 1487 |
1488 if (writer_->IsWriteBlocked()) { | 1488 if (writer_->IsWriteBlocked()) { |
1489 visitor_->OnWriteBlocked(); | 1489 visitor_->OnWriteBlocked(); |
1490 return false; | 1490 return false; |
1491 } | 1491 } |
1492 | 1492 |
1493 if (FLAGS_quic_respect_send_alarm2) { | 1493 // Allow acks to be sent immediately. |
1494 // Allow acks to be sent immediately. | 1494 // TODO(ianswett): Remove retransmittable from |
1495 // TODO(ianswett): Remove retransmittable from | 1495 // SendAlgorithmInterface::TimeUntilSend. |
1496 // SendAlgorithmInterface::TimeUntilSend. | 1496 if (retransmittable == NO_RETRANSMITTABLE_DATA) { |
1497 if (retransmittable == NO_RETRANSMITTABLE_DATA) { | 1497 return true; |
1498 return true; | 1498 } |
1499 } | 1499 // If the send alarm is set, wait for it to fire. |
1500 // If the send alarm is set, wait for it to fire. | 1500 if (send_alarm_->IsSet()) { |
1501 if (send_alarm_->IsSet()) { | 1501 return false; |
1502 return false; | |
1503 } | |
1504 } | 1502 } |
1505 | 1503 |
1506 QuicTime now = clock_->Now(); | 1504 QuicTime now = clock_->Now(); |
1507 QuicTime::Delta delay = | 1505 QuicTime::Delta delay = |
1508 sent_packet_manager_.TimeUntilSend(now, retransmittable); | 1506 sent_packet_manager_.TimeUntilSend(now, retransmittable); |
1509 if (delay.IsInfinite()) { | 1507 if (delay.IsInfinite()) { |
1510 send_alarm_->Cancel(); | 1508 send_alarm_->Cancel(); |
1511 return false; | 1509 return false; |
1512 } | 1510 } |
1513 | 1511 |
1514 // If the scheduler requires a delay, then we can not send this packet now. | 1512 // If the scheduler requires a delay, then we can not send this packet now. |
1515 if (!delay.IsZero()) { | 1513 if (!delay.IsZero()) { |
1516 send_alarm_->Update(now.Add(delay), QuicTime::Delta::FromMilliseconds(1)); | 1514 send_alarm_->Update(now.Add(delay), QuicTime::Delta::FromMilliseconds(1)); |
1517 DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds() | 1515 DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds() |
1518 << "ms"; | 1516 << "ms"; |
1519 return false; | 1517 return false; |
1520 } | 1518 } |
1521 if (!FLAGS_quic_respect_send_alarm2) { | |
1522 send_alarm_->Cancel(); | |
1523 } | |
1524 return true; | 1519 return true; |
1525 } | 1520 } |
1526 | 1521 |
1527 bool QuicConnection::WritePacket(SerializedPacket* packet) { | 1522 bool QuicConnection::WritePacket(SerializedPacket* packet) { |
1528 if (packet->packet_number < sent_packet_manager_.largest_sent_packet()) { | 1523 if (packet->packet_number < sent_packet_manager_.largest_sent_packet()) { |
1529 QUIC_BUG << "Attempt to write packet:" << packet->packet_number | 1524 QUIC_BUG << "Attempt to write packet:" << packet->packet_number |
1530 << " after:" << sent_packet_manager_.largest_sent_packet(); | 1525 << " after:" << sent_packet_manager_.largest_sent_packet(); |
1531 SendConnectionCloseWithDetails(QUIC_INTERNAL_ERROR, | 1526 SendConnectionCloseWithDetails(QUIC_INTERNAL_ERROR, |
1532 "Packet written out of order."); | 1527 "Packet written out of order."); |
1533 return true; | 1528 return true; |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2360 } | 2355 } |
2361 | 2356 |
2362 StringPiece QuicConnection::GetCurrentPacket() { | 2357 StringPiece QuicConnection::GetCurrentPacket() { |
2363 if (current_packet_data_ == nullptr) { | 2358 if (current_packet_data_ == nullptr) { |
2364 return StringPiece(); | 2359 return StringPiece(); |
2365 } | 2360 } |
2366 return StringPiece(current_packet_data_, last_size_); | 2361 return StringPiece(current_packet_data_, last_size_); |
2367 } | 2362 } |
2368 | 2363 |
2369 } // namespace net | 2364 } // namespace net |
OLD | NEW |