You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2019/01/28 05:03:20 UTC

[trafficserver] branch quic-latest updated: Set fin flag correctly when retransmitter splits STREAM frame

This is an automated email from the ASF dual-hosted git repository.

maskit pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
     new fa9deaa  Set fin flag correctly when retransmitter splits STREAM frame
fa9deaa is described below

commit fa9deaaf044b2d36fdb3132de6738fb1b92b9162
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Mon Jan 28 14:02:35 2019 +0900

    Set fin flag correctly when retransmitter splits STREAM frame
---
 iocore/net/quic/QUICFrameRetransmitter.cc | 37 ++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/iocore/net/quic/QUICFrameRetransmitter.cc b/iocore/net/quic/QUICFrameRetransmitter.cc
index 485e13d..7765ccc 100644
--- a/iocore/net/quic/QUICFrameRetransmitter.cc
+++ b/iocore/net/quic/QUICFrameRetransmitter.cc
@@ -99,27 +99,35 @@ QUICFrameRetransmitter::_create_stream_frame(QUICFrameInformationUPtr &info, uin
                                              std::deque<QUICFrameInformationUPtr> &tmp_queue, QUICFrameId id,
                                              QUICFrameGenerator *owner)
 {
+  QUICFrameUPtr frame          = QUICFrameFactory::create_null_frame();
   StreamFrameInfo *stream_info = reinterpret_cast<StreamFrameInfo *>(info->data);
-  // FIXME: has_offset and has_length should be configurable.
-  auto frame = QUICFrameFactory::create_stream_frame(stream_info->block, stream_info->stream_id, stream_info->offset,
-                                                     stream_info->has_fin, true, true, id, owner);
-  if (frame->size() > maximum_frame_size) {
-    QUICStreamFrame *stream_frame = static_cast<QUICStreamFrame *>(frame.get());
-    if (stream_frame->size() - stream_frame->data_length() > maximum_frame_size) {
-      // header length is larger than maximum_frame_size.
-      tmp_queue.push_back(std::move(info));
-      return QUICFrameFactory::create_null_frame();
-    }
 
-    IOBufferBlock *block = stream_frame->data();
-    size_t over_length   = stream_frame->size() - maximum_frame_size;
-    block->_end          = std::max(block->start(), block->_end - over_length);
+  static constexpr uint32_t MAX_STREAM_FRAME_OVERHEAD = 24;
+  if (maximum_frame_size <= MAX_STREAM_FRAME_OVERHEAD) {
+    tmp_queue.push_back(std::move(info));
+    return frame;
+  }
+
+  // FIXME MAX_STREAM_FRAME_OVERHEAD is here and there
+  // These size calculation should not exist multiple places
+  uint64_t maximmum_data_size = maximum_frame_size - MAX_STREAM_FRAME_OVERHEAD;
+  if (maximmum_data_size > static_cast<uint64_t>(stream_info->block->size())) {
+    frame = QUICFrameFactory::create_stream_frame(stream_info->block, stream_info->stream_id, stream_info->offset,
+                                                  stream_info->has_fin, true, true, id, owner);
+    ink_assert(frame->size() <= maximum_frame_size);
+    stream_info->block = nullptr;
+  } else {
+    frame = QUICFrameFactory::create_stream_frame(stream_info->block, stream_info->stream_id, stream_info->offset, false, true,
+                                                  true, id, owner);
+    QUICStreamFrame *stream_frame = static_cast<QUICStreamFrame *>(frame.get());
+    IOBufferBlock *block          = stream_frame->data();
+    size_t over_length            = stream_frame->size() - maximum_frame_size;
+    block->_end                   = std::max(block->start(), block->_end - over_length);
     if (block->read_avail() == 0) {
       // no payload
       tmp_queue.push_back(std::move(info));
       return QUICFrameFactory::create_null_frame();
     }
-
     stream_info->block->consume(stream_frame->data_length());
     stream_info->offset += stream_frame->data_length();
     ink_assert(frame->size() <= maximum_frame_size);
@@ -127,7 +135,6 @@ QUICFrameRetransmitter::_create_stream_frame(QUICFrameInformationUPtr &info, uin
     return frame;
   }
 
-  stream_info->block = nullptr;
   ink_assert(frame != nullptr);
   return frame;
 }