Commit ce562c0a authored by Nils Goroll's avatar Nils Goroll

Add a vtc to tell us where our default stacksize is too tight

Ref #2817
parent 11a2c94a
varnishtest "canary to tell us if our default stacksize is too tight"
server s1 {
rxreq
expect req.http.esi0 == "foo"
txresp -gzipbody {
<html>
Before include
<esi:include src="/a" sr="foo"/>
After include
</html>
}
rxreq
expect req.url == "/a1"
expect req.http.esi0 != "foo"
txresp -gzipbody {
<html>
Before include
<esi:include src="/b" sr="foo"/>
After include
</html>
}
rxreq
expect req.url == "/b2"
expect req.http.esi0 != "foo"
txresp -gzipbody {
<html>
Before include
<esi:include src="/c" sr="foo"/>
After include
</html>
}
rxreq
expect req.url == "/c3"
expect req.http.esi0 != "foo"
txresp -gzipbody {
<html>
Before include
<esi:include src="/d" sr="foo"/>
After include
</html>
}
rxreq
expect req.url == "/d4"
expect req.http.esi0 != "foo"
txresp -gzipbody {
<html>
Before include
<esi:include src="/e" sr="foo"/>
After include
</html>
}
rxreq
expect req.url == "/e5"
expect req.http.esi0 != "foo"
txresp -gzipbody {
<html>
LAST
</html>
}
} -start
varnish v1 -vcl+backend {
import std;
import debug;
sub recv0 { call recv1; std.log("STK recv0 " + debug.stk()); }
sub recv1 { call recv2; std.log("STK recv1 " + debug.stk()); }
sub recv2 { call recv3; std.log("STK recv2 " + debug.stk()); }
sub recv3 { call recv4; std.log("STK recv3 " + debug.stk()); }
sub recv4 { call recv5; std.log("STK recv4 " + debug.stk()); }
sub recv5 { call recv6; std.log("STK recv5 " + debug.stk()); }
sub recv6 { call recv7; std.log("STK recv6 " + debug.stk()); }
sub recv7 { call recv8; std.log("STK recv7 " + debug.stk()); }
sub recv8 { call recv9; std.log("STK recv8 " + debug.stk()); }
sub recv9 {
std.log("STK recv9 " + debug.stk());
set req.http.regex = regsub(req.url, "(.*)", "\1\1\1\1\1\1\1\1");
set req.http.regex = regsub(req.http.regex, "(.*)",
"\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1");
# hey geoff, this is deliberate
set req.http.regex = regsub(req.http.regex,
"(.*)(.{5})(.{6})(.{7})(.{8})", "/\5\4\3\2\1");
std.log("REGEX recv9 " + req.http.regex);
}
sub vcl_recv {
if (req.esi_level > 0) {
set req.url = req.url + req.esi_level;
} else {
set req.http.esi0 = "foo";
}
std.log("STK recv " + debug.stk());
call recv0;
}
sub vcl_backend_response {
set beresp.do_esi = true;
}
sub vcl_deliver {
std.log("STK deliver " + debug.stk());
}
} -start
client c1 {
txreq -hdr "Host: foo"
rxresp
expect resp.status == 200
}
client c1 -run
varnish v1 -expect esi_errors == 0
......@@ -234,3 +234,12 @@ $Function STRANDS return_strands(STRANDS strand)
$Function VOID catflap(ENUM {miss, first, last} type)
Test the HSH_Lookup catflap
$Function BYTES stk()
Return an approximation of the amount of stack used.
This function is by no means guaranteed to work cross platform and
should now only be used for diagnostic purposes.
0B is returned if no sensible value can be determined.
......@@ -699,3 +699,22 @@ xyzzy_catflap(VRT_CTX, VCL_ENUM type)
WRONG("Wrong VENUM");
}
}
VCL_BYTES
xyzzy_stk(VRT_CTX)
{
const VCL_BYTES max = 100 * 1024 * 1024;
const char *a, *b;
VCL_BYTES r;
a = TRUST_ME(&b);
b = TRUST_ME(ctx->req->wrk);
b += sizeof(*ctx->req->wrk);
if (b > a && (r = b - a) < max)
return (r);
if (a > b && (r = a - b) < max)
return (r);
return (0);
}
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