Skip to content

Commit a5e8ebc

Browse files
committed
SQUASHME: Function signature dridification
Keeping as a separate commit for now because I am not _entirely_ sure that this is an improvement. The explicit arguments, I think, made it clearer what the stash does.
1 parent ed965b6 commit a5e8ebc

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

bin/varnishd/cache/cache_req_fsm.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ struct ocstash {
9494
};
9595

9696
static void
97-
ocstash_fini(struct worker *wrk, struct ocstash **stashp)
97+
ReqFiniObjcoreStash(struct req *req)
9898
{
9999
struct ocstash *stash;
100100
unsigned u;
101101

102-
AN(stashp);
103-
if (*stashp == NULL)
102+
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
103+
if (req->ocstash == NULL)
104104
return;
105-
TAKE_OBJ_NOTNULL(stash, stashp, OCSTASH_MAGIC);
105+
TAKE_OBJ_NOTNULL(stash, &req->ocstash, OCSTASH_MAGIC);
106106
assert(stash->n <= stash->l);
107107
for (u = 0; u < stash->n; u++)
108-
(void)HSH_DerefObjCore(wrk, &stash->ocs[u], HSH_RUSH_POLICY);
108+
(void)HSH_DerefObjCore(req->wrk, &stash->ocs[u], HSH_RUSH_POLICY);
109109
if (stash->malloced)
110110
free(stash);
111111
}
@@ -118,27 +118,30 @@ stash_sz(unsigned cap)
118118

119119
// never fails unless malloc() fails
120120
static void
121-
stash_oc(struct ocstash **stashp, struct objcore **ocp, struct ws *ws, unsigned l)
121+
ReqStashObjcore(struct req *req)
122122
{
123123
struct ocstash *stash;
124+
unsigned l;
125+
size_t sz;
124126

125-
AN(stashp);
126-
AN(ocp);
127+
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
127128

128-
stash = *stashp;
129+
stash = req->ocstash;
129130
if (stash == NULL) {
130-
stash = WS_Alloc(ws, (unsigned)stash_sz(l));
131+
l = req->max_restarts + 1;
132+
sz = stash_sz(l);
133+
stash = WS_Alloc(req->ws, (unsigned)sz);
131134
if (stash == NULL)
132135
stash = malloc(stash_sz(l));
133136
AN(stash);
134-
memset(stash, 0, stash_sz(l));
137+
memset(stash, 0, sz);
135138
stash->magic = OCSTASH_MAGIC;
136139
stash->l = l;
137-
*stashp = stash;
140+
req->ocstash = stash;
138141
}
139142
CHECK_OBJ(stash, OCSTASH_MAGIC);
140143
assert(stash->n < stash->l);
141-
TAKE_OBJ_NOTNULL(stash->ocs[stash->n], ocp, OBJCORE_MAGIC);
144+
TAKE_OBJ_NOTNULL(stash->ocs[stash->n], &req->objcore, OBJCORE_MAGIC);
142145
stash->n++;
143146
}
144147

@@ -304,7 +307,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
304307

305308
if (wrk->vpi->handling != VCL_RET_DELIVER) {
306309
HSH_Cancel(wrk, req->objcore, NULL);
307-
stash_oc(&req->ocstash, &req->objcore, req->ws, req->max_restarts + 1);
310+
ReqStashObjcore(req);
308311
http_Teardown(req->resp);
309312

310313
switch (wrk->vpi->handling) {
@@ -350,7 +353,7 @@ cnt_vclfail(struct worker *wrk, struct req *req)
350353
AZ(req->objcore);
351354
AZ(req->stale_oc);
352355

353-
ocstash_fini(wrk, &req->ocstash);
356+
ReqFiniObjcoreStash(req);
354357

355358
INIT_OBJ(ctx, VRT_CTX_MAGIC);
356359
VCL_Req2Ctx(ctx, req);
@@ -751,7 +754,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
751754
WRONG("Illegal return from vcl_hit{}");
752755
}
753756

754-
stash_oc(&req->ocstash, &req->objcore, req->ws, req->max_restarts + 1);
757+
ReqStashObjcore(req);
755758

756759
if (busy != NULL) {
757760
(void)HSH_DerefObjCore(wrk, &busy, 0);
@@ -1279,7 +1282,7 @@ CNT_Request(struct req *req)
12791282
}
12801283
wrk->vsl = NULL;
12811284
if (nxt == REQ_FSM_DONE) {
1282-
ocstash_fini(wrk, &req->ocstash);
1285+
ReqFiniObjcoreStash(req);
12831286
INIT_OBJ(ctx, VRT_CTX_MAGIC);
12841287
VCL_Req2Ctx(ctx, req);
12851288
if (IS_TOPREQ(req)) {

0 commit comments

Comments
 (0)