[master] 382c528 obj.hits == 0 now realiably indicates a non-hit (miss or pass)
Nils Goroll
nils.goroll at uplex.de
Wed Jan 7 11:17:12 CET 2015
commit 382c5284d2812137fd336c1bcb3d7e4cde50f62f
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Jan 7 11:17:07 2015 +0100
obj.hits == 0 now realiably indicates a non-hit (miss or pass)
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 4c6f2c6..845eb99 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -643,7 +643,7 @@ VRT_r_obj_hits(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
- return (ctx->req->objcore->hits);
+ return (ctx->req->is_hit ? ctx->req->objcore->hits : 0);
}
unsigned
diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc
index c428add..7d2c9de 100644
--- a/bin/varnishtest/tests/v00013.vtc
+++ b/bin/varnishtest/tests/v00013.vtc
@@ -7,10 +7,17 @@ server s1 {
rxreq
expect req.url == "/foo"
txresp -body "foo"
+ rxreq
+ expect req.url == "/pass"
+ txresp -body "pass"
} -start
varnish v1 -vcl+backend {
-
+ sub vcl_recv {
+ if (req.url == "/pass") {
+ return (pass);
+ }
+ }
sub vcl_deliver {
set resp.http.foo = obj.hits;
}
@@ -38,4 +45,9 @@ client c1 {
expect resp.status == 200
expect resp.http.foo == 2
expect resp.http.bar >= 0.100
+
+ txreq -url /pass
+ rxresp
+ expect resp.status == 200
+ expect resp.http.foo == 0
} -run
More information about the varnish-commit
mailing list