You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/03/29 19:53:58 UTC

[trafficserver] branch 9.1.x updated (c888b3b -> d51a978)

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

zwoop pushed a change to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


    from c888b3b  Expose URL element methods through HTTPHdr (#7628)
     new 2c471ad  Remove ProxyTransaction::set_proxy_ssn (#7567)
     new a9870d9  Tidy up session/transaction destruction process (#7571)
     new d51a978  Add default implementation for allow_half_open (#7630)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 proxy/ProxySession.cc               |  25 +++---
 proxy/ProxySession.h                |   3 +-
 proxy/ProxyTransaction.cc           |  21 +++--
 proxy/ProxyTransaction.h            |  15 +---
 proxy/http/Http1ClientSession.cc    |  15 ++--
 proxy/http/Http1ClientSession.h     |   1 +
 proxy/http/Http1ServerSession.cc    |   7 ++
 proxy/http/Http1ServerSession.h     |   2 +
 proxy/http/Http1Transaction.cc      |   2 +-
 proxy/http/Http1Transaction.h       |   5 +-
 proxy/http/HttpSM.cc                |   1 +
 proxy/http/HttpSessionAccept.cc     |   1 +
 proxy/http2/Http2ClientSession.cc   |   5 +-
 proxy/http2/Http2ConnectionState.cc |   3 +-
 proxy/http2/Http2SessionAccept.cc   |   5 +-
 proxy/http2/Http2Stream.cc          | 167 +++++++++++++++++-------------------
 proxy/http2/Http2Stream.h           |  14 +--
 proxy/http3/Http3Session.cc         |   6 ++
 proxy/http3/Http3Session.h          |   1 +
 proxy/http3/Http3Transaction.cc     |  16 +---
 proxy/http3/Http3Transaction.h      |   2 -
 21 files changed, 151 insertions(+), 166 deletions(-)

[trafficserver] 01/03: Remove ProxyTransaction::set_proxy_ssn (#7567)

Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 2c471ad0929f6fd76a3e7a13a6da4a42c4b6a139
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Fri Mar 5 09:35:26 2021 +0900

    Remove ProxyTransaction::set_proxy_ssn (#7567)
    
    * Remove ProxyTransaction::set_proxy_ssn
    
    * Call ProxySession's constructor
    
    * Call Http1ServerSession's constructor
    
    (cherry picked from commit f4f4f59237018b91824f9130d57539e46c1def30)
---
 proxy/ProxyTransaction.cc           |  2 +-
 proxy/ProxyTransaction.h            | 11 ++---------
 proxy/http/Http1ClientSession.cc    |  3 +--
 proxy/http/Http1Transaction.h       |  2 +-
 proxy/http/HttpSM.cc                |  1 +
 proxy/http/HttpSessionAccept.cc     |  1 +
 proxy/http2/Http2ClientSession.cc   |  2 +-
 proxy/http2/Http2ConnectionState.cc |  3 +--
 proxy/http2/Http2SessionAccept.cc   |  5 +++--
 proxy/http2/Http2Stream.cc          |  7 ++-----
 proxy/http2/Http2Stream.h           |  5 ++---
 proxy/http3/Http3Transaction.cc     |  4 +---
 12 files changed, 17 insertions(+), 29 deletions(-)

diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc
index 15601f4..eedfa31 100644
--- a/proxy/ProxyTransaction.cc
+++ b/proxy/ProxyTransaction.cc
@@ -26,7 +26,7 @@
 
 #define HttpTxnDebug(fmt, ...) SsnDebug(this, "http_txn", fmt, __VA_ARGS__)
 
-ProxyTransaction::ProxyTransaction() : VConnection(nullptr) {}
+ProxyTransaction::ProxyTransaction(ProxySession *session) : VConnection(nullptr), _proxy_ssn(session) {}
 
 void
 ProxyTransaction::new_transaction(bool from_early_data)
diff --git a/proxy/ProxyTransaction.h b/proxy/ProxyTransaction.h
index e264ab9..420a0a8 100644
--- a/proxy/ProxyTransaction.h
+++ b/proxy/ProxyTransaction.h
@@ -32,7 +32,8 @@ class HttpSM;
 class ProxyTransaction : public VConnection
 {
 public:
-  ProxyTransaction();
+  ProxyTransaction() : VConnection(nullptr) {}
+  ProxyTransaction(ProxySession *ssn);
 
   /// Virtual Methods
   //
@@ -81,8 +82,6 @@ public:
   virtual bool get_half_close_flag() const;
   virtual bool is_chunked_encoding_supported() const;
 
-  virtual void set_proxy_ssn(ProxySession *set_proxy_ssn);
-
   // Returns true if there is a request body for this request
   virtual bool has_request_body(int64_t content_length, bool is_chunked_set) const;
 
@@ -191,12 +190,6 @@ ProxyTransaction::get_proxy_ssn()
   return _proxy_ssn;
 }
 
-inline void
-ProxyTransaction::set_proxy_ssn(ProxySession *new_proxy_ssn)
-{
-  _proxy_ssn = new_proxy_ssn;
-}
-
 inline PoolableSession *
 ProxyTransaction::get_server_session() const
 {
diff --git a/proxy/http/Http1ClientSession.cc b/proxy/http/Http1ClientSession.cc
index 14291cb..8e269ca 100644
--- a/proxy/http/Http1ClientSession.cc
+++ b/proxy/http/Http1ClientSession.cc
@@ -57,7 +57,7 @@ ink_mutex debug_cs_list_mutex;
 
 ClassAllocator<Http1ClientSession> http1ClientSessionAllocator("http1ClientSessionAllocator");
 
-Http1ClientSession::Http1ClientSession() {}
+Http1ClientSession::Http1ClientSession() : super(), trans(this) {}
 
 void
 Http1ClientSession::destroy()
@@ -449,7 +449,6 @@ Http1ClientSession::new_transaction()
 
   read_state = HCS_ACTIVE_READER;
 
-  trans.set_proxy_ssn(this);
   transact_count++;
 
   trans.new_transaction(read_from_early_data > 0 ? true : false);
diff --git a/proxy/http/Http1Transaction.h b/proxy/http/Http1Transaction.h
index d9c423d..4769bd3 100644
--- a/proxy/http/Http1Transaction.h
+++ b/proxy/http/Http1Transaction.h
@@ -32,7 +32,7 @@ class Http1Transaction : public ProxyTransaction
 public:
   using super_type = ProxyTransaction;
 
-  Http1Transaction() {}
+  Http1Transaction(ProxySession *session) : super_type(session) {}
 
   ////////////////////
   // Methods
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 427a728..c0f99e9 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -1827,6 +1827,7 @@ HttpSM::state_http_server_open(int event, void *data)
     Http1ServerSession *session = (TS_SERVER_SESSION_SHARING_POOL_THREAD == httpSessionManager.get_pool_type()) ?
                                     THREAD_ALLOC_INIT(httpServerSessionAllocator, mutex->thread_holding) :
                                     httpServerSessionAllocator.alloc();
+    new (session) Http1ServerSession();
     session->sharing_pool  = static_cast<TSServerSessionSharingPoolType>(t_state.http_config_param->server_session_sharing_pool);
     session->sharing_match = static_cast<TSServerSessionSharingMatchMask>(t_state.txn_conf->server_session_sharing_match);
 
diff --git a/proxy/http/HttpSessionAccept.cc b/proxy/http/HttpSessionAccept.cc
index ea9d075..c7d3b1f 100644
--- a/proxy/http/HttpSessionAccept.cc
+++ b/proxy/http/HttpSessionAccept.cc
@@ -50,6 +50,7 @@ HttpSessionAccept::accept(NetVConnection *netvc, MIOBuffer *iobuf, IOBufferReade
   }
 
   Http1ClientSession *new_session = THREAD_ALLOC_INIT(http1ClientSessionAllocator, this_ethread());
+  new (new_session) Http1ClientSession();
 
   new_session->accept_options = static_cast<Options *>(this);
   new_session->acl            = std::move(acl);
diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc
index d235cd2..38a84d5 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -65,7 +65,7 @@ send_connection_event(Continuation *cont, int event, void *edata)
   return cont->handleEvent(event, edata);
 }
 
-Http2ClientSession::Http2ClientSession() = default;
+Http2ClientSession::Http2ClientSession() : super() {}
 
 void
 Http2ClientSession::destroy()
diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
index 1d68105..1ee9c2b 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -1221,7 +1221,7 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error)
   }
 
   Http2Stream *new_stream = THREAD_ALLOC_INIT(http2StreamAllocator, this_ethread());
-  new_stream->init(new_id, client_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE));
+  new (new_stream) Http2Stream(ua_session, new_id, client_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE));
 
   ink_assert(nullptr != new_stream);
   ink_assert(!stream_list.in(new_stream));
@@ -1243,7 +1243,6 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error)
     zombie_event = nullptr;
   }
 
-  new_stream->set_proxy_ssn(ua_session);
   new_stream->mutex                     = new_ProxyMutex();
   new_stream->is_first_transaction_flag = get_stream_requests() == 0;
   increment_stream_requests();
diff --git a/proxy/http2/Http2SessionAccept.cc b/proxy/http2/Http2SessionAccept.cc
index f0226fd..3e02dc3 100644
--- a/proxy/http2/Http2SessionAccept.cc
+++ b/proxy/http2/Http2SessionAccept.cc
@@ -54,8 +54,9 @@ Http2SessionAccept::accept(NetVConnection *netvc, MIOBuffer *iobuf, IOBufferRead
   }
 
   Http2ClientSession *new_session = THREAD_ALLOC_INIT(http2ClientSessionAllocator, this_ethread());
-  new_session->acl                = std::move(session_acl);
-  new_session->accept_options     = &options;
+  new (new_session) Http2ClientSession();
+  new_session->acl            = std::move(session_acl);
+  new_session->accept_options = &options;
 
   // Pin session to current ET_NET thread
   new_session->setThreadAffinity(this_ethread());
diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc
index c45a997..f1f362d 100644
--- a/proxy/http2/Http2Stream.cc
+++ b/proxy/http2/Http2Stream.cc
@@ -39,14 +39,11 @@
 
 ClassAllocator<Http2Stream> http2StreamAllocator("http2StreamAllocator");
 
-Http2Stream::Http2Stream(Http2StreamId sid, ssize_t initial_rwnd) : _id(sid), _client_rwnd(initial_rwnd)
+Http2Stream::Http2Stream(ProxySession *session, Http2StreamId sid, ssize_t initial_rwnd)
+  : super(session), _id(sid), _client_rwnd(initial_rwnd)
 {
   SET_HANDLER(&Http2Stream::main_event_handler);
-}
 
-void
-Http2Stream::init(Http2StreamId sid, ssize_t initial_rwnd)
-{
   this->mark_milestone(Http2StreamMilestone::OPEN);
 
   this->_sm          = nullptr;
diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h
index 544cd1e..44e6f0c 100644
--- a/proxy/http2/Http2Stream.h
+++ b/proxy/http2/Http2Stream.h
@@ -54,9 +54,8 @@ public:
   const int retry_delay = HRTIME_MSECONDS(10);
   using super           = ProxyTransaction; ///< Parent type.
 
-  Http2Stream(Http2StreamId sid = 0, ssize_t initial_rwnd = Http2::initial_window_size);
-
-  void init(Http2StreamId sid, ssize_t initial_rwnd);
+  Http2Stream() {} // Just to satisfy ClassAllocator
+  Http2Stream(ProxySession *session, Http2StreamId sid, ssize_t initial_rwnd);
 
   int main_event_handler(int event, void *edata);
 
diff --git a/proxy/http3/Http3Transaction.cc b/proxy/http3/Http3Transaction.cc
index 1be472c..5cd490b 100644
--- a/proxy/http3/Http3Transaction.cc
+++ b/proxy/http3/Http3Transaction.cc
@@ -57,13 +57,11 @@
 //
 // HQTransaction
 //
-HQTransaction::HQTransaction(HQSession *session, QUICStreamIO *stream_io) : super(), _stream_io(stream_io)
+HQTransaction::HQTransaction(HQSession *session, QUICStreamIO *stream_io) : super(session), _stream_io(stream_io)
 {
   this->mutex   = new_ProxyMutex();
   this->_thread = this_ethread();
 
-  this->set_proxy_ssn(session);
-
   this->_reader = this->_read_vio_buf.alloc_reader();
 
   HTTPType http_type = HTTP_TYPE_UNKNOWN;

[trafficserver] 03/03: Add default implementation for allow_half_open (#7630)

Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit d51a978fc9469ffdee0278d83c3ffe0115dec313
Author: Susan Hinrichs <sh...@verizonmedia.com>
AuthorDate: Mon Mar 29 08:14:11 2021 -0500

    Add default implementation for allow_half_open (#7630)
    
    (cherry picked from commit da29e26e5d01920b3f1435e845c36bf46d56276b)
---
 proxy/ProxyTransaction.cc       | 6 ++++++
 proxy/ProxyTransaction.h        | 2 +-
 proxy/http2/Http2Stream.h       | 7 -------
 proxy/http3/Http3Transaction.cc | 6 ------
 proxy/http3/Http3Transaction.h  | 1 -
 5 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc
index fff5fe7..50d6682 100644
--- a/proxy/ProxyTransaction.cc
+++ b/proxy/ProxyTransaction.cc
@@ -220,3 +220,9 @@ ProxyTransaction::has_request_body(int64_t request_content_length, bool is_chunk
 {
   return request_content_length > 0 || is_chunked;
 }
+
+bool
+ProxyTransaction::allow_half_open() const
+{
+  return false;
+}
diff --git a/proxy/ProxyTransaction.h b/proxy/ProxyTransaction.h
index 9767510..0ae77f5 100644
--- a/proxy/ProxyTransaction.h
+++ b/proxy/ProxyTransaction.h
@@ -62,7 +62,7 @@ public:
   virtual int get_transaction_id() const = 0;
   virtual int get_transaction_priority_weight() const;
   virtual int get_transaction_priority_dependence() const;
-  virtual bool allow_half_open() const              = 0;
+  virtual bool allow_half_open() const;
   virtual void increment_client_transactions_stat() = 0;
   virtual void decrement_client_transactions_stat() = 0;
 
diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h
index dfac308..0208e7f 100644
--- a/proxy/http2/Http2Stream.h
+++ b/proxy/http2/Http2Stream.h
@@ -100,7 +100,6 @@ public:
   bool is_active_timeout_expired(ink_hrtime now);
   bool is_inactive_timeout_expired(ink_hrtime now);
 
-  bool allow_half_open() const override;
   bool is_first_transaction() const override;
   void increment_client_transactions_stat() override;
   void decrement_client_transactions_stat() override;
@@ -295,12 +294,6 @@ Http2Stream::payload_length_is_valid() const
 }
 
 inline bool
-Http2Stream::allow_half_open() const
-{
-  return false;
-}
-
-inline bool
 Http2Stream::is_client_state_writeable() const
 {
   return _state == Http2StreamState::HTTP2_STREAM_STATE_OPEN || _state == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE ||
diff --git a/proxy/http3/Http3Transaction.cc b/proxy/http3/Http3Transaction.cc
index c2f9de3..04afaa4 100644
--- a/proxy/http3/Http3Transaction.cc
+++ b/proxy/http3/Http3Transaction.cc
@@ -110,12 +110,6 @@ HQTransaction::release(IOBufferReader *r)
   this->_sm = nullptr;
 }
 
-bool
-HQTransaction::allow_half_open() const
-{
-  return false;
-}
-
 VIO *
 HQTransaction::do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf)
 {
diff --git a/proxy/http3/Http3Transaction.h b/proxy/http3/Http3Transaction.h
index 00826ea..9e643d6 100644
--- a/proxy/http3/Http3Transaction.h
+++ b/proxy/http3/Http3Transaction.h
@@ -49,7 +49,6 @@ public:
   void set_inactivity_timeout(ink_hrtime timeout_in) override;
   void cancel_inactivity_timeout() override;
   void transaction_done() override;
-  bool allow_half_open() const override;
   void release(IOBufferReader *r) override;
   int get_transaction_id() const override;
   void increment_client_transactions_stat() override;

[trafficserver] 02/03: Tidy up session/transaction destruction process (#7571)

Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit a9870d9cf536ff952c3628dad722a356ec160b72
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Tue Mar 9 09:34:15 2021 +0900

    Tidy up session/transaction destruction process (#7571)
    
    (cherry picked from commit fa603fd8c7878fe452218e45482fb4b5a0a726f5)
---
 proxy/ProxySession.cc             |  25 +++---
 proxy/ProxySession.h              |   3 +-
 proxy/ProxyTransaction.cc         |  13 ++--
 proxy/ProxyTransaction.h          |   2 +-
 proxy/http/Http1ClientSession.cc  |  12 ++-
 proxy/http/Http1ClientSession.h   |   1 +
 proxy/http/Http1ServerSession.cc  |   7 ++
 proxy/http/Http1ServerSession.h   |   2 +
 proxy/http/Http1Transaction.cc    |   2 +-
 proxy/http/Http1Transaction.h     |   3 +-
 proxy/http2/Http2ClientSession.cc |   3 +-
 proxy/http2/Http2Stream.cc        | 160 +++++++++++++++++++-------------------
 proxy/http2/Http2Stream.h         |   2 +-
 proxy/http3/Http3Session.cc       |   6 ++
 proxy/http3/Http3Session.h        |   1 +
 proxy/http3/Http3Transaction.cc   |   6 --
 proxy/http3/Http3Transaction.h    |   1 -
 17 files changed, 127 insertions(+), 122 deletions(-)

diff --git a/proxy/ProxySession.cc b/proxy/ProxySession.cc
index a866507..13d1399 100644
--- a/proxy/ProxySession.cc
+++ b/proxy/ProxySession.cc
@@ -30,6 +30,18 @@ ProxySession::ProxySession() : VConnection(nullptr) {}
 
 ProxySession::ProxySession(NetVConnection *vc) : VConnection(nullptr), _vc(vc) {}
 
+ProxySession::~ProxySession()
+{
+  if (schedule_event) {
+    schedule_event->cancel();
+    schedule_event = nullptr;
+  }
+  this->api_hooks.clear();
+  this->mutex.clear();
+  this->acl.clear();
+  this->_ssl.reset();
+}
+
 void
 ProxySession::set_session_active()
 {
@@ -69,19 +81,6 @@ static const TSEvent eventmap[TS_HTTP_LAST_HOOK + 1] = {
   TS_EVENT_NONE,                       // TS_HTTP_LAST_HOOK
 };
 
-void
-ProxySession::free()
-{
-  if (schedule_event) {
-    schedule_event->cancel();
-    schedule_event = nullptr;
-  }
-  this->api_hooks.clear();
-  this->mutex.clear();
-  this->acl.clear();
-  this->_ssl.reset();
-}
-
 int
 ProxySession::state_api_callout(int event, void *data)
 {
diff --git a/proxy/ProxySession.h b/proxy/ProxySession.h
index d31888f..350236c 100644
--- a/proxy/ProxySession.h
+++ b/proxy/ProxySession.h
@@ -79,6 +79,7 @@ class ProxySession : public VConnection, public PluginUserArgs<TS_USER_ARGS_SSN>
 public:
   ProxySession();
   ProxySession(NetVConnection *vc);
+  virtual ~ProxySession();
 
   // noncopyable
   ProxySession(ProxySession &) = delete;
@@ -94,7 +95,7 @@ public:
   virtual void release(ProxyTransaction *trans) = 0;
 
   virtual void destroy() = 0;
-  virtual void free();
+  virtual void free()    = 0;
 
   virtual void increment_current_active_connections_stat() = 0;
   virtual void decrement_current_active_connections_stat() = 0;
diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc
index eedfa31..fff5fe7 100644
--- a/proxy/ProxyTransaction.cc
+++ b/proxy/ProxyTransaction.cc
@@ -28,6 +28,12 @@
 
 ProxyTransaction::ProxyTransaction(ProxySession *session) : VConnection(nullptr), _proxy_ssn(session) {}
 
+ProxyTransaction::~ProxyTransaction()
+{
+  this->_sm = nullptr;
+  this->mutex.clear();
+}
+
 void
 ProxyTransaction::new_transaction(bool from_early_data)
 {
@@ -62,13 +68,6 @@ ProxyTransaction::attach_server_session(PoolableSession *ssession, bool transact
 }
 
 void
-ProxyTransaction::destroy()
-{
-  _sm = nullptr;
-  this->mutex.clear();
-}
-
-void
 ProxyTransaction::set_rx_error_code(ProxyError e)
 {
   if (this->_sm) {
diff --git a/proxy/ProxyTransaction.h b/proxy/ProxyTransaction.h
index 420a0a8..9767510 100644
--- a/proxy/ProxyTransaction.h
+++ b/proxy/ProxyTransaction.h
@@ -34,6 +34,7 @@ class ProxyTransaction : public VConnection
 public:
   ProxyTransaction() : VConnection(nullptr) {}
   ProxyTransaction(ProxySession *ssn);
+  virtual ~ProxyTransaction();
 
   /// Virtual Methods
   //
@@ -42,7 +43,6 @@ public:
   Action *adjust_thread(Continuation *cont, int event, void *data);
   virtual void release(IOBufferReader *r) = 0;
   virtual void transaction_done();
-  virtual void destroy();
 
   virtual void set_active_timeout(ink_hrtime timeout_in);
   virtual void set_inactivity_timeout(ink_hrtime timeout_in);
diff --git a/proxy/http/Http1ClientSession.cc b/proxy/http/Http1ClientSession.cc
index 8e269ca..3d24918 100644
--- a/proxy/http/Http1ClientSession.cc
+++ b/proxy/http/Http1ClientSession.cc
@@ -113,15 +113,12 @@ Http1ClientSession::free()
     conn_decrease = false;
   }
 
-  // Free the transaction resources
-  this->trans.super_type::destroy();
-
   if (_vc) {
     _vc->do_io_close();
     _vc = nullptr;
   }
 
-  super::free();
+  this->~Http1ClientSession();
   THREAD_FREE(this, http1ClientSessionAllocator, this_thread());
 }
 
@@ -392,7 +389,8 @@ Http1ClientSession::release(ProxyTransaction *trans)
 
   // When release is called from start() to read the first transaction, get_sm()
   // will return null.
-  HttpSM *sm = trans->get_sm();
+  HttpSM *sm                = trans->get_sm();
+  Http1Transaction *h1trans = static_cast<Http1Transaction *>(trans);
   if (sm) {
     MgmtInt ka_in = trans->get_sm()->t_state.txn_conf->keep_alive_no_activity_timeout_in;
     set_inactivity_timeout(HRTIME_SECONDS(ka_in));
@@ -410,7 +408,7 @@ Http1ClientSession::release(ProxyTransaction *trans)
   //  IO to wait for new data
   bool more_to_read = this->_reader->is_read_avail_more_than(0);
   if (more_to_read) {
-    trans->destroy();
+    h1trans->reset();
     HttpSsnDebug("[%" PRId64 "] data already in buffer, starting new transaction", con_id);
     new_transaction();
   } else {
@@ -424,7 +422,7 @@ Http1ClientSession::release(ProxyTransaction *trans)
       _vc->cancel_active_timeout();
       _vc->add_to_keep_alive_queue();
     }
-    trans->destroy();
+    h1trans->reset();
   }
 }
 
diff --git a/proxy/http/Http1ClientSession.h b/proxy/http/Http1ClientSession.h
index 0c6e2f5..1509806 100644
--- a/proxy/http/Http1ClientSession.h
+++ b/proxy/http/Http1ClientSession.h
@@ -54,6 +54,7 @@ class Http1ClientSession : public ProxySession
 public:
   typedef ProxySession super; ///< Parent type.
   Http1ClientSession();
+  ~Http1ClientSession() = default;
 
   // Implement ProxySession interface.
   void new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) override;
diff --git a/proxy/http/Http1ServerSession.cc b/proxy/http/Http1ServerSession.cc
index b1b94fb..d800b03 100644
--- a/proxy/http/Http1ServerSession.cc
+++ b/proxy/http/Http1ServerSession.cc
@@ -50,6 +50,7 @@ Http1ServerSession::destroy()
   }
 
   mutex.clear();
+  this->~Http1ServerSession();
   if (httpSessionManager.get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_THREAD) {
     THREAD_FREE(this, httpServerSessionAllocator, this_thread());
   } else {
@@ -58,6 +59,12 @@ Http1ServerSession::destroy()
 }
 
 void
+Http1ServerSession::free()
+{
+  // Unlike Http1ClientSession, Http1ServerSession is freed in destroy()
+}
+
+void
 Http1ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader)
 {
   ink_assert(new_vc != nullptr);
diff --git a/proxy/http/Http1ServerSession.h b/proxy/http/Http1ServerSession.h
index 9594006..95e7ebc 100644
--- a/proxy/http/Http1ServerSession.h
+++ b/proxy/http/Http1ServerSession.h
@@ -56,11 +56,13 @@ public:
   Http1ServerSession() : super_type() {}
   Http1ServerSession(self_type const &) = delete;
   self_type &operator=(self_type const &) = delete;
+  ~Http1ServerSession()                   = default;
 
   ////////////////////
   // Methods
   void release(ProxyTransaction *) override;
   void destroy() override;
+  void free() override;
 
   // VConnection Methods
   void do_io_close(int lerrno = -1) override;
diff --git a/proxy/http/Http1Transaction.cc b/proxy/http/Http1Transaction.cc
index 6a37e7c..55e4d13 100644
--- a/proxy/http/Http1Transaction.cc
+++ b/proxy/http/Http1Transaction.cc
@@ -31,7 +31,7 @@ Http1Transaction::release(IOBufferReader *r)
 }
 
 void
-Http1Transaction::destroy() // todo make ~Http1Transaction()
+Http1Transaction::reset()
 {
   _sm = nullptr;
 }
diff --git a/proxy/http/Http1Transaction.h b/proxy/http/Http1Transaction.h
index 4769bd3..bd5b6b7 100644
--- a/proxy/http/Http1Transaction.h
+++ b/proxy/http/Http1Transaction.h
@@ -33,11 +33,11 @@ public:
   using super_type = ProxyTransaction;
 
   Http1Transaction(ProxySession *session) : super_type(session) {}
+  ~Http1Transaction() = default;
 
   ////////////////////
   // Methods
   void release(IOBufferReader *r) override;
-  void destroy() override; // todo make ~Http1Transaction()
 
   bool allow_half_open() const override;
   void transaction_done() override;
@@ -45,6 +45,7 @@ public:
   void increment_client_transactions_stat() override;
   void decrement_client_transactions_stat() override;
 
+  void reset();
   void set_reader(IOBufferReader *reader);
 
   ////////////////////
diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc
index 38a84d5..434b4a3 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -159,10 +159,9 @@ Http2ClientSession::free()
   delete _h2_pushed_urls;
   this->connection_state.destroy();
 
-  super::free();
-
   free_MIOBuffer(this->read_buffer);
   free_MIOBuffer(this->write_buffer);
+  this->~Http2ClientSession();
   THREAD_FREE(this, http2ClientSessionAllocator, this_ethread());
 }
 
diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc
index f1f362d..25a4d64 100644
--- a/proxy/http2/Http2Stream.cc
+++ b/proxy/http2/Http2Stream.cc
@@ -62,6 +62,81 @@ Http2Stream::Http2Stream(ProxySession *session, Http2StreamId sid, ssize_t initi
   http_parser_init(&http_parser);
 }
 
+Http2Stream::~Http2Stream()
+{
+  REMEMBER(NO_EVENT, this->reentrancy_count);
+  Http2StreamDebug("Destroy stream, sent %" PRIu64 " bytes", this->bytes_sent);
+  SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+  // Clean up after yourself if this was an EOS
+  ink_release_assert(this->closed);
+  ink_release_assert(reentrancy_count == 0);
+
+  uint64_t cid = 0;
+
+  // Safe to initiate SSN_CLOSE if this is the last stream
+  if (_proxy_ssn) {
+    cid = _proxy_ssn->connection_id();
+
+    Http2ClientSession *h2_proxy_ssn = static_cast<Http2ClientSession *>(_proxy_ssn);
+    SCOPED_MUTEX_LOCK(lock, h2_proxy_ssn->connection_state.mutex, this_ethread());
+    // Make sure the stream is removed from the stream list and priority tree
+    // In many cases, this has been called earlier, so this call is a no-op
+    h2_proxy_ssn->connection_state.delete_stream(this);
+
+    h2_proxy_ssn->connection_state.decrement_stream_count();
+
+    // Update session's stream counts, so it accurately goes into keep-alive state
+    h2_proxy_ssn->connection_state.release_stream();
+
+    // Do not access `_proxy_ssn` in below. It might be freed by `release_stream`.
+  }
+
+  // Clean up the write VIO in case of inactivity timeout
+  this->do_io_write(nullptr, 0, nullptr);
+
+  this->_milestones.mark(Http2StreamMilestone::CLOSE);
+
+  ink_hrtime total_time = this->_milestones.elapsed(Http2StreamMilestone::OPEN, Http2StreamMilestone::CLOSE);
+  HTTP2_SUM_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_TRANSACTIONS_TIME, this->_thread, total_time);
+
+  // Slow Log
+  if (Http2::stream_slow_log_threshold != 0 && ink_hrtime_from_msec(Http2::stream_slow_log_threshold) < total_time) {
+    Error("[%" PRIu64 "] [%" PRIu32 "] [%" PRId64 "] Slow H2 Stream: "
+          "open: %" PRIu64 " "
+          "dec_hdrs: %.3f "
+          "txn: %.3f "
+          "enc_hdrs: %.3f "
+          "tx_hdrs: %.3f "
+          "tx_data: %.3f "
+          "close: %.3f",
+          cid, static_cast<uint32_t>(this->_id), this->_http_sm_id,
+          ink_hrtime_to_msec(this->_milestones[Http2StreamMilestone::OPEN]),
+          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_DECODE_HEADERS),
+          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_TXN),
+          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_ENCODE_HEADERS),
+          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_TX_HEADERS_FRAMES),
+          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_TX_DATA_FRAMES),
+          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::CLOSE));
+  }
+
+  _req_header.destroy();
+  response_header.destroy();
+
+  // Drop references to all buffer data
+  this->_request_buffer.clear();
+
+  // Free the mutexes in the VIO
+  read_vio.mutex.clear();
+  write_vio.mutex.clear();
+
+  if (header_blocks) {
+    ats_free(header_blocks);
+  }
+  _clear_timers();
+  clear_io_events();
+  http_parser_clear(&http_parser);
+}
+
 int
 Http2Stream::main_event_handler(int event, void *edata)
 {
@@ -407,7 +482,8 @@ Http2Stream::terminate_if_possible()
 
     Http2ClientSession *h2_proxy_ssn = static_cast<Http2ClientSession *>(this->_proxy_ssn);
     SCOPED_MUTEX_LOCK(lock, h2_proxy_ssn->connection_state.mutex, this_ethread());
-    destroy();
+    this->~Http2Stream();
+    THREAD_FREE(this, http2StreamAllocator, this_ethread());
   }
 }
 
@@ -465,7 +541,8 @@ Http2Stream::initiating_close()
     } else if (!sent_write_complete) {
       // Transaction is already gone or not started. Kill yourself
       do_io_close();
-      destroy();
+      terminate_stream = true;
+      terminate_if_possible();
     }
   }
 }
@@ -744,85 +821,6 @@ Http2Stream::reenable(VIO *vio)
   }
 }
 
-void
-Http2Stream::destroy()
-{
-  REMEMBER(NO_EVENT, this->reentrancy_count);
-  Http2StreamDebug("Destroy stream, sent %" PRIu64 " bytes", this->bytes_sent);
-  SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
-  // Clean up after yourself if this was an EOS
-  ink_release_assert(this->closed);
-  ink_release_assert(reentrancy_count == 0);
-
-  uint64_t cid = 0;
-
-  // Safe to initiate SSN_CLOSE if this is the last stream
-  if (_proxy_ssn) {
-    cid = _proxy_ssn->connection_id();
-
-    Http2ClientSession *h2_proxy_ssn = static_cast<Http2ClientSession *>(_proxy_ssn);
-    SCOPED_MUTEX_LOCK(lock, h2_proxy_ssn->connection_state.mutex, this_ethread());
-    // Make sure the stream is removed from the stream list and priority tree
-    // In many cases, this has been called earlier, so this call is a no-op
-    h2_proxy_ssn->connection_state.delete_stream(this);
-
-    h2_proxy_ssn->connection_state.decrement_stream_count();
-
-    // Update session's stream counts, so it accurately goes into keep-alive state
-    h2_proxy_ssn->connection_state.release_stream();
-
-    // Do not access `_proxy_ssn` in below. It might be freed by `release_stream`.
-  }
-
-  // Clean up the write VIO in case of inactivity timeout
-  this->do_io_write(nullptr, 0, nullptr);
-
-  this->_milestones.mark(Http2StreamMilestone::CLOSE);
-
-  ink_hrtime total_time = this->_milestones.elapsed(Http2StreamMilestone::OPEN, Http2StreamMilestone::CLOSE);
-  HTTP2_SUM_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_TRANSACTIONS_TIME, this->_thread, total_time);
-
-  // Slow Log
-  if (Http2::stream_slow_log_threshold != 0 && ink_hrtime_from_msec(Http2::stream_slow_log_threshold) < total_time) {
-    Error("[%" PRIu64 "] [%" PRIu32 "] [%" PRId64 "] Slow H2 Stream: "
-          "open: %" PRIu64 " "
-          "dec_hdrs: %.3f "
-          "txn: %.3f "
-          "enc_hdrs: %.3f "
-          "tx_hdrs: %.3f "
-          "tx_data: %.3f "
-          "close: %.3f",
-          cid, static_cast<uint32_t>(this->_id), this->_http_sm_id,
-          ink_hrtime_to_msec(this->_milestones[Http2StreamMilestone::OPEN]),
-          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_DECODE_HEADERS),
-          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_TXN),
-          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_ENCODE_HEADERS),
-          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_TX_HEADERS_FRAMES),
-          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::START_TX_DATA_FRAMES),
-          this->_milestones.difference_sec(Http2StreamMilestone::OPEN, Http2StreamMilestone::CLOSE));
-  }
-
-  _req_header.destroy();
-  response_header.destroy();
-
-  // Drop references to all buffer data
-  this->_request_buffer.clear();
-
-  // Free the mutexes in the VIO
-  read_vio.mutex.clear();
-  write_vio.mutex.clear();
-
-  if (header_blocks) {
-    ats_free(header_blocks);
-  }
-  _clear_timers();
-  clear_io_events();
-  http_parser_clear(&http_parser);
-
-  super::destroy();
-  THREAD_FREE(this, http2StreamAllocator, this_ethread());
-}
-
 IOBufferReader *
 Http2Stream::response_get_data_reader() const
 {
diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h
index 44e6f0c..dfac308 100644
--- a/proxy/http2/Http2Stream.h
+++ b/proxy/http2/Http2Stream.h
@@ -56,10 +56,10 @@ public:
 
   Http2Stream() {} // Just to satisfy ClassAllocator
   Http2Stream(ProxySession *session, Http2StreamId sid, ssize_t initial_rwnd);
+  ~Http2Stream();
 
   int main_event_handler(int event, void *edata);
 
-  void destroy() override;
   void release(IOBufferReader *r) override;
   void reenable(VIO *vio) override;
   void transaction_done() override;
diff --git a/proxy/http3/Http3Session.cc b/proxy/http3/Http3Session.cc
index 8e1168b..997e079 100644
--- a/proxy/http3/Http3Session.cc
+++ b/proxy/http3/Http3Session.cc
@@ -140,6 +140,12 @@ HQSession::destroy()
 }
 
 void
+HQSession::free()
+{
+  delete this;
+}
+
+void
 HQSession::release(ProxyTransaction *trans)
 {
   return;
diff --git a/proxy/http3/Http3Session.h b/proxy/http3/Http3Session.h
index 0d912ce..1663d1d 100644
--- a/proxy/http3/Http3Session.h
+++ b/proxy/http3/Http3Session.h
@@ -48,6 +48,7 @@ public:
   void new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) override;
   void start() override;
   void destroy() override;
+  void free() override;
   void release(ProxyTransaction *trans) override;
   int get_transact_count() const override;
 
diff --git a/proxy/http3/Http3Transaction.cc b/proxy/http3/Http3Transaction.cc
index 5cd490b..c2f9de3 100644
--- a/proxy/http3/Http3Transaction.cc
+++ b/proxy/http3/Http3Transaction.cc
@@ -216,12 +216,6 @@ HQTransaction::reenable(VIO *vio)
 }
 
 void
-HQTransaction::destroy()
-{
-  _sm = nullptr;
-}
-
-void
 HQTransaction::transaction_done()
 {
   // TODO: start closing transaction
diff --git a/proxy/http3/Http3Transaction.h b/proxy/http3/Http3Transaction.h
index 033a052..00826ea 100644
--- a/proxy/http3/Http3Transaction.h
+++ b/proxy/http3/Http3Transaction.h
@@ -50,7 +50,6 @@ public:
   void cancel_inactivity_timeout() override;
   void transaction_done() override;
   bool allow_half_open() const override;
-  void destroy() override;
   void release(IOBufferReader *r) override;
   int get_transaction_id() const override;
   void increment_client_transactions_stat() override;