Commit 597972e6 authored by Nils Goroll's avatar Nils Goroll Committed by Geoff Simmons

no more delivery special casing for empty T_DATA nodes

We used to set empty T_DATA nodes to delivered as soon as we encountered
them during unpending. While it seemed like a good idea to not spend
additional work with nodes which do not contain anything, the tree
integrity assertions as well as set_deliver() implicitly assume that

- a delivered node cannot follow an undelivered node unter a nexus and
- once the last node under a nexus is delivered, all of the nexus is
  delivered

Rather than sacrificing the sensible principle that a tree always is to
be delivered top to bottom, left to right, weakening our assertions and
possibly introducing new bugs when handling the resulting special cases,
we go for the simple, clean option and do away with a special case which
will not contribute much to overall performance anyway.
parent 3edc6c16
......@@ -803,6 +803,9 @@ push_data(struct req *req, struct bytes_tree *tree,
(void) tree;
(void) req;
AN(node->parent);
assert(node->parent->type == T_NEXUS);
/*
* we ignore any act from the node and push all we got
* with VDP_FLUSH at the last node
......@@ -815,8 +818,9 @@ push_data(struct req *req, struct bytes_tree *tree,
p = node->data.st->ptr;
}
AN(node->parent);
assert(node->parent->type == T_NEXUS);
if (p == NULL || node->data.len == 0)
return (0);
return (VDP_bytes(node->parent->nexus.req, act, p, node->data.len));
}
......@@ -944,7 +948,6 @@ worklist_unpend(struct req *req, struct bytes_tree *tree,
struct node_head *work)
{
struct node *node, *next;
const void *p;
enum check_state check = CHK_DELI;
(void) check; // for NODEBUG
......@@ -1064,28 +1067,7 @@ worklist_unpend(struct req *req, struct bytes_tree *tree,
}
assert(node->state == ST_DATA);
if (node->type == T_SUBREQ ||
node->type == T_FINAL ||
node->type == T_CRC) {
VSTAILQ_INSERT_TAIL(work, node, unpend);
set_unpending(tree, node);
check = CHK_ANY;
continue;
}
assert(node->type == T_DATA);
p = node->data.ptr;
if (p == NULL && node->data.len > 0) {
CHECK_OBJ_NOTNULL(node->data.st, STORAGE_MAGIC);
p = node->data.st->ptr;
}
if (p == NULL || node->data.len == 0) {
set_delivered(tree, node);
continue;
}
assert(node->type > T_NEXUS);
VSTAILQ_INSERT_TAIL(work, node, unpend);
set_unpending(tree, node);
......
varnishtest "uncacheable, empty fetches at ESI level 2"
server s1 {
rxreq
txresp -body {<Before esi1>
<esi:include src="esi1.html"/>
<esi:include src="esi2.html"/>
After esi2
}
} -start
server s2 {
rxreq
txresp -body {<esi:include src="esi1-1.html"/><esi:include src="esi1-2.html"/>}
} -start
server s3 {
rxreq
txresp -body {<esi:include src="esi2-1.html"/><esi:include src="esi2-2.html"/>}
} -start
server s4 {
rxreq
delay 2
txresp -hdr "Cache-Control: max-age=0" -nolen -hdr "Transfer-Encoding: chunked"
chunkedlen 3
chunkedlen 0
} -start
server s5 {
rxreq
delay 1
txresp -hdr "Cache-Control: max-age=0" -nolen -hdr "Transfer-Encoding: chunked"
chunkedlen 0
} -start
server s6 {
rxreq
txresp -hdr "Cache-Control: max-age=0" -nolen -hdr "Transfer-Encoding: chunked"
chunkedlen 0
} -start
server s7 {
rxreq
txresp -hdr "Cache-Control: max-age=0" -nolen -hdr "Transfer-Encoding: chunked"
chunkedlen 0
} -start
varnish v1 -arg "-l 100m" -vcl+backend {
import ${vmod_pesi};
sub vcl_recv {
return (pass);
}
sub vcl_backend_response {
set beresp.do_esi = true;
}
sub vcl_backend_fetch {
if (bereq.url == "/") {
set bereq.backend = s1;
}
elsif (bereq.url == "/esi1.html") {
set bereq.backend = s2;
}
elsif (bereq.url == "/esi2.html") {
set bereq.backend = s3;
}
elsif (bereq.url == "/esi1-1.html") {
set bereq.backend = s4;
}
elsif (bereq.url == "/esi1-2.html") {
set bereq.backend = s5;
}
elsif (bereq.url == "/esi2-1.html") {
set bereq.backend = s6;
}
elsif (bereq.url == "/esi2-2.html") {
set bereq.backend = s7;
}
}
sub vcl_deliver {
pesi.activate();
}
} -start
client c1 {
txreq
rxresphdrs
rxchunk
delay 1
rxchunk
} -run
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