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

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

commit d4556704e9bb5eff757c68c72bba3424595ec362
Author: Masaori Koshiba <[email protected]>
AuthorDate: Wed Apr 16 08:34:21 2025 +0900

    Cleanup HttpCacheSM & HttpCacheAction (#12189)
    
    (cherry picked from commit 561771b1bad4221631c655d9b443df849b1aeccf)
---
 include/proxy/http/HttpCacheSM.h                   | 40 +++++++++++++---------
 src/proxy/http/HttpCacheSM.cc                      | 36 ++++++-------------
 .../http/remap/unit-tests/nexthop_test_stubs.cc    |  3 +-
 3 files changed, 36 insertions(+), 43 deletions(-)

diff --git a/include/proxy/http/HttpCacheSM.h b/include/proxy/http/HttpCacheSM.h
index a693048aba..381977a987 100644
--- a/include/proxy/http/HttpCacheSM.h
+++ b/include/proxy/http/HttpCacheSM.h
@@ -41,27 +41,31 @@
 class HttpSM;
 class HttpCacheSM;
 
-struct HttpCacheAction : public Action {
-  HttpCacheAction();
+class HttpCacheAction : public Action
+{
+public:
   void cancel(Continuation *c = nullptr) override;
+
   void
-  init(HttpCacheSM *sm_arg)
+  init(HttpCacheSM *cache_sm)
   {
-    sm = sm_arg;
+    _cache_sm = cache_sm;
   };
+
   void
   reset()
   {
     cancelled = false;
   }
 
-  HttpCacheSM *sm = nullptr;
+private:
+  HttpCacheSM *_cache_sm = nullptr;
 };
 
 class HttpCacheSM : public Continuation
 {
 public:
-  HttpCacheSM();
+  HttpCacheSM() : Continuation(nullptr), captive_action() {}
 
   void
   init(HttpSM *sm_arg, Ptr<ProxyMutex> &amutex)
@@ -88,14 +92,14 @@ public:
   Action *pending_action = nullptr;
 
   // Function to set readwhilewrite_inprogress flag
-  inline void
+  void
   set_readwhilewrite_inprogress(bool value)
   {
     readwhilewrite_inprogress = value;
   }
 
   // Function to get the readwhilewrite_inprogress flag
-  inline bool
+  bool
   is_readwhilewrite_inprogress()
   {
     return readwhilewrite_inprogress;
@@ -113,7 +117,7 @@ public:
     return cache_read_vc ? (cache_read_vc->is_compressed_in_ram()) : false;
   }
 
-  inline void
+  void
   set_open_read_tries(int value)
   {
     open_read_tries = value;
@@ -125,7 +129,7 @@ public:
     return open_read_tries;
   }
 
-  inline void
+  void
   set_open_write_tries(int value)
   {
     open_write_tries = value;
@@ -161,7 +165,7 @@ public:
     return nullptr;
   }
 
-  inline void
+  void
   abort_read()
   {
     if (cache_read_vc) {
@@ -170,7 +174,8 @@ public:
       cache_read_vc = nullptr;
     }
   }
-  inline void
+
+  void
   abort_write()
   {
     if (cache_write_vc) {
@@ -179,7 +184,8 @@ public:
       cache_write_vc = nullptr;
     }
   }
-  inline void
+
+  void
   close_write()
   {
     if (cache_write_vc) {
@@ -188,7 +194,8 @@ public:
       cache_write_vc = nullptr;
     }
   }
-  inline void
+
+  void
   close_read()
   {
     if (cache_read_vc) {
@@ -197,7 +204,8 @@ public:
       cache_read_vc = nullptr;
     }
   }
-  inline void
+
+  void
   end_both()
   {
     // We close the read so that cache
@@ -206,7 +214,7 @@ public:
     abort_write();
   }
 
-  inline int
+  int
   get_last_error() const
   {
     return err_code;
diff --git a/src/proxy/http/HttpCacheSM.cc b/src/proxy/http/HttpCacheSM.cc
index aebab7e2ca..bcf1041fce 100644
--- a/src/proxy/http/HttpCacheSM.cc
+++ b/src/proxy/http/HttpCacheSM.cc
@@ -21,15 +21,6 @@
   limitations under the License.
  */
 
-/****************************************************************************
-
-   HttpCacheSM.cc
-
-   Description:
-
-
- ****************************************************************************/
-
 #include "proxy/http/HttpCacheSM.h"
 #include "proxy/http/HttpSM.h"
 #include "proxy/http/HttpDebugNames.h"
@@ -50,31 +41,26 @@
 namespace
 {
 DbgCtl dbg_ctl_http_cache{"http_cache"};
-
 } // end anonymous namespace
 
-HttpCacheAction::HttpCacheAction() {}
-
+////
+// HttpCacheAction
+//
 void
 HttpCacheAction::cancel(Continuation *c)
 {
-  ink_assert(c == nullptr || c == sm->master_sm);
-  ink_assert(this->cancelled == 0);
+  ink_assert(c == nullptr || c == _cache_sm->master_sm);
+  ink_assert(this->cancelled == false);
 
-  this->cancelled = 1;
-  if (sm->pending_action) {
-    sm->pending_action->cancel();
+  this->cancelled = true;
+  if (_cache_sm->pending_action) {
+    _cache_sm->pending_action->cancel();
   }
 }
 
-HttpCacheSM::HttpCacheSM()
-  : Continuation(nullptr),
-
-    captive_action()
-
-{
-}
-
+////
+// HttpCacheSM
+//
 /**
   Reset captive_action and counters for another cache operations.
   - e.g. following redirect starts over from cache lookup
diff --git a/src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc 
b/src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc
index 3f3360ccf7..ad58597c1b 100644
--- a/src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc
+++ b/src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc
@@ -54,7 +54,7 @@ HttpVCTable::HttpVCTable(HttpSM *smp)
 {
   sm = smp;
 }
-HttpCacheAction::HttpCacheAction() {}
+
 void
 HttpCacheAction::cancel(Continuation * /* c ATS_UNUSED */)
 {
@@ -62,7 +62,6 @@ HttpCacheAction::cancel(Continuation * /* c ATS_UNUSED */)
 PostDataBuffers::~PostDataBuffers() {}
 
 HttpTunnel::HttpTunnel() {}
-HttpCacheSM::HttpCacheSM() {}
 HttpTunnelConsumer::HttpTunnelConsumer() {}
 HttpTunnelProducer::HttpTunnelProducer() {}
 ChunkedHandler::ChunkedHandler() {}

Reply via email to