[master] dc7f9a9 Move the check for cached uncacheable objs (= "hit-for-pass") into default VCL.

Poul-Henning Kamp phk at varnish-cache.org
Wed Apr 3 12:59:55 CEST 2013


commit dc7f9a9e6daac082f6dc2514d49d03776ee60da1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Apr 3 10:59:01 2013 +0000

    Move the check for cached uncacheable objs (= "hit-for-pass") into
    default VCL.
    
    Add a back-stop, so that a return(deliver) gets turned into return(pass)
    with a VCL_Error logged.

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 1e51f7f..835ef42 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -793,25 +793,25 @@ cnt_lookup(struct worker *wrk, struct req *req)
 
 	VRY_Finish(req, NULL);
 
-	if (oc->flags & OC_F_PASS) {
+	if (oc->flags & OC_F_PASS)
 		wrk->stats.cache_hitpass++;
-		VSLb(req->vsl, SLT_HitPass, "%u", req->obj->vxid);
-		(void)HSH_Deref(&wrk->stats, NULL, &req->obj);
-		AZ(req->objcore);
-		req->req_step = R_STP_PASS;
-		return (REQ_FSM_MORE);
-	}
-
-	wrk->stats.cache_hit++;
+	else
+		wrk->stats.cache_hit++;
 	VSLb(req->vsl, SLT_Hit, "%u", req->obj->vxid);
 
 	AZ(req->objcore);
 	AZ(req->busyobj);
 
-	assert(!(req->obj->objcore->flags & OC_F_PASS));
-
 	VCL_lookup_method(req);
 
+	if ((req->obj->objcore->flags & OC_F_PASS) &&
+	    req->handling == VCL_RET_DELIVER) {
+		VSLb(req->vsl, SLT_VCL_Error,
+		    "obj.uncacheable set, but vcl_lookup{} returned 'deliver'"
+		    ", changing to 'pass'");
+		req->handling = VCL_RET_PASS;
+	}
+
 	if (req->handling == VCL_RET_DELIVER) {
 		//AZ(req->busyobj->bereq->ws);
 		//AZ(req->busyobj->beresp->ws);
diff --git a/bin/varnishd/default.vcl b/bin/varnishd/default.vcl
index a8432ab..cfd5880 100644
--- a/bin/varnishd/default.vcl
+++ b/bin/varnishd/default.vcl
@@ -94,6 +94,9 @@ sub vcl_hash {
 }
 
 sub vcl_lookup {
+    if (obj.uncacheable) {
+	return (pass);
+    }
     return (deliver);
 }
 



More information about the varnish-commit mailing list