Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial support for Cache-Control's no-cache directive #4073

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hash: Retire HSH_RUSH_POLICY
From now on, the policy will be derived from the objcore.
  • Loading branch information
dridi committed Dec 4, 2024
commit 00274994a8996dcc5f4a824d110ba59294566bf4
2 changes: 1 addition & 1 deletion bin/varnishd/cache/cache_ban_lurker.c
Original file line number Diff line number Diff line change
@@ -332,7 +332,7 @@ ban_lurker_test_ban(struct worker *wrk, struct ban *bt,
if (i)
ObjSendEvent(wrk, oc, OEV_BANCHG);
}
(void)HSH_DerefObjCore(wrk, &oc, 0);
(void)HSH_DerefObjCore(wrk, &oc);
}
}

3 changes: 1 addition & 2 deletions bin/varnishd/cache/cache_busyobj.c
Original file line number Diff line number Diff line change
@@ -179,8 +179,7 @@ VBO_ReleaseBusyObj(struct worker *wrk, struct busyobj **pbo)
wrk->stats->ws_backend_overflow++;

if (bo->fetch_objcore != NULL) {
(void)HSH_DerefObjCore(wrk, &bo->fetch_objcore,
HSH_RUSH_POLICY);
(void)HSH_DerefObjCore(wrk, &bo->fetch_objcore);
}

VRT_Assign_Backend(&bo->director_req, NULL);
6 changes: 3 additions & 3 deletions bin/varnishd/cache/cache_expire.c
Original file line number Diff line number Diff line change
@@ -213,7 +213,7 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
ObjSendEvent(wrk, oc, OEV_EXPIRE);
tmpoc = oc;
assert(oc->refcnt >= 2); /* Silence coverity */
(void)HSH_DerefObjCore(wrk, &oc, 0);
(void)HSH_DerefObjCore(wrk, &oc);
AZ(oc);
assert(tmpoc->refcnt >= 1); /* Silence coverity */
}
@@ -309,7 +309,7 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags, double now)
VXID(ObjGetXID(ep->wrk, oc)), EXP_Ttl(NULL, oc) - now,
(intmax_t)oc->hits);
ObjSendEvent(ep->wrk, oc, OEV_EXPIRE);
(void)HSH_DerefObjCore(ep->wrk, &oc, 0);
(void)HSH_DerefObjCore(ep->wrk, &oc);
return;
}

@@ -387,7 +387,7 @@ exp_expire(struct exp_priv *ep, vtim_real now)
VXID(ObjGetXID(ep->wrk, oc)), EXP_Ttl(NULL, oc) - now,
(intmax_t)oc->hits);
ObjSendEvent(ep->wrk, oc, OEV_EXPIRE);
(void)HSH_DerefObjCore(ep->wrk, &oc, 0);
(void)HSH_DerefObjCore(ep->wrk, &oc);
}
return (0);
}
8 changes: 4 additions & 4 deletions bin/varnishd/cache/cache_fetch.c
Original file line number Diff line number Diff line change
@@ -1112,7 +1112,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
http_Teardown(bo->beresp);
// cannot make assumptions about the number of references here #3434
if (bo->bereq_body != NULL)
(void) HSH_DerefObjCore(bo->wrk, &bo->bereq_body, 0);
(void)HSH_DerefObjCore(bo->wrk, &bo->bereq_body);

if (oc->boc->state == BOS_FINISHED) {
AZ(oc->flags & OC_F_FAILED);
@@ -1122,7 +1122,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv)
// AZ(oc->boc); // XXX

if (bo->stale_oc != NULL)
(void)HSH_DerefObjCore(wrk, &bo->stale_oc, 0);
(void)HSH_DerefObjCore(wrk, &bo->stale_oc);

wrk->vsl = NULL;
HSH_DerefBoc(wrk, oc);
@@ -1213,7 +1213,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
"No thread available for bgfetch");
(void)vbf_stp_fail(req->wrk, bo);
if (bo->stale_oc != NULL)
(void)HSH_DerefObjCore(wrk, &bo->stale_oc, 0);
(void)HSH_DerefObjCore(wrk, &bo->stale_oc);
HSH_DerefBoc(wrk, oc);
SES_Rel(bo->sp);
THR_SetBusyobj(NULL);
@@ -1236,5 +1236,5 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
assert(oc->boc == boc);
HSH_DerefBoc(wrk, oc);
if (mode == VBF_BACKGROUND)
(void)HSH_DerefObjCore(wrk, &oc, HSH_RUSH_POLICY);
(void)HSH_DerefObjCore(wrk, &oc);
}
12 changes: 5 additions & 7 deletions bin/varnishd/cache/cache_hash.c
Original file line number Diff line number Diff line change
@@ -760,7 +760,7 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
EXP_Remove(ocp[i], NULL);
else
EXP_Reduce(ocp[i], ttl_now, ttl, grace, keep);
(void)HSH_DerefObjCore(wrk, &ocp[i], 0);
(void)HSH_DerefObjCore(wrk, &ocp[i]);
AZ(ocp[i]);
total++;
}
@@ -903,7 +903,7 @@ HSH_Withdraw(struct worker *wrk, struct objcore **ocp)
assert(oh->refcnt > 0);
oc->flags = OC_F_WITHDRAWN;
hsh_rush1(wrk, oc, &rush);
AZ(HSH_DerefObjCoreUnlock(wrk, &oc, 0));
AZ(HSH_DerefObjCoreUnlock(wrk, &oc));

hsh_rush2(wrk, &rush);
}
@@ -1098,7 +1098,7 @@ HSH_DerefBoc(struct worker *wrk, struct objcore *oc)
*/

int
HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax)
HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp)
{
struct objcore *oc;
struct objhead *oh;
@@ -1111,11 +1111,11 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax)
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);

Lck_Lock(&oh->mtx);
return (HSH_DerefObjCoreUnlock(wrk, &oc, rushmax));
return (HSH_DerefObjCoreUnlock(wrk, &oc));
}

int
HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp, int rushmax)
HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp)
{
struct objcore *oc;
struct objhead *oh;
@@ -1125,8 +1125,6 @@ HSH_DerefObjCoreUnlock(struct worker *wrk, struct objcore **ocp, int rushmax)
TAKE_OBJ_NOTNULL(oc, ocp, OBJCORE_MAGIC);
assert(oc->refcnt > 0);

(void)rushmax;

oh = oc->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);

7 changes: 2 additions & 5 deletions bin/varnishd/cache/cache_objhead.h
Original file line number Diff line number Diff line change
@@ -76,11 +76,8 @@ int HSH_Snipe(const struct worker *, struct objcore *);
struct boc *HSH_RefBoc(const struct objcore *);
void HSH_DerefBoc(struct worker *wrk, struct objcore *);
void HSH_DeleteObjHead(const struct worker *, struct objhead *);

int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax);
#define HSH_RUSH_POLICY -1

int HSH_DerefObjCoreUnlock(struct worker *, struct objcore **, int rushmax);
int HSH_DerefObjCore(struct worker *, struct objcore **);
int HSH_DerefObjCoreUnlock(struct worker *, struct objcore **);
enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **);
void HSH_Ref(struct objcore *o);
void HSH_AddString(struct req *, void *ctx, const char *str);
12 changes: 6 additions & 6 deletions bin/varnishd/cache/cache_req_body.c
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
if (STV_NewObject(req->wrk, req->body_oc, stv, 0) == 0) {
req->req_body_status = BS_ERROR;
HSH_DerefBoc(req->wrk, req->body_oc);
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
(void)VFP_Error(vfc, "Object allocation failed:"
" Ran out of space in %s", stv->vclname);
return (-1);
@@ -96,15 +96,15 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
(void)VFP_Error(vfc, "req.body filters failed");
req->req_body_status = BS_ERROR;
HSH_DerefBoc(req->wrk, req->body_oc);
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
return (-1);
}


if (VFP_Open(ctx, vfc) < 0) {
req->req_body_status = BS_ERROR;
HSH_DerefBoc(req->wrk, req->body_oc);
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
return (-1);
}

@@ -152,7 +152,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)
VSLb_ts_req(req, "ReqBody", VTIM_real());
if (func != NULL) {
HSH_DerefBoc(req->wrk, req->body_oc);
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
if (vfps == VFP_END && r == 0 && (flush & OBJ_ITER_END) == 0)
r = func(priv, flush | OBJ_ITER_END, NULL, 0);
if (vfps != VFP_END) {
@@ -168,7 +168,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv)

if (vfps != VFP_END) {
req->req_body_status = BS_ERROR;
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0));
AZ(HSH_DerefObjCore(req->wrk, &req->body_oc));
return (-1);
}

@@ -289,7 +289,7 @@ VRB_Free(struct req *req)
if (req->body_oc == NULL)
return;

r = HSH_DerefObjCore(req->wrk, &req->body_oc, 0);
r = HSH_DerefObjCore(req->wrk, &req->body_oc);

// each busyobj may have gained a reference
assert (r >= 0);
16 changes: 8 additions & 8 deletions bin/varnishd/cache/cache_req_fsm.c
Original file line number Diff line number Diff line change
@@ -222,7 +222,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
ObjTouch(req->wrk, req->objcore, req->t_prev);

if (Resp_Setup_Deliver(req)) {
(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
(void)HSH_DerefObjCore(wrk, &req->objcore);
req->err_code = 500;
req->req_step = R_STP_SYNTH;
return (REQ_FSM_MORE);
@@ -240,7 +240,7 @@ cnt_deliver(struct worker *wrk, struct req *req)

if (wrk->vpi->handling != VCL_RET_DELIVER) {
HSH_Cancel(wrk, req->objcore, NULL);
(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
(void)HSH_DerefObjCore(wrk, &req->objcore);
http_Teardown(req->resp);

switch (wrk->vpi->handling) {
@@ -414,7 +414,7 @@ cnt_synth(struct worker *wrk, struct req *req)
VSLb(req->vsl, SLT_Error, "Could not get storage");
req->doclose = SC_OVERLOAD;
VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
(void)HSH_DerefObjCore(wrk, &req->objcore, 1);
(void)HSH_DerefObjCore(wrk, &req->objcore);
http_Teardown(req->resp);
return (REQ_FSM_DONE);
}
@@ -530,7 +530,7 @@ cnt_finish(struct worker *wrk, struct req *req)
req->boc = NULL;
}

(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
(void)HSH_DerefObjCore(wrk, &req->objcore);
http_Teardown(req->resp);

req->vdp_filter_list = NULL;
@@ -557,7 +557,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
if (req->objcore->flags & OC_F_FAILED) {
req->err_code = 503;
req->req_step = R_STP_SYNTH;
(void)HSH_DerefObjCore(wrk, &req->objcore, 1);
(void)HSH_DerefObjCore(wrk, &req->objcore);
AZ(req->objcore);
return (REQ_FSM_MORE);
}
@@ -685,7 +685,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
}

/* Drop our object, we won't need it */
(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);
(void)HSH_DerefObjCore(wrk, &req->objcore);

if (busy != NULL) {
HSH_Withdraw(wrk, &busy);
@@ -715,7 +715,7 @@ cnt_miss(struct worker *wrk, struct req *req)
wrk->stats->cache_miss++;
VBF_Fetch(wrk, req, req->objcore, req->stale_oc, VBF_NORMAL);
if (req->stale_oc != NULL)
(void)HSH_DerefObjCore(wrk, &req->stale_oc, 0);
(void)HSH_DerefObjCore(wrk, &req->stale_oc);
req->req_step = R_STP_FETCH;
return (REQ_FSM_MORE);
case VCL_RET_FAIL:
@@ -735,7 +735,7 @@ cnt_miss(struct worker *wrk, struct req *req)
}
VRY_Clear(req);
if (req->stale_oc != NULL)
(void)HSH_DerefObjCore(wrk, &req->stale_oc, 0);
(void)HSH_DerefObjCore(wrk, &req->stale_oc);
HSH_Withdraw(wrk, &req->objcore);
return (REQ_FSM_MORE);
}
2 changes: 1 addition & 1 deletion bin/varnishd/cache/cache_vrt_var.c
Original file line number Diff line number Diff line change
@@ -641,7 +641,7 @@ VRT_u_bereq_body(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
if (ctx->bo->bereq_body != NULL) {
(void)HSH_DerefObjCore(ctx->bo->wrk, &ctx->bo->bereq_body, 0);
(void)HSH_DerefObjCore(ctx->bo->wrk, &ctx->bo->bereq_body);
http_Unset(ctx->bo->bereq, H_Content_Length);
}

2 changes: 1 addition & 1 deletion bin/varnishd/storage/storage_lru.c
Original file line number Diff line number Diff line change
@@ -205,6 +205,6 @@ LRU_NukeOne(struct worker *wrk, struct lru *lru)
ObjSlim(wrk, oc);

VSLb(wrk->vsl, SLT_ExpKill, "LRU xid=%ju", VXID(ObjGetXID(wrk, oc)));
(void)HSH_DerefObjCore(wrk, &oc, 0); // Ref from HSH_Snipe
(void)HSH_DerefObjCore(wrk, &oc); // Ref from HSH_Snipe
return (1);
}
2 changes: 1 addition & 1 deletion bin/varnishd/storage/storage_persistent_silo.c
Original file line number Diff line number Diff line change
@@ -178,7 +178,7 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc,
HSH_Insert(wrk, so->hash, oc, ban);
AN(oc->ban);
HSH_DerefBoc(wrk, oc); // XXX Keep it an stream resurrection?
(void)HSH_DerefObjCore(wrk, &oc, HSH_RUSH_POLICY);
(void)HSH_DerefObjCore(wrk, &oc);
wrk->stats->n_vampireobject++;
}
Pool_Sumstat(wrk);