[master] 5dd70af Set the go-cold timer on newly loaded warm auto VCLs

Martin Blix Grydeland martin at varnish-software.com
Fri Mar 31 13:57:05 CEST 2017


commit 5dd70aff3e968f173d3b747b1d1a2bb805be5f6f
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Wed Mar 22 10:59:54 2017 +0100

    Set the go-cold timer on newly loaded warm auto VCLs
    
    Newly loaded VCLs didn't get their go cold timer set even when they
    were set to auto, causing them to never go cold automatically.
    
    Fixes: #2270

diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 8849752..9a1a42b 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -481,8 +481,13 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc,
 		mgt_vcl_del(vp);
 		VCLI_Out(cli, "%s", p);
 		VCLI_SetResult(cli, status);
+		free(p);
+		return;
 	}
 	free(p);
+
+	if (vp->warm && !strcmp(vp->state, "auto"))
+		vp->go_cold = VTIM_mono();
 }
 
 /*--------------------------------------------------------------------*/
diff --git a/bin/varnishtest/tests/r02270.vtc b/bin/varnishtest/tests/r02270.vtc
new file mode 100644
index 0000000..8547ca5
--- /dev/null
+++ b/bin/varnishtest/tests/r02270.vtc
@@ -0,0 +1,19 @@
+varnishtest "Test that never used VCLs go cold automatically"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -arg "-p vcl_cooldown=1" -vcl+backend {
+} -start
+
+varnish v1 -expect VBE.vcl1.s1.happy >= 0
+
+varnish v1 -cliok {vcl.inline vcl2 "vcl 4.0; backend s1 {.host = \"${s1_addr}\"; .port = \"${s1_port}\"; }"}
+
+varnish v1 -expect VBE.vcl2.s1.happy >= 0
+
+delay 5
+
+varnish v1 -expect !VBE.vcl2.s1.happy



More information about the varnish-commit mailing list