[master] 46da12f Fix a ordering issue in loading labeled vcls
Poul-Henning Kamp
phk at FreeBSD.org
Tue Aug 30 09:03:09 CEST 2016
commit 46da12f7bf95d1b8b19af54822d813e2a4401bef
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Aug 30 07:02:22 2016 +0000
Fix a ordering issue in loading labeled vcls
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index c475ff2..2de444b 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -299,20 +299,21 @@ static void
ban_export(void)
{
struct ban *b;
- struct vsb vsb;
+ struct vsb *vsb;
unsigned ln;
Lck_AssertHeld(&ban_mtx);
ln = VSC_C_main->bans_persisted_bytes -
VSC_C_main->bans_persisted_fragmentation;
- AN(VSB_new(&vsb, NULL, ln, VSB_AUTOEXTEND));
+ vsb = VSB_new_auto();
+ AN(vsb);
VTAILQ_FOREACH_REVERSE(b, &ban_head, banhead_s, list) {
- AZ(VSB_bcat(&vsb, b->spec, ban_len(b->spec)));
+ AZ(VSB_bcat(vsb, b->spec, ban_len(b->spec)));
}
- AZ(VSB_finish(&vsb));
- assert(VSB_len(&vsb) == ln);
- STV_BanExport((const uint8_t *)VSB_data(&vsb), VSB_len(&vsb));
- VSB_delete(&vsb);
+ AZ(VSB_finish(vsb));
+ assert(VSB_len(vsb) == ln);
+ STV_BanExport((const uint8_t *)VSB_data(vsb), VSB_len(vsb));
+ VSB_destroy(&vsb);
VSC_C_main->bans_persisted_bytes = ln;
VSC_C_main->bans_persisted_fragmentation = 0;
}
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 6b873a5..3fb2132 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -343,6 +343,8 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p)
AZ(mgt_vcl_setstate(cli, active_vcl, VCL_STATE_WARM));
VTAILQ_FOREACH(vp, &vclhead, list) {
+ if (!VTAILQ_EMPTY(&vp->dfrom))
+ continue;
if (!strcmp(vp->state, VCL_STATE_LABEL))
continue;
if (mgt_cli_askchild(status, p, "vcl.load \"%s\" %s %d%s\n",
@@ -360,6 +362,18 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p)
free(*p);
*p = NULL;
}
+ VTAILQ_FOREACH(vp, &vclhead, list) {
+ if (VTAILQ_EMPTY(&vp->dfrom))
+ continue;
+ if (!strcmp(vp->state, VCL_STATE_LABEL))
+ 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;
+ }
+
if (mgt_cli_askchild(status, p, "vcl.use \"%s\"\n", active_vcl->name))
return (1);
free(*p);
More information about the varnish-commit
mailing list