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 643f7420aeedea9602c5f941df0ca443c30721d6
Author: Masaori Koshiba <masa...@apache.org>
AuthorDate: Fri Apr 13 15:40:55 2018 +0900

    Add create_uni/bidi_stream to QUICStreamManager
---
 iocore/net/QUICNetVConnection.cc     |  3 ++-
 iocore/net/quic/QUICStreamManager.cc | 37 ++++++++++++++++++++++++++++++++++--
 iocore/net/quic/QUICStreamManager.h  |  8 +++++++-
 3 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 1463056..506223d 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -204,7 +204,8 @@ QUICNetVConnection::start()
   this->_remote_flow_controller = new 
QUICRemoteConnectionFlowController(UINT64_MAX);
   this->_local_flow_controller  = new 
QUICLocalConnectionFlowController(this->_loss_detector, UINT64_MAX);
   this->_path_validator         = new QUICPathValidator();
-  this->_stream_manager         = new QUICStreamManager(this->_loss_detector, 
this->connection_id(), this->_application_map);
+  this->_stream_manager =
+    new QUICStreamManager(this->_loss_detector, this->connection_id(), 
this->_application_map, this->netvc_context);
 
   this->_frame_dispatcher->add_handler(this);
   this->_frame_dispatcher->add_handler(this->_stream_manager);
diff --git a/iocore/net/quic/QUICStreamManager.cc 
b/iocore/net/quic/QUICStreamManager.cc
index a01ffce..f52cf52 100644
--- a/iocore/net/quic/QUICStreamManager.cc
+++ b/iocore/net/quic/QUICStreamManager.cc
@@ -32,9 +32,18 @@ static constexpr char tag[] = "quic_stream_manager";
 ClassAllocator<QUICStreamManager> 
quicStreamManagerAllocator("quicStreamManagerAllocator");
 ClassAllocator<QUICStream> quicStreamAllocator("quicStreamAllocator");
 
-QUICStreamManager::QUICStreamManager(QUICRTTProvider *rtt_provider, 
QUICConnectionId cid, QUICApplicationMap *app_map)
-  : _connection_id(cid), _app_map(app_map), _rtt_provider(rtt_provider)
+QUICStreamManager::QUICStreamManager(QUICRTTProvider *rtt_provider, 
QUICConnectionId cid, QUICApplicationMap *app_map,
+                                     NetVConnectionContext_t context)
+  : _connection_id(cid), _app_map(app_map), _netvc_context(context), 
_rtt_provider(rtt_provider)
 {
+  if (this->_netvc_context == NET_VCONNECTION_OUT) {
+    // stream 0 is for handshake, smallest client bidi stream id is 4
+    this->_next_stream_id_bidi = 
static_cast<uint32_t>(QUICStreamType::CLIENT_BIDI) + 4;
+    this->_next_stream_id_uni  = 
static_cast<uint32_t>(QUICStreamType::CLIENT_UNI);
+  } else {
+    this->_next_stream_id_bidi = 
static_cast<uint32_t>(QUICStreamType::SERVER_BIDI);
+    this->_next_stream_id_uni  = 
static_cast<uint32_t>(QUICStreamType::SERVER_UNI);
+  }
 }
 
 std::vector<QUICFrameType>
@@ -103,6 +112,30 @@ QUICStreamManager::create_stream(QUICStreamId stream_id)
 }
 
 QUICErrorUPtr
+QUICStreamManager::create_uni_stream(QUICStreamId &new_stream_id)
+{
+  QUICErrorUPtr error = this->create_stream(this->_next_stream_id_uni);
+  if (error->cls == QUICErrorClass::NONE) {
+    new_stream_id = this->_next_stream_id_uni;
+    this->_next_stream_id_uni += 2;
+  }
+
+  return error;
+}
+
+QUICErrorUPtr
+QUICStreamManager::create_bidi_stream(QUICStreamId &new_stream_id)
+{
+  QUICErrorUPtr error = this->create_stream(this->_next_stream_id_bidi);
+  if (error->cls == QUICErrorClass::NONE) {
+    new_stream_id = this->_next_stream_id_bidi;
+    this->_next_stream_id_bidi += 2;
+  }
+
+  return error;
+}
+
+QUICErrorUPtr
 QUICStreamManager::handle_frame(std::shared_ptr<const QUICFrame> frame)
 {
   QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
diff --git a/iocore/net/quic/QUICStreamManager.h 
b/iocore/net/quic/QUICStreamManager.h
index 9f8851a..3b14b41 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -38,7 +38,8 @@ class QUICStreamManager : public QUICFrameHandler, public 
QUICFrameGenerator
 {
 public:
   QUICStreamManager(){};
-  QUICStreamManager(QUICRTTProvider *rtt_provider, QUICConnectionId cid, 
QUICApplicationMap *app_map);
+  QUICStreamManager(QUICRTTProvider *rtt_provider, QUICConnectionId cid, 
QUICApplicationMap *app_map,
+                    NetVConnectionContext_t context);
 
   void init_flow_control_params(const std::shared_ptr<const 
QUICTransportParameters> &local_tp,
                                 const std::shared_ptr<const 
QUICTransportParameters> &remote_tp);
@@ -49,6 +50,8 @@ public:
 
   uint32_t stream_count() const;
   QUICErrorUPtr create_stream(QUICStreamId stream_id);
+  QUICErrorUPtr create_uni_stream(QUICStreamId &new_stream_id);
+  QUICErrorUPtr create_bidi_stream(QUICStreamId &new_stream_id);
 
   void set_default_application(QUICApplication *app);
   void reset_send_offset();
@@ -76,12 +79,15 @@ private:
 
   QUICConnectionId _connection_id                           = 0;
   QUICApplicationMap *_app_map                              = nullptr;
+  NetVConnectionContext_t _netvc_context                    = 
NET_VCONNECTION_UNSET;
   std::shared_ptr<const QUICTransportParameters> _local_tp  = nullptr;
   std::shared_ptr<const QUICTransportParameters> _remote_tp = nullptr;
   QUICStreamId _local_maximum_stream_id_bidi                = 0;
   QUICStreamId _local_maximum_stream_id_uni                 = 0;
   QUICStreamId _remote_maximum_stream_id_bidi               = 0;
   QUICStreamId _remote_maximum_stream_id_uni                = 0;
+  QUICStreamId _next_stream_id_uni                          = 0;
+  QUICStreamId _next_stream_id_bidi                         = 0;
   uint64_t _total_offset_sent                               = 0;
   QUICRTTProvider *_rtt_provider                            = nullptr;
 };

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

Reply via email to