[master] 49d32683d add bereq.is_hitpass and bereq.is_hitmiss
Nils Goroll
nils.goroll at uplex.de
Thu Nov 12 16:31:12 UTC 2020
commit 49d32683d96a6558a53e523713c584abf12424f0
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Nov 12 17:28:14 2020 +0100
add bereq.is_hitpass and bereq.is_hitmiss
as copies of the respective client side flags
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 4d7b1547c..0ba276571 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -1114,6 +1114,9 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
WRONG("Wrong fetch mode");
}
+ bo->is_hitpass = req->is_hitpass;
+ bo->is_hitmiss = req->is_hitmiss;
+
VSLb(bo->vsl, SLT_Begin, "bereq %u %s", VXID(req->vsl->wid), how);
VSLb(bo->vsl, SLT_VCL_use, "%s", VCL_Name(bo->vcl));
VSLb(req->vsl, SLT_Link, "bereq %u %s", VXID(bo->vsl->wid), how);
diff --git a/bin/varnishtest/tests/c00075.vtc b/bin/varnishtest/tests/c00075.vtc
index 6caacbfaa..4609862ba 100644
--- a/bin/varnishtest/tests/c00075.vtc
+++ b/bin/varnishtest/tests/c00075.vtc
@@ -53,6 +53,8 @@ server s1 {
varnish v1 \
-arg "-s default,1m" -vcl+backend {
sub vcl_backend_response {
+ set beresp.http.be-hitmiss = bereq.is_hitmiss;
+ set beresp.http.be-hitpass = bereq.is_hitpass;
if (bereq.url == "/hfp") {
return (pass(10m));
}
@@ -75,6 +77,8 @@ client c1 {
expect resp.bodylen == 65536
expect resp.http.is-hitmiss == false
expect resp.http.is-hitpass == false
+ expect resp.http.be-hitmiss == resp.http.is-hitmiss
+ expect resp.http.be-hitpass == resp.http.is-hitpass
expect_pattern
} -start
@@ -98,6 +102,8 @@ client c1 {
expect resp.bodylen == 65536
expect resp.http.is-hitmiss == true
expect resp.http.is-hitpass == false
+ expect resp.http.be-hitmiss == resp.http.is-hitmiss
+ expect resp.http.be-hitpass == resp.http.is-hitpass
expect_pattern
} -start
@@ -122,6 +128,8 @@ client c1 {
expect resp.bodylen == 65536
expect resp.http.is-hitmiss == false
expect resp.http.is-hitpass == false
+ expect resp.http.be-hitmiss == resp.http.is-hitmiss
+ expect resp.http.be-hitpass == resp.http.is-hitpass
expect_pattern
} -start
@@ -145,6 +153,8 @@ client c1 {
expect resp.bodylen == 65536
expect resp.http.is-hitmiss == false
expect resp.http.is-hitpass == true
+ expect resp.http.be-hitmiss == resp.http.is-hitmiss
+ expect resp.http.be-hitpass == resp.http.is-hitpass
expect_pattern
} -start
diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst
index 72098379a..27707dd7f 100644
--- a/doc/sphinx/reference/vcl_var.rst
+++ b/doc/sphinx/reference/vcl_var.rst
@@ -650,6 +650,22 @@ bereq.is_bgfetch
grace, and this fetch was kicked of in the background to get
a fresh copy.
+bereq.is_hitmiss
+
+ Type: BOOL
+
+ Readable from: backend
+
+ If this backend request was caused by a hitmiss.
+
+bereq.is_hitpass
+
+ Type: BOOL
+
+ Readable from: backend
+
+ If this backend request was caused by a hitpass.
+
beresp
~~~~~~
diff --git a/include/tbl/bo_flags.h b/include/tbl/bo_flags.h
index e96e21a86..ac0fdf241 100644
--- a/include/tbl/bo_flags.h
+++ b/include/tbl/bo_flags.h
@@ -43,6 +43,8 @@ BO_FLAG(do_pass, 0, 0, 0, 0, "")
BO_FLAG(uncacheable, 0, 0, 0, 0, "")
BO_FLAG(was_304, 0, 1, 0, 0, "")
BO_FLAG(is_bgfetch, 1, 0, 0, 0, "")
+BO_FLAG(is_hitmiss, 1, 0, 0, 0, "")
+BO_FLAG(is_hitpass, 1, 0, 0, 0, "")
#undef BO_FLAG
/*lint -restore */
More information about the varnish-commit
mailing list