[PATCH 1/5] Keep track of VCL initialization

Martin Blix Grydeland martin at varnish-software.com
Wed Jun 10 11:05:58 CEST 2015


Keep track of which VCL initialization steps has succeeded, and run
the fini steps in reverse only for those that were completed.
---
 lib/libvcc/vcc_compile.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index 06f3a3e..ac02736 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -309,14 +309,19 @@ EmitInitFini(const struct vcc *tl)
 {
 	struct inifin *p;
 
+	Fh(tl, 0, "\nstatic unsigned inistep;\n");
+
 	/*
 	 * INIT
 	 */
 	Fc(tl, 0, "\nstatic int\nVGC_Load(VRT_CTX)\n{\n\n");
+	Fc(tl, 0, "\tinistep = 0;\n\n");
 	VTAILQ_FOREACH(p, &tl->inifin, list) {
 		AZ(VSB_finish(p->ini));
+		assert(p->n > 0);
 		if (VSB_len(p->ini))
 			Fc(tl, 0, "\t/* %u */\n%s\n", p->n, VSB_data(p->ini));
+		Fc(tl, 0, "\tinistep = %u;\n\n", p->n);
 		VSB_delete(p->ini);
 	}
 
@@ -330,8 +335,12 @@ EmitInitFini(const struct vcc *tl)
 
 	VTAILQ_FOREACH_REVERSE(p, &tl->inifin, inifinhead, list) {
 		AZ(VSB_finish(p->fin));
-		if (VSB_len(p->fin))
-			Fc(tl, 0, "\t/* %u */\n%s\n", p->n, VSB_data(p->fin));
+		if (VSB_len(p->fin)) {
+			Fc(tl, 0, "\t/* %u */\n", p->n);
+			Fc(tl, 0, "\tif (inistep >= %u) {\n", p->n);
+			Fc(tl, 0, "%s\n", VSB_data(p->fin));
+			Fc(tl, 0, "\t}\n\n");
+		}
 		VSB_delete(p->fin);
 	}
 
-- 
2.1.4




More information about the varnish-dev mailing list