Commit cbe80476 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Reintroduce hit-for-pass with new and better syntax:

	sub vcl_backend_response {
                return (pass(2s));
        }
parent b00cbb23
......@@ -471,6 +471,11 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
if (bo->do_esi)
bo->do_stream = 0;
if (wrk->handling == VCL_RET_PASS) {
bo->fetch_objcore->flags |= OC_F_HFP;
bo->uncacheable = 1;
wrk->handling = VCL_RET_DELIVER;
}
if (bo->do_pass || bo->uncacheable)
bo->fetch_objcore->flags |= OC_F_PASS;
......
......@@ -436,7 +436,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
/* If still valid, use it */
assert(oh->refcnt > 1);
assert(oc->objhead == oh);
if (oc->flags & OC_F_PASS) {
if (oc->flags & OC_F_HFP) {
wrk->stats->cache_hitpass++;
oc = NULL;
} else if (oc->flags & OC_F_PASS) {
wrk->stats->cache_hitpass++;
oc = NULL;
*bocp = hsh_insert_busyobj(wrk, oh);
......
......@@ -427,10 +427,13 @@ cnt_lookup(struct worker *wrk, struct req *req)
if (lr == HSH_MISS) {
/* Found nothing */
AZ(oc);
AN(busy);
AN(busy->flags & OC_F_BUSY);
req->objcore = busy;
req->req_step = R_STP_MISS;
if (busy != NULL) {
AN(busy->flags & OC_F_BUSY);
req->objcore = busy;
req->req_step = R_STP_MISS;
} else {
req->req_step = R_STP_PASS;
}
return (REQ_FSM_MORE);
}
......
......@@ -85,6 +85,21 @@ VRT_acl_match(VRT_CTX, VCL_ACL acl, VCL_IP ip)
return (acl->match(ctx, ip));
}
void
VRT_hit_for_pass(VRT_CTX, VCL_DURATION d)
{
struct objcore *oc;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
oc = ctx->bo->fetch_objcore;
oc->ttl = d;
oc->grace = 0.0;
oc->keep = 0.0;
VSLb(ctx->vsl, SLT_TTL, "HFP %.0f %.0f %.0f %.0f",
oc->ttl, oc->grace, oc->keep, oc->t_origin);
}
/*--------------------------------------------------------------------*/
struct http *
......
varnishtest "Hit-for-pass (mk II)"
server s1 {
rxreq
txresp -hdr "foo: 1"
rxreq
txresp -hdr "foo: 2"
rxreq
txresp -hdr "foo: 3"
} -start
varnish v1 -vcl+backend {
sub vcl_miss {
set req.http.miss = "True";
}
sub vcl_pass {
set req.http.pass = "True";
}
sub vcl_backend_response {
return (pass(2s));
}
sub vcl_deliver {
set resp.http.miss = req.http.miss;
set resp.http.pass = req.http.pass;
}
} -start
client c1 {
txreq
rxresp
expect resp.http.miss == True
txreq
rxresp
expect resp.http.pass == True
delay 3
txreq
rxresp
expect resp.http.miss == True
} -run
......@@ -30,6 +30,7 @@
OC_FLAG(BUSY, busy, (1<<1))
OC_FLAG(PASS, pass, (1<<2))
OC_FLAG(HFP, hfp, (1<<3))
OC_FLAG(ABANDON, abandon, (1<<4))
OC_FLAG(PRIVATE, private, (1<<5))
OC_FLAG(FAILED, failed, (1<<6))
......
......@@ -134,7 +134,7 @@ returns = (
),
('backend_response',
"B",
('fail', 'deliver', 'retry', 'abandon')
('fail', 'deliver', 'retry', 'abandon', 'pass')
),
('backend_error',
"B",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment