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/02/21 06:42:10 UTC

[trafficserver] branch quic-latest updated: Remove QUICStreamManager::init()

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 72dc4b7  Remove QUICStreamManager::init()
72dc4b7 is described below

commit 72dc4b76f0951ec5163b1be635d5b2445d53778f
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Wed Feb 21 15:41:44 2018 +0900

    Remove QUICStreamManager::init()
---
 iocore/net/quic/QUICStream.cc        | 75 ++++++++++++++++++------------------
 iocore/net/quic/QUICStream.h         | 18 ++++++---
 iocore/net/quic/QUICStreamManager.cc |  7 ++--
 3 files changed, 53 insertions(+), 47 deletions(-)

diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc
index 071da7e..87386b0 100644
--- a/iocore/net/quic/QUICStream.cc
+++ b/iocore/net/quic/QUICStream.cc
@@ -36,6 +36,22 @@
   Debug("quic_flow_ctrl", "[%" PRIx64 "] [%" PRIx64 "] [%s] " fmt, static_cast<uint64_t>(this->_connection_id), this->_id, \
         QUICDebugNames::stream_state(this->_state), ##__VA_ARGS__)
 
+QUICStream::QUICStream(QUICFrameTransmitter *tx, QUICConnectionId cid, QUICStreamId sid, uint64_t recv_max_stream_data,
+                       uint64_t send_max_stream_data)
+  : VConnection(nullptr),
+    _connection_id(cid),
+    _id(sid),
+    _remote_flow_controller(send_max_stream_data, tx, _id),
+    _local_flow_controller(recv_max_stream_data, tx, _id),
+    _received_stream_frame_buffer(this),
+    _tx(tx)
+{
+  SET_HANDLER(&QUICStream::state_stream_open);
+  mutex = new_ProxyMutex();
+
+  this->init_flow_control_params(recv_max_stream_data, send_max_stream_data);
+}
+
 QUICStream::~QUICStream()
 {
   if (this->_read_event) {
@@ -50,32 +66,15 @@ QUICStream::~QUICStream()
 }
 
 void
-QUICStream::init(QUICFrameTransmitter *tx, QUICConnectionId cid, QUICStreamId sid, uint64_t recv_max_stream_data,
-                 uint64_t send_max_stream_data)
-{
-  SET_HANDLER(&QUICStream::state_stream_open);
-
-  this->mutex                   = new_ProxyMutex();
-  this->_tx                     = tx;
-  this->_connection_id          = cid;
-  this->_id                     = sid;
-  this->_remote_flow_controller = new QUICRemoteStreamFlowController(send_max_stream_data, _tx, _id);
-  this->_local_flow_controller  = new QUICLocalStreamFlowController(recv_max_stream_data, _tx, _id);
-  this->init_flow_control_params(recv_max_stream_data, send_max_stream_data);
-
-  QUICStreamDebug("Initialized");
-}
-
-void
 QUICStream::init_flow_control_params(uint32_t recv_max_stream_data, uint32_t send_max_stream_data)
 {
   this->_flow_control_buffer_size = recv_max_stream_data;
-  this->_local_flow_controller->forward_limit(recv_max_stream_data);
-  this->_remote_flow_controller->forward_limit(send_max_stream_data);
-  QUICStreamFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
-                    this->_local_flow_controller->current_limit());
-  QUICStreamFCDebug("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller->current_offset(),
-                    this->_remote_flow_controller->current_limit());
+  this->_local_flow_controller.forward_limit(recv_max_stream_data);
+  this->_remote_flow_controller.forward_limit(send_max_stream_data);
+  QUICStreamFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller.current_offset(),
+                    this->_local_flow_controller.current_limit());
+  QUICStreamFCDebug("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller.current_offset(),
+                    this->_remote_flow_controller.current_limit());
 }
 
 QUICStreamId
@@ -289,9 +288,9 @@ QUICStream::_write_to_read_vio(const std::shared_ptr<const QUICStreamFrame> &fra
   int bytes_added = this->_read_vio.buffer.writer()->write(frame->data(), frame->data_length());
   this->_read_vio.nbytes += bytes_added;
   // frame->offset() + frame->data_length() == this->_recv_offset
-  this->_local_flow_controller->forward_limit(frame->offset() + frame->data_length() + this->_flow_control_buffer_size);
-  QUICStreamFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
-                    this->_local_flow_controller->current_limit());
+  this->_local_flow_controller.forward_limit(frame->offset() + frame->data_length() + this->_flow_control_buffer_size);
+  QUICStreamFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller.current_offset(),
+                    this->_local_flow_controller.current_limit());
 
   this->_state.update_with_received_frame(*frame);
 }
@@ -314,9 +313,9 @@ QUICStream::recv(const std::shared_ptr<const QUICStreamFrame> frame)
   }
 
   // Flow Control - Even if it's allowed to receive on the state, it may exceed the limit
-  int ret = this->_local_flow_controller->update(frame->offset() + frame->data_length());
-  QUICStreamFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
-                    this->_local_flow_controller->current_limit());
+  int ret = this->_local_flow_controller.update(frame->offset() + frame->data_length());
+  QUICStreamFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller.current_offset(),
+                    this->_local_flow_controller.current_limit());
   if (ret != 0) {
     return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::FLOW_CONTROL_ERROR));
   }
@@ -341,9 +340,9 @@ QUICStream::recv(const std::shared_ptr<const QUICStreamFrame> frame)
 QUICErrorUPtr
 QUICStream::recv(const std::shared_ptr<const QUICMaxStreamDataFrame> frame)
 {
-  this->_remote_flow_controller->forward_limit(frame->maximum_stream_data());
-  QUICStreamFCDebug("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller->current_offset(),
-                    this->_remote_flow_controller->current_limit());
+  this->_remote_flow_controller.forward_limit(frame->maximum_stream_data());
+  QUICStreamFCDebug("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller.current_offset(),
+                    this->_remote_flow_controller.current_limit());
 
   QUICStreamDebug("restart sending");
   int64_t len = this->_process_write_vio();
@@ -464,7 +463,7 @@ QUICStream::_process_write_vio()
     int64_t len      = 0;
     bool fin         = false;
 
-    int64_t credit = this->_remote_flow_controller->current_limit() - this->_remote_flow_controller->current_offset();
+    int64_t credit = this->_remote_flow_controller.current_limit() - this->_remote_flow_controller.current_offset();
     if (credit != 0 && max_size > credit) {
       max_size = credit;
     }
@@ -484,9 +483,9 @@ QUICStream::_process_write_vio()
       break;
     }
 
-    int ret = this->_remote_flow_controller->update(this->_send_offset + len);
-    QUICStreamFCDebug("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller->current_offset(),
-                      this->_remote_flow_controller->current_limit());
+    int ret = this->_remote_flow_controller.update(this->_send_offset + len);
+    QUICStreamFCDebug("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller.current_offset(),
+                      this->_remote_flow_controller.current_limit());
     if (ret != 0) {
       QUICStreamDebug("Flow Controller blocked sending a STREAM frame");
       break;
@@ -526,11 +525,11 @@ QUICStream::nbytes_to_read()
 QUICOffset
 QUICStream::largest_offset_received()
 {
-  return this->_local_flow_controller->current_offset();
+  return this->_local_flow_controller.current_offset();
 }
 
 QUICOffset
 QUICStream::largest_offset_sent()
 {
-  return this->_remote_flow_controller->current_offset();
+  return this->_remote_flow_controller.current_offset();
 }
diff --git a/iocore/net/quic/QUICStream.h b/iocore/net/quic/QUICStream.h
index fb71386..e7e9879 100644
--- a/iocore/net/quic/QUICStream.h
+++ b/iocore/net/quic/QUICStream.h
@@ -45,10 +45,16 @@ class QUICStreamManager;
 class QUICStream : public VConnection
 {
 public:
-  QUICStream() : VConnection(nullptr), _received_stream_frame_buffer(this) {}
+  QUICStream()
+    : VConnection(nullptr),
+      _remote_flow_controller(0, nullptr, 0),
+      _local_flow_controller(0, nullptr, 0),
+      _received_stream_frame_buffer(this)
+  {
+  }
+  QUICStream(QUICFrameTransmitter *tx, QUICConnectionId cid, QUICStreamId sid, uint64_t recv_max_stream_data = 0,
+             uint64_t send_max_stream_data = 0);
   ~QUICStream();
-  void init(QUICFrameTransmitter *tx, QUICConnectionId cid, QUICStreamId id, uint64_t recv_max_stream_data = 0,
-            uint64_t send_max_stream_data = 0);
   // void start();
   int state_stream_open(int event, void *data);
   int state_stream_closed(int event, void *data);
@@ -96,9 +102,9 @@ private:
   QUICStreamId _id                = 0;
   QUICOffset _send_offset         = 0;
 
-  QUICRemoteStreamFlowController *_remote_flow_controller = nullptr;
-  QUICLocalStreamFlowController *_local_flow_controller   = nullptr;
-  uint64_t _flow_control_buffer_size                      = 1024;
+  QUICRemoteStreamFlowController _remote_flow_controller;
+  QUICLocalStreamFlowController _local_flow_controller;
+  uint64_t _flow_control_buffer_size = 1024;
 
   VIO _read_vio;
   VIO _write_vio;
diff --git a/iocore/net/quic/QUICStreamManager.cc b/iocore/net/quic/QUICStreamManager.cc
index 1f27a7d..ecc12c2 100644
--- a/iocore/net/quic/QUICStreamManager.cc
+++ b/iocore/net/quic/QUICStreamManager.cc
@@ -235,8 +235,6 @@ QUICStreamManager::_find_or_create_stream(QUICStreamId stream_id)
       return nullptr;
     }
 
-    // TODO Free the stream somewhere
-    stream                          = new (THREAD_ALLOC(quicStreamAllocator, this_ethread())) QUICStream();
     uint32_t local_max_stream_data  = 0;
     uint32_t remote_max_stream_data = 0;
     if (this->_local_tp) {
@@ -246,7 +244,10 @@ QUICStreamManager::_find_or_create_stream(QUICStreamId stream_id)
       QUICConfig::scoped_config params;
       local_max_stream_data = params->initial_max_stream_data();
     }
-    stream->init(this->_tx, this->_connection_id, stream_id, local_max_stream_data, remote_max_stream_data);
+
+    // TODO Free the stream somewhere
+    stream = THREAD_ALLOC(quicStreamAllocator, this_ethread());
+    new (stream) QUICStream(this->_tx, this->_connection_id, stream_id, local_max_stream_data, remote_max_stream_data);
 
     this->stream_list.push(stream);
   }

-- 
To stop receiving notification emails like this one, please contact
maskit@apache.org.