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 2018/08/23 02:29:17 UTC

[trafficserver] 01/03: Make QUICFlowController derived class from QUICFrameGenerator

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

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

commit 7dadd68544e117f80ea09ab98c15179011880528
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Thu Aug 23 11:01:56 2018 +0900

    Make QUICFlowController derived class from QUICFrameGenerator
---
 iocore/net/quic/QUICFlowController.cc           | 20 ++++++++++++++++++--
 iocore/net/quic/QUICFlowController.h            |  7 +++++--
 iocore/net/quic/QUICStream.cc                   |  4 ++--
 iocore/net/quic/test/test_QUICFlowController.cc |  6 +++---
 4 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/iocore/net/quic/QUICFlowController.cc b/iocore/net/quic/QUICFlowController.cc
index c833aa6..57357f1 100644
--- a/iocore/net/quic/QUICFlowController.cc
+++ b/iocore/net/quic/QUICFlowController.cc
@@ -100,14 +100,30 @@ QUICFlowController::set_limit(QUICOffset limit)
   this->_limit = limit;
 }
 
+bool
+QUICFlowController::will_generate_frame(QUICEncryptionLevel level)
+{
+  if (!this->_is_level_matched(level)) {
+    return false;
+  }
+
+  return this->_frame != nullptr;
+}
+
 QUICFrameUPtr
-QUICFlowController::generate_frame()
+QUICFlowController::generate_frame(QUICEncryptionLevel level, uint64_t connection_credit, uint16_t maximum_frame_size)
 {
   QUICFrameUPtr frame = QUICFrameFactory::create_null_frame();
-  if (this->_frame) {
+
+  if (!this->_is_level_matched(level)) {
+    return frame;
+  }
+
+  if (this->_frame && this->_frame->size() <= maximum_frame_size) {
     frame        = std::move(this->_frame);
     this->_frame = nullptr;
   }
+
   return frame;
 }
 
diff --git a/iocore/net/quic/QUICFlowController.h b/iocore/net/quic/QUICFlowController.h
index bc4a91a..8f9e387 100644
--- a/iocore/net/quic/QUICFlowController.h
+++ b/iocore/net/quic/QUICFlowController.h
@@ -26,6 +26,7 @@
 #include "../../eventsystem/I_EventSystem.h"
 #include "QUICTypes.h"
 #include "QUICFrame.h"
+#include "QUICFrameGenerator.h"
 #include "QUICLossDetector.h"
 
 class QUICRateAnalyzer
@@ -39,7 +40,7 @@ private:
   ink_hrtime _start_time = Thread::get_hrtime();
 };
 
-class QUICFlowController
+class QUICFlowController : public QUICFrameGenerator
 {
 public:
   uint64_t credit();
@@ -60,7 +61,9 @@ public:
    */
   void set_limit(QUICOffset limit);
 
-  QUICFrameUPtr generate_frame();
+  // QUICFrameGenerator
+  bool will_generate_frame(QUICEncryptionLevel level) override;
+  QUICFrameUPtr generate_frame(QUICEncryptionLevel level, uint64_t connection_credit, uint16_t maximum_frame_size) override;
 
 protected:
   QUICFlowController(uint64_t initial_limit) : _limit(initial_limit) {}
diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc
index 1965760..ff38147 100644
--- a/iocore/net/quic/QUICStream.cc
+++ b/iocore/net/quic/QUICStream.cc
@@ -398,7 +398,7 @@ QUICStream::generate_frame(QUICEncryptionLevel level, uint64_t connection_credit
   }
 
   QUICFrameUPtr frame = QUICFrameFactory::create_null_frame();
-  frame               = this->_local_flow_controller.generate_frame();
+  frame               = this->_local_flow_controller.generate_frame(level, connection_credit, maximum_frame_size);
   if (frame) {
     return frame;
   }
@@ -449,7 +449,7 @@ QUICStream::generate_frame(QUICEncryptionLevel level, uint64_t connection_credit
     this->_state.update_with_sending_frame(*frame);
   } else if (ret != 0) {
     QUICStreamDebug("Flow Controller blocked sending a STREAM frame");
-    frame = this->_remote_flow_controller.generate_frame();
+    frame = this->_remote_flow_controller.generate_frame(level, connection_credit, maximum_frame_size);
   }
   return frame;
 }
diff --git a/iocore/net/quic/test/test_QUICFlowController.cc b/iocore/net/quic/test/test_QUICFlowController.cc
index c52b8b2..0d8749c 100644
--- a/iocore/net/quic/test/test_QUICFlowController.cc
+++ b/iocore/net/quic/test/test_QUICFlowController.cc
@@ -97,7 +97,7 @@ TEST_CASE("QUICFlowController_Local_Connection", "[quic]")
   fc.forward_limit(2048);
   CHECK(fc.current_offset() == 1024);
   CHECK(fc.current_limit() == 2048);
-  QUICFrameUPtr frame = fc.generate_frame();
+  QUICFrameUPtr frame = fc.generate_frame(QUICEncryptionLevel::ONE_RTT, 0, 1024);
   CHECK(frame);
   CHECK(frame->type() == QUICFrameType::MAX_DATA);
 
@@ -148,7 +148,7 @@ TEST_CASE("QUICFlowController_Remote_Connection", "[quic]")
   CHECK(fc.current_offset() == 1024);
   CHECK(fc.current_limit() == 1024);
   CHECK(ret != 0);
-  QUICFrameUPtr frame = fc.generate_frame();
+  QUICFrameUPtr frame = fc.generate_frame(QUICEncryptionLevel::ONE_RTT, 0, 1024);
   CHECK(frame);
   CHECK(frame->type() == QUICFrameType::BLOCKED);
 
@@ -211,7 +211,7 @@ TEST_CASE("QUICFlowController_Local_Stream", "[quic]")
   fc.forward_limit(2048);
   CHECK(fc.current_offset() == 1024);
   CHECK(fc.current_limit() == 2048);
-  QUICFrameUPtr frame = fc.generate_frame();
+  QUICFrameUPtr frame = fc.generate_frame(QUICEncryptionLevel::ONE_RTT, 0, 1024);
   CHECK(frame);
   CHECK(frame->type() == QUICFrameType::MAX_STREAM_DATA);