[master] 7192541 Revert "Expose is_hit to VCL as resp.is_hit"

Nils Goroll nils.goroll at uplex.de
Wed Jan 7 11:17:12 CET 2015


commit 7192541d6512340e42ecf2b8d0a6ee1ff5a06029
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Jan 7 10:58:22 2015 +0100

    Revert "Expose is_hit to VCL as resp.is_hit"
    
    This reverts commit 468a0472fa313dbff69269afc085957642011abc.
    
    The next commit will make obj.hits reliable

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 82bf5ed..2e7fa47 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -540,7 +540,7 @@ struct req {
 	int			restarts;
 	int			esi_level;
 
-#define REQ_FLAG(l, o, r, w, d) unsigned	l:1;
+#define REQ_FLAG(l, r, w, d) unsigned	l:1;
 #include "tbl/req_flags.h"
 #undef REQ_FLAG
 
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 9bd99a7..d45458e 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -415,7 +415,7 @@ pan_req(const struct req *req)
 	}
 
 	VSB_printf(pan_vsp, "  flags = {\n");
-#define REQ_FLAG(l, o, r, w, d) if(req->l) VSB_printf(pan_vsp, "    " #l ",\n");
+#define REQ_FLAG(l, r, w, d) if(req->l) VSB_printf(pan_vsp, "    " #l ",\n");
 #include "tbl/req_flags.h"
 #undef REQ_FLAG
 	VSB_printf(pan_vsp, "  }\n");
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 5b2e5c2..4c6f2c6 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -566,29 +566,29 @@ VRT_r_bereq_xid(VRT_CTX)
  * req fields
  */
 
-#define VREQW0(obj, field)
-#define VREQW1(obj, field)						\
+#define VREQW0(field)
+#define VREQW1(field)						\
 void									\
-VRT_l_##obj##_##field(VRT_CTX, unsigned a)		\
+VRT_l_req_##field(VRT_CTX, unsigned a)		\
 {									\
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);				\
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);			\
 	ctx->req->field = a ? 1 : 0;					\
 }
 
-#define VREQR0(obj, field)
-#define VREQR1(obj, field)						\
+#define VREQR0(field)
+#define VREQR1(field)						\
 unsigned								\
-VRT_r_##obj##_##field(VRT_CTX)				\
+VRT_r_req_##field(VRT_CTX)				\
 {									\
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);				\
 	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);			\
 	return (ctx->req->field);					\
 }
 
-#define REQ_FLAG(l, o, r, w, d)			\
-	VREQR##r(o, l)					\
-	VREQW##w(o, l)
+#define REQ_FLAG(l, r, w, d) \
+	VREQR##r(l) \
+	VREQW##w(l)
 #include "tbl/req_flags.h"
 #undef REQ_FLAG
 
diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc
index 19e9f26..c428add 100644
--- a/bin/varnishtest/tests/v00013.vtc
+++ b/bin/varnishtest/tests/v00013.vtc
@@ -13,11 +13,6 @@ varnish v1 -vcl+backend {
 
 	sub vcl_deliver {
 		set resp.http.foo = obj.hits;
-		if (resp.is_hit) {
-			set resp.http.X-Hit = "yes";
-		} else {
-			set resp.http.X-Hit = "no";
-		}
 	}
 } -start
 
@@ -26,19 +21,16 @@ client c1 {
 	rxresp
 	expect resp.status == 200
 	expect resp.http.foo == 0
-	expect resp.http.X-hit == "no"
 
 	txreq
 	rxresp
 	expect resp.status == 200
 	expect resp.http.foo == 1
-	expect resp.http.X-hit == "yes"
 
 	txreq -url /foo
 	rxresp
 	expect resp.status == 200
 	expect resp.http.foo == 0
-	expect resp.http.X-hit == "no"
 	delay .1
 
 	txreq
@@ -46,5 +38,4 @@ client c1 {
 	expect resp.status == 200
 	expect resp.http.foo == 2
 	expect resp.http.bar >= 0.100
-	expect resp.http.X-hit == "yes"
 } -run
diff --git a/bin/varnishtest/tests/v00039.vtc b/bin/varnishtest/tests/v00039.vtc
index c248aa8..029e114 100644
--- a/bin/varnishtest/tests/v00039.vtc
+++ b/bin/varnishtest/tests/v00039.vtc
@@ -13,11 +13,6 @@ varnish v1 \
 	-vcl+backend {
 		sub vcl_deliver {
 			set resp.http.hits = obj.hits;
-			if (resp.is_hit) {
-				set resp.http.X-Hit = "yes";
-			} else {
-				set resp.http.X-Hit = "no";
-			}
 		}
 	} -start
 
@@ -28,7 +23,6 @@ client c1 {
 	expect resp.status == 200
 	expect resp.bodylen == 6
 	expect resp.http.hits == 0
-	expect resp.http.X-Hit == "no"
 
 	# This is a hit -> hits == 1
 	txreq -url "/" -hdr "Bar: 1"
@@ -36,7 +30,6 @@ client c1 {
 	expect resp.status == 200
 	expect resp.bodylen == 6
 	expect resp.http.hits == 1
-	expect resp.http.X-Hit == "yes"
 
 	# This is a miss on different vary -> hits == 0
 	txreq -url "/" -hdr "Bar: 2"
@@ -44,7 +37,6 @@ client c1 {
 	expect resp.status == 200
 	expect resp.bodylen == 4
 	expect resp.http.hits == 0
-	expect resp.http.X-Hit == "no"
 
 	# This is a hit -> hits == 1
 	txreq -url "/" -hdr "Bar: 2"
@@ -52,7 +44,6 @@ client c1 {
 	expect resp.status == 200
 	expect resp.bodylen == 4
 	expect resp.http.hits == 1
-	expect resp.http.X-Hit == "yes"
 
 } -run
 
diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h
index 55f20f7..6757d90 100644
--- a/include/tbl/req_flags.h
+++ b/include/tbl/req_flags.h
@@ -29,11 +29,11 @@
 
 /*lint -save -e525 -e539 */
 
-/* lower, vcl_obj, vcl_r, vcl_w, doc */
-REQ_FLAG(disable_esi,		none, 0, 0, "")
-REQ_FLAG(hash_ignore_busy,	req,  1, 1, "")
-REQ_FLAG(hash_always_miss,	req,  1, 1, "")
-REQ_FLAG(is_hit,		resp, 1, 0, "")
-REQ_FLAG(wantbody,		none, 0, 0, "")
-REQ_FLAG(gzip_resp,		none, 0, 0, "")
+/* lower, vcl_r, vcl_w, doc */
+REQ_FLAG(disable_esi,		0, 0, "")
+REQ_FLAG(hash_ignore_busy,	1, 1, "")
+REQ_FLAG(hash_always_miss,	1, 1, "")
+REQ_FLAG(is_hit,		0, 0, "")
+REQ_FLAG(wantbody,		0, 0, "")
+REQ_FLAG(gzip_resp,		0, 0, "")
 /*lint -restore */
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 699bab3..e582c0f 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -564,10 +564,8 @@ sp_variables = [
 		'INT',
 		( 'hit', 'deliver',),
 		( ), """
-		The count of cache-hits on this object.
-
-		NB: obj.hits is not a reliable way to determine cache
-		misses. See resp.is_hit.
+		The count of cache-hits on this object. A value of 0 indicates a
+		cache miss.
 		"""
 	),
 	('obj.http.',
@@ -647,13 +645,6 @@ sp_variables = [
 		The corresponding HTTP header.
 		"""
 	),
-	('resp.is_hit',
-		'BOOL',
-		( 'deliver',),
-		( ), """
-		If this response is from a cache hit.
-		"""
-	),
 	('now',
 		'TIME',
 		( 'all',),



More information about the varnish-commit mailing list