[master] 0f935ccec cache_req: make max_restarts consistent
Nils Goroll
nils.goroll at uplex.de
Sun Feb 9 18:41:06 UTC 2025
commit 0f935ccecfb66c5058099875f281ec4bb41306a7
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Sun Feb 9 18:49:38 2025 +0100
cache_req: make max_restarts consistent
assert(req->restarts <= cache_param->max_restarts) could otherwise fail when the
max_restarts parameter is reduced.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 0930fb117..1be031eb8 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -466,6 +466,7 @@ struct req {
body_status_t req_body_status;
stream_close_t doclose;
unsigned restarts;
+ unsigned max_restarts;
unsigned esi_level;
/* Delivery mode */
diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c
index 7be842d5e..ac188560c 100644
--- a/bin/varnishd/cache/cache_req.c
+++ b/bin/varnishd/cache/cache_req.c
@@ -195,6 +195,7 @@ Req_New(struct sess *sp)
req->t_req = NAN;
req->req_step = R_STP_TRANSPORT;
req->doclose = SC_NULL;
+ req->max_restarts = cache_param->max_restarts;
return (req);
}
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index bbcb3824f..89f71f0a9 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -236,7 +236,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
req->t_resp = W_TIM_real(wrk);
VCL_deliver_method(req->vcl, wrk, req, NULL, NULL);
- assert(req->restarts <= cache_param->max_restarts);
+ assert(req->restarts <= req->max_restarts);
if (wrk->vpi->handling != VCL_RET_DELIVER) {
HSH_Cancel(wrk, req->objcore, NULL);
@@ -356,8 +356,7 @@ cnt_synth(struct worker *wrk, struct req *req)
return (REQ_FSM_DONE);
}
- if (wrk->vpi->handling == VCL_RET_RESTART &&
- req->restarts > cache_param->max_restarts)
+ if (wrk->vpi->handling == VCL_RET_RESTART && req->restarts > req->max_restarts)
wrk->vpi->handling = VCL_RET_DELIVER;
if (wrk->vpi->handling == VCL_RET_RESTART) {
@@ -870,7 +869,7 @@ cnt_restart(struct worker *wrk, struct req *req)
AZ(req->objcore);
AZ(req->stale_oc);
- if (++req->restarts > cache_param->max_restarts) {
+ if (++req->restarts > req->max_restarts) {
VSLb(req->vsl, SLT_VCL_Error, "Too many restarts");
req->err_code = 503;
req->req_step = R_STP_SYNTH;
More information about the varnish-commit
mailing list