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/core/quic_packet_generator.h" | 5 #include "net/quic/core/quic_packet_generator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/quic/core/quic_bug_tracker.h" | 8 #include "net/quic/core/quic_bug_tracker.h" |
9 #include "net/quic/core/quic_flags.h" | 9 #include "net/quic/core/quic_flags.h" |
10 #include "net/quic/core/quic_utils.h" | 10 #include "net/quic/core/quic_utils.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if (retransmittable == HAS_RETRANSMITTABLE_DATA) { | 188 if (retransmittable == HAS_RETRANSMITTABLE_DATA) { |
189 DCHECK(!queued_control_frames_.empty()); // These are retransmittable. | 189 DCHECK(!queued_control_frames_.empty()); // These are retransmittable. |
190 } | 190 } |
191 return delegate_->ShouldGeneratePacket(retransmittable, NOT_HANDSHAKE); | 191 return delegate_->ShouldGeneratePacket(retransmittable, NOT_HANDSHAKE); |
192 } | 192 } |
193 | 193 |
194 void QuicPacketGenerator::SendQueuedFrames(bool flush) { | 194 void QuicPacketGenerator::SendQueuedFrames(bool flush) { |
195 // Only add pending frames if we are SURE we can then send the whole packet. | 195 // Only add pending frames if we are SURE we can then send the whole packet. |
196 while (HasPendingFrames() && | 196 while (HasPendingFrames() && |
197 (flush || CanSendWithNextPendingFrameAddition())) { | 197 (flush || CanSendWithNextPendingFrameAddition())) { |
198 if (FLAGS_quic_close_connection_on_huge_frames) { | 198 bool first_frame = packet_creator_.CanSetMaxPacketLength(); |
199 bool first_frame = packet_creator_.CanSetMaxPacketLength(); | 199 if (!AddNextPendingFrame() && first_frame) { |
200 if (!AddNextPendingFrame() && first_frame) { | 200 // A single frame cannot fit into the packet, tear down the connection. |
201 // A single frame cannot fit into the packet, tear down the connection. | 201 QUIC_BUG << "A single frame cannot fit into packet." |
202 QUIC_BUG << "A single frame cannot fit into packet." | 202 << " should_send_ack: " << should_send_ack_ |
203 << " should_send_ack: " << should_send_ack_ | 203 << " should_send_stop_waiting: " << should_send_stop_waiting_ |
204 << " should_send_stop_waiting: " << should_send_stop_waiting_ | 204 << " number of queued_control_frames: " |
205 << " number of queued_control_frames: " | 205 << queued_control_frames_.size(); |
206 << queued_control_frames_.size(); | 206 if (!queued_control_frames_.empty()) { |
207 if (!queued_control_frames_.empty()) { | 207 DVLOG(1) << queued_control_frames_[0]; |
208 DVLOG(1) << queued_control_frames_[0]; | |
209 } | |
210 delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET, | |
211 "Single frame cannot fit into a packet", | |
212 ConnectionCloseSource::FROM_SELF); | |
213 return; | |
214 } | 208 } |
215 } else { | 209 delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET, |
216 AddNextPendingFrame(); | 210 "Single frame cannot fit into a packet", |
| 211 ConnectionCloseSource::FROM_SELF); |
| 212 return; |
217 } | 213 } |
218 } | 214 } |
219 if (flush || !InBatchMode()) { | 215 if (flush || !InBatchMode()) { |
220 packet_creator_.Flush(); | 216 packet_creator_.Flush(); |
221 } | 217 } |
222 } | 218 } |
223 | 219 |
224 bool QuicPacketGenerator::InBatchMode() { | 220 bool QuicPacketGenerator::InBatchMode() { |
225 return batch_mode_; | 221 return batch_mode_; |
226 } | 222 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 334 |
339 void QuicPacketGenerator::SetCurrentPath( | 335 void QuicPacketGenerator::SetCurrentPath( |
340 QuicPathId path_id, | 336 QuicPathId path_id, |
341 QuicPacketNumber least_packet_awaited_by_peer, | 337 QuicPacketNumber least_packet_awaited_by_peer, |
342 QuicPacketCount max_packets_in_flight) { | 338 QuicPacketCount max_packets_in_flight) { |
343 packet_creator_.SetCurrentPath(path_id, least_packet_awaited_by_peer, | 339 packet_creator_.SetCurrentPath(path_id, least_packet_awaited_by_peer, |
344 max_packets_in_flight); | 340 max_packets_in_flight); |
345 } | 341 } |
346 | 342 |
347 } // namespace net | 343 } // namespace net |
OLD | NEW |