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 2024/02/17 00:04:20 UTC

(trafficserver) branch master updated: http3: Propagate events from QUICNetVC (#11071)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9d26d12adf http3: Propagate events from QUICNetVC (#11071)
9d26d12adf is described below

commit 9d26d12adf16a67d176aeb28c0e626bc10c68e6a
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Fri Feb 16 17:04:13 2024 -0700

    http3: Propagate events from QUICNetVC (#11071)
    
    * http3: Propagate events from QUICNetVC
    
    * Propagate events to HttpSM
---
 include/proxy/http3/Http3Session.h     |  4 ++--
 include/proxy/http3/Http3Transaction.h |  1 +
 src/iocore/net/P_QUICNetVConnection.h  |  2 ++
 src/iocore/net/QUICNetVConnection.cc   | 26 ++++++++++++++++++----
 src/proxy/http3/Http3Session.cc        | 40 +++++++++++++++++++---------------
 src/proxy/http3/Http3Transaction.cc    | 14 ++++++++++++
 6 files changed, 64 insertions(+), 23 deletions(-)

diff --git a/include/proxy/http3/Http3Session.h b/include/proxy/http3/Http3Session.h
index cfcb7e7f76..cc0d7c488b 100644
--- a/include/proxy/http3/Http3Session.h
+++ b/include/proxy/http3/Http3Session.h
@@ -37,8 +37,6 @@ public:
   virtual ~HQSession();
 
   // Implement VConnection interface
-  VIO *do_io_read(Continuation *c, int64_t nbytes = INT64_MAX, MIOBuffer *buf = nullptr) override;
-  VIO *do_io_write(Continuation *c = nullptr, int64_t nbytes = INT64_MAX, IOBufferReader *buf = 0, bool owner = false) override;
   void do_io_close(int lerrno = -1) override;
   void do_io_shutdown(ShutdownHowTo_t howto) override;
   void reenable(VIO *vio) override;
@@ -63,6 +61,8 @@ private:
   Queue<HQTransaction> _transaction_list;
 
   char _protocol_string[16];
+
+  int main_event_handler(int, void *);
 };
 
 class Http3Session : public HQSession
diff --git a/include/proxy/http3/Http3Transaction.h b/include/proxy/http3/Http3Transaction.h
index 833fc39ae8..3db3ac1d6d 100644
--- a/include/proxy/http3/Http3Transaction.h
+++ b/include/proxy/http3/Http3Transaction.h
@@ -84,6 +84,7 @@ protected:
   void _schedule_write_complete_event();
   void _unschedule_write_complete_event();
   void _close_write_complete_event(Event *e);
+  void _signal_event(int event);
   void _signal_read_event();
   void _signal_write_event();
   void _delete_if_possible();
diff --git a/src/iocore/net/P_QUICNetVConnection.h b/src/iocore/net/P_QUICNetVConnection.h
index bef664de34..06a366b968 100644
--- a/src/iocore/net/P_QUICNetVConnection.h
+++ b/src/iocore/net/P_QUICNetVConnection.h
@@ -204,6 +204,8 @@ private:
   void _handle_write_ready();
   void _handle_interval();
 
+  void _propagate_event(int event);
+
   void _switch_to_established_state();
 
   bool _handshake_completed = false;
diff --git a/src/iocore/net/QUICNetVConnection.cc b/src/iocore/net/QUICNetVConnection.cc
index 8642b62637..bfd0421357 100644
--- a/src/iocore/net/QUICNetVConnection.cc
+++ b/src/iocore/net/QUICNetVConnection.cc
@@ -171,6 +171,7 @@ QUICNetVConnection::state_handshake(int event, Event *data)
   case VC_EVENT_ACTIVE_TIMEOUT:
   case VC_EVENT_INACTIVITY_TIMEOUT:
     _unschedule_packet_write_ready();
+    this->_propagate_event(event);
     this->closed = 1;
     break;
   default:
@@ -207,6 +208,7 @@ QUICNetVConnection::state_established(int event, Event *data)
   case VC_EVENT_ACTIVE_TIMEOUT:
   case VC_EVENT_INACTIVITY_TIMEOUT:
     _unschedule_packet_write_ready();
+    this->_propagate_event(event);
     this->closed = 1;
     break;
   default:
@@ -254,6 +256,20 @@ QUICNetVConnection::_start_application()
   }
 }
 
+void
+QUICNetVConnection::_propagate_event(int event)
+{
+  QUICConVDebug("Propagating: %d", event);
+  if (this->read.vio.cont && this->read.vio.mutex == this->read.vio.cont->mutex) {
+    this->read.vio.cont->handleEvent(event, &this->read.vio);
+  } else if (this->write.vio.cont && this->write.vio.mutex == this->write.vio.cont->mutex) {
+    this->write.vio.cont->handleEvent(event, &this->write.vio);
+  } else {
+    // Proxy Session does not exist
+    QUICConVDebug("Session does not exist");
+  }
+}
+
 bool
 QUICNetVConnection::shouldDestroy()
 {
@@ -263,15 +279,17 @@ QUICNetVConnection::shouldDestroy()
 VIO *
 QUICNetVConnection::do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf)
 {
-  ink_assert(false);
-  return nullptr;
+  auto vio           = super::do_io_read(c, nbytes, buf);
+  this->read.enabled = 1;
+  return vio;
 }
 
 VIO *
 QUICNetVConnection::do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner)
 {
-  ink_assert(false);
-  return nullptr;
+  auto vio            = super::do_io_write(c, nbytes, buf);
+  this->write.enabled = 1;
+  return vio;
 }
 
 int
diff --git a/src/proxy/http3/Http3Session.cc b/src/proxy/http3/Http3Session.cc
index eb31215572..14ce9c18c4 100644
--- a/src/proxy/http3/Http3Session.cc
+++ b/src/proxy/http3/Http3Session.cc
@@ -90,20 +90,6 @@ HQSession::get_transaction(QUICStreamId id)
   return nullptr;
 }
 
-VIO *
-HQSession::do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf)
-{
-  ink_assert(false);
-  return nullptr;
-}
-
-VIO *
-HQSession::do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner)
-{
-  ink_assert(false);
-  return nullptr;
-}
-
 void
 HQSession::do_io_close(int lerrno)
 {
@@ -131,14 +117,15 @@ HQSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferRead
   this->con_id = new_vc->get_service<QUICSupport>()->get_quic_connection()->connection_id();
   this->_handle_if_ssl(new_vc);
 
-  return;
+  do_api_callout(TS_HTTP_SSN_START_HOOK);
 }
 
 void
 HQSession::start()
 {
-  ink_assert(false);
-  return;
+  SET_HANDLER(&HQSession::main_event_handler);
+  this->do_io_read(this, 0, nullptr);
+  this->do_io_write(this, 0, nullptr);
 }
 
 void
@@ -166,6 +153,25 @@ HQSession::get_transact_count() const
   return 0;
 }
 
+int
+HQSession::main_event_handler(int event, void *edata)
+{
+  switch (event) {
+  case VC_EVENT_ACTIVE_TIMEOUT:
+  case VC_EVENT_INACTIVITY_TIMEOUT:
+  case VC_EVENT_ERROR:
+  case VC_EVENT_EOS:
+    this->do_io_close();
+    for (HQTransaction *t = this->_transaction_list.head; t; t = static_cast<HQTransaction *>(t->link.next)) {
+      SCOPED_MUTEX_LOCK(lock, t->mutex, this_ethread());
+      t->handleEvent(event);
+    }
+    break;
+  }
+
+  return 0;
+}
+
 //
 // Http3Session
 //
diff --git a/src/proxy/http3/Http3Transaction.cc b/src/proxy/http3/Http3Transaction.cc
index 1b2388fcc4..11ce096ebd 100644
--- a/src/proxy/http3/Http3Transaction.cc
+++ b/src/proxy/http3/Http3Transaction.cc
@@ -345,6 +345,19 @@ HQTransaction::_close_write_complete_event(Event *e)
   }
 }
 
+void
+HQTransaction::_signal_event(int event)
+{
+  if (this->_write_vio.cont) {
+    SCOPED_MUTEX_LOCK(lock, this->_write_vio.mutex, this_ethread());
+    this->_write_vio.cont->handleEvent(event);
+  }
+  if (this->_read_vio.cont && this->_read_vio.cont != this->_write_vio.cont) {
+    SCOPED_MUTEX_LOCK(lock, this->_read_vio.mutex, this_ethread());
+    this->_read_vio.cont->handleEvent(event);
+  }
+}
+
 /**
  * @brief Signal event to this->_read_vio.cont
  */
@@ -490,6 +503,7 @@ Http3Transaction::state_stream_open(int event, Event *edata)
   case VC_EVENT_INACTIVITY_TIMEOUT:
   case VC_EVENT_ACTIVE_TIMEOUT: {
     Http3TransVDebug("%s (%d)", get_vc_event_name(event), event);
+    this->_signal_event(event);
     break;
   }
   default: