Commit 749b0a4a authored by Geoff Simmons's avatar Geoff Simmons

Set compilation and stats creation now done by vcl_init PRIV_TASK fini.

.compile() is still legal, but unnecessary and will be deprecated.

.create_stats() just sets a flag in the PRIV_TASK that stats should
be created by the fini method. If .compile() is called, .create_stats()
is now legal before or after .compile().
parent 12889755
......@@ -13,7 +13,6 @@ varnish v1 -vcl {
t.add("baz");
t.add("quux");
t.add("foobar");
t.compile();
}
sub vcl_recv {
......@@ -69,7 +68,6 @@ varnish v1 -vcl {
t.add("études");
t.add("étude's");
t.add("étude");
t.compile();
}
sub vcl_recv {
......@@ -202,7 +200,6 @@ varnish v1 -vcl {
s.add("electrode's");
s.add("disposition");
s.add("Rena's");
s.compile();
}
sub vcl_recv {
......@@ -829,7 +826,6 @@ varnish v1 -vcl {
sub vcl_init {
new s = selector.set();
s.add("foo");
s.compile();
}
sub vcl_recv {
......@@ -894,7 +890,6 @@ varnish v1 -vcl {
sub vcl_init {
new s = selector.set();
s.add("foo");
s.compile();
}
sub vcl_recv {
......@@ -921,18 +916,29 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * = End
} -run
varnish v1 -errvcl {vmod selector failure: t.compile(): "foo" added more than once} {
# .compile() is still legal, but unnecessary and deprecated.
varnish v1 -vcl {
import ${vmod_selector};
backend b None;
sub vcl_init {
new t = selector.set();
t.add("foo");
t.add("foo");
t.compile();
}
}
varnish v1 -errvcl {vmod selector failure: t set initialization: "foo" added more than once} {
import ${vmod_selector};
backend b None;
sub vcl_init {
new t = selector.set();
t.add("foo");
t.add("foo");
}
}
varnish v1 -errvcl {vmod selector failure: s.compile(): set was already compiled} {
import ${vmod_selector};
backend b None;
......@@ -990,6 +996,7 @@ logexpect l1 -wait
logexpect l1 -v v1 -d 0 -g raw -q "vxid == 0 and VCL_Error" {
expect 0 0 VCL_Error {^VCL \S+ vmod selector n\.compile\(\): no entries were added, nothing to compile, n\.match\(\) will always fail}
expect 0 0 VCL_Error {^VCL \S+ vmod selector s set initialization: no entries were added, nothing to compile, s\.match\(\) will always fail}
} -start
varnish v1 -vcl {
......@@ -999,13 +1006,11 @@ varnish v1 -vcl {
sub vcl_init {
new t = selector.set();
t.add("foo");
t.compile();
new n = selector.set();
n.compile();
new s = selector.set();
s.add("foo");
}
sub vcl_recv {
......@@ -1020,9 +1025,6 @@ varnish v1 -vcl {
if (req.http.Nil) {
set resp.http.Nil = n.match("foo");
}
if (req.http.Not-Compiled) {
set resp.http.Not-Compiled = s.match("foo");
}
return (deliver);
}
}
......@@ -1054,11 +1056,6 @@ logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect * = VCL_Error {^vmod selector failure: n\.match\(\): no entries were added$}
expect * = VCL_return fail
expect * = End
expect 0 * Begin req
expect * = VCL_Error {^vmod selector failure: s\.match\(\): set was not compiled$}
expect * = VCL_return fail
expect * = End
} -start
client c1 {
......@@ -1073,11 +1070,6 @@ client c1 {
expect_close
} -run
client c1 {
txreq -hdr "Not-Compiled: not-compiled"
expect_close
} -run
logexpect l1 -wait
# Call vcl.discard to exercise set object finalization.
......
......@@ -13,7 +13,6 @@ varnish v1 -vcl {
s.add("bar");
s.add("baz");
s.add("quux");
s.compile();
}
sub vcl_recv {
......@@ -146,7 +145,6 @@ varnish v1 -vcl {
s.add("foobarbaz");
s.add("foobar");
s.add("foo");
s.compile();
}
sub vcl_recv {
......@@ -327,7 +325,6 @@ varnish v1 -vcl {
s.add("foobar");
s.add("foobarbaz");
s.add("foobarbazquux");
s.compile();
}
sub vcl_recv {
......@@ -584,6 +581,7 @@ varnish v1 -vcl {
s.add("plaintiffs"); # 75
s.add("plainer"); # 76
s.add("plainest"); # 77
# .compile() still legal, but unnecessary and deprecated.
s.compile();
}
......@@ -1466,13 +1464,8 @@ varnish v1 -vcl {
sub vcl_init {
new t = selector.set();
t.add("foo");
t.compile();
new n = selector.set();
n.compile();
new c = selector.set();
c.add("bar");
}
sub vcl_recv {
......@@ -1484,9 +1477,6 @@ varnish v1 -vcl {
if (req.http.Nil) {
set resp.http.Nil = n.hasprefix("foo");
}
if (req.http.Not-Compiled) {
set resp.http.Not-Compiled = c.hasprefix("bar");
}
return (deliver);
}
}
......@@ -1511,11 +1501,6 @@ logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect * = VCL_Error {^vmod selector failure: n\.hasprefix\(\): no entries were added$}
expect * = VCL_return fail
expect * = End
expect 0 * Begin req
expect * = VCL_Error {^vmod selector failure: c\.hasprefix\(\): set was not compiled$}
expect * = VCL_return fail
expect * = End
} -start
client c1 {
......@@ -1523,11 +1508,6 @@ client c1 {
expect_close
} -run
client c1 {
txreq -hdr "Not-Compiled: not-compiled"
expect_close
} -run
logexpect l1 -wait
varnish v1 -vcl {
......@@ -1538,7 +1518,6 @@ varnish v1 -vcl {
sub vcl_init {
new s = selector.set();
s.add("foo");
s.compile();
}
sub vcl_recv {
......
......@@ -12,7 +12,6 @@ varnish v1 -vcl {
s.add("bar");
s.add("baz");
s.add("quux");
s.compile();
s.create_stats();
}
} -start
......@@ -55,7 +54,6 @@ varnish v1 -vcl {
p.add("foobar");
p.add("foobarbaz");
p.add("foobarbazquux");
p.compile();
p.create_stats();
# No .create_stats() call.
......@@ -68,7 +66,6 @@ varnish v1 -vcl {
# Calling .create_stats() on an empty set is
# pointless, but not an error.
new e = selector.set();
e.compile();
e.create_stats();
}
}
......@@ -303,7 +300,7 @@ varnish v1 -cliok "vcl.state vcl1 cold"
varnish v1 -cli "vcl.discard vcl1"
# No stats for vcl1 appear after discard.
varnish v1 -vsc SELECTOR.vc1.*
varnish v1 -vsc SELECTOR.vcl1.*
# The same for vcl2 after discard.
varnish v1 -cli "vcl.discard vcl2"
......@@ -341,14 +338,73 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * = End
} -run
varnish v1 -errvcl {vmod selector failure: s.create_stats(): set was not compiled} {
# .compile() still legal, although unnecessary and deprecated.
# Any order before or after .create_stats() is legal.
varnish v1 -vcl {
import ${vmod_selector};
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new s = selector.set();
s.add("foo");
s.create_stats();
s.compile();
s.create_stats();
new t = selector.set();
t.add("bar");
t.create_stats();
t.compile();
}
}
varnish v1 -expect SELECTOR.vcl5.s.elements == 1
varnish v1 -expect SELECTOR.vcl5.s.setsz > 0
varnish v1 -expect SELECTOR.vcl5.s.minlen == 3
varnish v1 -expect SELECTOR.vcl5.s.maxlen == 3
varnish v1 -expect SELECTOR.vcl5.s.trie_nodes > 0
varnish v1 -expect SELECTOR.vcl5.s.trie_nodesz > 0
varnish v1 -expect SELECTOR.vcl5.s.trie_leaves <= 1
varnish v1 -expect SELECTOR.vcl5.s.trie_depth_min > 0
varnish v1 -expect SELECTOR.vcl5.s.trie_depth_max > 0
varnish v1 -expect SELECTOR.vcl5.s.trie_depth_avg > 0
varnish v1 -expect SELECTOR.vcl5.s.trie_fanout_min >= 0
varnish v1 -expect SELECTOR.vcl5.s.trie_fanout_max >= 0
varnish v1 -expect SELECTOR.vcl5.s.trie_fanout_avg >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_buckets >= 1
varnish v1 -expect SELECTOR.vcl5.s.hash_collisions >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_keylen > 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_buckets_min >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_buckets_max >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_buckets_avg >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_strings_min >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_strings_max >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_strings_avg >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_klen_min >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_klen_max >= 0
varnish v1 -expect SELECTOR.vcl5.s.hash_h2_klen_avg >= 0
varnish v1 -expect SELECTOR.vcl5.t.elements == 1
varnish v1 -expect SELECTOR.vcl5.t.setsz > 0
varnish v1 -expect SELECTOR.vcl5.t.minlen == 3
varnish v1 -expect SELECTOR.vcl5.t.maxlen == 3
varnish v1 -expect SELECTOR.vcl5.t.trie_nodes > 0
varnish v1 -expect SELECTOR.vcl5.t.trie_nodesz > 0
varnish v1 -expect SELECTOR.vcl5.t.trie_leaves <= 1
varnish v1 -expect SELECTOR.vcl5.t.trie_depth_min > 0
varnish v1 -expect SELECTOR.vcl5.t.trie_depth_max > 0
varnish v1 -expect SELECTOR.vcl5.t.trie_depth_avg > 0
varnish v1 -expect SELECTOR.vcl5.t.trie_fanout_min >= 0
varnish v1 -expect SELECTOR.vcl5.t.trie_fanout_max >= 0
varnish v1 -expect SELECTOR.vcl5.t.trie_fanout_avg >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_buckets >= 1
varnish v1 -expect SELECTOR.vcl5.t.hash_collisions >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_keylen > 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_buckets_min >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_buckets_max >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_buckets_avg >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_strings_min >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_strings_max >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_strings_avg >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_klen_min >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_klen_max >= 0
varnish v1 -expect SELECTOR.vcl5.t.hash_h2_klen_avg >= 0
This diff is collapsed.
......@@ -371,7 +371,7 @@ To re-state the rules more informally:
prefixes). ``select`` is meant to pick an element when
``.hasprefix()`` finds more than one string.
$Object set(BOOL case_sensitive=1, BOOL allow_overlaps=1)
$Object set(PRIV_VCL, PRIV_TASK, BOOL case_sensitive=1, BOOL allow_overlaps=1)
Create a set object.
......@@ -471,7 +471,7 @@ fail. In that case, a warning is emitted to the log with the
transaction, the error message can only be seen when a tool like
``varnishlog(1)`` is used with raw grouping (``-g raw``).
$Method VOID .create_stats(PRIV_VCL)
$Method VOID .create_stats(PRIV_TASK)
Create statistics counters for this object that are displayed by tools
such as ``varnishstat(1)``. See `STATISTICS`_ for details. It must be
......
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