[master] 5260e3033 make VRT_fail() work with any initializier
Nils Goroll
nils.goroll at uplex.de
Mon Apr 15 11:59:06 UTC 2019
commit 5260e3033018e8fb5f50aa2a6541b9943afa98f6
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Mar 22 17:29:08 2019 +0100
make VRT_fail() work with any initializier
Historically, all initializers called from VGC_Load() would handle
failures individually (return (1) from VGC_Load) or not fail at
all. Now that we got VRT_fail(), it makes sense to generalize.
The upcoming use case is to properly handle failures from
VRT_new_backend_clustered().
diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index 203f34465..6f2e38adc 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -311,6 +311,10 @@ EmitInitFini(const struct vcc *tl)
assert(p->n > 0);
if (VSB_len(p->ini))
Fc(tl, 0, "\t/* %u */\n%s\n", p->n, VSB_data(p->ini));
+ if (p->ignore_errors == 0) {
+ Fc(tl, 0, "\tif (*ctx->handling == VCL_RET_FAIL)\n");
+ Fc(tl, 0, "\t\treturn(1);\n");
+ }
Fc(tl, 0, "\tvgc_inistep = %u;\n\n", p->n);
VSB_destroy(&p->ini);
@@ -664,10 +668,10 @@ vcc_CompileSource(struct vcc *tl, struct source *sp)
ifp = New_IniFin(tl);
VSB_printf(ifp->ini, "\tVGC_function_vcl_init(ctx);\n");
/*
- * We do not return(1) if this fails, because the failure
- * could be half way into vcl_init{} so vcl_fini{} must
- * always be called, also on failure.
+ * Because the failure could be half way into vcl_init{} so vcl_fini{}
+ * must always be called, also on failure.
*/
+ ifp->ignore_errors = 1;
VSB_printf(ifp->fin, "\t\tVGC_function_vcl_fini(ctx);");
/* Emit method functions */
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index ece13c662..5f9774ed5 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -200,6 +200,7 @@ struct inifin {
unsigned magic;
#define INIFIN_MAGIC 0x583c274c
unsigned n;
+ unsigned ignore_errors;
struct vsb *ini;
struct vsb *fin;
struct vsb *final;
More information about the varnish-commit
mailing list