]> err.no Git - varnish/commitdiff
The compiler should not care about field order in director decls.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 1 Aug 2008 12:44:53 +0000 (12:44 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 1 Aug 2008 12:44:53 +0000 (12:44 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3060 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishtest/tests/v00007.vtc
varnish-cache/lib/libvcl/vcc_dir_random.c
varnish-cache/lib/libvcl/vcc_dir_round_robin.c

index 436ab099141630ef7515f976b559d67d0a226e09..2e1a46585c02a7f7ee35be668cdfd0f04d1f9714 100644 (file)
@@ -12,7 +12,7 @@ server s1 {
 varnish v1 -vcl+backend {
        director foo random {
                { .backend = s1; .weight = 1; }
-               { .backend = s1; .weight = 1; }
+               { .weight = 1; .backend = s1; }
        }
 
        sub vcl_recv {
index 43fa15f5e7c4095c33a0655a59b31f353c0ed5e3..8f817199ceed125750a58673776cc650fd9c2c3d 100644 (file)
@@ -56,6 +56,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons
        int nbh, nelem;
        struct fld_spec *fs;
        unsigned u;
+       const char *first;
 
        fs = vcc_FldSpec(tl, "!backend", "!weight", NULL);
 
@@ -64,6 +65,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons
            PF(t_dir));
 
        for (nelem = 0; tl->t->tok != '}'; nelem++) {   /* List of members */
+               first = "";
                t_be = tl->t;
                vcc_ResetFldSpec(fs);
                nbh = -1;
@@ -78,7 +80,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons
                        if (vcc_IdIs(t_field, "backend")) {
                                vcc_ParseBackendHost(tl, &nbh,
                                    t_dir, t_policy, nelem);
-                               Fc(tl, 0, " .host = &bh_%d,", nbh);
+                               Fc(tl, 0, "%s .host = &bh_%d", first, nbh);
                                ERRCHK(tl);
                        } else if (vcc_IdIs(t_field, "weight")) {
                                ExpectErr(tl, CNUM);
@@ -92,13 +94,14 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons
                                        vcc_ErrWhere(tl, tl->t);
                                        return;
                                }
-                               Fc(tl, 0, " .weight = %u", u);
+                               Fc(tl, 0, "%s .weight = %u", first, u);
                                vcc_NextToken(tl);
                                ExpectErr(tl, ';');
                                vcc_NextToken(tl);
                        } else {
                                ErrInternal(tl);
                        }
+                       first = ", ";
                }
                vcc_FieldsOk(tl, fs);
                if (tl->err) {
index 53edb6cabd9c5c8450ae980e4af03d84a846538a..71b5b3634cc9f9e6d3bce078a1b126a12134934b 100644 (file)
@@ -54,6 +54,7 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy,
        struct token *t_field, *t_be;
        int nbh, nelem;
        struct fld_spec *fs;
+       const char *first;
 
        fs = vcc_FldSpec(tl, "!backend", NULL);
 
@@ -62,6 +63,7 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy,
            PF(t_dir));
 
        for (nelem = 0; tl->t->tok != '}'; nelem++) {   /* List of members */
+               first = "";
                t_be = tl->t;
                vcc_ResetFldSpec(fs);
                nbh = -1;
@@ -76,11 +78,12 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy,
                        if (vcc_IdIs(t_field, "backend")) {
                                vcc_ParseBackendHost(tl, &nbh,
                                    t_dir, t_policy, nelem);
-                               Fc(tl, 0, " .host = &bh_%d,", nbh);
+                               Fc(tl, 0, "%s .host = &bh_%d", first, nbh);
                                ERRCHK(tl);
                        } else {
                                ErrInternal(tl);
                        }
+                       first = ", ";
                }
                vcc_FieldsOk(tl, fs);
                if (tl->err) {