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 98cc9f1cc411899ac553816c023d77c57e61c008
Author: Masaori Koshiba <[email protected]>
AuthorDate: Tue Apr 15 07:16:38 2025 +0900

    Reset HttpCacheSM on following redirect (#12182)
    
    (cherry picked from commit 7eb355f2717259b7d522ac44e624dc01ad92e7d6)
---
 include/proxy/http/HttpCacheSM.h |  7 +++++++
 src/proxy/http/HttpCacheSM.cc    | 19 +++++++++++++++++++
 src/proxy/http/HttpSM.cc         |  3 +++
 3 files changed, 29 insertions(+)

diff --git a/include/proxy/http/HttpCacheSM.h b/include/proxy/http/HttpCacheSM.h
index 08ee888eb8..a693048aba 100644
--- a/include/proxy/http/HttpCacheSM.h
+++ b/include/proxy/http/HttpCacheSM.h
@@ -49,6 +49,12 @@ struct HttpCacheAction : public Action {
   {
     sm = sm_arg;
   };
+  void
+  reset()
+  {
+    cancelled = false;
+  }
+
   HttpCacheSM *sm = nullptr;
 };
 
@@ -64,6 +70,7 @@ public:
     mutex     = amutex;
     captive_action.init(this);
   }
+  void reset();
 
   Action *open_read(const HttpCacheKey *key, URL *url, HTTPHdr *hdr, const 
OverridableHttpConfigParams *params,
                     time_t pin_in_cache);
diff --git a/src/proxy/http/HttpCacheSM.cc b/src/proxy/http/HttpCacheSM.cc
index d436bdfc84..aebab7e2ca 100644
--- a/src/proxy/http/HttpCacheSM.cc
+++ b/src/proxy/http/HttpCacheSM.cc
@@ -75,6 +75,25 @@ HttpCacheSM::HttpCacheSM()
 {
 }
 
+/**
+  Reset captive_action and counters for another cache operations.
+  - e.g. following redirect starts over from cache lookup
+ */
+void
+HttpCacheSM::reset()
+{
+  captive_action.reset();
+
+  open_read_tries  = 0;
+  open_write_tries = 0;
+  open_write_start = 0;
+
+  lookup_max_recursive = 0;
+  current_lookup_level = 0;
+
+  err_code = 0;
+}
+
 //////////////////////////////////////////////////////////////////////////
 //
 //  HttpCacheSM::state_cache_open_read()
diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc
index a54cc7cccc..56b5f1cac7 100644
--- a/src/proxy/http/HttpSM.cc
+++ b/src/proxy/http/HttpSM.cc
@@ -8540,6 +8540,9 @@ HttpSM::redirect_request(const char *arg_redirect_url, 
const int arg_redirect_le
   }
 
   dump_header(dbg_ctl_http_hdrs, &t_state.hdr_info.client_request, sm_id, 
"Framed Client Request..checking");
+
+  // Reset HttpCacheSM for new cache operations
+  cache_sm.reset();
 }
 
 void

Reply via email to