Commit 0a712d95 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make sure object destructors are called as the first thing in the

VCL::fini cleanup
parent a1ed465f
......@@ -222,7 +222,7 @@ parse_new(struct vcc *tl)
bprintf(buf1, ", &%s, \"%s\"", sy1->name, sy1->name);
vcc_Eval_Func(tl, s_init, buf1, "ASDF", s_init + strlen(s_init) + 1);
Ff(tl, 0, "\t%s((struct req*)0, &%s);\n", s_fini, sy1->name);
Fd(tl, 0, "\t%s((struct req*)0, &%s);\n", s_fini, sy1->name);
ExpectErr(tl, ';');
bprintf(buf1, ", %s", sy1->name);
......
......@@ -189,6 +189,19 @@ Fi(const struct vcc *tl, int indent, const char *fmt, ...)
va_end(ap);
}
void
Fd(const struct vcc *tl, int indent, const char *fmt, ...)
{
va_list ap;
if (indent)
VSB_printf(tl->fd, "%*.*s", tl->findent, tl->findent, "");
va_start(ap, fmt);
VSB_vprintf(tl->fd, fmt, ap);
va_end(ap);
}
void
Ff(const struct vcc *tl, int indent, const char *fmt, ...)
{
......@@ -316,6 +329,9 @@ EmitFiniFunc(const struct vcc *tl)
Fc(tl, 0, "\nstatic void\nVGC_Fini(struct cli *cli)\n{\n\n");
AZ(VSB_finish(tl->fd));
VSB_cat(tl->fc, VSB_data(tl->fd));
/*
* We do this here, so we are sure they happen before any
* per-vcl vmod_privs get cleaned.
......@@ -517,6 +533,10 @@ vcc_NewVcc(const struct vcc *tl0)
tl->fi = VSB_new_auto();
assert(tl->fi != NULL);
/* Destroy Objects */
tl->fd = VSB_new_auto();
assert(tl->fd != NULL);
/* Finish C code */
tl->ff = VSB_new_auto();
assert(tl->ff != NULL);
......
......@@ -170,6 +170,7 @@ struct vcc {
struct vsb *fc; /* C-code */
struct vsb *fh; /* H-code (before C-code) */
struct vsb *fi; /* Init func code */
struct vsb *fd; /* Object destructors */
struct vsb *ff; /* Finish func code */
struct vsb *fb; /* Body of current sub
* NULL otherwise
......@@ -258,6 +259,8 @@ void Fi(const struct vcc *tl, int indent, const char *fmt, ...)
__printflike(3, 4);
void Ff(const struct vcc *tl, int indent, const char *fmt, ...)
__printflike(3, 4);
void Fd(const struct vcc *tl, int indent, const char *fmt, ...)
__printflike(3, 4);
void EncToken(struct vsb *sb, const struct token *t);
int IsMethod(const struct token *t);
void *TlAlloc(struct vcc *tl, unsigned len);
......
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