diff --git a/include/proxy/http/HttpCacheSM.h b/include/proxy/http/HttpCacheSM.h index 08ee888eb8a..a693048aba6 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 @@ class HttpCacheSM : public Continuation 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 f2ff756f6f5..b8b8ffc867a 100644 --- a/src/proxy/http/HttpCacheSM.cc +++ b/src/proxy/http/HttpCacheSM.cc @@ -73,6 +73,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 a54cc7cccc7..56b5f1cac7c 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