[master] a27af9f Fix an oversight: The correct and systematic thing is for vcl_hit{} to return(miss) rather than return(fetch).

Poul-Henning Kamp phk at FreeBSD.org
Tue Apr 28 11:07:07 CEST 2015


commit a27af9f8f286f1d7a38b91928426685a1f33493f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Apr 28 09:05:44 2015 +0000

    Fix an oversight:  The correct and systematic thing is for vcl_hit{}
    to return(miss) rather than return(fetch).
    
    For now return(fetch) is still allowed, we don't want to bump vcl
    version for something this trivial, but it emits a SLT_VCL_Error
    urging people to change their VCL.
    
    Fixes #1603

diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl
index 6ead64e..3ebe9ce 100644
--- a/bin/varnishd/builtin.vcl
+++ b/bin/varnishd/builtin.vcl
@@ -109,7 +109,7 @@ sub vcl_hit {
         return (deliver);
     }
     // fetch & deliver once we get the result
-    return (fetch);
+    return (miss);
 }
 
 sub vcl_miss {
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 54c2b5c..f695ad5 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -362,6 +362,10 @@ cnt_lookup(struct worker *wrk, struct req *req)
 		req->req_step = R_STP_DELIVER;
 		return (REQ_FSM_MORE);
 	case VCL_RET_FETCH:
+		VSLb(req->vsl, SLT_VCL_Error,
+		    "change return(fetch) to return(hit) in vcl_hit{}");
+		/* FALL-THROUGH */
+	case VCL_RET_MISS:
 		if (boc != NULL) {
 			req->objcore = boc;
 			req->stale_oc = oc;
diff --git a/bin/varnishtest/tests/r01335.vtc b/bin/varnishtest/tests/r01335.vtc
index 8a34d5b..85ff372 100644
--- a/bin/varnishtest/tests/r01335.vtc
+++ b/bin/varnishtest/tests/r01335.vtc
@@ -10,7 +10,7 @@ server s1 {
 varnish v1 -vcl+backend {
 	sub vcl_hit {
 		if (req.http.two == "2") {
-			return (fetch);
+			return (fetch);		// also #1603
 		}
 	}
 } -start
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 19da0e0..2c1226f 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -108,7 +108,7 @@ returns =(
 	),
 	('hit',
 		"C",
-		('synth', 'restart', 'pass', 'fetch', 'deliver',)
+		('synth', 'restart', 'pass', 'fetch', 'miss', 'deliver',)
 	),
 	('deliver',
 		"C",



More information about the varnish-commit mailing list