[master] a239c03 Allow vcl_init{} to return(fail) in which case vcl.load or vcl.inline fails too.

Poul-Henning Kamp phk at FreeBSD.org
Thu Sep 25 09:43:01 CEST 2014


commit a239c03cdc7bfdba540eff0ba71878b33285156c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Sep 25 07:41:59 2014 +0000

    Allow vcl_init{} to return(fail) in which case vcl.load or vcl.inline
    fails too.

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index c383e76..245a1c1 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -220,13 +220,19 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
 		FREE_OBJ(vcl);
 		return (1);
 	}
-	REPLACE(vcl->name, name);
-	VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
-	VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
 	ctx.method = VCL_MET_INIT;
 	ctx.handling = &hand;
 	(void)vcl->conf->init_func(&ctx);
+	if (hand == VCL_RET_FAIL) {
+		VCLI_Out(cli, "VCL \"%s\" vcl_init{} failed", name);
+		(void)dlclose(vcl->dlh);
+		FREE_OBJ(vcl);
+		return (1);
+	}
 	assert(hand == VCL_RET_OK);
+	REPLACE(vcl->name, name);
+	VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
+	VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
 	Lck_Lock(&vcl_mtx);
 	if (vcl_active == NULL)
 		vcl_active = vcl;
diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c
index 35e3806..7866f8a 100644
--- a/bin/varnishd/mgt/mgt_vcc.c
+++ b/bin/varnishd/mgt/mgt_vcc.c
@@ -538,7 +538,7 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv)
 		VCLI_SetResult(cli, CLIS_PARAM);
 		return;
 	}
-	VCLI_Out(cli, "VCL compiled.");
+	VCLI_Out(cli, "VCL compiled.\n");
 	if (child_pid >= 0 &&
 	    mgt_cli_askchild(&status, &p, "vcl.load %s %s\n", av[2], vf)) {
 		VCLI_SetResult(cli, status);
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 2bf7133..ac62cfc 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -140,7 +140,7 @@ returns =(
 
 	('init',
 		"",
-		('ok',)
+		('ok', 'fail')
 	),
 	('fini',
 		"",



More information about the varnish-commit mailing list