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 2022/07/07 02:27:57 UTC

[trafficserver] 09/12: Delete a stream at the end of a transaction

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

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

commit a3da4537f3eee192271669f5e7a38d9f58b4da60
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Thu Jun 30 10:05:16 2022 +0900

    Delete a stream at the end of a transaction
---
 iocore/net/quic/QUICStreamManager.h         |  3 ++-
 iocore/net/quic/QUICStreamManager_quiche.cc | 10 ++++++++++
 iocore/net/quic/QUICStreamManager_quiche.h  |  1 +
 proxy/http3/Http3App.cc                     | 30 ++++++++++++++++++++++++++++-
 proxy/http3/Http3App.h                      |  2 ++
 proxy/http3/Http3Session.cc                 |  8 ++++++++
 proxy/http3/Http3Session.h                  |  3 ++-
 7 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/iocore/net/quic/QUICStreamManager.h b/iocore/net/quic/QUICStreamManager.h
index 4701655e0..e7a3bfd2a 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -45,10 +45,11 @@ public:
 
   virtual uint32_t stream_count() const                   = 0;
   virtual QUICStream *find_stream(QUICStreamId stream_id) = 0;
-  ;
+
   virtual QUICConnectionErrorUPtr create_stream(QUICStreamId stream_id)           = 0;
   virtual QUICConnectionErrorUPtr create_uni_stream(QUICStreamId &new_stream_id)  = 0;
   virtual QUICConnectionErrorUPtr create_bidi_stream(QUICStreamId &new_stream_id) = 0;
+  virtual QUICConnectionErrorUPtr delete_stream(QUICStreamId &new_stream_id)      = 0;
   virtual void reset_stream(QUICStreamId stream_id, QUICStreamErrorUPtr error)    = 0;
 
   void set_default_application(QUICApplication *app);
diff --git a/iocore/net/quic/QUICStreamManager_quiche.cc b/iocore/net/quic/QUICStreamManager_quiche.cc
index 5d0f162fc..6321cf791 100644
--- a/iocore/net/quic/QUICStreamManager_quiche.cc
+++ b/iocore/net/quic/QUICStreamManager_quiche.cc
@@ -105,6 +105,16 @@ QUICStreamManagerImpl::create_bidi_stream(QUICStreamId &new_stream_id)
   return nullptr;
 }
 
+QUICConnectionErrorUPtr
+QUICStreamManagerImpl::delete_stream(QUICStreamId &stream_id)
+{
+  QUICStreamImpl *stream = static_cast<QUICStreamImpl *>(this->find_stream(stream_id));
+  stream_list.remove(stream);
+  delete stream;
+
+  return nullptr;
+}
+
 void
 QUICStreamManagerImpl::reset_stream(QUICStreamId stream_id, QUICStreamErrorUPtr error)
 {
diff --git a/iocore/net/quic/QUICStreamManager_quiche.h b/iocore/net/quic/QUICStreamManager_quiche.h
index 4b4ed65d2..80ea6055b 100644
--- a/iocore/net/quic/QUICStreamManager_quiche.h
+++ b/iocore/net/quic/QUICStreamManager_quiche.h
@@ -47,6 +47,7 @@ public:
   virtual QUICConnectionErrorUPtr create_stream(QUICStreamId stream_id) override;
   virtual QUICConnectionErrorUPtr create_uni_stream(QUICStreamId &new_stream_id) override;
   virtual QUICConnectionErrorUPtr create_bidi_stream(QUICStreamId &new_stream_id) override;
+  virtual QUICConnectionErrorUPtr delete_stream(QUICStreamId &new_stream_id) override;
   virtual void reset_stream(QUICStreamId stream_id, QUICStreamErrorUPtr error) override;
 
   // QUICStreamStateListener
diff --git a/proxy/http3/Http3App.cc b/proxy/http3/Http3App.cc
index d2da2f456..b6361d4bd 100644
--- a/proxy/http3/Http3App.cc
+++ b/proxy/http3/Http3App.cc
@@ -137,13 +137,19 @@ Http3App::main_event_handler(int event, Event *data)
     }
     break;
   case VC_EVENT_WRITE_READY:
-  case VC_EVENT_WRITE_COMPLETE:
     if (is_bidirectional) {
       this->_handle_bidi_stream_on_write_ready(event, vio);
     } else {
       this->_handle_uni_stream_on_write_ready(event, vio);
     }
     break;
+  case VC_EVENT_WRITE_COMPLETE:
+    if (is_bidirectional) {
+      this->_handle_bidi_stream_on_write_complete(event, vio);
+    } else {
+      this->_handle_uni_stream_on_write_complete(event, vio);
+    }
+    break;
   case VC_EVENT_EOS:
     if (is_bidirectional) {
       this->_handle_bidi_stream_on_eos(event, vio);
@@ -281,6 +287,12 @@ Http3App::_handle_uni_stream_on_write_ready(int /* event */, VIO *vio)
   }
 }
 
+void
+Http3App::_handle_uni_stream_on_write_complete(int /* event */, VIO *vio)
+{
+  // QUICStreamVCAdapter *adapter = static_cast<QUICStreamVCAdapter *>(vio->vc_server);
+}
+
 void
 Http3App::_handle_bidi_stream_on_eos(int /* event */, VIO *vio)
 {
@@ -327,6 +339,22 @@ Http3App::_handle_bidi_stream_on_write_ready(int event, VIO *vio)
   }
 }
 
+void
+Http3App::_handle_bidi_stream_on_write_complete(int event, VIO *vio)
+{
+  QUICStreamVCAdapter *adapter = static_cast<QUICStreamVCAdapter *>(vio->vc_server);
+
+  QUICStreamId stream_id = adapter->stream().id();
+  Http3Transaction *txn  = static_cast<Http3Transaction *>(this->_ssn->get_transaction(stream_id));
+  if (txn != nullptr) {
+    SCOPED_MUTEX_LOCK(lock, txn->mutex, this_ethread());
+    txn->handleEvent(event);
+  }
+  // FIXME There may be data to read
+  this->_ssn->remove_transaction(txn);
+  this->_qc->stream_manager()->delete_stream(stream_id);
+}
+
 //
 // SETTINGS frame handler
 //
diff --git a/proxy/http3/Http3App.h b/proxy/http3/Http3App.h
index 5de5aea05..6cc8bee49 100644
--- a/proxy/http3/Http3App.h
+++ b/proxy/http3/Http3App.h
@@ -68,9 +68,11 @@ protected:
 private:
   void _handle_uni_stream_on_read_ready(int event, VIO *vio);
   void _handle_uni_stream_on_write_ready(int event, VIO *vio);
+  void _handle_uni_stream_on_write_complete(int event, VIO *vio);
   void _handle_uni_stream_on_eos(int event, VIO *vio);
   void _handle_bidi_stream_on_read_ready(int event, VIO *vio);
   void _handle_bidi_stream_on_write_ready(int event, VIO *vio);
+  void _handle_bidi_stream_on_write_complete(int event, VIO *vio);
   void _handle_bidi_stream_on_eos(int event, VIO *vio);
 
   void _set_qpack_stream(Http3StreamType type, QUICStreamVCAdapter *adapter);
diff --git a/proxy/http3/Http3Session.cc b/proxy/http3/Http3Session.cc
index 98057ce82..0c653a6d9 100644
--- a/proxy/http3/Http3Session.cc
+++ b/proxy/http3/Http3Session.cc
@@ -51,6 +51,14 @@ HQSession::add_transaction(HQTransaction *trans)
   return;
 }
 
+void
+HQSession::remove_transaction(HQTransaction *trans)
+{
+  this->_transaction_list.remove(trans);
+
+  return;
+}
+
 const char *
 HQSession::get_protocol_string() const
 {
diff --git a/proxy/http3/Http3Session.h b/proxy/http3/Http3Session.h
index bfb37d676..4d78b27a9 100644
--- a/proxy/http3/Http3Session.h
+++ b/proxy/http3/Http3Session.h
@@ -53,7 +53,8 @@ public:
   int get_transact_count() const override;
 
   // HQSession
-  void add_transaction(HQTransaction *);
+  void add_transaction(HQTransaction *trans);
+  void remove_transaction(HQTransaction *trans);
   HQTransaction *get_transaction(QUICStreamId);
 
 private: