Permalink
Browse files

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

  • Loading branch information...
1 parent 19ff7a5 commit 2b013025ddd134e283603c4d78687ac0209159a4 @bsdphk bsdphk committed Jan 10, 2017
Showing with 38 additions and 34 deletions.
  1. +35 −33 bin/varnishd/mgt/mgt_vcl.c
  2. +3 −1 bin/varnishtest/tests/r02177.vtc
@@ -74,6 +74,7 @@ struct vclprog {
VTAILQ_HEAD(, vcldep) dfrom;
VTAILQ_HEAD(, vcldep) dto;
int nto;
+ int loaded;
};
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)
{
struct vclprog *vp;
struct vcldep *vd;
+ int done;
AN(active_vcl);
/* The VCL has not been loaded yet, it cannot fail */
AZ(mgt_vcl_setstate(cli, active_vcl, VCL_STATE_WARM));
- VTAILQ_FOREACH(vp, &vclhead, list) {
- if (!VTAILQ_EMPTY(&vp->dfrom))
- continue;
- if (mcf_is_label(vp))
- continue;
- if (mgt_cli_askchild(status, p, "vcl.load \"%s\" %s %d%s\n",
- vp->name, vp->fname, vp->warm, vp->state))
- return (1);
- free(*p);
- *p = NULL;
- }
- VTAILQ_FOREACH(vp, &vclhead, list) {
- if (!mcf_is_label(vp))
- continue;
- vd = VTAILQ_FIRST(&vp->dfrom);
- AN(vd);
- if (mgt_cli_askchild(status, p, "vcl.label %s %s\n",
- vp->name, vd->to->name))
- return (1);
- free(*p);
- *p = NULL;
- }
- VTAILQ_FOREACH(vp, &vclhead, list) {
- if (VTAILQ_EMPTY(&vp->dfrom))
- continue;
- if (mcf_is_label(vp))
- continue;
- if (mgt_cli_askchild(status, p, "vcl.load \"%s\" %s %d%s\n",
- vp->name, vp->fname, vp->warm, vp->state))
- return (1);
- free(*p);
- *p = NULL;
- }
+ VTAILQ_FOREACH(vp, &vclhead, list)
+ vp->loaded = 0;
+
+ do {
+ done = 1;
+ VTAILQ_FOREACH(vp, &vclhead, list) {
+ if (vp->loaded)
+ continue;
+ VTAILQ_FOREACH(vd, &vp->dfrom, lfrom)
+ if (!vd->to->loaded)
+ break;
+ if (vd != NULL) {
+ done = 0;
+ continue;
+ }
+ if (mcf_is_label(vp)) {
+ vd = VTAILQ_FIRST(&vp->dfrom);
+ AN(vd);
+ if (mgt_cli_askchild(status, p,
+ "vcl.label %s %s\n",
+ vp->name, vd->to->name))
+ return (1);
+ } else {
+ if (mgt_cli_askchild(status, p,
+ "vcl.load \"%s\" %s %d%s\n",
+ vp->name, vp->fname, vp->warm, vp->state))
+ return (1);
+ }
+ vp->loaded = 1;
+ free(*p);
+ *p = NULL;
+ }
+ } while(!done);
if (mgt_cli_askchild(status, p, "vcl.use \"%s\"\n", active_vcl->name))
return (1);
@@ -12,7 +12,7 @@ server s2 {
varnish v1 -vcl {
backend s1 { .host="${s1_addr}"; .port="${s1_port}"; }
-} -start
+}
varnish v1 -cli "vcl.label lbl1 vcl1"
@@ -44,6 +44,8 @@ varnish v1 -vcl {
}
varnish v1 -cliok "vcl.list"
+varnish v1 -start
+varnish v1 -cliok "vcl.list"
logexpect l1 -v v1 -g raw {
expect * * VCL_Error "Illegal return.vcl.: Not after restarts"

0 comments on commit 2b01302

Please sign in to comment.