Skip to content

Commit 561771b

Browse files
authored
Cleanup HttpCacheSM & HttpCacheAction (#12189)
1 parent e3ec782 commit 561771b

3 files changed

Lines changed: 36 additions & 43 deletions

File tree

include/proxy/http/HttpCacheSM.h

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,31 @@
4141
class HttpSM;
4242
class HttpCacheSM;
4343

44-
struct HttpCacheAction : public Action {
45-
HttpCacheAction();
44+
class HttpCacheAction : public Action
45+
{
46+
public:
4647
void cancel(Continuation *c = nullptr) override;
48+
4749
void
48-
init(HttpCacheSM *sm_arg)
50+
init(HttpCacheSM *cache_sm)
4951
{
50-
sm = sm_arg;
52+
_cache_sm = cache_sm;
5153
};
54+
5255
void
5356
reset()
5457
{
5558
cancelled = false;
5659
}
5760

58-
HttpCacheSM *sm = nullptr;
61+
private:
62+
HttpCacheSM *_cache_sm = nullptr;
5963
};
6064

6165
class HttpCacheSM : public Continuation
6266
{
6367
public:
64-
HttpCacheSM();
68+
HttpCacheSM() : Continuation(nullptr), captive_action() {}
6569

6670
void
6771
init(HttpSM *sm_arg, Ptr<ProxyMutex> &amutex)
@@ -88,14 +92,14 @@ class HttpCacheSM : public Continuation
8892
Action *pending_action = nullptr;
8993

9094
// Function to set readwhilewrite_inprogress flag
91-
inline void
95+
void
9296
set_readwhilewrite_inprogress(bool value)
9397
{
9498
readwhilewrite_inprogress = value;
9599
}
96100

97101
// Function to get the readwhilewrite_inprogress flag
98-
inline bool
102+
bool
99103
is_readwhilewrite_inprogress()
100104
{
101105
return readwhilewrite_inprogress;
@@ -113,7 +117,7 @@ class HttpCacheSM : public Continuation
113117
return cache_read_vc ? (cache_read_vc->is_compressed_in_ram()) : false;
114118
}
115119

116-
inline void
120+
void
117121
set_open_read_tries(int value)
118122
{
119123
open_read_tries = value;
@@ -125,7 +129,7 @@ class HttpCacheSM : public Continuation
125129
return open_read_tries;
126130
}
127131

128-
inline void
132+
void
129133
set_open_write_tries(int value)
130134
{
131135
open_write_tries = value;
@@ -161,7 +165,7 @@ class HttpCacheSM : public Continuation
161165
return nullptr;
162166
}
163167

164-
inline void
168+
void
165169
abort_read()
166170
{
167171
if (cache_read_vc) {
@@ -170,7 +174,8 @@ class HttpCacheSM : public Continuation
170174
cache_read_vc = nullptr;
171175
}
172176
}
173-
inline void
177+
178+
void
174179
abort_write()
175180
{
176181
if (cache_write_vc) {
@@ -179,7 +184,8 @@ class HttpCacheSM : public Continuation
179184
cache_write_vc = nullptr;
180185
}
181186
}
182-
inline void
187+
188+
void
183189
close_write()
184190
{
185191
if (cache_write_vc) {
@@ -188,7 +194,8 @@ class HttpCacheSM : public Continuation
188194
cache_write_vc = nullptr;
189195
}
190196
}
191-
inline void
197+
198+
void
192199
close_read()
193200
{
194201
if (cache_read_vc) {
@@ -197,7 +204,8 @@ class HttpCacheSM : public Continuation
197204
cache_read_vc = nullptr;
198205
}
199206
}
200-
inline void
207+
208+
void
201209
end_both()
202210
{
203211
// We close the read so that cache
@@ -206,7 +214,7 @@ class HttpCacheSM : public Continuation
206214
abort_write();
207215
}
208216

209-
inline int
217+
int
210218
get_last_error() const
211219
{
212220
return err_code;

src/proxy/http/HttpCacheSM.cc

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@
2121
limitations under the License.
2222
*/
2323

24-
/****************************************************************************
25-
26-
HttpCacheSM.cc
27-
28-
Description:
29-
30-
31-
****************************************************************************/
32-
3324
#include "proxy/http/HttpCacheSM.h"
3425
#include "proxy/http/HttpSM.h"
3526
#include "proxy/http/HttpDebugNames.h"
@@ -50,31 +41,26 @@
5041
namespace
5142
{
5243
DbgCtl dbg_ctl_http_cache{"http_cache"};
53-
5444
} // end anonymous namespace
5545

56-
HttpCacheAction::HttpCacheAction() {}
57-
46+
////
47+
// HttpCacheAction
48+
//
5849
void
5950
HttpCacheAction::cancel(Continuation *c)
6051
{
61-
ink_assert(c == nullptr || c == sm->master_sm);
62-
ink_assert(this->cancelled == 0);
52+
ink_assert(c == nullptr || c == _cache_sm->master_sm);
53+
ink_assert(this->cancelled == false);
6354

64-
this->cancelled = 1;
65-
if (sm->pending_action) {
66-
sm->pending_action->cancel();
55+
this->cancelled = true;
56+
if (_cache_sm->pending_action) {
57+
_cache_sm->pending_action->cancel();
6758
}
6859
}
6960

70-
HttpCacheSM::HttpCacheSM()
71-
: Continuation(nullptr),
72-
73-
captive_action()
74-
75-
{
76-
}
77-
61+
////
62+
// HttpCacheSM
63+
//
7864
/**
7965
Reset captive_action and counters for another cache operations.
8066
- e.g. following redirect starts over from cache lookup

src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@ HttpVCTable::HttpVCTable(HttpSM *smp)
5454
{
5555
sm = smp;
5656
}
57-
HttpCacheAction::HttpCacheAction() {}
57+
5858
void
5959
HttpCacheAction::cancel(Continuation * /* c ATS_UNUSED */)
6060
{
6161
}
6262
PostDataBuffers::~PostDataBuffers() {}
6363

6464
HttpTunnel::HttpTunnel() {}
65-
HttpCacheSM::HttpCacheSM() {}
6665
HttpTunnelConsumer::HttpTunnelConsumer() {}
6766
HttpTunnelProducer::HttpTunnelProducer() {}
6867
ChunkedHandler::ChunkedHandler() {}

0 commit comments

Comments
 (0)