[master] 43b2397ef Clear vary prediction marker (vary_l) on restarts

Nils Goroll nils.goroll at uplex.de
Wed Oct 12 09:38:06 UTC 2022


commit 43b2397ef416d112bf0f985cc55072c85775d869
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Oct 11 13:28:24 2022 +0200

    Clear vary prediction marker (vary_l) on restarts
    
    In dea05fa4a855140cd807f75dccfa196b4099fa1a, an assertion was added
    that, if a vary prediction exists as marked by vary_l, that marker
    matches the actual length.
    
    This change uncovered an inconsistency where, for waitinglist returns,
    the predictive vary was cleared unconditionally (req->vary_b[2] = '\0'
    in VRY_Prep()), but vary_l was not.
    
    Consequently, before dea05fa4a855140cd807f75dccfa196b4099fa1a,
    VRY_Finish() would copy more of the (possibly empty) vary spec
    than necessary.
    
    This commit fixes the inconsistency and adds specific testing
    for the case.
    
    Fixes #3858

diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c
index 1edc80436..943350eac 100644
--- a/bin/varnishd/cache/cache_vary.c
+++ b/bin/varnishd/cache/cache_vary.c
@@ -237,6 +237,7 @@ VRY_Prep(struct req *req)
 	req->vary_e = req->vary_b + WS_ReservationSize(req->ws);
 	if (req->vary_b + 2 < req->vary_e)
 		req->vary_b[2] = '\0';
+	req->vary_l = NULL;
 }
 
 void
diff --git a/bin/varnishtest/tests/c00004.vtc b/bin/varnishtest/tests/c00004.vtc
index c4d7ad5c2..0af46c8b9 100644
--- a/bin/varnishtest/tests/c00004.vtc
+++ b/bin/varnishtest/tests/c00004.vtc
@@ -1,5 +1,7 @@
 varnishtest "Test Vary functionality"
 
+barrier b1 cond 3
+
 server s1 {
 	rxreq
 	expect req.http.foobar == "1"
@@ -20,6 +22,17 @@ server s1 {
 	rxreq
 	expect req.http.foobar == ""
 	txresp -hdr "Vary: Foobar" -hdr "Snafu: 5" -body "5555\n"
+
+	# #3858 test vary prediction turning out wrong
+	# no Vary, HFM and waitinglist
+	rxreq
+	expect req.http.foobar == "x"
+	barrier b1 sync
+	txresp -hdr "Cache-Control: no-cache"
+
+	rxreq
+	expect req.http.foobar == "x"
+	txresp -hdr "Cache-Control: no-cache"
 } -start
 
 varnish v1 -vcl+backend {} -start
@@ -67,5 +80,24 @@ client c1 {
 	expect resp.status == 200
 	expect resp.http.X-Varnish == "1011"
 	expect resp.http.snafu == "5"
-
 } -run
+
+client c1 {
+	txreq -hdr "Foobar: x"
+	barrier b1 sync
+	rxresp
+	expect resp.status == 200
+	expect resp.http.Vary == <undef>
+} -start
+
+client c2 {
+	txreq -hdr "Foobar: x"
+	barrier b1 sync
+	rxresp
+	expect resp.status == 200
+	expect resp.http.Vary == <undef>
+} -start
+
+
+client c1 -wait
+client c2 -wait


More information about the varnish-commit mailing list