Commit 48b09e9d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Only run ->fini steps for ->init steps which succeeded.

Patch from Martin, with additional attention to VGC layout by me.
parent 166ce403
......@@ -221,7 +221,7 @@ parse_new(struct vcc *tl)
bprintf(buf1, ", &vo_%s, \"%s\"", sy1->name, sy1->name);
vcc_Eval_Func(tl, s_init, buf1, sy2->name, s_init + strlen(s_init) + 1);
ifp = New_IniFin(tl);
VSB_printf(ifp->fin, "\t%s(&vo_%s);", s_fini, sy1->name);
VSB_printf(ifp->fin, "\t\t%s(&vo_%s);", s_fini, sy1->name);
ExpectErr(tl, ';');
bprintf(buf1, ", vo_%s", sy1->name);
......
......@@ -413,7 +413,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
"\tVRT_init_vbe(ctx, &%s, &vgc_dir_priv_%s);",
vgcname, vgcname);
VSB_printf(ifp->fin,
"\tVRT_fini_vbe(ctx, &%s, &vgc_dir_priv_%s);",
"\t\tVRT_fini_vbe(ctx, &%s,\n\t\t &vgc_dir_priv_%s);",
vgcname, vgcname);
VSB_printf(ifp->event,
"\tVRT_event_vbe(ctx, ev, %s, &vgc_dir_priv_%s);",
......
......@@ -309,14 +309,19 @@ EmitInitFini(const struct vcc *tl)
{
struct inifin *p;
Fh(tl, 0, "\nstatic unsigned vgc_inistep;\n");
/*
* INIT
*/
Fc(tl, 0, "\nstatic int\nVGC_Load(VRT_CTX)\n{\n\n");
Fc(tl, 0, "\tvgc_inistep = 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, "\tvgc_inistep = %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 (vgc_inistep >= %u) {\n", p->n);
Fc(tl, 0, "%s\n", VSB_data(p->fin));
Fc(tl, 0, "\t}\n\n");
}
VSB_delete(p->fin);
}
......
......@@ -75,7 +75,7 @@ vcc_regexp(struct vcc *tl)
VSB_printf(ifp->ini, "\tVRT_re_init(&%s, ",buf);
EncToken(ifp->ini, tl->t);
VSB_printf(ifp->ini, ");");
VSB_printf(ifp->fin, "\tVRT_re_fini(%s);", buf);
VSB_printf(ifp->fin, "\t\tVRT_re_fini(%s);", buf);
return (p);
}
......
......@@ -181,8 +181,8 @@ vcc_ParseImport(struct vcc *tl)
VSB_printf(ifp->ini, "\t\treturn(1);");
/* XXX: zero the function pointer structure ?*/
VSB_printf(ifp->fin, "\tVRT_priv_fini(&vmod_priv_%.*s);", PF(mod));
VSB_printf(ifp->fin, "\n\tVRT_Vmod_Fini(&VGC_vmod_%.*s);", PF(mod));
VSB_printf(ifp->fin, "\t\tVRT_priv_fini(&vmod_priv_%.*s);", PF(mod));
VSB_printf(ifp->fin, "\n\t\tVRT_Vmod_Fini(&VGC_vmod_%.*s);", PF(mod));
ifp = NULL;
......
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