Skip to content

Commit 7eb355f

Browse files
authored
Reset HttpCacheSM on following redirect (#12182)
1 parent 4558d1d commit 7eb355f

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

include/proxy/http/HttpCacheSM.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ struct HttpCacheAction : public Action {
4949
{
5050
sm = sm_arg;
5151
};
52+
void
53+
reset()
54+
{
55+
cancelled = false;
56+
}
57+
5258
HttpCacheSM *sm = nullptr;
5359
};
5460

@@ -64,6 +70,7 @@ class HttpCacheSM : public Continuation
6470
mutex = amutex;
6571
captive_action.init(this);
6672
}
73+
void reset();
6774

6875
Action *open_read(const HttpCacheKey *key, URL *url, HTTPHdr *hdr, const OverridableHttpConfigParams *params,
6976
time_t pin_in_cache);

src/proxy/http/HttpCacheSM.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ HttpCacheSM::HttpCacheSM()
7373
{
7474
}
7575

76+
/**
77+
Reset captive_action and counters for another cache operations.
78+
- e.g. following redirect starts over from cache lookup
79+
*/
80+
void
81+
HttpCacheSM::reset()
82+
{
83+
captive_action.reset();
84+
85+
open_read_tries = 0;
86+
open_write_tries = 0;
87+
open_write_start = 0;
88+
89+
lookup_max_recursive = 0;
90+
current_lookup_level = 0;
91+
92+
err_code = 0;
93+
}
94+
7695
//////////////////////////////////////////////////////////////////////////
7796
//
7897
// HttpCacheSM::state_cache_open_read()

src/proxy/http/HttpSM.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8540,6 +8540,9 @@ HttpSM::redirect_request(const char *arg_redirect_url, const int arg_redirect_le
85408540
}
85418541

85428542
dump_header(dbg_ctl_http_hdrs, &t_state.hdr_info.client_request, sm_id, "Framed Client Request..checking");
8543+
8544+
// Reset HttpCacheSM for new cache operations
8545+
cache_sm.reset();
85438546
}
85448547

85458548
void

0 commit comments

Comments
 (0)