Commit 2b013025 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Load the vcls and labels into the child process in dependency order.

parent 19ff7a59
...@@ -74,6 +74,7 @@ struct vclprog { ...@@ -74,6 +74,7 @@ struct vclprog {
VTAILQ_HEAD(, vcldep) dfrom; VTAILQ_HEAD(, vcldep) dfrom;
VTAILQ_HEAD(, vcldep) dto; VTAILQ_HEAD(, vcldep) dto;
int nto; int nto;
int loaded;
}; };
static VTAILQ_HEAD(, vclprog) vclhead = VTAILQ_HEAD_INITIALIZER(vclhead); static VTAILQ_HEAD(, vclprog) vclhead = VTAILQ_HEAD_INITIALIZER(vclhead);
...@@ -409,45 +410,46 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p) ...@@ -409,45 +410,46 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p)
{ {
struct vclprog *vp; struct vclprog *vp;
struct vcldep *vd; struct vcldep *vd;
int done;
AN(active_vcl); AN(active_vcl);
/* The VCL has not been loaded yet, it cannot fail */ /* The VCL has not been loaded yet, it cannot fail */
AZ(mgt_vcl_setstate(cli, active_vcl, VCL_STATE_WARM)); AZ(mgt_vcl_setstate(cli, active_vcl, VCL_STATE_WARM));
VTAILQ_FOREACH(vp, &vclhead, list) { VTAILQ_FOREACH(vp, &vclhead, list)
if (!VTAILQ_EMPTY(&vp->dfrom)) vp->loaded = 0;
continue;
if (mcf_is_label(vp)) do {
continue; done = 1;
if (mgt_cli_askchild(status, p, "vcl.load \"%s\" %s %d%s\n", VTAILQ_FOREACH(vp, &vclhead, list) {
vp->name, vp->fname, vp->warm, vp->state)) if (vp->loaded)
return (1); continue;
free(*p); VTAILQ_FOREACH(vd, &vp->dfrom, lfrom)
*p = NULL; if (!vd->to->loaded)
} break;
VTAILQ_FOREACH(vp, &vclhead, list) { if (vd != NULL) {
if (!mcf_is_label(vp)) done = 0;
continue; continue;
vd = VTAILQ_FIRST(&vp->dfrom); }
AN(vd); if (mcf_is_label(vp)) {
if (mgt_cli_askchild(status, p, "vcl.label %s %s\n", vd = VTAILQ_FIRST(&vp->dfrom);
vp->name, vd->to->name)) AN(vd);
return (1); if (mgt_cli_askchild(status, p,
free(*p); "vcl.label %s %s\n",
*p = NULL; vp->name, vd->to->name))
} return (1);
VTAILQ_FOREACH(vp, &vclhead, list) { } else {
if (VTAILQ_EMPTY(&vp->dfrom)) if (mgt_cli_askchild(status, p,
continue; "vcl.load \"%s\" %s %d%s\n",
if (mcf_is_label(vp)) vp->name, vp->fname, vp->warm, vp->state))
continue; return (1);
if (mgt_cli_askchild(status, p, "vcl.load \"%s\" %s %d%s\n", }
vp->name, vp->fname, vp->warm, vp->state)) vp->loaded = 1;
return (1); free(*p);
free(*p); *p = NULL;
*p = NULL; }
} } while(!done);
if (mgt_cli_askchild(status, p, "vcl.use \"%s\"\n", active_vcl->name)) if (mgt_cli_askchild(status, p, "vcl.use \"%s\"\n", active_vcl->name))
return (1); return (1);
......
...@@ -12,7 +12,7 @@ server s2 { ...@@ -12,7 +12,7 @@ server s2 {
varnish v1 -vcl { varnish v1 -vcl {
backend s1 { .host="${s1_addr}"; .port="${s1_port}"; } backend s1 { .host="${s1_addr}"; .port="${s1_port}"; }
} -start }
varnish v1 -cli "vcl.label lbl1 vcl1" varnish v1 -cli "vcl.label lbl1 vcl1"
...@@ -43,6 +43,8 @@ varnish v1 -vcl { ...@@ -43,6 +43,8 @@ varnish v1 -vcl {
} }
} }
varnish v1 -cliok "vcl.list"
varnish v1 -start
varnish v1 -cliok "vcl.list" varnish v1 -cliok "vcl.list"
logexpect l1 -v v1 -g raw { logexpect l1 -v v1 -g raw {
......
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