
martin at varnish-software
Apr 10, 2012, 7:37 AM
Views: 141
Permalink
|
|
[PATCH] Reset req->err_code to zero when doing restart from vcl_fetch()
|
|
By resetting the req->err_code upon restarting after vcl_fetch(), a proper 503 will be issued if this later triggers a max restarts error instead of whatever status code the aborted backend connection returned. Test case by: scoof Fixes: #1113 --- bin/varnishd/cache/cache_center.c | 1 + bin/varnishtest/tests/r01113.vtc | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 bin/varnishtest/tests/r01113.vtc diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c index 7104e0f..1fa8604 100644 --- a/bin/varnishd/cache/cache_center.c +++ b/bin/varnishd/cache/cache_center.c @@ -661,6 +661,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req) switch (req->handling) { case VCL_RET_RESTART: req->restarts++; + req->err_code = 0; sp->step = STP_RECV; return (0); case VCL_RET_ERROR: diff --git a/bin/varnishtest/tests/r01113.vtc b/bin/varnishtest/tests/r01113.vtc new file mode 100644 index 0000000..efbfd55 --- /dev/null +++ b/bin/varnishtest/tests/r01113.vtc @@ -0,0 +1,21 @@ +varnishtest "HTTP status code when hitting max_restarts" + +server s1 { + rxreq + txresp + accept + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + return(restart); + } +} -start -cliok "param.set max_restarts 1" + +client c1 { + txreq + rxresp + expect resp.status == 503 +} -run -- 1.7.4.1 _______________________________________________ varnish-dev mailing list varnish-dev [at] varnish-cache https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
|