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/07/21 19:18:18 UTC

[trafficserver] branch master updated: Changes HttpSM to be Proxy Allocated (#8082)

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

zwoop 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 4682e8d  Changes HttpSM to be Proxy Allocated (#8082)
4682e8d is described below

commit 4682e8df30c4e41ec9b604a067bb17356e9eddcf
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Wed Jul 21 13:18:08 2021 -0600

    Changes HttpSM to be Proxy Allocated (#8082)
---
 iocore/eventsystem/I_Thread.h    | 1 +
 proxy/ProxyTransaction.cc        | 4 +++-
 proxy/http/HttpSM.cc             | 2 +-
 proxy/http/HttpSM.h              | 7 -------
 src/traffic_server/InkAPITest.cc | 6 ++++--
 5 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/iocore/eventsystem/I_Thread.h b/iocore/eventsystem/I_Thread.h
index 3c7905b..f0f5d38 100644
--- a/iocore/eventsystem/I_Thread.h
+++ b/iocore/eventsystem/I_Thread.h
@@ -122,6 +122,7 @@ public:
   ProxyAllocator http1ClientSessionAllocator;
   ProxyAllocator http2ClientSessionAllocator;
   ProxyAllocator http2StreamAllocator;
+  ProxyAllocator httpSMAllocator;
   ProxyAllocator quicClientSessionAllocator;
   ProxyAllocator httpServerSessionAllocator;
   ProxyAllocator hdrHeapAllocator;
diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc
index bb63ebc..3f1ace9 100644
--- a/proxy/ProxyTransaction.cc
+++ b/proxy/ProxyTransaction.cc
@@ -26,6 +26,8 @@
 
 #define HttpTxnDebug(fmt, ...) SsnDebug(this, "http_txn", fmt, __VA_ARGS__)
 
+extern ClassAllocator<HttpSM> httpSMAllocator;
+
 ProxyTransaction::ProxyTransaction(ProxySession *session) : VConnection(nullptr), _proxy_ssn(session) {}
 
 ProxyTransaction::~ProxyTransaction()
@@ -43,7 +45,7 @@ ProxyTransaction::new_transaction(bool from_early_data)
   // connection re-use
 
   ink_release_assert(_proxy_ssn != nullptr);
-  _sm = HttpSM::allocate();
+  _sm = THREAD_ALLOC(httpSMAllocator, this_thread());
   _sm->init(from_early_data);
   HttpTxnDebug("[%" PRId64 "] Starting transaction %d using sm [%" PRId64 "]", _proxy_ssn->connection_id(),
                _proxy_ssn->get_transact_count(), _sm->sm_id);
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index f45a902..1634c1e 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -375,7 +375,7 @@ void
 HttpSM::destroy()
 {
   cleanup();
-  httpSMAllocator.free(this);
+  THREAD_FREE(this, httpSMAllocator, this_thread());
 }
 
 void
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index bac1c8a..ad97d72 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -703,13 +703,6 @@ HttpSM::get_cache_sm()
   return cache_sm;
 }
 
-inline HttpSM *
-HttpSM::allocate()
-{
-  extern ClassAllocator<HttpSM> httpSMAllocator;
-  return httpSMAllocator.alloc();
-}
-
 inline int
 HttpSM::write_response_header_into_buffer(HTTPHdr *h, MIOBuffer *b)
 {
diff --git a/src/traffic_server/InkAPITest.cc b/src/traffic_server/InkAPITest.cc
index af0374e..4f9b10c 100644
--- a/src/traffic_server/InkAPITest.cc
+++ b/src/traffic_server/InkAPITest.cc
@@ -8696,11 +8696,13 @@ std::array<std::string_view, TS_CONFIG_LAST_ENTRY> SDK_Overridable_Configs = {
    "proxy.config.hostdb.ip_resolve",
    "proxy.config.http.connect.dead.policy"}};
 
+extern ClassAllocator<HttpSM> httpSMAllocator;
+
 REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus)
 {
   TSOverridableConfigKey key;
   TSRecordDataType type;
-  HttpSM *s      = HttpSM::allocate();
+  HttpSM *s      = THREAD_ALLOC(httpSMAllocator, this_thread());
   bool success   = true;
   TSHttpTxn txnp = reinterpret_cast<TSHttpTxn>(s);
   InkRand generator(17);
@@ -8804,7 +8806,7 @@ REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /* atype
 
 REGRESSION_TEST(SDK_API_TXN_HTTP_INFO_GET)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus)
 {
-  HttpSM *s      = HttpSM::allocate();
+  HttpSM *s      = THREAD_ALLOC(httpSMAllocator, this_thread());
   bool success   = true;
   TSHttpTxn txnp = reinterpret_cast<TSHttpTxn>(s);
   TSMgmtInt ival_read;