[master] ac69df7 varnishd -C on a bad vcl should exit with status 2 as it does without -C

Nils Goroll nils.goroll at uplex.de
Tue Apr 14 18:55:17 CEST 2015


commit ac69df7db6ea97dc244df357e14013e720fe9801
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Apr 14 18:54:44 2015 +0200

    varnishd -C on a bad vcl should exit with status 2 as it does without -C

diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 3622b12..f77ceb7 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -644,6 +644,7 @@ main(int argc, char * const *argv)
 	if (b_arg != NULL || f_arg != NULL) {
 		mgt_vcc_default(cli, b_arg, vcl, C_flag);
 		if (C_flag) {
+			cli_check(cli);
 			AZ(VSB_finish(cli->sb));
 			fprintf(stderr, "%s\n", VSB_data(cli->sb));
 			exit(0);
diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c
index 76df5e6..f350614 100644
--- a/bin/varnishd/mgt/mgt_vcc.c
+++ b/bin/varnishd/mgt/mgt_vcc.c
@@ -327,7 +327,7 @@ mgt_VccCompile(struct cli *cli, const char *vclname, const char *vclsrc,
 	if (status || C_flag) {
 		(void)unlink(vp.libfile);
 		free(vp.libfile);
-		if (!C_flag) {
+		if (status) {
 			VCLI_Out(cli, "VCL compilation failed");
 			VCLI_SetResult(cli, CLIS_PARAM);
 		}
diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc
index 13bd015..d76a6fe 100644
--- a/bin/varnishtest/tests/a00009.vtc
+++ b/bin/varnishtest/tests/a00009.vtc
@@ -3,6 +3,8 @@ varnishtest "Code coverage of VCL compiler and RSTdump etc"
 shell "${varnishd} -b 127.0.0.1:80 -C -n ${tmpdir} > /dev/null 2>&1"
 shell "${varnishd} -x dumprstparam > /dev/null 2>&1"
 shell "${varnishd} -x dumprstvsl > /dev/null 2>&1"
+err_shell {VCL version declaration missing} "test -d  ${tmpdir} || mkdir ${tmpdir} ; echo 'bad vcl' >${tmpdir}/t.vcl ; ${varnishd} -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1"
+err_shell {VCL version declaration missing} "test -d  ${tmpdir} || mkdir ${tmpdir} ; echo 'bad vcl' >${tmpdir}/t.vcl ; ${varnishd} -C -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1"
 err_shell {-spersistent has been deprecated} "${varnishd} -spersistent 2>&1"
 err_shell {Unknown jail method "xyz"} "${varnishd} -jxyz 2>&1"
 err_shell {-j must be the first argument} "${varnishd} -jnone -jxyz 2>&1"



More information about the varnish-commit mailing list