Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Unified Diff: net/quic/quic_stream_sequencer.cc

Issue 12334063: Land recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more EXPECT_FALSE Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_stream_sequencer.h ('k') | net/quic/quic_stream_sequencer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_stream_sequencer.cc
diff --git a/net/quic/quic_stream_sequencer.cc b/net/quic/quic_stream_sequencer.cc
index f4959ae03b97226126c768883027eb62cefb2e91..ec2a41018a8c55f1638ad33b658934a047cc07f4 100644
--- a/net/quic/quic_stream_sequencer.cc
+++ b/net/quic/quic_stream_sequencer.cc
@@ -44,11 +44,10 @@ bool QuicStreamSequencer::WillAcceptStreamFrame(
size_t data_len = frame.data.size();
DCHECK_LE(data_len, max_frame_memory_);
- QuicStreamOffset byte_offset = frame.offset;
- if (byte_offset < num_bytes_consumed_ ||
- frames_.find(byte_offset) != frames_.end()) {
- return false;
+ if (IsDuplicate(frame)) {
+ return true;
}
+ QuicStreamOffset byte_offset = frame.offset;
if (data_len > max_frame_memory_) {
// We're never going to buffer this frame and we can't pass it up.
// The stream might only consume part of it and we'd need a partial ack.
@@ -72,6 +71,10 @@ bool QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) {
// OnStreamFrame. Error handling should be done by the caller.
return false;
}
+ if (IsDuplicate(frame)) {
+ // Silently ignore duplicates.
+ return true;
+ }
QuicStreamOffset byte_offset = frame.offset;
const char* data = frame.data.data();
@@ -98,7 +101,6 @@ bool QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) {
byte_offset += bytes_consumed;
}
}
-
DVLOG(1) << "Buffering packet at offset " << byte_offset;
frames_.insert(make_pair(byte_offset, string(data, data_len)));
return true;
@@ -151,6 +153,15 @@ bool QuicStreamSequencer::IsClosed() const {
return num_bytes_consumed_ >= close_offset_ && half_close_ == false;
}
+bool QuicStreamSequencer::IsDuplicate(const QuicStreamFrame& frame) const {
+ // A frame is duplicate if the frame offset is smaller than our bytes consumed
+ // or we have stored the frame in our map.
+ // TODO(pwestin): Is it possible that a new frame contain more data even if
+ // the offset is the same?
+ return (frame.offset < num_bytes_consumed_ ||
+ frames_.find(frame.offset) != frames_.end());
+}
+
void QuicStreamSequencer::FlushBufferedFrames() {
FrameMap::iterator it = frames_.find(num_bytes_consumed_);
while (it != frames_.end()) {
« no previous file with comments | « net/quic/quic_stream_sequencer.h ('k') | net/quic/quic_stream_sequencer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698