[master] 12e1dcd Turn an impossible condition into an assertion

Nils Goroll nils.goroll at uplex.de
Mon Oct 2 13:41:07 UTC 2017


commit 12e1dcd12b8c2da3636ae8a5ceba5faae31c24ef
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Oct 2 13:59:50 2017 +0200

    Turn an impossible condition into an assertion
    
    req->restarts only gets incremented in cnt_restart, so it will never
    exceed max_restarts here.
    
    Related to #2405

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index e36e3aa..217192b 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -160,9 +160,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
 	VCL_deliver_method(req->vcl, wrk, req, NULL, NULL);
 	VSLb_ts_req(req, "Process", W_TIM_real(wrk));
 
-	/* Stop the insanity before it turns "Hotel California" on us */
-	if (req->restarts >= cache_param->max_restarts)
-		wrk->handling = VCL_RET_DELIVER;
+	assert(req->restarts <= cache_param->max_restarts);
 
 	if (wrk->handling != VCL_RET_DELIVER) {
 		(void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY);


More information about the varnish-commit mailing list