Commit 5260e303 authored by Nils Goroll's avatar Nils Goroll

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().
parent 4e333597
......@@ -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 */
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment