[master] dbfa7b4 Nitpicking around the corners of vcl labels
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jun 15 10:42:08 CEST 2016
commit dbfa7b4233795ed5d4895dae2a57271460df2dff
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jun 15 07:58:16 2016 +0000
Nitpicking around the corners of vcl labels
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index f9cc6bd..1308b97 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -437,7 +437,9 @@ mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv)
if (vp->label != NULL) {
AN(vp->warm);
VCLI_SetResult(cli, CLIS_PARAM);
- VCLI_Out(cli, "Must remove label to discard VCL\n");
+ VCLI_Out(cli,
+ "Cannot discard labeled (\"%s\") VCL program.\n",
+ vp->label->name);
return;
}
(void)mgt_vcl_setstate(cli, vp, VCL_STATE_COLD);
@@ -500,6 +502,12 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv)
VCLI_Out(cli, "VCL labels cannot point to labels");
return;
}
+ if (vpt->label != NULL) {
+ VCLI_SetResult(cli, CLIS_PARAM);
+ VCLI_Out(cli, "VCL already labeled (\"%s\")",
+ vpt->label->name);
+ return;
+ }
vpl = mgt_vcl_byname(av[2]);
if (vpl == NULL)
vpl = mgt_vcl_add(av[2], NULL, VCL_STATE_LABEL);
@@ -511,8 +519,10 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv)
}
vpl->warm = 1;
if (vpl->label != NULL) {
+ assert(vpl->label->label == vpl);
+ /* XXX SET vp->label AUTO */
vpl->label->label = NULL;
- /* XXX SET AUTO */
+ vpl->label = NULL;
}
vpl->label = vpt;
vpt->label = vpl;
diff --git a/bin/varnishtest/tests/v00048.vtc b/bin/varnishtest/tests/v00048.vtc
index e048ac7..744047d 100644
--- a/bin/varnishtest/tests/v00048.vtc
+++ b/bin/varnishtest/tests/v00048.vtc
@@ -31,7 +31,11 @@ client c1 {
varnish v1 -cliok "vcl.list"
varnish v1 -clierr 106 "vcl.label foo vcl0"
+varnish v1 -cliok "vcl.label foo vcl2"
+varnish v1 -clierr 106 "vcl.label bar vcl2"
+varnish v1 -clierr 106 "vcl.discard vcl2"
varnish v1 -cliok "vcl.label foo vcl1"
+varnish v1 -clierr 106 "vcl.label vcl1 vcl2"
varnish v1 -clierr 106 "vcl.state foo cold"
varnish v1 -clierr 106 "vcl.label bar foo"
varnish v1 -clierr 106 "vcl.discard vcl1"
More information about the varnish-commit
mailing list