Skip to content

Commit d99d2ad

Browse files
committed
fix backend.list x.y when labels are in use
labels are struct vcl objects for which most members are empty/null, with the label member pointing to the labeled vcl. As such, label vcl objects also have no vdire struct. Hence, when iterating over VCLs to find backends, labels need to be skipped.
1 parent 255ec5b commit d99d2ad

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

bin/varnishd/cache/cache_vcl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ vcl_iterdir(struct cli *cli, const char *pat, const struct vcl *vcl,
530530
int i, found = 0;
531531
struct vcldir *vdir;
532532

533+
AN(vcl->vdire); // no labels
534+
533535
Lck_AssertHeld(&vcl_mtx);
534536
VTAILQ_FOREACH(vdir, &vcl->vdire->directors, directors_list) {
535537
CHECK_OBJ(vdir, VCLDIR_MAGIC);
@@ -575,6 +577,9 @@ VCL_IterDirector(struct cli *cli, const char *pat,
575577
} else {
576578
Lck_Lock(&vcl_mtx);
577579
VTAILQ_FOREACH(vcl, &vcl_head, list) {
580+
// skip labels
581+
if (! vcl->vdire)
582+
continue;
578583
i = vcl_iterdir(cli, VSB_data(vsb), vcl, func, priv);
579584
if (i < 0) {
580585
found = i;

bin/varnishtest/tests/c00077.vtc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ varnish v1 -clierr 106 "vcl.label vcl.A vcl1"
1515
varnish v1 -cliok "vcl.label vclA vcl1"
1616
# labeling twice #2834
1717
varnish v1 -cliok "vcl.label vclA vcl1"
18+
varnish v1 -cliok "backend.list vcl1.*"
1819

1920
varnish v1 -vcl+backend {
2021
sub vcl_recv {

0 commit comments

Comments
 (0)